Repository navigation
feat(grades): list your own grades with edstem grades - #18
Conversation
Add a read-only `edstem lessons score <lessons...>` that reports the signed-in user's final-submission result per lesson: graded (score, maxScore, submittedAt), unmarked, unreleased, or not_submitted. EdApiError now keeps Ed's error code, so Ed's 403 results_unreleased is reported as a status rather than an error. The projection is an allowlist: Ed's result also carries the student's name and email and other unmarked users' IDs, none of which are printed.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 293fb575d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { ...submitted, status: "unmarked" }; | ||
| } | ||
| const maxScore = marking.slideTotals.reduce((sum, total) => sum + total, 0); | ||
| return { ...submitted, maxScore: maxScore > 0 ? maxScore : null, score: marking.mark, status: "graded" }; |
There was a problem hiding this comment.
Apply the final attempt's mark override
When the final attempt has a non-null mark_override, fetchLessonAttempts discards that field and this line always publishes attempt_result.mark. Instructor-adjusted submissions can therefore report the pre-override score (or become unmarked if the calculated mark is null); carry the final attempt's override through and apply it after the results-release check, including an override of zero.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in c868aab. Ed's web client computes the student's final mark as attempt.markOverride ?? sum(userSlideMarks), so the override wins, including zero. It now applies after the results_unreleased check, and also when Ed has no calculated mark. Three new tests cover override, zero override, and override-while-unreleased.
Ed's web client shows the final attempt's mark_override in place of the calculated mark, including an override of zero. Apply it after the results-release check, so an override stays hidden until release.
|
Hi @MortyYJT and thanks for the contribution! This is solid work. I like the privacy allowlist, and the ownership checks are exactly right. The changes below are mostly about fitting the command into the rest of the unicorn ecosystem. Blocking
Non-blocking
The override fix in c868aab looks good. An MCP tool can come in a follow-up. |
|
furthermore, i recommend reading https://unicorn.tuuhub.com/docs/concepts/command-model/ as a development reference. (the full Shared behaviour section) |
Follow review: a `grades` noun with the shared `list` verb replaces `lessons score`, scoped by unit and lesson-name queries like `lessons mark-read`, with moodle's words (grade, max, ungraded) and a title on each row. Only lessons whose kind is "attempt" are queried, so content lessons cost no requests. One failing lesson is reported as unavailable while auth and network errors still stop the listing; the ownership checks throw a plain Error. unreleased and unavailable get their own tones in tables.
|
Thanks for the careful review and the pointer to the command model. All of it is in d9c5124; the PR description is updated to match. Blocking
Non-blocking
Two small additions from reading the Shared behaviour docs: |
|
The approach looks right to me. A few suggestions, none of them blocking:
|
- Parse the lesson list's submitted_at into Lesson.submittedAt; a lesson with none goes straight to not_submitted without the attempts request. Submitted lessons still read the attempts, which carry mark_override and the final submission. - Ask Ed about up to three lessons at a time, keeping the unit's order; a rejected token or a network failure still fails the listing.
|
Thanks for the suggestions. 1 and 2 are in 937f54f; 3 is left as is.
|
|
LGTM, thx! |
|
Docs are now available: Grades guide and the |
There was no way to ask edstem-cli "what did I get for this assignment". Tools that need it read the token file and call Ed directly, duplicating auth, region and retry handling. This adds a read-only
edstem grades [list] UNIT [queries...]that lists the signed-in user's own final-submission grades for a unit, following the family's command model and moodle-cli'sgradeswords.gradedgradeis the final mark,maxis derived as the sum of Ed's slide totals (omitted if any total is unreadable)ungradedunreleased403 results_unreleaseduntil staff release resultsnot_submittedunavailableerrorsays why and the rest of the unit is still listedsrc/ed/client.ts:fetchLessonAttempts(lessonId, userId)readsGET lessons/{id}/attempts/{userId}, andfetchLessonMarkingStatus(lessonId, attemptId)readsGET lessons/{id}/marking_status?attempt={id}, both through the existing privateget().EdApiErrorgains an optionalcodeholding Ed's own error code; it defaults to"", so existing callers are unaffected.src/ed/operations.ts:listGradesresolves the unit and lessons the waylessons mark-read UNIT [queries...]does (the query matcher is now one shared helper), and only queries lessons whosekindis"attempt". In two real units that was exactly the submission lessons (3 of 42, 1 of 12), so content lessons cost no requests. A staffmark_overrideon the final attempt, including zero, replaces the calculated mark, as in Ed's web client (attempt.markOverride ?? sum(userSlideMarks)); it is applied after the release check. A failing lesson becomesunavailable; a rejected token or a network failure still stops the listing. The ownership checks throw a plainError.src/ed/projections.ts:projectGradeis an allowlist. Ed's result also carries the student's name, email andsourced_id, plus other users' IDs; none of them are printed.gradesnoun with thelistverb, soedstem grades UNIT [words...]defaults tolistandedstem gradesalone gives the unit picker at a terminal or ausageerror with the usage line elsewhere.unreleasedandunavailableare outside the shared status vocabulary, so tables tone themwarninganddanger.CONTEXT.md, a row in the README table and in the skill intent table, and a regeneratedSKILL.md.GET only: it never starts, saves or submits an attempt. The attempts path uses the token owner's ID, and both the final attempt and
attempt_resultmust belong to that user. MCP gets no new tool here;get_gradescan follow in a separate PR.Tests
npm run check,npm run test:node(330 passing at 937f54f; 328 before the review follow-up),npm run build:localandnpm run skill:generateall pass;SKILL.mdis committed.bun test tests/remote(22) andbun test tests/worker(10) passed at d9c5124; 937f54f does not touch them and they were not re-run locally (no Bun here).final_id: null,mark_override, an unreadable slide total, andcodekept on a 403.listGrades: each status; thekindand query filters (a content lesson is never queried); an override including zero, with no calculated mark, and while unreleased; one failing lesson reported asunavailablewhile the next is still listed; auth and network failures stopping the listing; an attempt or result owned by someone else becomingunavailablewithout its data.grades 100 --jsonprints only allowlisted fields (no name, email or other user IDs) and sends only GETs; query words narrow the rows; seven query words still default tolist;unreleasedandunavailableare coloured in a table.No test reaches the real Ed API: every test drives
EdClientwith a mockedfetchor a mocked client.Not verified
Ed does not document either endpoint; their shapes come from live responses. I ran the built CLI against a live AU account on one of my own units: two
graded, matching the values an earlier direct-API script returned, and oneunreleased; a query narrowed it to one row. Not exercised live:ungraded,not_submitted,unavailable, a non-nullmark_override, and the US and EU regions.kind: "attempt"was checked on two units only.