Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0bf98e6
(feat) import taken and current courses from a transcript PDF (TIG-282)
Windshield-Viper Nov 24, 2026
c51abfb
(fix) TIG-282: parse the real TigerHub transcript layout
Windshield-Viper Nov 24, 2026
0b1c110
(feat) TIG-282: choose which plan a transcript import goes into
Windshield-Viper Nov 24, 2026
5d6433d
(feat) TIG-282: show the class year used to place imported courses
Windshield-Viper Nov 24, 2026
3da422e
(fix) TIG-282: skip year-first summer/winter terms
Windshield-Viper Nov 24, 2026
307228b
(fix) TIG-282: never save an import over a plan that failed to load
Windshield-Viper Nov 24, 2026
f499d2d
(fix) TIG-282: also block imports into the current plan when it faile…
Windshield-Viper Nov 24, 2026
b2ee8f1
(test) TIG-282: pin season-first academic-year summer headings
Windshield-Viper Nov 24, 2026
0479d1b
(fix) TIG-282: ignore stale plan loads; skip audited courses
Windshield-Viper Nov 24, 2026
64e9eba
(fix) TIG-282: wait for the current plan to load before importing
Windshield-Viper Nov 24, 2026
a454d7b
(fix) TIG-282: cancel a pending import when the student leaves its plan
Windshield-Viper Nov 24, 2026
6963664
(fix) TIG-282: skip failed courses; tighten import cancel rule
Windshield-Viper Nov 24, 2026
af04b1f
(fix) TIG-282: don't read a title-ending letter as a grade without co…
Windshield-Viper Nov 24, 2026
d9243b4
(fix) TIG-282: a plan switch invalidates loads for the plan being left
Windshield-Viper Nov 24, 2026
fa19189
(fix) TIG-282: ambiguous grade letters become 'Check grade', not a guess
Windshield-Viper Nov 24, 2026
a3f8d60
(fix) TIG-282: guard every active-plan change; INC needs a check
Windshield-Viper Nov 24, 2026
93e14bb
(fix) TIG-282: a completed retake wins over an unclear earlier attempt
Windshield-Viper Nov 24, 2026
87550d8
(fix) TIG-282: say so when the session expired during an upload
Windshield-Viper Nov 24, 2026
6c785fc
(fix) TIG-282: ignore responses from overtaken plan actions
Windshield-Viper Nov 24, 2026
a32aa6a
(fix) TIG-282: run plan changes one at a time; resync after failures
Windshield-Viper Nov 24, 2026
503a042
(fix) TIG-282: read the grade basis after a cross-listing
Windshield-Viper Nov 24, 2026
fe28e99
(fix) TIG-282: schedule loads and saves name their plan
Windshield-Viper Nov 24, 2026
e64c65f
(fix) TIG-282: an import into another plan waits its turn with plan s…
Windshield-Viper Nov 24, 2026
06bcfb6
(fix) TIG-282: still report a failed save after switching plans
Windshield-Viper Nov 24, 2026
41a7a72
(fix) TIG-282: keep uploads in memory; imports wait for pending saves
Windshield-Viper Nov 24, 2026
67796a8
(fix) TIG-282: full review pass on saves, plan actions and uploads
Windshield-Viper Nov 24, 2026
7bc0c52
(fix) TIG-282: loading a plan waits for writes already sent to it
Windshield-Viper Nov 24, 2026
9f29e8e
(fix) TIG-282: copies wait for saves; failures always reported; terms…
Windshield-Viper Nov 24, 2026
a536369
(fix) TIG-282: import dialog adds once and defaults its plan when it …
Windshield-Viper Nov 24, 2026
43d8bf4
(fix) TIG-282: import preview waits for the target plan's pending saves
Windshield-Viper Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions docs/decisions/TIG-282-transcript-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# TIG-282: import taken and current courses (decision log)

Branch: `tig-282-import-pre-existing-taken-and-currently-taking`, cut from `parallel-planning/view`
(independent of TIG-330 and TIG-337). The issue has no description, so the decisions below set the scope.

## What ships

