extractTestEventDetails function

TestCalendarEventDetails extractTestEventDetails(
  1. Bs4Element element,
  2. Student realStudent
)

Implementation

TestCalendarEventDetails extractTestEventDetails(
    Bs4Element element, Student realStudent) {
  List<Bs4Element> tables = element.findAll("table");
  Bs4Element infoTable = tables.first;
  Bs4Element studentTable = tables.last;
  List<TestStudent> allStudents = [];
  bool hasPrep = studentTable.children[0].children[0].children[4].text
      .toLowerCase()
      .startsWith("forb.");
  List<Bs4Element> studentRows = studentTable.children[0].children;
  studentRows.removeAt(0);
  for (var studentRow in studentRows) {
    allStudents.add(extractTestStudent(studentRow, hasPrep));
  }
  TestStudent student = allStudents.firstWhere(
    (element) => element.name == realStudent.name,
  );
  var room = infoTable.children[0].children[4].children[1].text;
  String teacherString = infoTable.children[0].children[0].children[3].text;
  List<String> teachers = teacherString.split("\n").map((e) {
    return e.split(" - ")[0];
  }).toList();
  return TestCalendarEventDetails(teachers, room, student, allStudents);
}