Description:
fixed timeout bug for wrong submission (thanks to @dtinth), and js bugs occurring in IE
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r232:f00dec11b375 - - 2 files changed: 6 inserted, 2 deleted

@@ -270,25 +270,25
270 recent_id = recent.to_i
270 recent_id = recent.to_i
271 @announcements = @announcements.find_all { |a| a.id > recent_id }
271 @announcements = @announcements.find_all { |a| a.id > recent_id }
272 end
272 end
273 end
273 end
274
274
275 def prepare_timeout_information(problems)
275 def prepare_timeout_information(problems)
276 @submission_timeouts = {}
276 @submission_timeouts = {}
277 problems.each do |problem|
277 problems.each do |problem|
278 assignment = @user.get_recent_test_pair_assignment_for(problem)
278 assignment = @user.get_recent_test_pair_assignment_for(problem)
279 if assignment == nil
279 if assignment == nil
280 timeout = nil
280 timeout = nil
281 else
281 else
282 - if assignment.expired?
282 + if (assignment.expired?) or (assignment.submitted)
283 timeout = 0
283 timeout = 0
284 else
284 else
285 timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
285 timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime
286 end
286 end
287 end
287 end
288 @submission_timeouts[problem.id] = timeout
288 @submission_timeouts[problem.id] = timeout
289 end
289 end
290 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
290 @submission_timeouts.each_pair {|k,v| puts "#{k} => #{v}"}
291 end
291 end
292
292
293 def prepare_list_information
293 def prepare_list_information
294 @user = User.find(session[:user_id])
294 @user = User.find(session[:user_id])
@@ -1,58 +1,62
1 var CodejomTimeout = {
1 var CodejomTimeout = {
2
2
3 timeStarted: null,
3 timeStarted: null,
4
4
5 inputDataDuration: 5, // 5 minutes
5 inputDataDuration: 5, // 5 minutes
6
6
7 timeouts: [],
7 timeouts: [],
8
8
9 updateProblemMessages: function() {
9 updateProblemMessages: function() {
10 CodejomTimeout.timeouts.each(function(data) {
10 CodejomTimeout.timeouts.each(function(data) {
11 + if(data==null)
12 + return;
11 if(data.timeout==null) {
13 if(data.timeout==null) {
12 $("problem-submission-form-" + data.problem).hide();
14 $("problem-submission-form-" + data.problem).hide();
13 } else if(data.timeout==0) {
15 } else if(data.timeout==0) {
14 $("problem-timing-message-" + data.problem).innerHTML =
16 $("problem-timing-message-" + data.problem).innerHTML =
15 "The recent input data is expired. Please download a new one. You'll have 5 minute to submit.";
17 "The recent input data is expired. Please download a new one. You'll have 5 minute to submit.";
16 $("problem-submission-form-" + data.problem).hide();
18 $("problem-submission-form-" + data.problem).hide();
17 } else {
19 } else {
18 $("problem-timing-message-" + data.problem).innerHTML =
20 $("problem-timing-message-" + data.problem).innerHTML =
19 "You have about " + parseInt(data.timeout/60) + " minute(s) and " + parseInt(data.timeout % 60) + " second(s) to submit.";
21 "You have about " + parseInt(data.timeout/60) + " minute(s) and " + parseInt(data.timeout % 60) + " second(s) to submit.";
20 $("problem-submission-form-" + data.problem).show();
22 $("problem-submission-form-" + data.problem).show();
21 }
23 }
22 });
24 });
23 },
25 },
24
26
25 refreshProblemMessages: function() {
27 refreshProblemMessages: function() {
26 var timeElapsed = ((new Date()).getTime() - CodejomTimeout.timeStarted)/1000;
28 var timeElapsed = ((new Date()).getTime() - CodejomTimeout.timeStarted)/1000;
27 // update timeout info
29 // update timeout info
28 CodejomTimeout.timeouts.each(function(data) {
30 CodejomTimeout.timeouts.each(function(data) {
31 + if(data==null)
32 + return;
29 if(data.timeout > timeElapsed) {
33 if(data.timeout > timeElapsed) {
30 data.timeout -= timeElapsed;
34 data.timeout -= timeElapsed;
31 } else if(data.timeout > 0) {
35 } else if(data.timeout > 0) {
32 data.timeout = 0;
36 data.timeout = 0;
33 }
37 }
34 });
38 });
35
39
36 CodejomTimeout.updateProblemMessages();
40 CodejomTimeout.updateProblemMessages();
37 CodejomTimeout.registerRefreshEvent();
41 CodejomTimeout.registerRefreshEvent();
38 },
42 },
39
43
40 registerRefreshEvent: function() {
44 registerRefreshEvent: function() {
41 CodejomTimeout.timeStarted = (new Date()).getTime(),
45 CodejomTimeout.timeStarted = (new Date()).getTime(),
42 setTimeout(function () {
46 setTimeout(function () {
43 CodejomTimeout.refreshProblemMessages();
47 CodejomTimeout.refreshProblemMessages();
44 }, 2700);
48 }, 2700);
45 },
49 },
46
50
47 updateTimeoutAfterDownloadClick: function(problem) {
51 updateTimeoutAfterDownloadClick: function(problem) {
48 CodejomTimeout.timeouts
52 CodejomTimeout.timeouts
49 - .filter(function(data) { return data.problem==problem; })
53 + .filter(function(data) { return (data!=null) && (data.problem==problem); })
50 .each(function(data) {
54 .each(function(data) {
51 if(data.timeout==0 || data.timeout==null) {
55 if(data.timeout==0 || data.timeout==null) {
52 // TODO: use value from rails app.
56 // TODO: use value from rails app.
53 data.timeout = CodejomTimeout.inputDataDuration * 60;
57 data.timeout = CodejomTimeout.inputDataDuration * 60;
54 }
58 }
55 });
59 });
56 CodejomTimeout.updateProblemMessages();
60 CodejomTimeout.updateProblemMessages();
57 },
61 },
58 };
62 };
You need to be logged in to leave comments. Login now