mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

Rewrite the algorithm for exam attempts #5199

Closed annagav closed 2 years ago

annagav commented 2 years ago

Pre-Flight checklist

What are the relevant tickets?

Fix #5198

What's this PR do?

Update the algorithm for determining the number of attempts still available to the user and whether they have to pay for the course again.

How should this be manually tested?

Take a look at the tests, make sure all cases are covered. Tests should pass. The new algorithm for determining the number of attempts left:


Find all payments before the "first date"
Find the number of used attempts before the "second date"
if the number of used attempts is less than the amount of attempts given:
    Compute the carry over amount of attempts, converting them from double attempts to single attempts
if the number of unused attempts (before second date) is 0:
    Then we only compute the number of attempts in the new way, i.e. payment = attempt
else
    # the user has more attempts than payments
    # this means the user made at least one payment and attempt both after the first date
    find the number of attempts without the double attempts and subtract that from new payments
codecov-commenter commented 2 years ago

Codecov Report

Merging #5199 (15a05e0) into master (9f52ab5) will increase coverage by 3.80%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5199      +/-   ##
==========================================
+ Coverage   93.95%   97.75%   +3.80%     
==========================================
  Files         499      301     -198     
  Lines       23148    14281    -8867     
  Branches     1417        0    -1417     
==========================================
- Hits        21749    13961    -7788     
+ Misses       1294      320     -974     
+ Partials      105        0     -105     
Impacted Files Coverage Δ
dashboard/api.py
dashboard/utils.py
exams/models.py
profiles/models.py
grades/admin.py
dashboard/signals.py
search/apps.py
discussions/apps.py
search/management/commands/recreate_index.py
dashboard/permissions.py
... and 188 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9f52ab5...15a05e0. Read the comment docs.

annagav commented 2 years ago

@arslanashraf7 this is ready for another review. Thanks