getCourseSemesterList method
Fetches the list of available semesters for the authenticated student.
Returns a list of semester identifiers (year and semester number) for which course schedules are available. The server identifies the student from the session cookie established by SSO.
This method should be called before getCourseTable to determine which semesters have course data available.
Implementation
Future<List<SemesterDto>> getCourseSemesterList() async {
final response = await _courseDio.get('tw/Select.jsp');
// Find available course tables by reading anchor references
// Document structure: table>tr>td>img+a[href]
final document = parse(response.data);
final tableAnchors = document.querySelectorAll('table a[href]');
final tableLinks = tableAnchors
.map((e) => e.attributes['href'])
.nonNulls
.toList();
// Parse links and extract query parameters
// Link format: Select.jsp?format=-2&code=111360109&year=114&sem=1
return tableLinks.map((link) {
final queryParams = Uri.parse(link).queryParameters;
return (
year: int.tryParse(queryParams['year'] ?? ''),
term: int.tryParse(queryParams['sem'] ?? ''),
);
}).toList();
}