From 28c4036a1c112f3e0e1bce2e1c0a0663aae21d11 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 28 Feb 2017 11:46:01 +0530 Subject: Show remaining time of students in monitor --- yaksh/templates/yaksh/monitor.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html index b84f050..fbcca9c 100644 --- a/yaksh/templates/yaksh/monitor.html +++ b/yaksh/templates/yaksh/monitor.html @@ -12,6 +12,14 @@ $(document).ready(function() { $("#result-table").tablesorter({sortList: [[5,1]]}); + var papers_length = "{{papers|length}}" + for (var i=0; i < papers_length; i++){ + var time_left = $("#time_left"+[i]); + var date = new Date(null); + date.setSeconds(time_left.text()); + var result = date.toISOString().substr(11, 8); + time_left.text(result) + } }); @@ -60,7 +68,7 @@ $(document).ready(function()
-Name | @@ -70,7 +78,7 @@ $(document).ready(function()Questions answered | Marks obtained | Attempts | -Status | +Time Remaining | {{ paper.user.username }} | {{ paper.user.profile.roll_number }} | {{ paper.user.profile.institute }} | -{{ paper.get_answered_str }} | +{{ paper.get_answered_str }} | {{ paper.marks_obtained }} | {{ paper.answers.count }} | -{{ paper.status }} | +{{ paper.time_left }} | + {% endfor %} -- cgit From 3c1abece2c1ba60c561c8e9258aef6e9e7525eba Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 2 Mar 2017 19:10:58 +0530 Subject: Change js to convert seconds --- yaksh/templates/yaksh/monitor.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'yaksh') diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html index fbcca9c..d2c89ce 100644 --- a/yaksh/templates/yaksh/monitor.html +++ b/yaksh/templates/yaksh/monitor.html @@ -12,15 +12,16 @@ $(document).ready(function() { $("#result-table").tablesorter({sortList: [[5,1]]}); - var papers_length = "{{papers|length}}" + var papers_length = "{{papers|length}}"; for (var i=0; i < papers_length; i++){ var time_left = $("#time_left"+[i]); - var date = new Date(null); - date.setSeconds(time_left.text()); - var result = date.toISOString().substr(11, 8); - time_left.text(result) - } - }); + var time = time_left.text(); + var hh = Math.floor(time / 3600); + var mm = Math.floor((time - (hh * 3600)) / 60); + var ss = time - (hh * 3600) - (mm * 60); + time_left.text(hh + ":" + mm + ":" + ss) + } +}); {% endblock %} -- cgit
---|