Disable exam-prep precedence locking for STUDENT learners.

Exam-prep content is gated by subscription/tier only. Learn English sequential locking is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-07-15 00:32:58 -07:00
parent 6b02a5a1fc
commit 7ff22080f0
6 changed files with 25 additions and 10 deletions

View File

@ -2,7 +2,8 @@ package domain
// LMSEntityAccess describes learner gating for a program, course, module, or lesson.
// Included for STUDENT and OPEN_LEARNER; omitted (nil) for staff roles in API responses.
// OPEN_LEARNER always has is_accessible and is_completed true and bypasses subscription gates; STUDENT reflects real progress and gating.
// OPEN_LEARNER always has is_accessible and is_completed true and bypasses subscription gates.
// STUDENT Learn English access reflects sequential prerequisites; exam-prep is accessible when subscription/tier allows (no precedence locks).
// Progress fields count completed published practices vs total published practices in the
// entity's scope. progress_percent keeps the legacy whole-number value; use
// progress_percent_precise for decimal precision in learner UIs.

View File

@ -22,11 +22,18 @@ func (r Role) IsValid() bool {
}
}
// UsesLMSSequentialGating is true when LMS APIs apply sequential prerequisite locks (403 when blocked).
// UsesLMSSequentialGating is true when Learn English (LMS) APIs apply sequential prerequisite locks (403 when blocked).
// Exam-prep does not use this — see UsesExamPrepSequentialGating.
func (r Role) UsesLMSSequentialGating() bool {
return r == RoleStudent
}
// UsesExamPrepSequentialGating is true when exam-prep APIs apply precedence / practice-order locks.
// Currently disabled for all roles: STUDENT access is subscription/tier only; OPEN_LEARNER already bypasses gates.
func (r Role) UsesExamPrepSequentialGating() bool {
return false
}
// IsCustomerLearnerRole is true for platform roles that sign in as customers and consume learner-facing LMS APIs.
func (r Role) IsCustomerLearnerRole() bool {
return r == RoleStudent || r == RoleOpenLearner

View File

@ -8,7 +8,10 @@ func TestRoleOpenLearnerBypassesSubscriptionAndSequentialLocks(t *testing.T) {
t.Fatal("OPEN_LEARNER must bypass subscription gates")
}
if role.UsesLMSSequentialGating() {
t.Fatal("OPEN_LEARNER must not use sequential / precedence locking")
t.Fatal("OPEN_LEARNER must not use Learn English sequential locking")
}
if role.UsesExamPrepSequentialGating() {
t.Fatal("OPEN_LEARNER must not use exam-prep sequential locking")
}
if !role.IsCustomerLearnerRole() {
t.Fatal("OPEN_LEARNER should be a customer learner role")
@ -21,6 +24,9 @@ func TestRoleStudentKeepsSubscriptionAndSequentialLocks(t *testing.T) {
t.Fatal("STUDENT must not bypass subscription gates")
}
if !role.UsesLMSSequentialGating() {
t.Fatal("STUDENT must use sequential / precedence locking")
t.Fatal("STUDENT must use Learn English sequential / precedence locking")
}
if role.UsesExamPrepSequentialGating() {
t.Fatal("STUDENT must not use exam-prep sequential / precedence locking")
}
}

View File

@ -435,7 +435,7 @@ func (s *Service) ApplyExamPrepAccessCatalogCourse(ctx context.Context, role dom
return err
}
ok, reason := true, ""
if role.UsesLMSSequentialGating() {
if role.UsesExamPrepSequentialGating() {
ok, reason, err = s.CanAccessExamPrepCatalogCourse(ctx, userID, cc.ID)
if err != nil {
return err
@ -456,7 +456,7 @@ func (s *Service) ApplyExamPrepAccessUnit(ctx context.Context, role domain.Role,
return err
}
ok, reason := true, ""
if role.UsesLMSSequentialGating() {
if role.UsesExamPrepSequentialGating() {
ok, reason, err = s.CanAccessExamPrepUnit(ctx, userID, u.ID)
if err != nil {
return err
@ -477,7 +477,7 @@ func (s *Service) ApplyExamPrepAccessModule(ctx context.Context, role domain.Rol
return err
}
ok, reason := true, ""
if role.UsesLMSSequentialGating() {
if role.UsesExamPrepSequentialGating() {
ok, reason, err = s.CanAccessExamPrepModule(ctx, userID, m.ID)
if err != nil {
return err
@ -498,7 +498,7 @@ func (s *Service) ApplyExamPrepAccessLesson(ctx context.Context, role domain.Rol
return err
}
ok, reason := true, ""
if role.UsesLMSSequentialGating() {
if role.UsesExamPrepSequentialGating() {
ok, reason, err = s.CanAccessExamPrepLesson(ctx, userID, les.ID)
if err != nil {
return err

View File

@ -352,7 +352,7 @@ var AllPermissions = []domain.PermissionSeed{
}
// defaultStudentLearnerPermissions is the learner consumption permission set shared by STUDENT and OPEN_LEARNER.
// LMS sequential prerequisite locking applies only to STUDENT in application handlers.
// Learn English sequential prerequisite locking applies only to STUDENT; exam-prep has no precedence locking.
var defaultStudentLearnerPermissions = []string{
// Course browsing
"course_categories.list", "course_categories.get",

View File

@ -10,7 +10,8 @@ import (
func (h *Handler) enforceExamPrepPracticeSequenceForStudent(c *fiber.Ctx, questionSetID int64) error {
role, _ := c.Locals("role").(domain.Role)
if !role.UsesLMSSequentialGating() {
// Exam-prep has no precedence locking; subscription/tier middleware is the access gate.
if !role.UsesExamPrepSequentialGating() {
return nil
}
userID, ok := c.Locals("user_id").(int64)