Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-proctoring
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-proctoring
Commits
3e4f500a
Commit
3e4f500a
authored
Jul 08, 2015
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API method to get a list of all exams for a course
parent
b17b841b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
edx_proctoring/api.py
+19
-0
edx_proctoring/models.py
+7
-0
edx_proctoring/tests/test_api.py
+7
-0
No files found.
edx_proctoring/api.py
View file @
3e4f500a
...
...
@@ -219,6 +219,17 @@ def stop_exam_attempt(exam_id, user_id):
return
exam_attempt_obj
.
id
def
get_all_exams_for_course
(
course_id
):
"""
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
get_exam_by_id
"""
exams
=
ProctoredExam
.
get_all_exams_for_course
(
course_id
)
return
[
ProctoredExamSerializer
(
proctored_exam
)
.
data
for
proctored_exam
in
exams
]
def
get_active_exams_for_user
(
user_id
,
course_id
=
None
):
"""
This method will return a list of active exams for the user,
...
...
@@ -277,9 +288,17 @@ def get_student_view(user_id, course_id, content_id, context):
exam_id
=
None
try
:
exam
=
get_exam_by_content_id
(
course_id
,
content_id
)
if
not
exam
[
'is_active'
]:
# Exam is no longer active
# Note, we don't hard delete exams since we need to retain
# data
return
None
exam_id
=
exam
[
'id'
]
is_proctored
=
exam
[
'is_proctored'
]
except
ProctoredExamNotFoundException
:
# This really shouldn't happen
# as Studio will be setting this up
is_proctored
=
context
.
get
(
'is_proctored'
,
False
)
exam_id
=
create_exam
(
course_id
=
course_id
,
...
...
edx_proctoring/models.py
View file @
3e4f500a
...
...
@@ -65,6 +65,13 @@ class ProctoredExam(TimeStampedModel):
proctored_exam
=
None
return
proctored_exam
@classmethod
def
get_all_exams_for_course
(
cls
,
course_id
):
"""
Returns all exams for a give course
"""
return
cls
.
objects
.
filter
(
course_id
=
course_id
)
class
ProctoredExamStudentAttempt
(
TimeStampedModel
):
"""
...
...
edx_proctoring/tests/test_api.py
View file @
3e4f500a
...
...
@@ -16,6 +16,7 @@ from edx_proctoring.api import (
get_exam_attempt
,
create_exam_attempt
,
get_student_view
,
get_all_exams_for_course
,
)
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
...
...
@@ -152,6 +153,12 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
assertEqual
(
proctored_exam
[
'content_id'
],
self
.
content_id
)
self
.
assertEqual
(
proctored_exam
[
'exam_name'
],
self
.
exam_name
)
exams
=
get_all_exams_for_course
(
self
.
course_id
)
self
.
assertEqual
(
len
(
exams
),
1
)
self
.
assertEqual
(
exams
[
0
][
'course_id'
],
self
.
course_id
)
self
.
assertEqual
(
exams
[
0
][
'content_id'
],
self
.
content_id
)
self
.
assertEqual
(
exams
[
0
][
'exam_name'
],
self
.
exam_name
)
def
test_get_invalid_proctored_exam
(
self
):
"""
test to get the exam by the invalid exam_id which will
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment