Skip to content

feat: React to verified upgrades by unarchiving the course#41

Merged
kdmccormick merged 1 commit into
mainfrom
kdmccormick/event-for-unarchive
May 14, 2026
Merged

feat: React to verified upgrades by unarchiving the course#41
kdmccormick merged 1 commit into
mainfrom
kdmccormick/event-for-unarchive

Conversation

@kdmccormick
Copy link
Copy Markdown
Member

@kdmccormick kdmccormick commented May 13, 2026

Replaces the placeholder COURSE_CATALOG_INFO_CHANGED handler with one that ties the events example to the rest of the plugin's archive functionality: when a learner's enrollment goes active in the verified mode, any existing CourseArchiveStatus row marking that course as archived is flipped back to unarchived (and the archive_date cleared, matching views.py).

Modeled as a one-time event reaction rather than a continuous filter rule so that a learner who deliberately re-archives a verified course after the upgrade has that choice respected.

README + apps.py example comment updated to describe the new handler.

Testing

Set up the sample plugin, log in as a user and enroll in a course, go to the learner dashboard, and then archive that course.

From a terminal, run this (update email address, course ID, and tutor dev/local as needed):

tutor dev run lms \
    ./manage.py lms change_enrollment \
    -e 'admin@local.openedx.io' \
    -c 'course-v1:OpenedX+DemoX+DemoCourse' \
    --from audit --to verified

Refresh the learner dashboard. Notice that it's un-archived ✨

Re-architve it, and refresh. Notice that it stays re-archived. Now run this:

tutor dev run lms \
    ./manage.py lms change_enrollment \
    -e 'admin@local.openedx.io' \
    -c 'course-v1:OpenedX+DemoX+DemoCourse' \
    --from verified --to audit

Notice that it stays archived, since we the target mode is audit, not verified.

AI

Claude wrote it all, starting with this prompt:

I want to make the backend-plugin-sample event handler (in signals.py) more interesting and relevant to the rest of the plugin. specifically i'd like this behavior:

  • Listen for COURSE_ENROLLMENT_CHANGED
  • When caught, if the enrollment change is_active and mode is "verified" (hard-coded string match is OK), then....
    • If the user has archived the course (as saved in CourseArchiveStatus model), then mark it un-archived

the rationale is that if a user has been upgraded to Verified, then the course shouldn't be hidden away in the Archive section of their dashboard (but, if they re-archive it in the future, then we respect that--hence the one-time event handler and not a continuous checking of course mode when computing isArchivedByLearner.

make sense? this might help: https://github.com/openedx/openedx-events. ask questions eagerly

plus some followups about removing COURSE_CATALOG_INFO_CHANGED, updating the docs, and adding tests. I reviewed all the code myself.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.99%. Comparing base (913f1b1) to head (5408c81).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
+ Coverage   88.40%   92.99%   +4.58%     
==========================================
  Files          14       16       +2     
  Lines         414      471      +57     
  Branches       16       17       +1     
==========================================
+ Hits          366      438      +72     
+ Misses         40       23      -17     
- Partials        8       10       +2     
Flag Coverage Δ
unittests 92.99% <ø> (+4.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kdmccormick kdmccormick requested a review from feanil May 13, 2026 19:36
@kdmccormick kdmccormick force-pushed the kdmccormick/event-for-unarchive branch from ee2e241 to 6a3d4aa Compare May 13, 2026 19:40
@kdmccormick kdmccormick force-pushed the kdmccormick/filter-for-archive branch 2 times, most recently from 456097f to 4276199 Compare May 13, 2026 20:00
@kdmccormick kdmccormick force-pushed the kdmccormick/event-for-unarchive branch from 6a3d4aa to 8908367 Compare May 13, 2026 20:01
@kdmccormick kdmccormick marked this pull request as ready for review May 13, 2026 20:02
Replaces the placeholder COURSE_CATALOG_INFO_CHANGED handler with one that
ties the events example to the rest of the plugin's archive functionality:
when a learner's enrollment goes active in the verified mode, any existing
CourseArchiveStatus row marking that course as archived is flipped back to
unarchived (and the archive_date cleared, matching views.py).

Modeled as a one-time event reaction rather than a continuous filter rule
so that a learner who deliberately re-archives a verified course after the
upgrade has that choice respected.

README + apps.py example comment updated to describe the new handler.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kdmccormick kdmccormick force-pushed the kdmccormick/event-for-unarchive branch from 8908367 to 5408c81 Compare May 13, 2026 20:06
@kdmccormick kdmccormick changed the base branch from kdmccormick/filter-for-archive to main May 13, 2026 20:06
@kdmccormick kdmccormick merged commit 27f27c4 into main May 14, 2026
9 checks passed
@kdmccormick kdmccormick deleted the kdmccormick/event-for-unarchive branch May 14, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants