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/quince.1 with Upstream 20240304-1709511617 #641

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions lms/djangoapps/course_home_api/course_metadata/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def get_url(self, tab):
return request.build_absolute_uri(tab.link_func(self.context.get('course'), reverse))


class CourseModeSerrializer(serializers.Serializer):
"""
Serializer for the Course Mode
"""
slug = serializers.CharField()
name = serializers.CharField()


class CourseHomeMetadataSerializer(VerifiedModeSerializer):
"""
Serializer for the Course Home Course Metadata
Expand All @@ -48,3 +56,4 @@ class CourseHomeMetadataSerializer(VerifiedModeSerializer):
username = serializers.CharField()
user_timezone = serializers.CharField()
can_view_certificate = serializers.BooleanField()
course_modes = CourseModeSerrializer(many=True)
4 changes: 4 additions & 0 deletions lms/djangoapps/course_home_api/course_metadata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
from openedx.core.djangoapps.courseware_api.utils import get_celebrations_dict

from common.djangoapps.course_modes.models import CourseMode
from common.djangoapps.student.models import CourseEnrollment
from lms.djangoapps.course_api.api import course_detail
from lms.djangoapps.course_goals.models import UserActivity
Expand Down Expand Up @@ -117,6 +118,8 @@ def get(self, request, *args, **kwargs):
# Record course goals user activity for (web) learning mfe course tabs
UserActivity.record_user_activity(request.user, course_key)

course_modes = CourseMode.modes_for_course(course_key, include_expired=True, only_selectable=False)

data = {
'course_id': course.id,
'username': username,
Expand All @@ -133,6 +136,7 @@ def get(self, request, *args, **kwargs):
'celebrations': celebrations,
'user_timezone': user_timezone,
'can_view_certificate': certificates_viewable_for_course(course),
'course_modes': course_modes,
}
context = self.get_serializer_context()
context['course'] = course
Expand Down
Loading