Skip to content

[31] Add vec/batch operations to course-registry: enroll many, complete many #31

Description

@merlik787-droi

Problem Statement

Course-registry has only single-learner enrollment (enroll) and single-module completion (complete_module). A real deployment would benefit from batch operations:

  • enroll_many(learners: Vec<Address>, id) for cohort onboarding.
  • complete_module_many(learners: Vec<Address>, id) for workflow automation (less critical because each module completion is a separate signal).

Without batch operations, the protocol forces every operation to be a separate transaction.

Why It Matters

  • Operational efficiency: a 100-learner cohort onboarding today requires 100 separate transactions.
  • Atomicity constraints scale poorly across batches.

Expected Outcome

  • enroll_many(env, learners: Vec<Address>, id) -> Vec<Result<Address, ContractError>>:
    • Authenticated by admin (the cohort enrollment pattern).
    • For each learner, validate course exists and is active.
    • Insert progress record.
    • Emit Enrolled { learner }.

Acceptance Criteria

  • Returns vec of results without aborting on partial failure.
  • Snapshot tests with 100 learners.
  • Documentation update.

Implementation Notes

  • Consider gas cost: Soroban's Vec arg size limit.
  • Use Vec::push_back pattern as elsewhere.

Files / Modules Affected

  • contracts/course-registry/src/lib.rs
  • contracts/course-registry/src/test.rs
  • contracts/course-registry/README.md

Dependencies

Issue #28 (ContractError).

Difficulty

Easy.

Estimated Effort

3–4 hours.

Suggested Labels

feature, performance, P2, course-registry


Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions