This commit is contained in:
@@ -116,6 +116,28 @@ export default function parseAbsence(input, teacherMap = {}) {
|
|||||||
markConsumed(matchStart, matchEnd);
|
markConsumed(matchStart, matchEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1a. Teachers with "-startHour-exk" suffix (e.g. "Sv-5-exk")
|
||||||
|
const teacherStartExkRe = /([A-Za-z]+)-(\d+)-exk/gi;
|
||||||
|
while ((m = teacherStartExkRe.exec(s)) !== null) {
|
||||||
|
const matchStart = m.index;
|
||||||
|
const matchEnd = teacherStartExkRe.lastIndex;
|
||||||
|
if (isConsumed(matchStart)) continue;
|
||||||
|
|
||||||
|
const teacherCode = m[1];
|
||||||
|
const from = Number(m[2]);
|
||||||
|
const { name } = resolveTeacher(teacherCode, teacherMap);
|
||||||
|
|
||||||
|
if (from >= 1 && from <= LAST_HOUR) {
|
||||||
|
results.push({
|
||||||
|
teacher: name,
|
||||||
|
teacherCode: teacherCode.toLowerCase(),
|
||||||
|
type: "exkurze",
|
||||||
|
hours: { from, to: LAST_HOUR },
|
||||||
|
});
|
||||||
|
markConsumed(matchStart, matchEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Teachers with "-exk" suffix
|
// 2. Teachers with "-exk" suffix
|
||||||
const teacherExkRe = /([A-Za-z]+)-exk/gi;
|
const teacherExkRe = /([A-Za-z]+)-exk/gi;
|
||||||
while ((m = teacherExkRe.exec(s)) !== null) {
|
while ((m = teacherExkRe.exec(s)) !== null) {
|
||||||
|
|||||||
@@ -248,6 +248,15 @@ test("Vc 1. h", [
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
test("Sv-5-exk", [
|
||||||
|
{
|
||||||
|
teacher: "Ing. Jan Šváb",
|
||||||
|
teacherCode: "sv",
|
||||||
|
type: "exkurze",
|
||||||
|
hours: { from: 5, to: 10 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
function test(input, expectedOutput) {
|
function test(input, expectedOutput) {
|
||||||
const res = parseAbsence(input, teachermap);
|
const res = parseAbsence(input, teachermap);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user