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
08460713
Commit
08460713
authored
Jul 16, 2015
by
Muhammad Shoaib
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert the serializers method and added test for the endpoints
parent
4936f7a7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
37 deletions
+92
-37
edx_proctoring/serializers.py
+0
-13
edx_proctoring/static/proctoring/templates/student-proctored-exam-attempts.underscore
+3
-1
edx_proctoring/tests/test_api.py
+23
-2
edx_proctoring/tests/test_views.py
+66
-20
edx_proctoring/views.py
+0
-1
No files found.
edx_proctoring/serializers.py
View file @
08460713
...
...
@@ -2,7 +2,6 @@
from
rest_framework
import
serializers
from
django.contrib.auth.models
import
User
from
edx_proctoring.models
import
ProctoredExam
,
ProctoredExamStudentAttempt
,
ProctoredExamStudentAllowance
from
edx_proctoring.utils
import
humanized_time
DATETIME_FORMAT
=
"
%
b
%
d,
%
Y
%
I:
%
M
%
p"
# "MMMM dd, yyyy HH:MM"
...
...
@@ -71,18 +70,6 @@ class ProctoredExamStudentAttemptSerializer(serializers.ModelSerializer):
"""
proctored_exam
=
ProctoredExamSerializer
()
user
=
UserSerializer
()
allowed_time_limit_mins
=
serializers
.
SerializerMethodField
(
method_name
=
"get_allowed_time_limit_mins"
)
started_at
=
serializers
.
SerializerMethodField
(
method_name
=
"get_started_at"
)
completed_at
=
serializers
.
SerializerMethodField
(
method_name
=
"get_completed_at"
)
def
get_allowed_time_limit_mins
(
self
,
obj
):
return
humanized_time
(
obj
.
allowed_time_limit_mins
)
def
get_started_at
(
self
,
obj
):
return
obj
.
started_at
.
strftime
(
DATETIME_FORMAT
)
if
obj
.
started_at
else
"N/A"
def
get_completed_at
(
self
,
obj
):
return
obj
.
completed_at
.
strftime
(
DATETIME_FORMAT
)
if
obj
.
completed_at
else
"N/A"
class
Meta
:
"""
...
...
edx_proctoring/static/proctoring/templates/student-proctored-exam-attempts.underscore
View file @
08460713
...
...
@@ -99,11 +99,13 @@
<td> <%= proctored_exam_attempt.allowed_time_limit_mins %></td>
<td> <%= proctored_exam_attempt.started_at %></td>
<td> <%= proctored_exam_attempt.completed_at %></td>
<td>
<% if (proctored_exam_attempt.status){ %>
<%= proctored_exam_attempt.status %>
</td>
<%= proctored_exam_attempt.status %>
<% } else { %>
N/A
<% } %>
</td>
<td>
<% if (proctored_exam_attempt.status){ %>
<a href="#" class="remove-attempt" data-attempt-id="<%= proctored_exam_attempt.id %>" >[x]</a>
...
...
edx_proctoring/tests/test_api.py
View file @
08460713
...
...
@@ -23,8 +23,8 @@ from edx_proctoring.api import (
get_all_exams_for_course
,
get_exam_attempt_by_id
,
remove_exam_attempt_by_id
,
get_all_exam_attempts
)
get_all_exam_attempts
,
get_filtered_exam_attempts
)
from
edx_proctoring.exceptions
import
(
ProctoredExamAlreadyExists
,
ProctoredExamNotFoundException
,
...
...
@@ -386,6 +386,27 @@ class ProctoredExamApiTests(LoggedInTestCase):
self
.
assertEqual
(
len
(
student_active_exams
[
0
][
'allowances'
]),
2
)
self
.
assertEqual
(
len
(
student_active_exams
[
1
][
'allowances'
]),
0
)
def
test_get_filtered_exam_attempts
(
self
):
"""
Test to get all the exams filtered by the course_id
and search type.
"""
exam_attempt
=
self
.
_create_started_exam_attempt
()
exam_id
=
create_exam
(
course_id
=
self
.
course_id
,
content_id
=
'test_content_2'
,
exam_name
=
'Final Test Exam'
,
time_limit_mins
=
self
.
default_time_limit
)
new_exam_attempt
=
create_exam_attempt
(
exam_id
=
exam_id
,
user_id
=
self
.
user_id
)
filtered_attempts
=
get_filtered_exam_attempts
(
self
.
course_id
,
self
.
user
.
username
)
self
.
assertEqual
(
len
(
filtered_attempts
),
2
)
self
.
assertEqual
(
filtered_attempts
[
0
][
'id'
],
exam_attempt
.
id
)
self
.
assertEqual
(
filtered_attempts
[
1
][
'id'
],
new_exam_attempt
)
def
test_get_all_exam_attempts
(
self
):
"""
Test to get all the exam attempts.
...
...
edx_proctoring/tests/test_views.py
View file @
08460713
...
...
@@ -385,7 +385,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
,
'
attempt_proctored'
:
True
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
...
...
@@ -411,7 +411,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
,
'
attempt_proctored'
:
True
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
...
...
@@ -455,7 +455,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
,
'
attempt_proctored'
:
True
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
...
...
@@ -488,7 +488,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
,
'
attempt_proctored'
:
True
,
'start_clock'
:
True
,
}
response
=
self
.
client
.
post
(
...
...
@@ -530,7 +530,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'external_id'
:
proctored_exam
.
external_id
'attempt_proctored'
:
True
,
'start_clock'
:
False
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -566,8 +567,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
user_id'
:
self
.
student_taking_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
'
attempt_proctored'
:
True
,
'
start_clock'
:
False
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -602,8 +603,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
user_id'
:
self
.
student_taking_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
'
attempt_proctored'
:
True
,
'
start_clock'
:
False
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -618,6 +619,53 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
response_data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
len
(
response_data
[
'proctored_exam_attempts'
]),
1
)
def
test_get_filtered_exam_attempts
(
self
):
"""
Test to get the exam attempts in a course.
"""
# 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
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'start_clock'
:
False
,
'attempt_proctored'
:
True
}
# create a exam attempt
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
attempt_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
client
.
login_user
(
self
.
second_user
)
# create a new exam attempt for second student
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
attempt_data
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
client
.
login_user
(
self
.
user
)
response
=
self
.
client
.
get
(
reverse
(
'edx_proctoring.proctored_exam.attempt.search'
,
kwargs
=
{
'course_id'
:
proctored_exam
.
course_id
,
'search_by'
:
'tester'
}
)
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
json
.
loads
(
response
.
content
)
self
.
assertEqual
(
len
(
response_data
[
'proctored_exam_attempts'
]),
2
)
def
test_stop_others_attempt
(
self
):
"""
Start an exam (create an exam attempt)
...
...
@@ -632,8 +680,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
)
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
user_id'
:
self
.
student_taking_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
'
attempt_proctored'
:
True
,
'
start_clock'
:
False
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -688,9 +736,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'user_id'
:
self
.
user
.
id
,
'external_id'
:
proctored_exam
.
external_id
,
'start_clock'
:
True
'start_clock'
:
True
,
'attempts_proctored'
:
True
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -722,9 +769,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'user_id'
:
self
.
user
.
id
,
'external_id'
:
proctored_exam
.
external_id
,
'start_clock'
:
True
'start_clock'
:
True
,
'attempt_proctored'
:
True
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -759,8 +805,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt_data
=
{
'exam_id'
:
proctored_exam
.
id
,
'
user_id'
:
self
.
student_taking_exam
.
id
,
'
external_id'
:
proctored_exam
.
external_id
'
attempt_proctored'
:
True
,
'
start_clock'
:
True
}
response
=
self
.
client
.
post
(
reverse
(
'edx_proctoring.proctored_exam.attempt.collection'
),
...
...
@@ -796,8 +842,8 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
# create an attempt but don't start it
attempt_data
=
{
'attempt_proctored'
:
True
,
'exam_id'
:
proctored_exam
.
id
,
'external_id'
:
proctored_exam
.
external_id
,
'start_clock'
:
False
,
}
response
=
self
.
client
.
post
(
...
...
edx_proctoring/views.py
View file @
08460713
...
...
@@ -5,7 +5,6 @@ Proctored Exams HTTP-based API endpoints
import
logging
import
pytz
from
datetime
import
datetime
,
timedelta
from
django.core.urlresolvers
import
reverse
from
django.utils.decorators
import
method_decorator
from
django.conf
import
settings
...
...
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