code wiki / _hdl_build / nx_cms_lms.nx
nx_cms_lms.nx source
↩ module page · 39 lines · 2128 B
1// nx_cms_lms.nx -- CMS LMS / MEMBERSHIP (sovereign courses, sequential progress, certificates). The
2// LearnDash/MemberPress class, made Nishi-native: enrollment gates ALL lesson access, lessons unlock
3// SEQUENTIALLY (drip -- lesson k is reachable only once the prior lessons are complete), progress
4// cannot skip ahead or double-count, and a certificate is earned only by an enrolled learner who has
5// completed every lesson. Pure deterministic integer logic -- no LearnDash license/cloud, the progress
6// ledger lives on-box (privacy-native, the exceed angle). license_tier: ORIGINAL
7import "nx_syscalls.nx"
8
9// enroll a learner (membership): access is gated on this everywhere.
10func lms_can_access(enrolled: i64) -> i64 { if enrolled == 1 { return 1 } return 0 }
11
12// is lesson_idx reachable? requires enrollment AND that all earlier lessons are complete (sequential
13// drip). completed_count = how many lessons the learner has finished, in order. The next lesson
14// (idx == completed_count) and all already-completed lessons are unlocked; later ones are not.
15func lms_lesson_unlocked(enrolled: i64, lesson_idx: i64, completed_count: i64) -> i64 {
16 if enrolled != 1 { return 0 }
17 if lesson_idx <= completed_count { return 1 }
18 return 0
19}
20
21// mark lesson_idx complete. Honors ordering: only the NEXT expected lesson advances progress; a skip-
22// ahead or a re-complete leaves the count unchanged (no double-count, no skipping). Returns new count.
23func lms_complete_lesson(completed_count: i64, lesson_idx: i64, total: i64) -> i64 {
24 if lesson_idx != completed_count { return completed_count }
25 if completed_count >= total { return completed_count }
26 return completed_count + 1
27}
28
29// has the learner finished the whole course?
30func lms_course_complete(completed_count: i64, total: i64) -> i64 {
31 if completed_count >= total { return 1 }
32 return 0
33}
34
35// certificate eligibility: must be ENROLLED and have COMPLETED every lesson.
36func lms_cert_eligible(enrolled: i64, completed_count: i64, total: i64) -> i64 {
37 if enrolled != 1 { return 0 }
38 return lms_course_complete(completed_count, total)
39}