Scrape submitted text for past-due submissions, not just editable ones
Once a submission's due date passes, the legacy homework page renders the student's text read-only in a `<div class="comment">` that is a sibling *after* `</section id="submission">`, which then holds only the file list. `parseHomeworkPage` searched for that div *inside* the submission section, so for every past-due submission it silently returned no submitted text while still reporting the grade and feedback — the reader would conclude the student handed in nothing. Search the whole page instead. `class="comment"` (quote right after the word) stays specific: the teacher's feedback is `class="comment ckcontent"` and does not match, and the editable-textarea branch is still tried first. Found by standing up a local instance from the deployed images and reading a real 33.40 page for a seeded past-due submission; the earlier test fixture had nested the div inside the section, which is why the gap was invisible. The fixtures now match the real DOM. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -73,9 +73,17 @@ export function parseHomeworkPage(html: string): SubmissionDetail | undefined {
|
||||
|
||||
// The student's own text: a textarea while the submission is still editable,
|
||||
// a plain div once it is not.
|
||||
//
|
||||
// The read-only div is a *sibling after* `</section id="submission">`, not a
|
||||
// child of it — that section then holds only the file list. Scoping this
|
||||
// search to the section therefore found nothing for every submission past
|
||||
// its due date, silently dropping the submitted text while still reporting
|
||||
// the grade. `class="comment"` (with the quote right after the word) is
|
||||
// specific enough to search the whole page: the teacher's feedback is
|
||||
// `class="comment ckcontent"` and so cannot match.
|
||||
const typed =
|
||||
/data-testid="submission-text"[^>]*>([\s\S]*?)<\/textarea>/.exec(html)?.[1] ??
|
||||
(submission ? /<div class="comment"[^>]*>([\s\S]*?)<\/div>/.exec(submission)?.[1] : undefined);
|
||||
/<div class="comment"[^>]*>([\s\S]*?)<\/div>/.exec(html)?.[1];
|
||||
const typedText = clean(typed);
|
||||
if (typedText) detail.submittedText = typedText;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user