Skip to content

Commit

Permalink
Merge pull request #33691 from Inferato/lytvynenko/bulk_email_checkbo…
Browse files Browse the repository at this point in the history
…x_quince

fix: course mode added to the metadata
  • Loading branch information
Feanil Patel authored Feb 29, 2024
2 parents ac68aae + 6725fa6 commit b679152
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit b679152

Please sign in to comment.