Merge pull request #28675 from edx/AA-905

Populate the course goals user activity table when a user visits course-specific pages
This commit is contained in:
Matthew Piatetsky
2021-09-20 13:52:27 -04:00
committed by GitHub
16 changed files with 469 additions and 8 deletions

View File

@@ -20,6 +20,8 @@ from edx_rest_framework_extensions.auth.session.authentication import SessionAut
from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.course_api.api import course_detail
from lms.djangoapps.course_goals.models import UserActivity
from lms.djangoapps.course_goals.toggles import RECORD_USER_ACTIVITY_FLAG
from lms.djangoapps.course_home_api.toggles import course_home_legacy_is_active
from lms.djangoapps.courseware.access import has_access
from lms.djangoapps.courseware.courses import get_course_with_access
@@ -152,5 +154,11 @@ class CourseDeadlinesMobileView(RetrieveAPIView):
# Although this course data is not used this method will return 404 if course does not exist
get_course_with_access(request.user, 'load', course_key)
if RECORD_USER_ACTIVITY_FLAG.is_enabled():
# Record user activity for tracking progress towards a user's course goals (for mobile app)
UserActivity.record_user_activity(
request.user, course_key, request=request, only_if_mobile_app=True
)
serializer = self.get_serializer({})
return Response(serializer.data)