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
c57e6dc7
Commit
c57e6dc7
authored
Jun 25, 2015
by
Afzal Wali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged some endpoints.
parent
a7e5bbea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
34 deletions
+124
-34
edx_proctoring/urls.py
+16
-6
edx_proctoring/views.py
+108
-28
No files found.
edx_proctoring/urls.py
View file @
c57e6dc7
...
...
@@ -8,14 +8,24 @@ from django.conf.urls import patterns, url, include
urlpatterns
=
patterns
(
# pylint: disable=invalid-name
''
,
url
(
r'edx_proctoring/v1/proctored_exam/
status$
'
,
views
.
StudentProctoredExamStatus
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.
status
'
r'edx_proctoring/v1/proctored_exam/
exam
'
,
views
.
ProctoredExamView
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.
exam
'
),
url
(
r'edx_proctoring/v1/proctored_exam/create$'
,
views
.
CreateExamView
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.create'
r'edx_proctoring/v1/proctored_exam/attempt$'
,
views
.
StudentProctoredExamAttempt
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.attempt'
),
url
(
r'edx_proctoring/v1/proctored_exam/allowance'
,
views
.
ExamAllowanceView
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.allowance'
),
url
(
r'edx_proctoring/v1/proctored_exam/active_exams_for_user'
,
views
.
ActiveExamsForUserView
.
as_view
(),
name
=
'edx_proctoring.proctored_exam.active_exams_for_user'
),
url
(
r'^'
,
include
(
'rest_framework.urls'
,
namespace
=
'rest_framework'
))
)
edx_proctoring/views.py
View file @
c57e6dc7
...
...
@@ -4,47 +4,27 @@ Proctored Exams HTTP-based API endpoints
import
logging
from
django.db
import
IntegrityError
from
django.db.models
import
Model
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
edx_proctoring.api
import
create_exam
from
edx_proctoring.api
import
create_exam
,
update_exam
from
.utils
import
AuthenticatedAPIView
LOG
=
logging
.
getLogger
(
"edx_proctoring_views"
)
class
StudentProctoredExamStatus
(
AuthenticatedAPIView
):
"""
Returns the status of the proctored exam.
class
ProctoredExamView
(
AuthenticatedAPIView
):
"""
def
get
(
self
,
request
):
# pylint: disable=unused-argument
"""
HTTP GET Handler
"""
/edx_proctoring/v1/proctored_exam/exam
response_dict
=
{
'in_timed_exam'
:
True
,
'is_proctored'
:
True
,
'exam_display_name'
:
'Midterm'
,
'exam_url_path'
:
''
,
'time_remaining_seconds'
:
45
,
'low_threshold'
:
30
,
'critically_low_threshold'
:
15
,
}
return
Response
(
response_dict
,
status
=
status
.
HTTP_200_OK
)
class
CreateExamView
(
AuthenticatedAPIView
):
"""
HTTP POST
Creates a new Exam.
POST /edx_proctoring/v1/proctored_exam/create
{
"course_id": "edX/DemoX/Demo_Course",
"content_id":
""
,
"content_id":
123
,
"exam_name": "Midterm",
"time_limit_mins": "90",
"is_proctored": true,
...
...
@@ -68,10 +48,25 @@ class CreateExamView(AuthenticatedAPIView):
**Exceptions**
* HTTP_400_BAD_REQUEST, data={"message": "Trying to create a duplicate exam."}
HTTP PUT
Updates an existing Exam.
exam_id,
exam_name=None,
time_limit_mins=None,
is_proctored=None,
external_id=None,
is_active=None
HTTP GET
returns an existing exam
Scenarios
by id
by content id
"""
def
post
(
self
,
request
):
"""
Http POST handler.
Http POST handler.
Creates an exam.
"""
try
:
exam_id
=
create_exam
(
...
...
@@ -87,7 +82,92 @@ class CreateExamView(AuthenticatedAPIView):
except
IntegrityError
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
,
data
=
{
"
message"
:
u
"Trying to create a duplicate exam."
}
data
=
{
"
detail"
:
"Trying to create a duplicate exam."
}
)
def
put
(
self
,
request
):
"""
HTTP PUT handler. To update an exam.
calls the update_exam
"""
try
:
exam_id
=
update_exam
(
exam_id
=
request
.
DATA
.
get
(
'exam_id'
,
""
),
exam_name
=
request
.
DATA
.
get
(
'exam_name'
,
""
),
time_limit_mins
=
request
.
DATA
.
get
(
'time_limit_mins'
,
""
),
is_proctored
=
True
if
request
.
DATA
.
get
(
'is_proctored'
,
"False"
)
.
lower
()
==
'true'
else
False
,
external_id
=
request
.
DATA
.
get
(
'external_id'
,
""
),
is_active
=
True
if
request
.
DATA
.
get
(
'is_active'
,
""
)
.
lower
()
==
'true'
else
False
,
)
return
Response
({
'exam_id'
:
exam_id
})
except
Model
.
DoesNotExist
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
,
data
=
{
"detail"
:
"The exam_id does not exist."
}
)
def
get
(
self
,
request
):
"""
HTTP GET handler.
Scenarios:
by id
by content id
"""
class
StudentProctoredExamAttempt
(
AuthenticatedAPIView
):
"""
Returns the status of the proctored exam.
"""
def
get
(
self
,
request
):
# pylint: disable=unused-argument
"""
HTTP GET Handler. Returns the status of the exam attempt.
"""
response_dict
=
{
'in_timed_exam'
:
True
,
'is_proctored'
:
True
,
'exam_display_name'
:
'Midterm'
,
'exam_url_path'
:
''
,
'time_remaining_seconds'
:
45
,
'low_threshold'
:
30
,
'critically_low_threshold'
:
15
,
}
return
Response
(
response_dict
,
status
=
status
.
HTTP_200_OK
)
def
post
(
self
,
request
):
"""
HTTP POST handler. To start an exam.
"""
def
put
(
self
,
request
):
"""
HTTP POST handler. To stop an exam.
"""
class
ExamAllowanceView
(
AuthenticatedAPIView
):
"""
"""
def
put
(
self
,
request
):
"""
HTTP GET handler. Adds or updates Allowance
"""
def
delete
(
self
,
request
):
"""
HTTP DELETE handler. Removes Allowance.
"""
class
ActiveExamsForUserView
(
AuthenticatedAPIView
):
"""
"""
def
get
(
self
,
request
):
"""
returns the get_active_exams_for_user
"""
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