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

Sync opencraft-release/redwood.1 with Upstream 20241014-1728865275 #696

Open
wants to merge 20 commits into
base: opencraft-release/redwood.1
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
aa70fea
feat: hide the survey report banner for a month after clicking the di…
Asespinel Jun 19, 2024
e5f074b
chore: upgrade Django to 4.2.14
magajh Jul 15, 2024
932e504
Merge pull request #35120 from magajh/open-release/redwood.master
Jul 15, 2024
4744ea1
chore!: uprgade social-auth-app-django to version 5.4.1
iamsobanjaved Jun 10, 2024
670772b
chore: add migration from social_django
iamsobanjaved Jun 27, 2024
2165da0
chore: Re-compile requirements.
feanil Jul 23, 2024
b4a1e01
Merge pull request #35166 from openedx/feanil/backport_django_social_…
Jul 23, 2024
ed72248
fix: libraries across orgs
connorhaugh Feb 15, 2024
d23b41e
docs: imporved comment
connorhaugh Feb 15, 2024
d757cfa
fix: cohorts data can be private
connorhaugh Oct 4, 2023
62269f8
fix: Remove errant pluses from a bad merge.
feanil Jul 25, 2024
8813e8b
style: Fix a pylint and style violations.
feanil Jul 25, 2024
3160ff6
Merge pull request #35180 from openedx/feanil/backporting
Jul 25, 2024
1e0d575
fix: course progress url returned based on course_home_mfe_progress_t…
FatemeKhodayari Jul 30, 2024
c5d7507
chore: upgrade Django to 4.2.15 (#35240)
magajh Aug 6, 2024
d5c84e9
backport fix: disable submit button for archived courses (#34920) to …
Anas12091101 Aug 8, 2024
fa97f13
fix: Prevent error page recursion (#35209)
timmc-edx Jul 31, 2024
3d50dd8
Merge pull request #35259 from raccoongang/max/backport-error-page-re…
cmltaWt0 Aug 8, 2024
5ea3b98
feat: course about page markup and styles improvements (#34892)
ihor-romaniuk Sep 9, 2024
9c8059b
fix: backport: hide new library button for ineligible users in split …
kaustavb12 Sep 19, 2024
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
Prev Previous commit
Next Next commit
fix: course progress url returned based on course_home_mfe_progress_t…
…ab_is_active (openedx#35149)
  • Loading branch information
FatemeKhodayari authored Jul 30, 2024
commit 1e0d575f5ff686ccc600e1efc1aab9e812a059ee
3 changes: 2 additions & 1 deletion lms/djangoapps/learner_home/serializers.py
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
from common.djangoapps.course_modes.models import CourseMode
from openedx.features.course_experience import course_home_url
from xmodule.data import CertificatesDisplayBehaviors
from lms.djangoapps.learner_home.utils import course_progress_url


class LiteralField(serializers.Field):
@@ -116,7 +117,7 @@ def get_homeUrl(self, instance):
return course_home_url(instance.course_id)

def get_progressUrl(self, instance):
return reverse("progress", kwargs={"course_id": instance.course_id})
return course_progress_url(instance.course_id)

def get_unenrollUrl(self, instance):
return reverse("course_run_refund_status", args=[instance.course_id])
26 changes: 25 additions & 1 deletion lms/djangoapps/learner_home/test_serializers.py
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
SuggestedCourseSerializer,
UnfulfilledEntitlementSerializer,
)

from lms.djangoapps.learner_home.utils import course_progress_url
from lms.djangoapps.learner_home.test_utils import (
datetime_to_django_format,
random_bool,
@@ -224,6 +224,30 @@ def test_missing_resume_url(self):
# Then the resumeUrl is None, which is allowed
self.assertIsNone(output_data["resumeUrl"])

def is_progress_url_matching_course_home_mfe_progress_tab_is_active(self):
"""
Compares the progress URL generated by CourseRunSerializer to the expected progress URL.

:return: True if the generated progress URL matches the expected, False otherwise.
"""
input_data = self.create_test_enrollment()
input_context = self.create_test_context(input_data.course.id)
output_data = CourseRunSerializer(input_data, context=input_context).data
return output_data['progressUrl'] == course_progress_url(input_data.course.id)

@mock.patch('lms.djangoapps.learner_home.utils.course_home_mfe_progress_tab_is_active')
def test_progress_url(self, mock_course_home_mfe_progress_tab_is_active):
"""
Tests the progress URL generated by the CourseRunSerializer. When course_home_mfe_progress_tab_is_active
is true, the generated progress URL must point to the progress page of the course home (learning) MFE.
Otherwise, it must point to the legacy progress page.
"""
mock_course_home_mfe_progress_tab_is_active.return_value = True
self.assertTrue(self.is_progress_url_matching_course_home_mfe_progress_tab_is_active())

mock_course_home_mfe_progress_tab_is_active.return_value = False
self.assertTrue(self.is_progress_url_matching_course_home_mfe_progress_tab_is_active())


@ddt.ddt
class TestCoursewareAccessSerializer(LearnerDashboardBaseTest):
16 changes: 16 additions & 0 deletions lms/djangoapps/learner_home/utils.py
Original file line number Diff line number Diff line change
@@ -4,13 +4,16 @@

import logging

from django.urls import reverse
from django.contrib.auth import get_user_model
from django.core.exceptions import MultipleObjectsReturned
from rest_framework.exceptions import PermissionDenied, NotFound

from common.djangoapps.student.models import (
get_user_by_username_or_email,
)
from lms.djangoapps.course_home_api.toggles import course_home_mfe_progress_tab_is_active
from openedx.features.course_experience.url_helpers import get_learning_mfe_home_url

log = logging.getLogger(__name__)
User = get_user_model()
@@ -54,3 +57,16 @@ def get_masquerade_user(request):
)
log.info(success_msg)
return masquerade_user


def course_progress_url(course_key) -> str:
"""
Returns the course progress page's URL for the current user.

:param course_key: The course key for which the home url is being requested.

:return: The course progress page URL.
"""
if course_home_mfe_progress_tab_is_active(course_key):
return get_learning_mfe_home_url(course_key, url_fragment='progress')
return reverse('progress', kwargs={'course_id': course_key})