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

[BB-8488] Link course enrollments to learning pathways #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pkulkark
Copy link
Member

@pkulkark pkulkark commented Mar 4, 2024

Description

This PR links course enrollments to learning pathways for more granular control over individual course enrollments. It extends the admin feature to bulk enroll users into the courses in the pathway.

Testing Instructions

  1. Set up devstack
  2. Clone this repository to <devstack root>/src
  3. Start lms: $ make dev.up.lms
  4. Enter lms shell: $ make dev.shell.lms
  5. Install this plugin: # pip install -e /edx/src/learning-paths-plugin/
  6. Run migrations: # ./manage.py lms migrate learning_paths
  7. Restart lms: $ make dev.stop.lms dev.up.lms
  8. Login as verified user and check dashboard for enrolled courses.
  9. As an admin user, create a learning path at http://localhost:18000/admin/learning_paths/learningpath/ with a few courses in the learning steps section.
  10. In the "Bulk enroll users" field, add verified username and save the learning path.
  11. Login again as verified user and verify that the user has been enrolled in all the courses listed in the learning steps section.

@pkulkark pkulkark force-pushed the pooja/link-course-enrollments-to-pathway branch 2 times, most recently from 5a849e5 to 3d0fb15 Compare March 4, 2024 16:41
@pkulkark pkulkark force-pushed the pooja/link-course-enrollments-to-pathway branch from 3d0fb15 to 2725429 Compare March 4, 2024 16:43
Copy link
Contributor

@CefBoud CefBoud left a comment

Choose a reason for hiding this comment

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

@pkulkark Thank you for your work on this. I left a few comments. Please let me know what you think.

Comment on lines +20 to +24
try:
learning_path_step = LearningPathStep.objects.get(course_key=course_key)
except LearningPathStep.DoesNotExist:
logger.info("Course is not part of any Learning Path. Ignoring.")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't possible for a Course to correspond to multiple LearningSteps in different LearningPaths?

Copy link
Member Author

Choose a reason for hiding this comment

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

@CefBoud That's a good point you brought up. Let's say there's a course that's part of 2 different LearningPaths. If a user enrolls into it, should they be automatically enrolled into both the LearningPaths? Or should the enrollments in LearningPaths be only through the admin (i.e. should be done explicitly)? I'm inclined towards keeping it explicit but that would mean doing away with this whole signal.py file. What do you think?

Comment on lines +16 to +17
if created: # Only react to new enrollments
course_key = instance.course_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to only react to new enrollments? How about unenrollment?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea was to automatically create a learningpathcourseenrollment object, if a course was added to a learning path (after initial learning path enrollments were done) and a user enrolled into it. But the changes here might not be needed at all (see previous comment).

LearningPathEnrollment, on_delete=models.CASCADE
)
course_key = CourseKeyField(max_length=255)
status = models.CharField(max_length=9, choices=STATUS_CHOICES)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be maybe replaced with an is_active BooleanField?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep sure. I was just following the same things as ProgramCourseEnrollment field.

learning_path=form.instance
).values_list("course_key", flat=True)
for course_key in courses:
LearningPathCourseEnrollment.objects.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe create only if it doesn't already exist? Otherwise, this will fail if a user is added a second time to the form (by mistake or intentionally)

logger = logging.getLogger(__name__)


@receiver(post_save, sender=CourseEnrollment)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: how about using the COURSE_ENROLLMENT_CREATED signal?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering if we should just do away with the CourseEnrollment foreign key and only use the COURSE_ENROLLMENT_CREATED and COURSE_UNENROLLMENT_COMPLETED signals to link the learning path enrollments to course enrollments. While the current approach works within lms, it breaks the modularity of the plugin and creates too much of a dependency on lms (CI tests can't pass without lms). What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't need the CourseEnrollement object, yeah, definitely.

Comment on lines +137 to +138
for course_key in courses:
LearningPathCourseEnrollment.objects.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about using bulk_create here?

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.

2 participants