generateOperations method

List<Map<String, dynamic>> generateOperations()

Generates a list of operations based on the cell mappings.

Implementation

List<Map<String, dynamic>> generateOperations() {
  List<Map<String, dynamic>> operations = [];
  // Retrieve the cell mappings
  final detailsMapping = cellMappings[Mapping.details];
  final componentsMapping = cellMappings[Mapping.components];
  final weightMapping = cellMappings[Mapping.weightage];

  /// Add Details mapping operations
  for (var it in detailsMapping) {
    operations.add({"type": "updateCells", ...it});
  }

  /// Add Components mapping operations
  for (var it in componentsMapping) {
    // Unhide the sheet
    operations.add({"type": "showSheet", "sheet": it["sheet"]});
    // Fill the cells with given values
    operations.add({"type": "updateCells", ...it});
    // Unhide the columns: startColumn to startColumn + [count]
    operations.add({
      "type": "showColumn",
      "sheet": it["sheet"],
      "column": "${it["startColumn"]}",
      "count": it["questionsCount"]
    });
    // Unhide the grade (every 20th) column For `IA`. (its shown by default for every other sheet)
    operations.add({
      "type": "showColumn",
      "sheet": it["sheet"],
      "column": getColName(it["startColumn"], 20),
      "count": 1
    });
  }

  /// Add Weightage mapping operations
  for (var it in weightMapping) {
    operations.add({"type": "updateCells", ...it});
  }
  return operations;
}