PrairieLearn / PrairieTest-feedback

Public repo to house PrairieTest bug reports, feature requests, and more
0 stars 0 forks source link

Exams not visible for students during review sessions #71

Open Jim-Sosnowski opened 1 month ago

Jim-Sosnowski commented 1 month ago

During review sessions, students are not able to access their exams directly through PrairieTest.

Here is what a student experiences.

1) The student takes an exam in the CBTF. 2) They come to a review session to review their exam in the CBTF. 3) Everything is linked correctly in PT but when the exam starts the student sees a message stating "Assessment is no longer available." 4) To access the exam, students click on assessments (I believe in PL) and see the exam there. 5) They click on the exam and can review it.

nwalters512 commented 1 month ago

The link that PT shows links to .../assessment/ID, whereas if an assessment instance already exists, the PL homepage will link to .../assessment_instance/ID. My hypothesis is that there is some difference in behavior between these two routes.

ZacWarham commented 1 month ago

Just adding an additional note that may be helpful from our experience for allowing cheatsheets during exams. We noticed that it only occurred when we had active: false (albeit a needed statement) in the assessment that we were trying to view

nwalters512 commented 1 month ago

That's consistent with Jim's note that this is for review sessions, where access rules would have "active": false.

nwalters512 commented 1 month ago

When arriving at PL via the PT link, we hit this case since it's using the ..../assessment/:id route:

https://github.com/PrairieLearn/PrairieLearn/blob/730a0b7cfd09825a3a6c07861c9c8aaafaf43f43/apps/prairielearn/src/middlewares/studentAssessmentAccess.ts#L15-L22

res.locals.assessment_instance is indeed undefined, and res.locals.authz_result.active is false because of the access rule, so we immediately block access. However, that condition is never hit when accessing the assessment instance from the PL assessment list, since res.locals.assessment_instance will be defined on the .../assessment_instance/:id route.

nwalters512 commented 1 month ago

As for the solution: I think we just need to query for and redirect to an assessment instance a little earlier. That is, we need to do this little thing before the studentAssessmentAccess middleware gets a chance to block access:

https://github.com/PrairieLearn/PrairieLearn/blob/730a0b7cfd09825a3a6c07861c9c8aaafaf43f43/apps/prairielearn/src/pages/studentAssessment/studentAssessment.ts#L41-L54

We should consider how multi-instance assessments are handled, as we wouldn't know which specific instance to redirect to. This probably won't be common for CBTF exams, and we could probably defer handling this case until later. A possible solution is to render the list of instances on the studentAssessment page.

mwest1066 commented 1 month ago

This basic approach sounds sensible to me. Good find! 🕵️