🐛 Fix lessons spanning over more than two lessons
This commit is contained in:
@ -58,8 +58,18 @@ export function parseSubstitutionPlan(html) {
|
||||
rowData[columntitle] = cleantext;
|
||||
});
|
||||
|
||||
// Split change if it spans over multiple lessons
|
||||
const rawLesson = rowData.lesson;
|
||||
const lessons = rawLesson.match(/\d+/g).map(Number);
|
||||
const fromToLessons = rawLesson.match(/\d+/g).map(Number);
|
||||
const from = fromToLessons[0];
|
||||
const to = fromToLessons[1] || fromToLessons[0];
|
||||
|
||||
// Generate numbers from `from` to `to`
|
||||
const lessons = Array(to - from + 1)
|
||||
.fill()
|
||||
.map((_e, i) => i + from);
|
||||
|
||||
// Create new change for each lesson the change spans over
|
||||
for (const lesson of lessons) {
|
||||
rowData.lesson = lesson;
|
||||
data.push({ ...rowData });
|
||||
|
Reference in New Issue
Block a user