Commit 4336daf4 by Muhammad Shoaib

change the allowed time to humanized from,

parent a4260231
...@@ -85,10 +85,66 @@ var edx = edx || {}; ...@@ -85,10 +85,66 @@ var edx = edx || {};
collectionChanged: function () { collectionChanged: function () {
this.hydrate(); this.hydrate();
}, },
humanized_time: function(time_in_minutes) {
var hours = parseInt(time_in_minutes / 60);
var minutes = time_in_minutes % 60;
var hours_present = false;
if (hours == 0) {
hours_present = false;
var template = ""
}
else if (hours == 1) {
template = hours + " Hour ";
hours_present = true;
}
else if (hours >= 2) {
console.log(hours);
template = hours + " Hours ";
hours_present = true
}
else {
template = "error";
}
if (template !== "error") {
if (minutes == 0) {
if (!hours_present) {
template = minutes + " Minutes";
}
}
else if ( minutes == 1 ) {
if (hours_present) {
template = template + " and " +minutes + " Minute";
}
else {
template = template + minutes + " Minute";
}
}
else {
if (hours_present) {
template = template + " and " + minutes + " Minutes";
}
else {
template = template + minutes + " Minutes";
}
}
}
return template;
},
render: function () { render: function () {
if (this.template !== null) { if (this.template !== null) {
var attempts = this.collection.toJSON()[0].proctored_exam_attempts;
var proctored_attempts = [];
var self = this;
$.each( attempts, function( index, attempt ){
attempt.allowed_time_limit_mins = self.humanized_time(attempt.allowed_time_limit_mins);
proctored_attempts.push(attempt);
});
var html = this.template({ var html = this.template({
proctored_exam_attempts: this.collection.toJSON()[0].proctored_exam_attempts, proctored_exam_attempts: proctored_attempts,
pagination_info: this.collection.toJSON()[0].pagination_info, pagination_info: this.collection.toJSON()[0].pagination_info,
attempt_url: this.collection.toJSON()[0].attempt_url attempt_url: this.collection.toJSON()[0].attempt_url
}); });
......
<div class="wrapper-content wrapper"> <div class="wrapper-content wrapper">
<section class="content"> <section class="content">
<%
var humanized_time = function(time_in_minutes) {
var hours = parseInt(time_in_minutes / 60);
var minutes = time_in_minutes % 60;
var hours_present = false;
if (hours == 0) {
hours_present = false;
var template = ""
}
else if (hours == 1) {
template = hours + " Hour ";
hours_present = true;
}
else if (hours >= 2) {
console.log(hours);
template = hours + " Hours ";
hours_present = true
}
else {
template = "error";
}
if (template !== "error") {
if (minutes == 0) {
if (!hours_present) {
template = minutes + " Minutes";
}
}
else if ( minutes == 1 ) {
if (hours_present) {
template = template + " and " +minutes + " Minute";
}
else {
template = template + minutes + " Minute";
}
}
else {
if (hours_present) {
template = template + " and " + minutes + " Minutes";
}
else {
template = template + minutes + " Minutes";
}
}
}
return template;
}
%>
<div class="top-header"> <div class="top-header">
<div class='search-attempts'> <div class='search-attempts'>
<input type="text" id="search_attempt_id" placeholder="e.g johndoe or john.do@gmail.com" /> <input type="text" id="search_attempt_id" placeholder="e.g johndoe or john.do@gmail.com" />
...@@ -143,7 +92,7 @@ ...@@ -143,7 +92,7 @@
<td> <td>
<%- interpolate(gettext(' %(exam_display_name)s '), { exam_display_name: proctored_exam_attempt.proctored_exam.exam_name }, true) %> <%- interpolate(gettext(' %(exam_display_name)s '), { exam_display_name: proctored_exam_attempt.proctored_exam.exam_name }, true) %>
</td> </td>
<td> <%= humanized_time(proctored_exam_attempt.allowed_time_limit_mins) %></td> <td> <%= proctored_exam_attempt.allowed_time_limit_mins %></td>
<td> <td>
<% if (proctored_exam_attempt.started_at){ %> <% if (proctored_exam_attempt.started_at){ %>
<%= new Date(proctored_exam_attempt.started_at).toString("MMMM dd, yyyy HH:MM") %> <%= new Date(proctored_exam_attempt.started_at).toString("MMMM dd, yyyy HH:MM") %>
...@@ -165,7 +114,7 @@ ...@@ -165,7 +114,7 @@
<% } %> <% } %>
<td> <td>
<% if (proctored_exam_attempt.status){ %> <% if (proctored_exam_attempt.status){ %>
<a class="remove-attempt" data-attempt-id="<%= proctored_exam_attempt.id %>" >[x]</a> <a href="#" class="remove-attempt" data-attempt-id="<%= proctored_exam_attempt.id %>" >[x]</a>
</td> </td>
<% } else { %> <% } else { %>
N/A N/A
......
...@@ -42,7 +42,7 @@ from edx_proctoring.serializers import ProctoredExamSerializer ...@@ -42,7 +42,7 @@ from edx_proctoring.serializers import ProctoredExamSerializer
from .utils import AuthenticatedAPIView from .utils import AuthenticatedAPIView
ATTEMPTS_PER_PAGE = 1 ATTEMPTS_PER_PAGE = 3
LOG = logging.getLogger("edx_proctoring_views") LOG = logging.getLogger("edx_proctoring_views")
......
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