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
d8b5c979
Commit
d8b5c979
authored
Jul 08, 2015
by
Muhammad Shoaib
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the new endpoint for the proctored exams in the course
parent
a4a1775e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
12 deletions
+61
-12
edx_proctoring/api.py
+28
-0
edx_proctoring/models.py
+8
-0
edx_proctoring/urls.py
+6
-0
edx_proctoring/views.py
+19
-12
No files found.
edx_proctoring/api.py
View file @
d8b5c979
...
@@ -104,6 +104,34 @@ def get_exam_by_id(exam_id):
...
@@ -104,6 +104,34 @@ 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.
...
...
edx_proctoring/models.py
View file @
d8b5c979
...
@@ -44,6 +44,14 @@ class ProctoredExam(TimeStampedModel):
...
@@ -44,6 +44,14 @@ 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,
...
...
edx_proctoring/urls.py
View file @
d8b5c979
...
@@ -25,6 +25,12 @@ urlpatterns = patterns( # pylint: disable=invalid-name
...
@@ -25,6 +25,12 @@ urlpatterns = patterns( # pylint: disable=invalid-name
name
=
'edx_proctoring.proctored_exam.exam_by_content_id'
name
=
'edx_proctoring.proctored_exam.exam_by_content_id'
),
),
url
(
url
(
r'edx_proctoring/v1/proctored_exam/exam/course_id/{}$'
.
format
(
settings
.
COURSE_ID_PATTERN
),
views
.
ProctoredExamView
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.exams_by_course_id'
),
url
(
r'edx_proctoring/v1/proctored_exam/attempt$'
,
r'edx_proctoring/v1/proctored_exam/attempt$'
,
views
.
StudentProctoredExamAttempt
.
as_view
(),
views
.
StudentProctoredExamAttempt
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.attempt'
name
=
'edx_proctoring.proctored_exam.attempt'
...
...
edx_proctoring/views.py
View file @
d8b5c979
...
@@ -21,7 +21,7 @@ from edx_proctoring.api import (
...
@@ -21,7 +21,7 @@ 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_allowances_for_course
,
get_exams_by_course_id
)
from
edx_proctoring.exceptions
import
(
from
edx_proctoring.exceptions
import
(
ProctoredBaseException
,
ProctoredBaseException
,
ProctoredExamNotFoundException
,
ProctoredExamNotFoundException
,
...
@@ -176,17 +176,24 @@ class ProctoredExamView(AuthenticatedAPIView):
...
@@ -176,17 +176,24 @@ class ProctoredExamView(AuthenticatedAPIView):
data
=
{
"detail"
:
"The exam_id does not exist."
}
data
=
{
"detail"
:
"The exam_id does not exist."
}
)
)
else
:
else
:
# get by course_id & content_id
if
course_id
is
not
None
:
try
:
if
content_id
is
not
None
:
return
Response
(
# get by course_id & content_id
data
=
get_exam_by_content_id
(
course_id
,
content_id
),
try
:
status
=
status
.
HTTP_200_OK
return
Response
(
)
data
=
get_exam_by_content_id
(
course_id
,
content_id
),
except
ProctoredExamNotFoundException
:
status
=
status
.
HTTP_200_OK
return
Response
(
)
status
=
status
.
HTTP_400_BAD_REQUEST
,
except
ProctoredExamNotFoundException
:
data
=
{
"detail"
:
"The exam with course_id, content_id does not exist."
}
return
Response
(
)
status
=
status
.
HTTP_400_BAD_REQUEST
,
data
=
{
"detail"
:
"The exam with course_id, content_id does not exist."
}
)
else
:
result_set
=
get_exams_by_course_id
(
course_id
=
course_id
)
return
Response
(
result_set
)
class
StudentProctoredExamAttempt
(
AuthenticatedAPIView
):
class
StudentProctoredExamAttempt
(
AuthenticatedAPIView
):
...
...
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