Commit ae47a13d by Muhammad Shoaib

removed the duplicate method implementation

parent ff31afa0
...@@ -104,34 +104,6 @@ def get_exam_by_id(exam_id): ...@@ -104,34 +104,6 @@ def get_exam_by_id(exam_id):
return serialized_exam_object.data return serialized_exam_object.data
def get_exams_by_course_id(course_id):
"""
Looks up exam by the course_id. Raises exception if not found.
Returns a list containing dictionary version of the Django ORM object
e.g.
[{
"course_id": "edX/DemoX/Demo_Course",
"content_id": "123",
"external_id": "",
"exam_name": "Midterm",
"time_limit_mins": 90,
"is_proctored": true,
"is_active": true
},
{
...: ...,
...: ...
},
..
]
"""
proctored_exams = ProctoredExam.get_exams_by_course_id(course_id)
serialized_proctored_exams = [ProctoredExamSerializer(proctored_exam).data for proctored_exam in proctored_exams]
return serialized_proctored_exams
def get_exam_by_content_id(course_id, content_id): def get_exam_by_content_id(course_id, content_id):
""" """
Looks up exam by the course_id/content_id pair. Raises exception if not found. Looks up exam by the course_id/content_id pair. Raises exception if not found.
...@@ -266,6 +238,24 @@ def get_all_exams_for_course(course_id): ...@@ -266,6 +238,24 @@ def get_all_exams_for_course(course_id):
This method will return all exams for a course. This will return a list This method will return all exams for a course. This will return a list
of dictionaries, whose schema is the same as what is returned in of dictionaries, whose schema is the same as what is returned in
get_exam_by_id get_exam_by_id
Returns a list containing dictionary version of the Django ORM object
e.g.
[{
"course_id": "edX/DemoX/Demo_Course",
"content_id": "123",
"external_id": "",
"exam_name": "Midterm",
"time_limit_mins": 90,
"is_proctored": true,
"is_active": true
},
{
...: ...,
...: ...
},
..
]
""" """
exams = ProctoredExam.get_all_exams_for_course(course_id) exams = ProctoredExam.get_all_exams_for_course(course_id)
......
...@@ -44,14 +44,6 @@ class ProctoredExam(TimeStampedModel): ...@@ -44,14 +44,6 @@ class ProctoredExam(TimeStampedModel):
db_table = 'proctoring_proctoredexam' db_table = 'proctoring_proctoredexam'
@classmethod @classmethod
def get_exams_by_course_id(cls, course_id):
"""
Returns the list of proctored exams
"""
return cls.objects.filter(course_id=course_id)
@classmethod
def get_exam_by_content_id(cls, course_id, content_id): def get_exam_by_content_id(cls, course_id, content_id):
""" """
Returns the Proctored Exam if found else returns None, Returns the Proctored Exam if found else returns None,
......
...@@ -16,7 +16,6 @@ from edx_proctoring.api import ( ...@@ -16,7 +16,6 @@ from edx_proctoring.api import (
get_exam_attempt, get_exam_attempt,
create_exam_attempt, create_exam_attempt,
get_student_view, get_student_view,
get_exams_by_course_id,
get_allowances_for_course, get_allowances_for_course,
get_all_exams_for_course get_all_exams_for_course
) )
...@@ -120,15 +119,6 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -120,15 +119,6 @@ class ProctoredExamApiTests(LoggedInTestCase):
proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value
) )
def test_get_exams_by_course_id(self):
"""
Test to get the exams by course_id
"""
proctored_exams = get_exams_by_course_id(self.course_id)
self.assertEqual(len(proctored_exams), 1)
self.assertEqual(proctored_exams[0]['exam_name'], self.exam_name)
self.assertEqual(proctored_exams[0]['course_id'], self.course_id)
def test_create_duplicate_exam(self): def test_create_duplicate_exam(self):
""" """
Test to create a proctored exam that has already exist in the Test to create a proctored exam that has already exist in the
......
...@@ -21,7 +21,9 @@ from edx_proctoring.api import ( ...@@ -21,7 +21,9 @@ from edx_proctoring.api import (
remove_allowance_for_user, remove_allowance_for_user,
get_active_exams_for_user, get_active_exams_for_user,
create_exam_attempt, create_exam_attempt,
get_allowances_for_course, get_exams_by_course_id) get_allowances_for_course,
get_all_exams_for_course
)
from edx_proctoring.exceptions import ( from edx_proctoring.exceptions import (
ProctoredBaseException, ProctoredBaseException,
ProctoredExamNotFoundException, ProctoredExamNotFoundException,
...@@ -190,7 +192,7 @@ class ProctoredExamView(AuthenticatedAPIView): ...@@ -190,7 +192,7 @@ class ProctoredExamView(AuthenticatedAPIView):
data={"detail": "The exam with course_id, content_id does not exist."} data={"detail": "The exam with course_id, content_id does not exist."}
) )
else: else:
result_set = get_exams_by_course_id( result_set = get_all_exams_for_course(
course_id=course_id course_id=course_id
) )
return Response(result_set) return Response(result_set)
......
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