mitodl / micromasters

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

Exams: Logic to determine if learner needs to pay for an exam doesn't work in some cases #5198

Closed briangrossman closed 2 years ago

briangrossman commented 2 years ago

Steps to Reproduce

In certain scenarios, the logic to determine if a learner needs to pay for an exam authorization is incorrect, asking a learner to pay when they don't need to. This is due to the code that was introduced to go from two authorizations per order to one (https://github.com/mitodl/micromasters/issues/4646).

Steps:

Expected Behavior

Actual Behavior

Stacktrace

Here's some hints

Here's the code that determines if a learner needs to pay: https://github.com/mitodl/micromasters/blob/9f52ab55cf2381dcb6d886ddb78dca0ed9466b27/dashboard/api.py#L615-L639

Note the left side of the conditional is simply checking the number of authorizations used: return ExamAuthorization.objects.filter(user=mmtrack.user, course=course, exam_taken=True).count() >= attempt_limit

Something like this might work. Round( 0.5 * number of authorizations used prior to exam_attempts_first_date) + number of authorizations used after exam_attempts_first_date >= attempt_limit

Also, the code that issues authorizations should be checked as well.

Related Issues

annagav commented 2 years ago

@briangrossman This is a bit challenging to fix because of the changing conditions on which users were receiving their attempts. If the user paid before the "first date" then they have two attempts. But only as long as they use the two attempts before the "second date". If they did not manage to use the two attempts before the "second date" then it is one attempt per payment. So all we have to check is that whether they used their attempts on time or not. But the challenge arises here: since course payment is not attached to any exam runs, it is difficult to associate course payments to attempts they have had.

The proposed solution above doesn't work because it doesn't take into account when they have paid for the course. Users who paid before the the "first date" still have time between "first" and "second" date to use 2 attempts per payment.

I feel like there is no precise solution to this, also given that the unused attempts expired after the "second date". I think we have to come up with an approximation of a solution.

briangrossman commented 2 years ago

@annagav This is definitely a tricky one. I've started gathering some thoughts in this document. In particular, I've outlined a few cases that are currently incorrect.

Your point about course payments being difficult to associate with attempts is a good one. When I have been addressing Zendesk tickets, I have been creating a "timeline" to help me determine how many authorizations learners have left. I can associated attempts with the first order that still has authorization(s) remaining.

e.g. In this case, the learner still has an authorization

- Order: 10/8/2020
- Attempted Exam: 06/04/2021
- Attempted Exam: 01/31/2022
- Order: 3/1/2022

What are your thoughts on the best way to proceed?