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
a7f4c56a
Commit
a7f4c56a
authored
Jul 14, 2015
by
Afzal Wali
Committed by
Muhammad Shoaib
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests
parent
51c79046
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
5 deletions
+60
-5
edx_proctoring/api.py
+2
-0
edx_proctoring/tests/test_api.py
+15
-2
edx_proctoring/tests/test_models.py
+2
-1
edx_proctoring/tests/test_views.py
+40
-0
edx_proctoring/views.py
+1
-2
No files found.
edx_proctoring/api.py
View file @
a7f4c56a
...
@@ -306,6 +306,7 @@ def stop_exam_attempt(exam_id, user_id):
...
@@ -306,6 +306,7 @@ def stop_exam_attempt(exam_id, user_id):
exam_attempt_obj
.
save
()
exam_attempt_obj
.
save
()
return
exam_attempt_obj
.
id
return
exam_attempt_obj
.
id
def
remove_exam_attempt_by_id
(
attempt_id
):
def
remove_exam_attempt_by_id
(
attempt_id
):
"""
"""
Removes an exam attempt given the attempt id.
Removes an exam attempt given the attempt id.
...
@@ -323,6 +324,7 @@ def remove_exam_attempt_by_id(attempt_id):
...
@@ -323,6 +324,7 @@ def remove_exam_attempt_by_id(attempt_id):
existing_attempt
.
delete_exam_attempt
()
existing_attempt
.
delete_exam_attempt
()
def
get_all_exams_for_course
(
course_id
):
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
...
...
edx_proctoring/tests/test_api.py
View file @
a7f4c56a
...
@@ -21,8 +21,8 @@ from edx_proctoring.api import (
...
@@ -21,8 +21,8 @@ from edx_proctoring.api import (
get_student_view
,
get_student_view
,
get_allowances_for_course
,
get_allowances_for_course
,
get_all_exams_for_course
,
get_all_exams_for_course
,
get_exam_attempt_by_id
get_exam_attempt_by_id
,
)
remove_exam_attempt_by_id
)
from
edx_proctoring.exceptions
import
(
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
ProctoredExamAlreadyExists
,
ProctoredExamNotFoundException
,
ProctoredExamNotFoundException
,
...
@@ -336,6 +336,19 @@ class ProctoredExamApiTests(LoggedInTestCase):
...
@@ -336,6 +336,19 @@ class ProctoredExamApiTests(LoggedInTestCase):
)
)
self
.
assertEqual
(
proctored_exam_student_attempt
.
id
,
proctored_exam_attempt_id
)
self
.
assertEqual
(
proctored_exam_student_attempt
.
id
,
proctored_exam_attempt_id
)
def
test_remove_exam_attempt
(
self
):
"""
Calling the api remove function removes the attempt.
"""
with
self
.
assertRaises
(
StudentExamAttemptDoesNotExistsException
):
remove_exam_attempt_by_id
(
9999
)
proctored_exam_student_attempt
=
self
.
_create_unstarted_exam_attempt
()
remove_exam_attempt_by_id
(
proctored_exam_student_attempt
.
id
)
with
self
.
assertRaises
(
StudentExamAttemptDoesNotExistsException
):
remove_exam_attempt_by_id
(
proctored_exam_student_attempt
.
id
)
def
test_stop_a_non_started_exam
(
self
):
def
test_stop_a_non_started_exam
(
self
):
"""
"""
Stop an exam attempt that had not started yet.
Stop an exam attempt that had not started yet.
...
...
edx_proctoring/tests/test_models.py
View file @
a7f4c56a
...
@@ -114,6 +114,7 @@ class ProctoredExamStudentAttemptTests(LoggedInTestCase):
...
@@ -114,6 +114,7 @@ class ProctoredExamStudentAttemptTests(LoggedInTestCase):
def
test_delete_proctored_exam_attempt
(
self
):
# pylint: disable=invalid-name
def
test_delete_proctored_exam_attempt
(
self
):
# pylint: disable=invalid-name
"""
"""
Deleting the proctored exam attempt creates an entry in the history table.
"""
"""
proctored_exam
=
ProctoredExam
.
objects
.
create
(
proctored_exam
=
ProctoredExam
.
objects
.
create
(
course_id
=
'test_course'
,
course_id
=
'test_course'
,
...
@@ -137,7 +138,7 @@ class ProctoredExamStudentAttemptTests(LoggedInTestCase):
...
@@ -137,7 +138,7 @@ class ProctoredExamStudentAttemptTests(LoggedInTestCase):
attempt_history
=
ProctoredExamStudentAttemptHistory
.
objects
.
filter
(
user_id
=
1
)
attempt_history
=
ProctoredExamStudentAttemptHistory
.
objects
.
filter
(
user_id
=
1
)
self
.
assertEqual
(
len
(
attempt_history
),
0
)
self
.
assertEqual
(
len
(
attempt_history
),
0
)
attempt
.
delete
()
attempt
.
delete
_exam_attempt
()
attempt_history
=
ProctoredExamStudentAttemptHistory
.
objects
.
filter
(
user_id
=
1
)
attempt_history
=
ProctoredExamStudentAttemptHistory
.
objects
.
filter
(
user_id
=
1
)
self
.
assertEqual
(
len
(
attempt_history
),
1
)
self
.
assertEqual
(
len
(
attempt_history
),
1
)
edx_proctoring/tests/test_views.py
View file @
a7f4c56a
...
@@ -433,6 +433,46 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
...
@@ -433,6 +433,46 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNotNone
(
response_data
[
'started_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
self
.
assertIsNone
(
response_data
[
'completed_at'
])
def
test_remove_attempt
(
self
):
"""
Confirms that an attempt can be removed
"""
# Create an exam.
proctored_exam
=
ProctoredExam
.
objects
.
create
(
course_id
=
'a/b/c'
,
content_id
=
'test_content'
,
exam_name
=
'Test Exam'
,
external_id
=
'123aXqe3'
,
time_limit_mins
=
90
)
response
=
self
.
client
.
delete
(
reverse
(
'edx_proctoring.proctored_exam.attempt'
,
args
=
[
1
])
)
self
.
assertEqual
(
response
.
status_code
,
400
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'external_id'
:
proctored_exam
.
external_id
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
attempt_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
json
.
loads
(
response
.
content
)
attempt_id
=
response_data
[
'exam_attempt_id'
]
self
.
assertGreater
(
attempt_id
,
0
)
response
=
self
.
client
.
delete
(
reverse
(
'edx_proctoring.proctored_exam.attempt'
,
args
=
[
attempt_id
])
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_read_others_attempt
(
self
):
def
test_read_others_attempt
(
self
):
"""
"""
Confirms that we cnanot read someone elses attempt
Confirms that we cnanot read someone elses attempt
...
...
edx_proctoring/views.py
View file @
a7f4c56a
...
@@ -313,7 +313,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
...
@@ -313,7 +313,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
)
)
@method_decorator
(
require_staff
)
@method_decorator
(
require_staff
)
def
delete
(
self
,
request
,
attempt_id
):
def
delete
(
self
,
request
,
attempt_id
):
# pylint: disable=unused-argument
"""
"""
HTTP DELETE handler. Removes an exam attempt.
HTTP DELETE handler. Removes an exam attempt.
"""
"""
...
@@ -339,7 +339,6 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
...
@@ -339,7 +339,6 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
)
)
class
StudentProctoredExamAttemptCollection
(
AuthenticatedAPIView
):
class
StudentProctoredExamAttemptCollection
(
AuthenticatedAPIView
):
"""
"""
Endpoint for the StudentProctoredExamAttempt
Endpoint for the StudentProctoredExamAttempt
...
...
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