- **Header → Import transcript** opens a dialog. The student uploads the TigerHub *unofficial transcript*
PDF, reviews what was found (code, title, Taken or Taking now, target semester), unchecks anything
unwanted, and clicks **Add N courses**.
- **`POST /api/v1/import_transcript/`** (login required) parses the PDF in memory and returns a preview.
It stores nothing and saves nothing. The chosen courses are added on the client and saved with the
normal `update_schedule_and_get_requirements` call, as one save, into the plan the student picks.
- **`tigerpath/transcript.py`** is the parser: pure functions, unit-tested, and runnable locally with
`python -m tigerpath.transcript TRANSCRIPT.pdf [CLASS_YEAR]`, which prints codes, terms and status
only (no grades).

## Decisions

### D1. Data source: the transcript PDF upload (chosen by you)

Alternatives considered: pasting TigerHub text (depends on page layout) and an OIT student API
(needs access the repo doesn't have).

### D2. Checked against a real TigerHub transcript

A real "Undergraduate Internal Transcript" PDF from TigerHub (Oracle/PeopleSoft) showed three things the
first version got wrong. All three are fixed and covered by tests that use made-up courses in the same
layout (no student data is in the repo):

1. **The PDF is encrypted with an empty open-password** (it only restricts editing). It's now opened with
`decrypt("")`; a PDF with a real password is still refused.
2. **The table is laid out in columns** (`COS 226 GRD Title Grade Distrib Area`), so the
department and number are separated by several spaces. The course pattern now allows any spacing.
3. **Each row ends with a Distrib Area** (`QCR`, `NONE`, `Writing`, …) after the Grade column, and the
Grade column is blank while a course is in progress. Status is now read column by column: grade basis
(`GRD`/`PDF`/`AUD`), title, then grade, skipping distribution areas. A title ending in "B" or an `AUD`
basis is never read as a grade. Single-spaced text without columns falls back to reading tokens from
the end, skipping numbers and distribution areas; there a lone grade letter only counts as a grade next to a credit or grade-point number, since without columns it could also end the title ("Part B", "Microeconomics W"). Such rows are marked **Check grade** and are not pre-selected: the student decides, so a possible withdrawal is never added automatically and a real course is never silently dropped.

**Grades:** a passing final grade (A to D, P) means taken; an incomplete (`INC`) is marked **Check grade**, since the course wasn't finished at the end of the term. A blank grade, `IP` or "In Progress" means
currently taking. Failed (`F`), withdrawn (`W`) and audited (grade basis `AUD`) rows are skipped, since none earns credit. Term headings like "2026-2027 Fall", "Fall 2023" and
"Spring Term 2022-23" are recognised; Summer and Winter terms are skipped.

**Still unverified:** a transcript with *finished* terms (letter grades in the Grade column). The layout
is the same, and the tests cover it, but run `python -m tigerpath.transcript` on a multi-term
transcript when one is available.

### D3. Privacy: no storage and no grades returned

The upload is read in memory only and then discarded:
- The cap is 2 MB, below Django's 2.5 MB in-memory upload threshold.
- The view uses only the memory upload handler, so nothing is spooled to a temporary file. Larger
requests, and requests that don't state their length, are refused before the body is read, and login is
checked first.
- PDFs over 20 pages are refused (a transcript is a few pages).
- A term ends at TigerHub's summary block ("Total Course Credits", "Unofficial GPA") and at credit sections
that aren't Princeton terms (advanced standing, transfer, test credit), so rows after them aren't filed
into the last term.
- The file must start with `%PDF-`. PDFs that need a real password are rejected.

Grades only decide taken versus current, and they're never sent back to the browser (a test asserts this).

### D4. Review before adding, never auto-add

The endpoint only previews. A row can't be added if it's:
- already somewhere in the plan;
- listed twice on the transcript;
- outside the four years (for example a future term), or unplaceable because there's no class year
(the dialog says to set it in Settings).

Courses not in the TigerPath catalog are listed as "not added".

### D5. "Taking now" isn't stored on the course

The schedule format has no status field, and adding one would touch the classic UI and the requirement
verifier. Status is shown in the review step only. Current-term courses are placed in their semester
like any other course.

### D6. The student picks which plan to import into (revised)

The first version imported into the active plan only. Review asked for a choice, so the review step now has an
**Add to** dropdown with every plan, defaulting to the current one.
- **Current plan:** duplicates are checked in the review list, and Add makes one normal save.
- **Another plan:** Add reads that plan's courses by id, adds the new ones (skipping any already there), and
saves that plan by id, without changing which plan is active. If the student is still where they started,
TigerPath then opens that plan. The review list checks duplicates against the picked plan, and the dialog
says what will happen before you confirm. If the read or save fails, nothing is imported and a notice says so.
- See D8 for why loads and saves name their plan.

### D8. Schedule loads and saves name their plan (`planId`)

The server used to save every schedule to whichever plan was *active*, and switching plans changes that at once.
So a save still in flight when the student switched plans (or an import into another plan) could land on the
wrong plan. Review kept finding new versions of that race, so the fix is at the root:
- `get_schedule` and `get_requirements` take an optional `?planId=` (the same code as #546's compare view, so
the two PRs merge cleanly). `update_schedule` and `update_schedule_and_get_requirements` take an optional
`planId` in the POST body and write only that plan. A plan that isn't the user's returns 404 and nothing is
written. Without `planId`, everything works as before, so the classic UI is unchanged.
- The new planner remembers which plan the on-screen schedule came from, and every save names it. A plan
whose courses failed to load can't be saved over.
- Saves to one plan go out one at a time, in order. Each save sends the whole schedule, so two in flight
could land out of order and the older one would win. An import into a plan waits its turn in the same
line, after edits already sent. Loading a plan also waits for writes already sent to it, so switching
away and straight back never shows (and then saves back) the schedule from before an edit.
Duplicating a plan and the import dialog's duplicate check wait the same way, so a copy includes edits
still being saved and a course just removed from a plan can be picked again.
- Failures are always said: a save that fails after the student moved on (or came back), a plan switch
that fails, and a plan that fails to load (an empty board would look like deleted courses).
- Saves must be POST: CSRF protection only covers POST, and a GET used to clear the active plan. A schedule
that isn't a JSON list is refused with a 400.
- Plan changes (switch, create, copy, delete, settings) run one at a time; only the newest one's result is shown.
- Tests: a save naming a non-active plan lands there and leaves the active plan alone; another user's plan is
rejected for both reads and saves; GET and malformed saves change nothing.

### D7. New dependency: `pypdf==6.21.4`

It's pure Python, with no system libraries to install, and it's pinned like the rest of `requirements.txt`.
Layout-mode extraction keeps table rows on one line; plain extraction is the fallback.
14 changes: 14 additions & 0 deletions frontend/src/new/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Board from './components/Board';
import RequirementsPanel from './components/RequirementsPanel';
import CourseDrawer from './components/CourseDrawer';
import SettingsModal from './components/SettingsModal';
import ImportTranscriptModal from './components/ImportTranscriptModal';
import './styles.css';

const semesterIndexOf = (droppableId) => parseInt(droppableId.replace('sem', ''), 10);
Expand All @@ -27,6 +28,7 @@ export default function App() {
const [draggingSeason, setDraggingSeason] = useState(null);
const [pathModal, setPathModal] = useState(null); // {mode: 'create'|'edit', plan}
const [settingsOpen, setSettingsOpen] = useState(false);
const [importOpen, setImportOpen] = useState(false);
const [creditPath, setCreditPath] = useState(null);

const themeName = profile?.theme || 'purple';
Expand Down Expand Up @@ -103,6 +105,7 @@ export default function App() {
<div className="tp-app" data-theme={themeName}>
<Header
onOpenSettings={() => setSettingsOpen(true)}
onImportTranscript={() => setImportOpen(true)}
onSwitchToClassic={switchToClassic}
onStartTutorial={startTutorial}
/>
Expand Down Expand Up @@ -193,6 +196,17 @@ export default function App() {
/>
)}

{importOpen && (
<ImportTranscriptModal
schedule={schedule}
plans={plans}
activePlanId={activePlan?.id}
readPlanSchedule={planner.readPlanSchedule}
onImport={planner.importCourses}
onClose={() => setImportOpen(false)}
/>
)}

{settingsOpen && (
<SettingsModal
profile={profile}
Expand Down
53 changes: 50 additions & 3 deletions frontend/src/new/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ export const updatePlanSettings = ({ planId, name, majorIds, minorCodes }) =>
minorCodes: JSON.stringify(minorCodes || []),
});

export const getSchedule = () => apiFetch('/api/v1/get_schedule/');
// Pass planId to read a plan without making it active (the active plan otherwise).
export const getSchedule = (planId) =>
apiFetch(
planId == null
? '/api/v1/get_schedule/'
: `/api/v1/get_schedule/?planId=${encodeURIComponent(planId)}`
);
// "grouped" returns {majors, degrees, minors} covering every major on the plan.
export const getRequirements = () => apiFetch('/api/v1/get_requirements/?layout=grouped');
export const saveScheduleAndGetRequirements = (strippedSchedule) =>
export const getRequirements = (planId) =>
apiFetch(
`/api/v1/get_requirements/?layout=grouped${planId == null ? '' : `&planId=${encodeURIComponent(planId)}`}`
);
// Saves name their plan so a save always lands on the plan the schedule was loaded from, even if
// the active plan changes while the request is in flight.
export const saveScheduleAndGetRequirements = (strippedSchedule, planId) =>
apiPost('/api/v1/update_schedule_and_get_requirements/?layout=grouped', {
schedule: JSON.stringify(strippedSchedule),
...(planId == null ? {} : { planId: String(planId) }),
});

export const searchCourses = (query, signal) =>
Expand All @@ -53,3 +65,38 @@ export async function saveSettings({ year, theme }) {
});
if (!response.ok) throw new Error(`API error: ${response.status}`);
}

