Skip to content

Fix certificate generation for nested programs to check the required program - #3858

Merged
jkachel merged 1 commit into
mainfrom
jkachel/12823-pt-2-fix-bugs-in-program-consideration
Aug 18, 2026
Merged

Fix certificate generation for nested programs to check the required program#3858
jkachel merged 1 commit into
mainfrom
jkachel/12823-pt-2-fix-bugs-in-program-consideration

Conversation

@jkachel

@jkachel jkachel commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

mitodl/hq#12805

Description (What does it do?)

https://github.com/mitodl/hq/issues/12823 attempted to fix an issue with certificate generation for programs, wherein a program with a nested audit-only program wouldn't generate certificates because it was only looking for certificates (and audit programs never get those, so even if you passed the program you were out of luck). But, there was an error in this; it was looking at node.program to get the required program, which is incorrect.

This fixes the check to use node.required_program, which is the program that is the requirement. (node.program is the program that the node belongs to.) Some additional debug logging is also now present so what it is doing is more obvious and traceable in the logs.

In addition, the test for this was updated but it wasn't updated well enough, so it passed even when it shouldn't have. This was also fixed.

How can this be tested?

To get a test rig set up for this, I created:

  • Three courses with a run each - each supporting audit and verified modes, with CMS pages, and with certificates
  • One program that has a single required course (one of the above three), no electives branch, and only supports audit mode
  • One program that has a single required program (the audit program from previous step), two elective requirements (the remaining courses), and supporting audit and verified modes
  • Course run enrollments for a user in each of the three runs
  • Audit-mode program enrollment for the audit-only program
  • Verified-mode program enrollment for the
  • Passing grades for same user in each of the three runs
  • Course run certificates for the user in each of the three runs - created manually as to avoid having to depend on grades being in edX
  • No program cerficiates

Then, check _has_earned_program_cert in a Django shell:

from users.models import User
from courses.models import Program
from courses.api import _has_earned_program_cert
user = User.objects.get(pk=805)
program = Program.objects.get(pk=74)
_has_earned_program_cert(user, program)

This should return True.

You should then also be able to generate the cert with a management command: ./manage.py manage_program_certificates --user theuser@odl.local --program program-v1:prog --create

You should be able to further test with failing grades or non-certificate courses:

  • If the user doesn't have a certificate in the audit-only program's courses, they should not get a certificate in the verified-mode program
  • If the user doesn't have a passing grade in the audit-only program's audit-only courses, they should also not get a certificate in the verified-mode program

The course behavior and considerations weren't changed in this PR and are covered by other tests so not strictly necessary to check them here.

…h_ the requirement, not the program that was _required_
@github-actions

Copy link
Copy Markdown

OpenAPI Changes

Show/hide changes
## Changes for v0.yaml:
No changes detected

## Changes for v1.yaml:
No changes detected

## Changes for v2.yaml:
No changes detected

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@annagav
annagav self-requested a review August 18, 2026 12:39

@annagav annagav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jkachel
jkachel merged commit d443f94 into main Aug 18, 2026
13 checks passed
@jkachel
jkachel deleted the jkachel/12823-pt-2-fix-bugs-in-program-consideration branch August 18, 2026 15:06
@odlbot odlbot mentioned this pull request Aug 18, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants