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

PAE-845 Enhance prerequisites to allow more flexible configuration #59

Open
wants to merge 16 commits into
base: pearson-release/juniper.stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
afaef49
feat: add run_extension_point to use pearson_core functionality for p…
anfbermudezme Nov 11, 2021
7fbd18d
feat: add run_extension_point to use pearson_core functionality for s…
anfbermudezme Nov 11, 2021
7f5577a
feat: add custom functionality to improve learner experience regardin…
anfbermudezme Nov 22, 2021
fd1cb3d
feat: add custom behavior for prerequisites to redirect links in cour…
anfbermudezme Nov 30, 2021
06d1b0f
fix: add a general solution instead of particular for prerequisites c…
anfbermudezme Dec 2, 2021
4c780d4
refactor: add all code related to the PEARSON_CORE_STUDENT_NOT_ENROLL…
anfbermudezme Dec 4, 2021
35df324
refactor: remove useless whitespaces
anfbermudezme Dec 7, 2021
5eb6ccb
refactor: correct code with variables used once.
anfbermudezme Dec 7, 2021
1ac789f
refactor: assign variable to make intention clear.
anfbermudezme Dec 13, 2021
c3a4646
refactor: correct identation.
anfbermudezme Dec 28, 2021
54599d5
refactor: remove unnecessary run_extension_point
anfbermudezme Dec 29, 2021
878a61a
chore: pass the course string to pearson-core using run_extension_point.
anfbermudezme Jan 26, 2022
f8f73be
refactor: add entry for run_extension_point in course_about view and …
anfbermudezme Feb 1, 2022
d92af02
docs: add inline comments for run_extension_point functions.
anfbermudezme Feb 9, 2022
abacb35
refactor: add safe getter for key.
anfbermudezme Feb 10, 2022
8abfea8
refactor: correct inline comments and code details.
anfbermudezme Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,13 @@ def settings_handler(request, course_key_string):
if not all(is_valid_course_key(course_key) for course_key in prerequisite_course_keys):
return JsonResponseBadRequest({"error": _("Invalid prerequisite course key")})
set_prerequisite_courses(course_key, prerequisite_course_keys)
# Add all courses with same org and number to milestones
PREREQUISITE_NOT_MET = 0
run_extension_point(
'PEARSON_CORE_MILESTONE_PREREQUISITES_MODULE',
course_key=course_key,
prerequisite_course_key=CourseKey.from_string(prerequisite_course_keys[PREREQUISITE_NOT_MET]),
)
else:
# None is chosen, so remove the course prerequisites
course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires")
Expand Down
15 changes: 15 additions & 0 deletions common/djangoapps/student/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
from openedx.core.djangolib.markup import HTML, Text
from openedx.features.enterprise_support.api import get_dashboard_consent_notification
from openedx.core.djangoapps.plugins.plugins_hooks import run_extension_point
from shoppingcart.models import CourseRegistrationCode, DonationConfiguration
from student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME
from student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments
Expand Down Expand Up @@ -804,6 +805,19 @@ def student_dashboard(request):
)
courses_requirements_not_met = get_pre_requisite_courses_not_completed(user, courses_having_prerequisites)

# Sort requirements for each course in course_requirements_not_met
courses_requirements_not_met = run_extension_point(
'PEARSON_CORE_SORT_ENROLLED_PREREQUISITES',
user=user,
courses_requirements_not_met=courses_requirements_not_met,
)
# Get the SKU value for the requirements of each course in courses_requirements_not_met
skus_not_enrollment_in_requirements = run_extension_point(
'PEARSON_CORE_STUDENT_NOT_ENROLLED_IN_REQUIREMENTS',
user=user,
courses_requirements_not_met=courses_requirements_not_met,
)

if 'notlive' in request.GET:
redirect_message = _("The course you are looking for does not start until {date}.").format(
date=request.GET['notlive']
Expand Down Expand Up @@ -865,6 +879,7 @@ def student_dashboard(request):
'enrolled_courses_either_paid': enrolled_courses_either_paid,
'provider_states': [],
'courses_requirements_not_met': courses_requirements_not_met,
'sku_not_enrollment_in_requirement': skus_not_enrollment_in_requirements,
'nav_hidden': True,
'inverted_programs': inverted_programs,
'show_program_listing': ProgramsApiConfig.is_enabled(),
Expand Down
22 changes: 20 additions & 2 deletions lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
from track import segment
from util.cache import cache, cache_if_anonymous
from util.db import outer_atomic
from util.milestones_helpers import get_prerequisite_courses_display
from util.milestones_helpers import get_prerequisite_courses_display, get_pre_requisite_courses_not_completed
from util.views import ensure_valid_course_key, ensure_valid_usage_key
from xmodule.course_module import COURSE_VISIBILITY_PUBLIC, COURSE_VISIBILITY_PUBLIC_OUTLINE
from xmodule.modulestore.django import modulestore
Expand Down Expand Up @@ -953,9 +953,23 @@ def course_about(request, course_id):

is_shib_course = uses_shib(course)

# get prerequisite courses display names
# Get prerequisite courses display names
pre_requisite_courses = get_prerequisite_courses_display(course)

courses_requirements_not_met = get_pre_requisite_courses_not_completed(request.user, frozenset({course.id}))
# Sort requirements for each course in course_requirements_not_met
skus_not_enrollment_in_requirements = run_extension_point(
'PEARSON_CORE_STUDENT_NOT_ENROLLED_IN_REQUIREMENTS',
user=request.user,
courses_requirements_not_met=courses_requirements_not_met,
)
# Dictionary with the first requirement in course_requirements_not_met
course_requirements = run_extension_point(
'PEARSON_CORE_STUDENT_COURSE_REQUIREMENTS_FOR_COURSEWARE',
courses_requirements_not_met=courses_requirements_not_met,
course_locator=course.id,
)

# Overview
overview = CourseOverview.get_from_id(course.id)

Expand Down Expand Up @@ -994,6 +1008,10 @@ def course_about(request, course_id):
# context. This value is therefor explicitly set to render the appropriate header.
'disable_courseware_header': True,
'pre_requisite_courses': pre_requisite_courses,
'course_requirements': course_requirements,
'student_not_enrollment_in_requirement': \
skus_not_enrollment_in_requirements.get(course.id),
"ecommerce_payment_page": EcommerceService().payment_page_url(),

Choose a reason for hiding this comment

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

Why do you need this? @anfbermudezme

Copy link
Author

Choose a reason for hiding this comment

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

To pass the context variable to the theme.

image

'course_image_urls': overview.image_urls,
'reviews_fragment_view': reviews_fragment_view,
'sidebar_html_enabled': sidebar_html_enabled,
Expand Down