/**
* TIG-282: upload a transcript PDF and get back a preview of its courses. The server stores
* nothing; courses are only added when the student confirms (through the normal schedule save).
*/
export async function importTranscript(file) {
const body = new FormData();
body.append('transcript', file);
const sessionExpired = 'Your session has expired. Reload the page to sign in again, then retry the import.';
let response;
try {
response = await fetch('/api/v1/import_transcript/', {
method: 'POST',
credentials: 'same-origin',
headers: { 'X-CSRFToken': getCookie('csrftoken') },
body,
});
} catch {
// Offline, or an expired session redirected to the (cross-site) login page, which fetch can't follow.
throw new Error("Couldn't reach TigerPath. Check your connection, or reload the page to sign in again, then retry the import.");
}
// An expired session can also land on a same-site login page: 200 with HTML. A CSRF failure (403)
// after a long idle is HTML too; both are fixed by reloading.
const isJson = (response.headers.get('Content-Type') || '').includes('application/json');
if (response.redirected || (!isJson && (response.ok || response.status === 403))) {
throw new Error(sessionExpired);
}
if (!isJson) throw new Error('Could not read that transcript. Please try again.');
const payload = await response.json().catch(() => null);
if (!response.ok) throw new Error(payload?.error || 'Could not read that transcript. Please try again.');
if (!payload || !Array.isArray(payload.courses)) {
throw new Error('Could not read that transcript. Please try again.');
}
return payload;
}
6 changes: 5 additions & 1 deletion frontend/src/new/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Icon from './Icon';
const FEEDBACK_URL =
'https://docs.google.com/forms/d/e/1FAIpQLSdjBwHsURKujVqfnUk7nyocAMnFDFI6fyubDmqYMgLElpm_Nw/viewform';

