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

feat: add new course access error_code for enterprise learners in future courses #33913

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

pwnage101
Copy link
Contributor

@pwnage101 pwnage101 commented Dec 11, 2023

Description

Normally, the course API would return an access error_code of course_not_started if the course has not started yet. This change breaks that up into two codes:

  • if the course has not started:
    • return course_not_started_enterprise_learner if the learner is enrolled as a subsidized enterprise learner.
    • else, return course_not_started.

This supports a change to the frontend which will interpret course_not_started_enterprise_learner differently and trigger a redirect to the enterprise (B2B) learner dashboard instead of the B2C dashboard.

ENT-8078

Supporting information

Companion PR: openedx/frontend-app-learning#1251

@pwnage101 pwnage101 marked this pull request as draft December 11, 2023 23:52
Arguments:
display_error_to_user: If True, display this error to users in the UI.
"""
error_code = "course_not_started_enterprise_learner"
Copy link
Contributor Author

@pwnage101 pwnage101 Dec 11, 2023

Choose a reason for hiding this comment

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

here's the error_code to match up in the case statement on the frontend.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078 branch 2 times, most recently from 436dbeb to 67ef00d Compare December 12, 2023 21:05
@pwnage101 pwnage101 changed the title feat: strawman for ENT-8078 feat: add new course access error_code for enterprise learners in future courses Dec 14, 2023
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078 branch 3 times, most recently from 8cc79fb to c417aa8 Compare December 14, 2023 01:25
@pwnage101 pwnage101 marked this pull request as ready for review December 14, 2023 01:25
@pwnage101 pwnage101 requested a review from jansenk December 14, 2023 01:56
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078 branch 3 times, most recently from d0aa6b3 to 583a56b Compare December 15, 2023 06:15
…ure courses

Normally, the course API would return an access error_code of
`course_not_started` if the course has not started yet.  This change
breaks that up into two codes:

* if the course has not started:
  * return error_code=`course_not_started_enterprise_learner` if the
    learner is enrolled as a subsidized enterprise learner.
  * else, return error_code=`course_not_started`.

This supports a change to the frontend which will interpret
`course_not_started_enterprise_learner` differently and trigger a
redirect to the enterprise (B2B) learner dashboard instead of the B2C
dashboard.

ENT-8078
@pwnage101
Copy link
Contributor Author

I just incorporated enterprise_customer_from_session_or_learner_data as suggested and overhauled a couple unit tests to cover the case of an enterprise enrollment. The special redirect error code will now only trigger ONLY after establishing all of the following:

  • The learner is linked to an enterprise customer,
  • The enterprise customer has subsidized the learner's enrollment in the requested course,
  • The enterprise customer has the learner portal enabled.

@@ -75,6 +76,7 @@ def check_start_date(user, days_early_for_beta, start, course_key, display_error
Returns:
AccessResponse: Either ACCESS_GRANTED or StartDateError.
"""
from openedx.features.enterprise_support.api import enterprise_customer_from_session_or_learner_data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't really understand what's going on here, but adding this at the top of the file caused a circular import error. This pattern is used elsewhere in this same file so I just copied it.

@macdiesel macdiesel merged commit 8ec4b2b into master Dec 15, 2023
64 checks passed
@macdiesel macdiesel deleted the pwnage101/ENT-8078 branch December 15, 2023 12:46
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants