From 13c672415f0ef922c77c63ffa7843c88f881a0bc Mon Sep 17 00:00:00 2001 From: smmariquit Date: Mon, 16 Nov 2026 21:44:17 +0800 Subject: [PATCH] fix(checklist): either-or checklist lines take either course - BA Philo ECON 11 or POSC 10, BA Socio SOC 130/135, 160/165 and 170/175 - BS Chem and BS AChem CMSC 12 or AMAT 152, BS AChem AAE 111 or 120 - BS MST DEVC 40 or MST 40, BS ABio ABT 198 or 200a and ABT 200 or 190 - BS HE thesis is CERP, HFDS or SDS 200, from the 2025 catalogs --- CHANGELOG.md | 5 +++++ extension/requirements.test.js | 13 +++++++++++++ extension/src/curriculum.js | 11 +++++++++++ extension/src/requirements.js | 12 ++++++++---- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e978c..34a6bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Changes +- A checklist line that names either of two courses, like SOC 130 or SOC 135 in BA Socio and CERP, HFDS or SDS 200 in BS HE, takes either one. Eight programs have these lines in the 2025 catalogs. + ## 2.1.22 (2026-11-16) ### Changes diff --git a/extension/requirements.test.js b/extension/requirements.test.js index 84dc12b..4c2ba20 100644 --- a/extension/requirements.test.js +++ b/extension/requirements.test.js @@ -182,6 +182,19 @@ console.log('requirements.test.js: surplus electives passed'); } console.log('requirements.test.js: BSCS special problem and practicum passed'); +// An either-or checklist line takes the other course, and a second one is an elective. +{ + const row = (code, units) => ({ code, title: '', units, result: 'passed' }); + const he = plannerCourseList(UPLB_PROGRAMS.BSHE, null, UPLB_CATALOG); + const thesis = fillRequirementSlots(he, [row('HFDS 200', 3), row('HFDS 200', 3)]); + assert.ok(thesis.has('CERP 200') && thesis.has('CERP 200 (2)'), 'HFDS 200 fills the BS HE thesis rows'); + const socio = plannerCourseList(UPLB_PROGRAMS.BASOCIO, null, UPLB_CATALOG); + const both = fillRequirementSlots(socio, [row('SOC 135', 3), row('SOC 130', 3)]); + assert.strictEqual(both.get('SOC 130').code, 'SOC 130'); + assert.ok([...both.values()].some(r => r.code === 'SOC 135') && !both.has('SOC 135'), 'the other course counts as an elective'); +} +console.log('requirements.test.js: either-or checklist lines passed'); + // BA Comm: a restricted elective takes only the subjects its title names. { const row = (code) => ({ code, title: '', units: 3, result: 'passed' }); diff --git a/extension/src/curriculum.js b/extension/src/curriculum.js index a606abc..c5b9cc6 100644 --- a/extension/src/curriculum.js +++ b/extension/src/curriculum.js @@ -2053,6 +2053,7 @@ const UPLB_PROGRAMS = { { "code": "DEVC 40", "title": "Fundamentals of Educational Communication and Technology", + "alt": ["MST 40"], "units": 3, "year": 2, "sem": "2", @@ -3114,6 +3115,7 @@ const UPLB_PROGRAMS = { { "code": "CMSC 12", "title": "Foundations of Computer Science", + "alt": ["AMAT 152"], "units": 3, "year": 2, "sem": "1", @@ -4401,6 +4403,7 @@ const UPLB_PROGRAMS = { { "code": "SOC 130", "title": "Social Psychology", + "alt": ["SOC 135"], "units": 3, "year": 2, "sem": "1", @@ -4629,6 +4632,7 @@ const UPLB_PROGRAMS = { { "code": "SOC 160", "title": "Social Change", + "alt": ["SOC 165"], "units": 3, "year": 4, "sem": "2", @@ -4637,6 +4641,7 @@ const UPLB_PROGRAMS = { { "code": "SOC 170", "title": "Social Problems", + "alt": ["SOC 175"], "units": 3, "year": 4, "sem": "2", @@ -4792,6 +4797,7 @@ const UPLB_PROGRAMS = { { "code": "ECON 11", "title": "General Economics", + "alt": ["POSC 10"], "units": 3, "year": 1, "sem": "2", @@ -6074,6 +6080,7 @@ const UPLB_PROGRAMS = { { "code": "ABT 198", "title": "Practicum", + "alt": ["ABT 200A"], "units": 3, "year": 3, "sem": "midyear", @@ -6125,6 +6132,7 @@ const UPLB_PROGRAMS = { { "code": "ABT 200", "title": "Undergraduate Thesis", + "alt": ["ABT 190"], "units": 3, "year": 4, "sem": "1", @@ -6798,6 +6806,7 @@ const UPLB_PROGRAMS = { { "code": "CMSC 12", "title": "Foundations of Computer Science", + "alt": ["AMAT 152"], "units": 3, "year": 2, "sem": "1", @@ -6894,6 +6903,7 @@ const UPLB_PROGRAMS = { { "code": "AAE 111", "title": "Farm Management", + "alt": ["AAE 120"], "units": 3, "year": 3, "sem": "1", @@ -14070,6 +14080,7 @@ const UPLB_PROGRAMS = { { "code": "CERP 200", "title": "Undergraduate Thesis", + "alt": ["HFDS 200", "SDS 200"], "units": 3, "year": 4, "sem": "1", diff --git a/extension/src/requirements.js b/extension/src/requirements.js index 70100af..e342d01 100644 --- a/extension/src/requirements.js +++ b/extension/src/requirements.js @@ -70,13 +70,17 @@ const BUILT_IN_EQUIVALENTS = [['KAS 1', 'HIST 1']]; function fillRequirementSlots(courses, rows, substitutions = {}) { const norm = r => normalizeCourseCode(r.code); const named = new Set(courses.filter(c => !c.genericRequirement).map(c => normalizeCourseCode(c.code))); + // A checklist row that names either of two courses takes the other one too. + const altOf = new Map(courses.flatMap(c => (c.alt || []).map(a => [a, normalizeCourseCode(c.code)]))); + const base = r => named.has(norm(r)) ? norm(r) : altOf.get(norm(r)) || norm(r); const fill = new Map(); // A repeat enrollment fills the next "CODE (n)" row. - rows.forEach(r => { - let code = norm(r); - for (let n = 2; fill.has(code) && named.has(`${norm(r)} (${n})`); n++) code = `${norm(r)} (${n})`; + [...rows.filter(r => named.has(norm(r))), ...rows.filter(r => !named.has(norm(r)))].forEach(r => { + let code = base(r); + for (let n = 2; fill.has(code) && named.has(`${base(r)} (${n})`); n++) code = `${base(r)} (${n})`; if (named.has(code) && !fill.has(code)) fill.set(code, r); }); + const filled = new Set([...fill.values()].map(norm)); const used = new Set(); [...Object.entries(substitutions || {}), ...BUILT_IN_EQUIVALENTS].forEach(([req, taken]) => { const code = normalizeCourseCode(req); @@ -90,7 +94,7 @@ function fillRequirementSlots(courses, rows, substitutions = {}) { const seen = new Set(); const outside = rows.filter(r => { const code = norm(r); - if (named.has(code) || used.has(code) || seen.has(code)) return false; + if (named.has(code) || used.has(code) || seen.has(code) || filled.has(code)) return false; // HK 12 repeats once per sport. if (!/^(HK|PE)\b/.test(code)) seen.add(code); return true;