Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk certificate generation not working from BO #1063

Open
NamFra opened this issue Feb 21, 2025 · 5 comments
Open

Bulk certificate generation not working from BO #1063

NamFra opened this issue Feb 21, 2025 · 5 comments
Labels
back-office bug Something isn't working

Comments

@NamFra
Copy link

NamFra commented Feb 21, 2025

Bug Report

Problematic behavior

Bulk certificate generation does not seem to work from Joanie's back office, requiring the use of the Django admin panel instead (see #1061).
Currently, only certificate generation for a specific order works.

Expected behavior/code

Enable certificate generation directly from the back office, at the product level.

Ideally, this process could be improved (as discussed between @jonathanreveille and @cuchulainn-fun 😉 – which could be a separate feature request), for example:

  • Allowing the upload of a list of eligible order/user references.
  • Displaying a list of eligible orders with the ability to deselect those that should not receive a certificate (🤩).

This would help prevent accidental certificate generation for previous sessions.

For reference, for courses offering both Certificates and Open Badges, we frequently need to modify the course grading in Open edX before de generation. This prevents setting up an automatic certificate generation via a cron job :/

Steps to Reproduce

  1. In the back office, go to the page of a product (or course) where certificates need to be generated.
  2. Click on the "Generate certificates" button.
  3. No certificates are generated.
  4. Try generating a certificate for a specific order and see that it works.

Environment

  • Joanie version: 2.16.0

Possible Solution

There seems to be a verification step that fails, even in the back office.
This step does not occur when generating a certificate for a specific order.

For exemple, this requests fails in 404: https://joanie.preprod-fun.apps.openfun.fr/api/v1.0/admin/course-product-relations/590316b1-958f-4601-a64b-d6c2044b3e49/check_certificates_generation_process/
And its preview shows details: "No cache data found."

Additional context/Screenshots

Bulk generation (left) vs. Order generation (right):

Image

"No cache data found." preview:

Image

Bulk generation attempt:

joanie-bulk-gen-fails_v2.webm

Order generation:

joanie-order-gen-OK.webm

More info: Trello card

🙏

@NamFra NamFra added bug Something isn't working back-office labels Feb 21, 2025
@jonathanreveille
Copy link
Member

jonathanreveille commented Feb 24, 2025

Just for information, there can be 2 reasons why you have this message : No cache data found.
This endpoint check_certificates_generation_process just verifies if the (celery) task in background is done or not depending if it finds it.

It's either :

  • the request to generate was never initiated,
  • the request is already done.
    Both returns 404 Not Found status code.

Only when the process is ongoing that you can find the cache data, here it returns a status code 200 OK.

Although, there should something else going wrong since no certificates are generated.

jonathanreveille added a commit that referenced this issue Feb 24, 2025
It is now possible to launch the generation of certificates
for products of type certificate from the BO.

Fix #1063
@jonathanreveille jonathanreveille self-assigned this Feb 24, 2025
jonathanreveille added a commit that referenced this issue Feb 24, 2025
It is now possible to launch the generation of certificates
for products of type certificate from the BO.

Fix #1063
jonathanreveille added a commit that referenced this issue Feb 24, 2025
It is now possible to launch the generation of certificates
for products of type certificate from the BO.

Fix #1063
@jonathanreveille
Copy link
Member

jonathanreveille commented Feb 24, 2025

We have decided to make this issue in priority and make sure that the generation of certificates for products of type certificates works. We want our admin users to use the BO, instead of the Django admin.

@jonathanreveille jonathanreveille removed their assignment Feb 24, 2025
jonathanreveille added a commit that referenced this issue Feb 24, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
jonathanreveille added a commit that referenced this issue Feb 25, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
jonathanreveille added a commit that referenced this issue Feb 25, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
jonathanreveille added a commit that referenced this issue Feb 25, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
jonathanreveille added a commit that referenced this issue Feb 25, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
@NamFra
Copy link
Author

NamFra commented Feb 25, 2025

Thanks for the info, @jonathanreveille, that makes sense!

We ran a new test in production (for the first time on this product) to go through all the steps, and we noticed that a 404 appears even before the generation starts:

joanie-gen-bo-fail.webm

This is great for focusing on generation from the back-office rather than from the admin panel. 🙏
We also prefer this option!

If there’s still anything to investigate or understand about this bug, @cuchulainn-fun has two certificate generations planned this week (we discussed this with @jbpenrath).
Feel free to let him know if you need to observe what happens in real conditions!

jonathanreveille added a commit that referenced this issue Feb 25, 2025
It is now possible to launch the generation of certificates
for orders with product of type certificate from the BO.

Fix #1063
@jonathanreveille
Copy link
Member

jonathanreveille commented Feb 25, 2025

The 404 NOT FOUND error is not yet explicit, we apologize for that matter.

Actually, the queryset that retrieves eligible orders that can get their certificates generated does not work as intended. That queryset would only work with product type credential, and not yet product type certificate... 😓
With the upcoming fix that is not yet in pre-production (still in review), it will be possible to generate those.

Thus, the second endpoint that callscheck_certificates_generation_process verifies if the process is ongoing in the background with a celery task. Since the queryset did not find any orders to generate certificate, the task has already ended and it returns NOT_FOUND 404 status code. Only when the generation of certificates is in process, you should be able to see a 200 OK response with additional data telling you how many certificates are being generated, and how many were already generated before calling the action initially.

@NamFra
Copy link
Author

NamFra commented Feb 25, 2025

Thanks for this explanation @jonathanreveille, it's very clear!
Great job identifying and fixing the issue 👏 We'll test it in pre-production as soon as it's available
🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-office bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants