Repository navigation
fix: read the entrance exam status on the progress tab - #2249
brian-smith-tcril wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## frontend-base #2249 +/- ##
==============================================
Coverage 96.78% 96.79%
==============================================
Files 475 478 +3
Lines 7368 7386 +18
Branches 1723 1727 +4
==============================================
+ Hits 7131 7149 +18
Misses 223 223
Partials 14 14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f51d72e to
23cbb1e
Compare
On master the certificate status card reads the courseware metadata query with enabled: false for the learner's entrance exam result, and nothing on the progress tab fetches that query, so the card never has it (#2243). Under the shell a tab switch keeps the query cache, so the card would differ between a page load and a switch once a courseware page fills it. ProgressTab now fetches the courseware metadata on the learner's own page and passes it to the tab page with the progress data, so the card mounts with the status known: a learner who has not passed the entrance exam sees no card, in one render, and the visited event carries that state. On progress/:targetUserId the query is neither fetched nor waited for, and the card ignores what the cache holds: GET /api/courseware/course/ answers for the requester, not the learner on the page (#2244), and the requester's own progress page can leave their status in the cache. The card passes null there, as it does on a fresh load of that page. The courseware metadata slice of courseware/data ports to support this: getCourseMetadata, coursewareMeta.ts, coursewareMetadataQuery with useCoursewareMetadata in place of its stub, and the courseMetadata factory. #2195 brings the rest of api.js, apiHooks.ts and the factories; useMinimalCourseOutline stays a stub until then. master's apiHooks.test.tsx has no case of its own for useCoursewareMetadata, so cases for the hook are added beside it. Part of #2190. Co-Authored-By: Claude <[email protected]>
23cbb1e to
bea109b
Compare
arbrandes
left a comment
There was a problem hiding this comment.
Pre-emptively approved, but Claude did flag one thing we should probably take a look at before merging. Comment inline.
|
|
||
| const entranceExamPassed = entranceExamData?.entranceExamPassed ?? null; | ||
| // GET /api/courseware/course/ answers for the requester, not the target user: https://github.com/openedx/frontend-app-learning/issues/2244 | ||
| const entranceExamPassed = targetUserId ? null : (entranceExamData?.entranceExamPassed ?? null); |
There was a problem hiding this comment.
I don't think we should hide the card based on this flag. Probably best to keep master's behavior for now: always pass null here, and don't fetch the courseware metadata on the progress tab at all.
The problem is that the LMS only sets entrance_exam_passed to true if the learner actually passed the exam (code). It stays false for learners an instructor allowed to skip the exam, and for course staff who are enrolled. Those people can take the whole course, but with this change they'd never see the cards that let them request a certificate, verify their ID, or upgrade.
We can't tell "failed the exam" from "was allowed to skip it" on the frontend, so I think this needs the backend change described in #2244 first.
Summary
The progress tab's certificate card now has the learner's entrance exam status.
master's card reads it from the courseware metadata query without fetching, and nothing on the progress tab fetches that query, so the card never has it (#2243).ProgressTabnow fetches the courseware metadata on a learner's own page and waits for it with the progress data. One change a learner can see: a learner who has not passed the entrance exam sees no certificate card, wheremastershows the card the course would show without an exam. The legacy tree undersrc/is untouched.Part of #1905. Resolves #2190. Stacked above #2247.
Note
For reviewers: hiding the card is
master's code running for the first time, not new logic:getCourseExitModereturnsentranceExamFailand the card has no branch for it. That #1429 meant this is read from its code. #1429 does not say so (decision log entry 2).What changed
ProgressTabfetches the courseware metadata and waits for it. It runsuseCoursewareMetadata(courseId)and passes the query to the tab-page frame intabDataQueries, beside the progress query.CertificateStatuskeepsmaster'senabled: falseread, which the page now fills, so the card mounts with the status known, renders once, and sends itsvisitedevent from that render.progress/:targetUserIdthe query is neither run nor waited for, and the card passesnullwhatever the query cache holds:GET /api/courseware/course/answers for the requester, not the learner in the route (Progress tab: staff viewing a learner's progress cannot get that learner's entrance exam status #2244). Both conditions carry Progress tab: staff viewing a learner's progress cannot get that learner's entrance exam status #2244's URL.courseware/data/ports to support this.coursewareMeta.tswhole,getCourseMetadatainapi.js,coursewareMetadataQueryanduseCoursewareMetadatainapiHooks.tsin place of the stub from refactor: port the modules the progress tab shares to frontend-base #2246, and thecourseMetadatafactory. Port the courseware container and redirects to frontend-base #2195 adds the rest of each file at the same path;useMinimalCourseOutlinestays a stub until then.ProgressTab.test.jsxgains five "Entrance exam status" cases.courseware/data/apiHooks.test.tsxis new, with cases for the hook. Two comments in the lower layers' tests, false once the query is real, are corrected.Known differences from
mastermasterthey see the card for their grade and enrollment, for example the "not passing" card.GET /api/courseware/course/<id>. If it fails, the tab shows its error view. The endpoint records user activity for the requester.master. Staff see that learner's card without the entrance exam status until the progress response carries it (Progress tab: staff viewing a learner's progress cannot get that learner's entrance exam status #2244).Testing
At the layer's commit, in
frontend-base/: lint, the tests,buildandbuild:cipass. Lint ran with the package's.jsxfiles included (openedx/frontend-base#327).it.skipunder Wire up the frontend-base masquerade bar #2194, and the streak-celebration case under Port the celebrations to frontend-base #2201).Coverage. The package is at 100% of lines, against its 96.15% bar. Counted from the local coverage report the way Codecov counts a patch, this layer adds 17 lines with none missed or partly covered.
Manual testing on the package's dev site against tutor dev, with one enrolled learner in the demo course: the real courseware metadata request and its
entrance_exam_passedfield on the progress page; the certificate card showing, then gone with the response faked to say the exam is not passed; and no such request on a staff view of another learner's progress. The record is below.Decisions
What was decided while building this layer; the scope is in #2190, the bug in #2243 and the staff view in #2244.
Full decision log
Decisions: the entrance exam status on the progress tab (#2249)
Decisions made while building this layer of #2190. The scope is in #2190's plan, the bug
is described in #2243 and the staff view in #2244. The tab itself is ported in #2247, the
layer below.
The progress tab fetches the courseware metadata and waits for it on a learner's
own page.
ProgressTabrunsuseCoursewareMetadata(courseId)as a fetching queryand passes it to the tab-page frame in
tabDataQueries, beside the progress query.CertificateStatuskeepsmaster's line, a read of that query withenabled: false; the page above it now fills what it reads.masternothing on the progress tab fetches that query and every way into thetab is a page load, so the read is always empty (Progress tab: the certificate card never receives the entrance exam status #2243).
ported (Port the courseware container and redirects to frontend-base #2195), a learner switching from one to Progress would reach the card with
the status cached, and a page load would not. Fetching on the page removes that
difference.
visitedevent from its first render.Without the wait the card would render with no status, send the event, and then
render again when the response arrived: a learner who has not passed the exam would
see the card appear and vanish.
What a learner now sees: no certificate card until the entrance exam is passed.
This is the one change from
mastera learner can see. Onmasterthat learner seesthe card the course would show without an exam, for example "In order to qualify for
a certificate, you must have a passing grade".
master's code, running for the first time.getCourseExitModereturns
entranceExamFailbefore it looks at anything else, and the card has nobranch for that mode, so it renders nothing.
added the read, the
entranceExamPassedline and the extra argument to the card,and did not add them to
CourseExit.jsx, the function's other caller outside theunit navigation. Those lines have no purpose unless the card is meant to react to a
failed exam. fix: corrects the navigation issue if the student does not pass the entrance exam #1429 and the issue it closed, [Bug] Students have access to course content even if the Entrance Exam wasn't finished #1415, are about the unit navigation's
Next button; neither mentions the progress tab, and no test covered the card's
branch.
useModel('coursewareMeta', courseId)ona page that never loaded that model, and refactor!: read sections and coursewareMeta from the courseware queries, not useModel #2140 converted it to the query read with
the same result.
see on
master. It was raised during the manual pass and not taken.On another learner's page nothing changes, and the card ignores the cache.
GET /api/courseware/course/answers for the requester, not for the learner in theroute, and a staff member who never sat the exam reports
falsefor themselves(Progress tab: staff viewing a learner's progress cannot get that learner's entrance exam status #2244). So on
progress/:targetUserId:ProgressTabdoes not run the query and does not wait for it.CertificateStatuspassesnullwhatever the cache holds. The query key names nouser, so the requester's own progress page, or a courseware page once Port the courseware container and redirects to frontend-base #2195 lands,
can leave the requester's status there.
nullis whatmaster's read gives onthat page.
carrying the status, removes them.
and then navigates to
progress/10with the router. With the card's conditionremoved, that case alone fails.
Arriving at one's own page with the status already cached. The page does not
wait: the card renders from the cached status and the query refetches in the
background, as every query on every tab does. If the status changed since it was
cached, the first render and the
visitedevent use the old value and the cardcorrects itself when the response arrives. In this PR only the progress page fills
that cache. This is read from the code; no case covers this arrival.
The
visitedevent has no entrance exam variant. InentranceExamFailmode thecard sends the progress response's
cert_statusas it is, which ismaster's code.The suite's case asserts that literal value and one call.
Costs. One more request on each load of a learner's own progress page. A failure
of that request shows the tab's error view, where
master's card never asked. Theendpoint records user activity for the requester.
The courseware metadata slice of
courseware/data/ports here. The fix needsthe real query, and the rest of the module ports with Port the courseware container and redirects to frontend-base #2195.
coursewareMeta.tsports whole.api.jsholdsgetCourseMetadataonly, andapiHooks.tsholdscoursewareMetadataQueryanduseCoursewareMetadata. Each filehas one manifest line; Port the courseware container and redirects to frontend-base #2195 adds the rest of each file at the same path.
useMinimalCourseOutlinestays the stub refactor: port the modules the progress tab shares to frontend-base #2246 added, under Port the courseware container and redirects to frontend-base #2195's URL.courseMetadatafactory ports, with a__factories__/index.jswhose otherfour imports are commented out under Port the courseware container and redirects to frontend-base #2195's URL.
useCoursewareMetadatabuilds its options withcoursewareMetadataQuery(courseId!)and is disabled without a course id, as the hooks in
course-home/data/apiHooks.tsdo.
Tests.
ProgressTab.test.jsxgains "Entrance exam status": no card and onevisitedevent for a learner who has not passed; the card for one who has; one courseware
metadata request on a learner's own page and none on another learner's; the cache
case of entry 3. The suite's
beforeEachanswers the new request, since anunanswered one rejects and the page now waits for it.
courseware/data/apiHooks.test.tsxis new: the query carries the query defaults,the hook fetches once, and it requests nothing when disabled or without a course
id.
masterhas a file at this path with cases for eleven other hooks and queriesand none of its own for
useCoursewareMetadata, which only does the fetching inits
useSequenceIdsanduseIsCourseLoadedcases; Port the courseware container and redirects to frontend-base #2195 ports those into thisfile. Leaving the new file out loses one branch, the hook called with no options,
which is
master's signature and has no caller yet.getCourseMetadataand the normalizer get no cases of their own. A first versionhad three (the request URL, the normalized shape, the clock offset). Leaving them
out lost no line or branch, since the progress cases run both, and they asserted
behaviour the port does not change, so they were dropped.
course-exit/utils.test.tssaid both courseware queries are stubs, andProgressTabComponents.test.tsxsaid nothing on the tab loads the coursewaremetadata.
One commit. The fix, the slice it needs and their tests. A split into failing
tests and then the fix was considered and not made for this layer.
Coverage at this layer. 100% of lines for the package. Counted from the local
coverage report the way Codecov counts a patch, the layer adds 17 lines with none
missed or partly covered. The
useMinimalCourseOutlinestub's function is notcalled (Port the courseware container and redirects to frontend-base #2195).
The manual pass: the real request, and the card going away once. The suite
answers the new request from a factory, so the first look is the real request from
the real app and the real response's
entrance_exam_passed. Setting up a coursewith an entrance exam was not worth it for the second look: a local patch, never
committed, edits the two responses where they arrive, so the normalizer and
everything after it run as they are. The patch gives the progress response an
unverifiedcertificate, not arequestingone, whose card has a button thatposts a certificate request.
Manual testing
The layer makes the progress page wait for one more request,
GET /api/courseware/course/<id>,and hides the certificate card when that response says the entrance exam is not passed.
The suite fakes the request, so what needs eyes is the real request in the real app, and
the card going away once in a real browser. A course with an entrance exam is not needed:
the second look fakes the two responses with a local patch.
Setup
The dev site as for the progress tab layer, on
bsmith/progress-entrance-exam.The same enrolled learner and the demo course.
For look 2 only, the fakes: the patch below, applied with
git applyand taken outwith
git apply -Rwhen done. It is never committed. It changes two requestfunctions:
getProgressTabData: the response'scertificate_databecomes{ cert_status: 'unverified' }andverification_data.statusbecomes'pending', soa certificate card with no button shows.
getCourseMetadata: the response'sentrance_exam_data.entrance_exam_passedbecomesfalse, only when the page URL has?exam=failed.The same two edits as browser overrides on the two responses do the same job.
Two looks
http://apps.local.openedx.io:2000/learning/course/course-v1:OpenedX+DemoX+DemoCourse/progresswith DevTools' Network panel filtered to
courseware, and reload. There is onerequest to
/api/courseware/course/course-v1:OpenedX+DemoX+DemoCourse, with abrowser_timezoneparameter and status 200. Its response hasentrance_exam_data.entrance_exam_passed, and the value istrueorfalse. Thepage renders as it did on the progress tab layer.
Why here: the page now waits for this request and shows the tab's error view
when it fails; the suite answers it from a factory, so neither the real request
nor the real response's field has been seen.
Please note: the value of
entrance_exam_passedyou see.same page: a "Certificate status" card shows, saying the ID verification is
pending. Add
?exam=failedto the URL and load it: the card is not there, and itdoes not flash in while the page loads. The rest of the page is unchanged.
Why here: this is the layer's one visible change, and it has only run in jsdom.
Optional
…/progress/<userId>with Network filtered tocourseware: no request to/api/courseware/course/. The suite asserts this; this only adds the real route.Checked outside the app
suites, 412 passed, 7 skipped, 100% of lines.
run twice, 2026-11-12. With the test page's URL as it is, "shows the certificate card
to a learner who has passed the entrance exam" passes, and the visited event carries
certificate_status_variant: 'unverified': the faked card renders, with no consoleoutput. With the URL set to
http://localhost/?exam=failed, the same case failswith the card not found: the switch hides it. The patch was then taken back out.
Left to the suite
ProgressTab.test.jsx, "Entrance exam status":the query cache.
courseware/data/apiHooks.test.tsx: the hook fetches once, and requests nothing whendisabled or without a course id.
Not this layer
Everything in the progress tab layer's section. The courseware pages that also read this
query port with #2195 and #2196.
Results
2026-11-12, Brian, on the dev site, on
bsmith/progress-entrance-exam, with thefakes patch applied for the whole pass and taken out afterwards.
before the patch edits it, so the request and the field are the real ones; the page
itself already carried the faked certificate data.
qualify for a certificate, you must have a passing grade", the "not passing" card, not
the "ID verification is pending" card the step names. With the faked
unverifiedcertificate either card can show, depending on the course home metadata's
can_view_certificate; the step's wording was a guess at which.entrance_exam_passedwastruein the real response (Brian, askedafterwards). The demo course has no entrance exam.
afterwards), and it was gone with
?exam=failed.🤖 Generated with Claude Code