diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 0b12b917e..af9896b01 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,35 +3,55 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); + var time = <%=exercise.time %>; + var total_seconds = time * 60; + getTime(total_seconds); }); - function getTime() { - + function getTime(total_seconds) { + start_time = new Date($("#start_time").html()); + end_time = start_time + 60*60*<%=exercise.time %>; + now = new Date(); + //start = new Date(start_time); + //end_time = start_time; + var total_seconds = total_seconds - 1; + var hours = total_seconds / 60 / 60; + var hoursRound = Math.floor(hours); + var minutes = total_seconds /60 - (60 * hoursRound); + var minutesRound = Math.floor(minutes); + var seconds = total_seconds - (60 * 60 * hoursRound) - (60 * minutesRound); + var secondsRound = Math.round(seconds); + $("#rest_hours").html(hoursRound); + $("#rest_minutes").html(minutesRound); + $("#rest_seconds").html(secondsRound); + if(total_seconds >0) { + setTimeout("getTime("+total_seconds+");", 1000); + } }