getMaterials method
- ISchoolCourseDto course
Fetches the list of course materials for the specified course.
Returns references to all files and materials posted to I-School Plus
for the given course.
The course should be obtained from getCourseList.
Each material reference includes a title and SCORM resource identifier (href) that can be passed to getMaterial to obtain download information.
Materials are extracted from the course's SCORM manifest XML. Folder/directory items without actual files are automatically excluded.
Implementation
Future<List<MaterialRefDto>> getMaterials(ISchoolCourseDto course) async {
await _selectCourse(course);
// Fetch and parse the SCORM manifest XML for file listings
final manifestResponse = await _iSchoolPlusDio.get('path/SCORM_loadCA.php');
final manifestDocument = parse(manifestResponse.data);
// Extract all <item> elements that have identifierref attribute (actual files)
// Items without identifierref are folders/directories and are excluded
final items = manifestDocument.querySelectorAll('item[identifierref]');
return items.map((item) {
final titleElement = item.querySelector('title');
final title = titleElement?.text.split('\t').first.trim();
// Find the corresponding <resource> element
final identifierRef = item.attributes['identifierref']!;
final resource = manifestDocument.querySelector(
'resource[identifier="$identifierRef"]',
);
final href = resource?.attributes['href'];
return (
course: course,
title: title,
href: href,
);
}).toList();
}