Commit 494806f0 by Muhammad Shoaib

WIp

parent 3f2712e6
......@@ -71,7 +71,7 @@ var edx = edx || {};
},
render: function () {
if (this.template !== null) {
var html = this.template(this.collection.toJSON());
var html = this.template({proctored_exam_attempts: this.collection.toJSON()[0].proctored_exam_attempts});
this.$el.html(html);
this.$el.show();
}
......
......@@ -3,34 +3,51 @@
<table class="allowance-table">
<thead>
<tr class="allowance-headings">
<th class="exam-name"><%- gettext("Exam Name") %></th>
<tr class="exam-attempt-headings">
<th class="username"><%- gettext("Username") %></th>
<th class="email"><%- gettext("Email") %></th>
<th class="allowance-name"><%- gettext("Is Exam Completed") %> </th>
<th class="allowance-value"><%- gettext("Is Exam Completed in Time") %></th>
<th class="c_action"><%- gettext("Verification Status") %> </th>
<th class="attempt-exam-name"><%- gettext("Exam Name") %></th>
<th class="attempt-allowed-time"><%- gettext("Allowed Time for Student") %> </th>
<th class="attempt-started-at"><%- gettext("started At") %></th>
<th class="attempt-completed-at"><%- gettext("Completed At") %> </th>
<th class="attempt-status"><%- gettext("Status") %> </th>
<th class="attempt-action"><%- gettext("Action") %> </th>
</tr>
</thead>
<tbody>
<% _.each(proctored_exam_attempts, function(proctored_exam_attempt){ %>
<tr class="allowance-items">
<td>
<%- interpolate(gettext(' %(exam_display_name)s '), { exam_display_name: proctored_exam_attempt.proctored_exam.exam_name }, true) %>
<%- interpolate(gettext(' %(username)s '), { username: proctored_exam_attempt.user.username }, true) %>
</td>
<td>
<%- interpolate(gettext(' %(username)s '), { username: proctored_exam_attempt.user.username }, true) %>
</td>
<%- interpolate(gettext(' %(exam_display_name)s '), { exam_display_name: proctored_exam_attempt.proctored_exam.exam_name }, true) %>
</td>
<td> <%= proctored_exam_attempt.allowed_time_limit_mins %></td>
<td>
<%- interpolate(gettext(' %(email)s '), { email: proctored_exam_attempt.user.email }, true) %>
<% if (proctored_exam_attempt.started_at){ %>
<%= proctored_exam_attempt.started_at %>
<% } else { %>
N/A
<% } %>
</td>
<td>
True
<% if (proctored_exam_attempt.completed_at){ %>
<%= proctored_exam_attempt.completed_at %> </td>
<% } else { %>
N/A
<% } %>
<td>
<% if (proctored_exam_attempt.status){ %>
<%= proctored_exam_attempt.status %> </td>
<% } else { %>
N/A
<% } %>
<td>
<% if (proctored_exam_attempt.status){ %>
<% } else { %>
N/A
<% } %>
</td>
<td>False</td>
<td>
True
</td>
</tr>
<% }); %>
</tbody>
......
......@@ -429,7 +429,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.content)
self.assertEqual(response_data['id'], attempt_id)
self.assertEqual(response_data['proctored_exam_id'], proctored_exam.id)
self.assertEqual(response_data['proctored_exam']['id'], proctored_exam.id)
self.assertIsNotNone(response_data['started_at'])
self.assertIsNone(response_data['completed_at'])
......
......@@ -37,7 +37,7 @@ urlpatterns = patterns( # pylint: disable=invalid-name
),
url(
r'edx_proctoring/v1/proctored_exam/attempt/course_id/{}$'.format(settings.COURSE_ID_PATTERN),
views.StudentProctoredExamAttempt.as_view(),
views.StudentProctoredExamAttemptCollection.as_view(),
name='edx_proctoring.proctored_exam.attempt'
),
url(
......
......@@ -253,7 +253,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
raise StudentExamAttemptDoesNotExistsException(err_msg)
# make sure the the attempt belongs to the calling user_id
if attempt['user_id'] != request.user.id:
if attempt['user']['id'] != request.user.id:
err_msg = (
'Attempted to access attempt_id {attempt_id} but '
'does not have access to it.'.format(
......@@ -290,7 +290,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
raise StudentExamAttemptDoesNotExistsException(err_msg)
# make sure the the attempt belongs to the calling user_id
if attempt['user_id'] != request.user.id:
if attempt['user']['id'] != request.user.id:
err_msg = (
'Attempted to access attempt_id {attempt_id} but '
'does not have access to it.'.format(
......@@ -300,7 +300,7 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
raise ProctoredExamPermissionDenied(err_msg)
exam_attempt_id = stop_exam_attempt(
exam_id=attempt['proctored_exam_id'],
exam_id=attempt['proctored_exam']['id'],
user_id=request.user.id
)
return Response({"exam_attempt_id": exam_attempt_id})
......@@ -366,7 +366,7 @@ class StudentProctoredExamAttemptCollection(AuthenticatedAPIView):
"""
if course_id is not None:
exam_attempts = get_all_exam_attempts(course_id)
paginator = Paginator(exam_attempts, 1) # Show 1 attempts per page
paginator = Paginator(exam_attempts, 1) # Show 1 attempts per page
page = request.GET.get('page')
try:
exam_attempts_page = paginator.page(page)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment