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

When creating enrollment set is_active explicitly in the enrollment api call #2300

Merged
merged 7 commits into from
Jul 31, 2024

Conversation

annagav
Copy link
Contributor

@annagav annagav commented Jul 17, 2024

What are the relevant tickets?

Fix #2225 and #1797

Description (What does it do?)

If use enrolls, unenrolls, and enrolls again, the course run enrollment in edx should be active, otherwise the user can't access the course on edx, just like it happened for this user https://github.com/mitodl/hq/issues/4367.

On open edx is_active = False is equivalent to being unenrolled.

How can this be tested?

Locally you can test if by enrolling in a course for an audit track, then unenrolling, then paying again. You can pay with a coupon too.
The api would get called again. This double call of create enrollment api is going to set is_active to true on repeated call.

@pdpinch
Copy link
Member

pdpinch commented Jul 18, 2024 via email

@annagav annagav marked this pull request as ready for review July 23, 2024 12:11
@annagav annagav changed the title set is_active on enrollment When creating enrollment set is_active on enrollment api call Jul 23, 2024
@annagav annagav changed the title When creating enrollment set is_active on enrollment api call When creating enrollment set is_active explicitly in the enrollment api call Jul 23, 2024
@annagav
Copy link
Contributor Author

annagav commented Jul 23, 2024

Why?

If user re-enrolls their enrollment stays inactive and they can't access the course through the courseware.

@cp-at-mit cp-at-mit self-assigned this Jul 25, 2024
openedx/api.py Outdated
@@ -668,6 +668,7 @@ def enroll_in_edx_course_runs(
mode=mode,
username=username,
force_enrollment=force_enrollment,
enrollment_attributes={"name": "is_active", "value": True},
Copy link
Contributor

@arslanashraf7 arslanashraf7 Jul 26, 2024

Choose a reason for hiding this comment

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

I think setting is_active in enrollment_attributes would not work. We will need to send is_active as an independent key in the post data.

Here are some of the details behind:

If we take a look at this enrollment code in Open edX you will notice that they are getting the is_active key right from the post data field and not the enrollment_attributes. So, I think this change would not do the trick for us.

In my opinion here is what we would need to do:

  1. Allow create_student_enrollment to take an is_active attr which can be True by default
  2. Add is_active in enrollment_data
  3. Update the usages of create_student_enrollment in MITx Online project as per needs.

@annagav
Copy link
Contributor Author

annagav commented Jul 26, 2024

So just adding here more clarification on the issue.

The enrollment stays inactive only following a "verified" enrollment as a result of payment for the course run.

If re-enroll in as audit again, then is works correctly.

@annagav
Copy link
Contributor Author

annagav commented Jul 26, 2024

So I have been playing with the api and what I found is this:

Set up:

There is an existing enrollment that has is_active=False( meaning the user unenrolled).

Action:

If I make an api ( edx_client.enrollments.create_student_enrollment)call with the same MODE is_active gets set to True.
If I make the same api call but the MODE is not the same (changing from audit to verified or vice versa), then the MODE gets updated but is_active stays False.

@annagav annagav force-pushed the ag/edx_api_active_true branch from 67db5d8 to f8529b0 Compare July 29, 2024 20:03
@annagav annagav force-pushed the ag/edx_api_active_true branch from e18d75f to 0fff7b7 Compare July 29, 2024 21:12
@annagav annagav merged commit 5a532d3 into main Jul 31, 2024
7 checks passed
@annagav annagav deleted the ag/edx_api_active_true branch July 31, 2024 01:52
@odlbot odlbot mentioned this pull request Jul 31, 2024
1 task
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.

Enrollment issue when user unenrolls and enrolls again and pays
4 participants