Skip to content

feat(course-registry): add unenroll and is_enrolled - #73

Open
Degentle12 wants to merge 1 commit into
Kqirox:mainfrom
Degentle12:issue-17-unenroll-is-enrolled
Open

feat(course-registry): add unenroll and is_enrolled#73
Degentle12 wants to merge 1 commit into
Kqirox:mainfrom
Degentle12:issue-17-unenroll-is-enrolled

Conversation

@Degentle12

Copy link
Copy Markdown

Problem

course-registry::enroll writes DataKey::Progress(learner, id) = 0u32 but provides no inverse. A learner who enrolls by mistake is permanently enrolled — enroll panics with "Learner already enrolled" on retry — and the progress record persists in storage forever.

Solution

  • unenroll(env, learner, id) — Removes the learner's progress record from storage. Learner-authorized. Panics with "Not enrolled" if no record exists and "Already completed" for finished courses (completion is irreversible).
  • is_enrolled(env, learner, id) -> bool — View helper returning true if a progress record exists.
  • Unenrolled contract event emitted on successful unenrollment.
  • 13 unit tests covering: success, storage removal, event emission, re-enrollment, completed-course panic, excess-progress panic, unauthorized access, and all is_enrolled states.

Closes #17

- Add Unenrolled contractevent with learner and course_id topics
- Add unenroll(env, learner, id) to remove a learner progress record
  Panics: "Not enrolled", "Already completed", "Course not found"
- Add is_enrolled(env, learner, id) -> bool view helper
- Add 13 unit tests: success, storage removal, events, re-enrollment,
  completed-course panic, excess-progress panic, unauthorized access,
  and is_enrolled across all enrollment states

Closes Kqirox#17
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.

[17] Add retrieve_unenrolled and a refundable unenroll flow to course-registry

1 participant