export default function Header({ onOpenSettings, onSwitchToClassic, onStartTutorial }) {
export default function Header({ onOpenSettings, onSwitchToClassic, onStartTutorial, onImportTranscript }) {
return (
<header className="tp-header dont-print">
<a className="tp-brand" href="/">
Expand All @@ -20,6 +20,10 @@ export default function Header({ onOpenSettings, onSwitchToClassic, onStartTutor
<Icon name="info" size={17} />
<span>Tutorial</span>
</button>
<button type="button" className="tp-nav-btn" onClick={onImportTranscript}>
<Icon name="upload" size={17} />
<span>Import transcript</span>
</button>
<button type="button" id="tp-settings-btn" className="tp-nav-btn" onClick={onOpenSettings}>
<Icon name="settings" size={17} />
<span>Settings</span>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/new/components/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const PATHS = {
plusCircle: ['M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z', 'M8 12h8', 'M12 8v8'],
history: ['M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8', 'M3 3v5h5', 'M12 7v5l4 2'],
loader: ['M21 12a9 9 0 1 1-6.22-8.56'],
upload: ['M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4', 'M17 8l-5-5-5 5', 'M12 3v12'],
};

export default function Icon({ name, size = 18, strokeWidth = 2, className = '', title }) {
Expand Down
Loading
Loading