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
07f070c4
Commit
07f070c4
authored
Jul 14, 2015
by
Afzal Wali
Committed by
Muhammad Shoaib
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove exam attempt.
parent
494806f0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
7 deletions
+76
-7
edx_proctoring/api.py
+16
-0
edx_proctoring/models.py
+5
-0
edx_proctoring/static/proctoring/js/models/proctored_exam_attempt_model.js
+1
-1
edx_proctoring/static/proctoring/js/proctored_app.js
+2
-1
edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js
+21
-1
edx_proctoring/static/proctoring/templates/student-proctored-exam-attempts.underscore
+1
-4
edx_proctoring/views.py
+30
-0
No files found.
edx_proctoring/api.py
View file @
07f070c4
...
@@ -306,6 +306,22 @@ def stop_exam_attempt(exam_id, user_id):
...
@@ -306,6 +306,22 @@ 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_code
(
attempt_code
):
"""
Removes an exam attempt given the attempt code.
"""
existing_attempt
=
ProctoredExamStudentAttempt
.
get_exam_attempt_by_code
(
attempt_code
)
if
not
existing_attempt
:
err_msg
=
(
'Cannot remove attempt for attempt_code = {attempt_code} '
'because it does not exist!'
)
.
format
(
attempt_code
=
attempt_code
)
raise
StudentExamAttemptDoesNotExistsException
(
err_msg
)
existing_attempt
.
delete_exam_attempt
()
def
get_all_exams_for_course
(
course_id
):
def
get_all_exams_for_course
(
course_id
):
"""
"""
...
...
edx_proctoring/models.py
View file @
07f070c4
...
@@ -202,6 +202,11 @@ class ProctoredExamStudentAttempt(TimeStampedModel):
...
@@ -202,6 +202,11 @@ class ProctoredExamStudentAttempt(TimeStampedModel):
return
cls
.
objects
.
filter
(
filtered_query
)
return
cls
.
objects
.
filter
(
filtered_query
)
def
delete_exam_attempt
(
self
):
"""
deletes the exam attempt object.
"""
self
.
delete
()
class
QuerySetWithUpdateOverride
(
models
.
query
.
QuerySet
):
class
QuerySetWithUpdateOverride
(
models
.
query
.
QuerySet
):
"""
"""
...
...
edx_proctoring/static/proctoring/js/models/proctored_exam_attempt_model.js
View file @
07f070c4
...
@@ -8,7 +8,7 @@ var edx = edx || {};
...
@@ -8,7 +8,7 @@ var edx = edx || {};
edx
.
instructor_dashboard
.
proctoring
=
edx
.
instructor_dashboard
.
proctoring
||
{};
edx
.
instructor_dashboard
.
proctoring
=
edx
.
instructor_dashboard
.
proctoring
||
{};
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
=
Backbone
.
Model
.
extend
({
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
=
Backbone
.
Model
.
extend
({
url
:
'/api/edx_proctoring/v1/proctored_exam/a
llowance
'
url
:
'/api/edx_proctoring/v1/proctored_exam/a
ttempt/
'
});
});
this
.
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
=
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
;
this
.
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
=
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
;
...
...
edx_proctoring/static/proctoring/js/proctored_app.js
View file @
07f070c4
...
@@ -8,6 +8,7 @@ $(function() {
...
@@ -8,6 +8,7 @@ $(function() {
var
proctored_exam_attempt_view
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
({
var
proctored_exam_attempt_view
=
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
({
el
:
$
(
'.student-proctored-exam-container'
),
el
:
$
(
'.student-proctored-exam-container'
),
template_url
:
'/static/proctoring/templates/student-proctored-exam-attempts.underscore'
,
template_url
:
'/static/proctoring/templates/student-proctored-exam-attempts.underscore'
,
collection
:
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptCollection
()
collection
:
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptCollection
(),
model
:
new
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptModel
()
});
});
});
});
edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js
View file @
07f070c4
...
@@ -11,10 +11,12 @@ var edx = edx || {};
...
@@ -11,10 +11,12 @@ var edx = edx || {};
this
.
$el
=
options
.
el
;
this
.
$el
=
options
.
el
;
this
.
collection
=
options
.
collection
;
this
.
collection
=
options
.
collection
;
this
.
tempate_url
=
options
.
template_url
;
this
.
tempate_url
=
options
.
template_url
;
this
.
model
=
options
.
model
;
this
.
course_id
=
this
.
$el
.
data
(
'course-id'
);
this
.
course_id
=
this
.
$el
.
data
(
'course-id'
);
this
.
template
=
null
;
this
.
template
=
null
;
this
.
initial_url
=
this
.
collection
.
url
;
this
.
initial_url
=
this
.
collection
.
url
;
this
.
attempt_url
=
this
.
model
.
url
;
this
.
collection
.
url
=
this
.
initial_url
+
this
.
course_id
;
this
.
collection
.
url
=
this
.
initial_url
+
this
.
course_id
;
/* re-render if the model changes */
/* re-render if the model changes */
...
@@ -24,7 +26,7 @@ var edx = edx || {};
...
@@ -24,7 +26,7 @@ var edx = edx || {};
this
.
loadTemplateData
();
this
.
loadTemplateData
();
},
},
events
:
{
events
:
{
"click .remove-attempt"
:
"onRemoveAttempt"
},
},
getCSRFToken
:
function
()
{
getCSRFToken
:
function
()
{
var
cookieValue
=
null
;
var
cookieValue
=
null
;
...
@@ -75,6 +77,24 @@ var edx = edx || {};
...
@@ -75,6 +77,24 @@ var edx = edx || {};
this
.
$el
.
html
(
html
);
this
.
$el
.
html
(
html
);
this
.
$el
.
show
();
this
.
$el
.
show
();
}
}
},
onRemoveAttempt
:
function
(
event
)
{
event
.
preventDefault
();
var
$target
=
$
(
event
.
currentTarget
);
var
attemptId
=
$target
.
data
(
"attemptId"
);
var
self
=
this
;
self
.
model
.
url
=
this
.
attempt_url
+
attemptId
;
self
.
model
.
fetch
(
{
headers
:
{
"X-CSRFToken"
:
this
.
getCSRFToken
()
},
type
:
'DELETE'
,
success
:
function
()
{
// fetch the attempts again.
self
.
hydrate
();
}
});
}
}
});
});
this
.
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
=
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
;
this
.
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
=
edx
.
instructor_dashboard
.
proctoring
.
ProctoredExamAttemptView
;
...
...
edx_proctoring/static/proctoring/templates/student-proctored-exam-attempts.underscore
View file @
07f070c4
...
@@ -43,10 +43,7 @@
...
@@ -43,10 +43,7 @@
N/A
N/A
<% } %>
<% } %>
<td>
<td>
<% if (proctored_exam_attempt.status){ %>
<button type="button" class="remove-attempt blue-button" data-attempt-id="<%= proctored_exam_attempt.id %>" ><%- gettext("Remove") %></button>
<% } else { %>
N/A
<% } %>
</td>
</td>
</tr>
</tr>
<% }); %>
<% }); %>
...
...
edx_proctoring/views.py
View file @
07f070c4
...
@@ -311,6 +311,36 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
...
@@ -311,6 +311,36 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
data
=
{
"detail"
:
str
(
ex
)}
data
=
{
"detail"
:
str
(
ex
)}
)
)
@method_decorator
(
require_staff
)
def
delete
(
self
,
request
,
attempt_id
):
"""
HTTP DELETE handler. Removes an exam attempt.
"""
try
:
attempt
=
get_exam_attempt_by_id
(
attempt_id
)
if
not
attempt
:
err_msg
=
(
'Attempted to access attempt_id {attempt_id} but '
'it does not exist.'
.
format
(
attempt_id
=
attempt_id
)
)
raise
StudentExamAttemptDoesNotExistsException
(
err_msg
)
exam_attempt_id
=
stop_exam_attempt
(
exam_id
=
attempt
[
'proctored_exam'
][
'id'
],
user_id
=
request
.
user
.
id
)
return
Response
({
"exam_attempt_id"
:
exam_attempt_id
})
except
ProctoredBaseException
,
ex
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
,
data
=
{
"detail"
:
str
(
ex
)}
)
class
StudentProctoredExamAttemptCollection
(
AuthenticatedAPIView
):
class
StudentProctoredExamAttemptCollection
(
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