Commit 6f90af77 by Muhammad Shoaib

PHX-11 Initial Work

parent edc4d2a1
...@@ -336,6 +336,14 @@ def get_all_exams_for_course(course_id): ...@@ -336,6 +336,14 @@ def get_all_exams_for_course(course_id):
return [ProctoredExamSerializer(proctored_exam).data for proctored_exam in exams] return [ProctoredExamSerializer(proctored_exam).data for proctored_exam in exams]
def get_all_exam_attempts(course_id):
"""
Returns all the exam attempts for the course id.
"""
exam_attempts = ProctoredExamStudentAttempt.get_all_exam_attempts(course_id)
return [ProctoredExamStudentAttemptSerializer(active_exam).data for active_exam in exam_attempts]
def get_active_exams_for_user(user_id, course_id=None): def get_active_exams_for_user(user_id, course_id=None):
""" """
This method will return a list of active exams for the user, This method will return a list of active exams for the user,
......
...@@ -184,6 +184,14 @@ class ProctoredExamStudentAttempt(TimeStampedModel): ...@@ -184,6 +184,14 @@ class ProctoredExamStudentAttempt(TimeStampedModel):
return exam_attempt_obj return exam_attempt_obj
@classmethod @classmethod
def get_all_exam_attempts(cls, course_id):
"""
Returns the Student Exam Attempts for the given course_id.
"""
return cls.objects.filter(proctored_exam__course_id=course_id)
@classmethod
def get_active_student_attempts(cls, user_id, course_id=None): def get_active_student_attempts(cls, user_id, course_id=None):
""" """
Returns the active student exams (user in-progress exams) Returns the active student exams (user in-progress exams)
......
...@@ -36,6 +36,11 @@ urlpatterns = patterns( # pylint: disable=invalid-name ...@@ -36,6 +36,11 @@ urlpatterns = patterns( # pylint: disable=invalid-name
name='edx_proctoring.proctored_exam.attempt' name='edx_proctoring.proctored_exam.attempt'
), ),
url( url(
r'edx_proctoring/v1/proctored_exam/attempt/course_id/{}$'.format(settings.COURSE_ID_PATTERN),
views.StudentProctoredExamAttempt.as_view(),
name='edx_proctoring.proctored_exam.attempt'
),
url(
r'edx_proctoring/v1/proctored_exam/attempt$', r'edx_proctoring/v1/proctored_exam/attempt$',
views.StudentProctoredExamAttemptCollection.as_view(), views.StudentProctoredExamAttemptCollection.as_view(),
name='edx_proctoring.proctored_exam.attempt.collection' name='edx_proctoring.proctored_exam.attempt.collection'
......
...@@ -358,11 +358,10 @@ class StudentProctoredExamAttemptCollection(AuthenticatedAPIView): ...@@ -358,11 +358,10 @@ class StudentProctoredExamAttemptCollection(AuthenticatedAPIView):
return the status of the exam attempt return the status of the exam attempt
""" """
def get(self, request): def get(self, request, course_id=None): # pylint: disable=unused-argument
""" """
HTTP GET Handler. Returns the status of the exam attempt. HTTP GET Handler. Returns the status of the exam attempt.
""" """
exams = get_active_exams_for_user(request.user.id) exams = get_active_exams_for_user(request.user.id)
if exams: if exams:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment