Skip to content

test(progress-tracker): cover learner stats, completion percentage, and quiz retakes - #367

Merged
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
all-opensource-projects:test/progress-tracker-stats-percentage-retake-coverage
Aug 30, 2026
Merged

test(progress-tracker): cover learner stats, completion percentage, and quiz retakes#367
DeFiVC merged 1 commit into
ChainLearnOfficial:mainfrom
all-opensource-projects:test/progress-tracker-stats-percentage-retake-coverage

Conversation

@meshackyaro

Copy link
Copy Markdown
Contributor

Summary

Issues #247, #248, and #249 ask for get_learner_stats, get_completion_percentage, and retake_quiz on the progress-tracker contract. These are duplicates of already-closed issues #232, #233, and #234, and the functions themselves already exist on main (added in #364/8716288). That commit, however, only touched the test file to fix a struct literal for the compiler — it added zero test coverage for any of the five new functions it introduced.

This PR adds the missing unit test coverage for the three functions these issues ask about, in tests/unit/progress_tests.rs:

All 45 tests in the progress_tests binary pass (30 existing + 15 new).

Note: cargo test on main currently fails to build at all because contracts/learn-token/src/storage.rs defines is_paused/set_paused twice (lines 248 and 736, from #366) — unrelated to this PR's scope, so it isn't touched here, but it blocks running the full workspace test suite until it's fixed separately.

Test plan

  • cargo test --test progress_tests — 45 passed, 0 failed (verified locally with the unrelated learn-token duplicate-definition build error worked around; not part of this diff)

Closes #247, Closes #248, Closes #249

…nd quiz retakes

get_learner_stats, get_completion_percentage, and retake_quiz were merged
with production code but no test coverage, leaving their edge cases
(zero-quiz averages, aggregation across courses, retake score validation,
event emission, eligibility flips) unverified.

Adds unit tests for:
- get_completion_percentage: matches stored overall_progress, panics when
  not enrolled.
- get_learner_courses / get_learner_stats: empty/zero results for a new
  learner, aggregation across multiple courses, and an average that
  divides by quizzes submitted rather than courses enrolled.
- retake_quiz: replaces a score without double-counting it, emits
  quiz_retaken (and credential_eligible on a flip to eligible), and
  rejects a non-improving score, an unsubmitted quiz, an out-of-range
  score, or an unenrolled learner.

Closes ChainLearnOfficial#247, Closes ChainLearnOfficial#248, Closes ChainLearnOfficial#249
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@meshackyaro Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@DeFiVC
DeFiVC merged commit 702a92e into ChainLearnOfficial:main Aug 30, 2026
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.

. Add quiz retake support . Add course completion percentage query . Add learner statistics aggregation

2 participants