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

Enhance Program letter generation w.r.t their active status #5257

Closed arslanashraf7 closed 1 year ago

arslanashraf7 commented 1 year ago

This won't be the case for our regular flow since the letters will only be generated when a program is completed, but due to a bug in the past, a lot of program letters were created which shouldn't have been. We invalidated those in https://github.com/mitodl/micromasters/pull/5253. We also introduced the is_active field there and made amendments in the code to serve the letters based on their active status only.

The existing implementation of the letter generation function checks if a letter already exists before creating a new one. This could be a problem for the letters that we invalidated as mentioned above it's possible that those users can complete these program(s) at some point in the future. In that case, we should mark their existing letter as active instead of creating a new one. So this logic needs to be changed a bit to handle that case.

Steps to Reproduce

You need manual intervention to generate this case.

  1. Create a Program letter for a user manually and mark it as inactive, also make sure that the program is not complete for that user
  2. Now complete the program, add a final grade entry and you should notice that the Program letter is still inactive.

Expected Behavior

For existing letters that are inactive, when the user completes the program they should be marked active

Actual Behavior

The existing letters won't be marked active in case of completion