Description:
[web] fix nil problem in various place, some styling
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@259 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r129:adeb816b0bb6 - - 4 files changed: 10 inserted, 11 deleted
@@ -13,66 +13,65 | |||
|
13 | 13 | end |
|
14 | 14 | return @@configurations[key] |
|
15 | 15 | end |
|
16 | 16 | |
|
17 | 17 | def self.[](key) |
|
18 | 18 | self.get(key) |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | def self.reload |
|
22 | 22 | self.read_config |
|
23 | 23 | end |
|
24 | 24 | |
|
25 | 25 | def self.clear |
|
26 | 26 | @@configurations = nil |
|
27 | 27 | end |
|
28 | 28 | |
|
29 | 29 | # |
|
30 | 30 | # View decision |
|
31 | 31 | # |
|
32 | 32 | def self.show_submitbox_to?(user) |
|
33 | 33 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
34 | 34 | return false if mode=='analysis' |
|
35 | 35 | if (mode=='contest') |
|
36 | 36 | return false if (user.site!=nil) and |
|
37 |
- ((user.site.started |
|
|
37 | + ((user.site.started!=true) or (user.site.finished?)) | |
|
38 | 38 | end |
|
39 | 39 | return true |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | 42 | def self.show_tasks_to?(user) |
|
43 | 43 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
44 | 44 | if (mode=='contest') |
|
45 |
- return false if (user.site!=nil) and (user.site.started |
|
|
45 | + return false if (user.site!=nil) and (user.site.started!=true) | |
|
46 | 46 | end |
|
47 | 47 | return true |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | def self.allow_test_request(user) |
|
51 | 51 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
52 | 52 | if (mode=='contest') |
|
53 |
- return false if (user.site!=nil) and ((user.site.started |
|
|
54 | - (user.site.time_left < 30.minutes)) | |
|
53 | + return false if (user.site!=nil) and ((user.site.started!=true) or (user.site.time_left < 30.minutes)) | |
|
55 | 54 | end |
|
56 | 55 | return false if mode=='analysis' |
|
57 | 56 | return true |
|
58 | 57 | end |
|
59 | 58 | |
|
60 | 59 | protected |
|
61 | 60 | def self.read_config |
|
62 | 61 | @@configurations = {} |
|
63 | 62 | Configuration.find(:all).each do |conf| |
|
64 | 63 | key = conf.key |
|
65 | 64 | val = conf.value |
|
66 | 65 | case conf.value_type |
|
67 | 66 | when 'string' |
|
68 | 67 | @@configurations[key] = val |
|
69 | 68 | |
|
70 | 69 | when 'integer' |
|
71 | 70 | @@configurations[key] = val.to_i |
|
72 | 71 | |
|
73 | 72 | when 'boolean' |
|
74 | 73 | @@configurations[key] = (val=='true') |
|
75 | 74 | end |
|
76 | 75 | end |
|
77 | 76 | end |
|
78 | 77 |
@@ -1,42 +1,47 | |||
|
1 | 1 | class Site < ActiveRecord::Base |
|
2 | 2 | |
|
3 | 3 | belongs_to :country |
|
4 | 4 | has_many :users |
|
5 | 5 | |
|
6 | 6 | def clear_start_time_if_not_started |
|
7 | 7 | if !self.started |
|
8 | 8 | self.start_time = nil |
|
9 | 9 | end |
|
10 | 10 | end |
|
11 | 11 | |
|
12 | 12 | def time_left |
|
13 | 13 | contest_time = Configuration['contest.time_limit'] |
|
14 | 14 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
15 | 15 | h = tmatch[1].to_i |
|
16 | 16 | m = tmatch[2].to_i |
|
17 | - finish_time = self.start_time + h.hour + m.minute | |
|
17 | + | |
|
18 | 18 | current_time = Time.now.gmtime |
|
19 | + if self.start_time!=nil | |
|
20 | + finish_time = self.start_time + h.hour + m.minute | |
|
21 | + else | |
|
22 | + finish_time = current_time + h.hour + m.minute | |
|
23 | + end | |
|
19 | 24 | |
|
20 | 25 | if current_time > finish_time |
|
21 | 26 | return current_time - current_time |
|
22 | 27 | else |
|
23 | 28 | finish_time - current_time |
|
24 | 29 | end |
|
25 | 30 | else |
|
26 | 31 | nil |
|
27 | 32 | end |
|
28 | 33 | end |
|
29 | 34 | |
|
30 | 35 | def finished? |
|
31 | 36 | if !self.started |
|
32 | 37 | return false |
|
33 | 38 | end |
|
34 | 39 | |
|
35 | 40 | contest_time = Configuration['contest.time_limit'] |
|
36 | 41 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
37 | 42 | h = tmatch[1].to_i |
|
38 | 43 | m = tmatch[2].to_i |
|
39 | 44 | return Time.now.gmtime > (self.start_time + h.hour + m.minute) |
|
40 | 45 | else |
|
41 | 46 | false |
|
42 | 47 | end |
@@ -4,29 +4,24 | |||
|
4 | 4 | .announcementbox |
|
5 | 5 | %span{:class => 'title'} |
|
6 | 6 | Announcements |
|
7 | 7 | = render :partial => 'announcement', :collection => @announcements |
|
8 | 8 | |
|
9 | 9 | - if Configuration.show_submitbox_to?(@user) |
|
10 | 10 | .submitbox |
|
11 | 11 | = error_messages_for 'submission' |
|
12 | 12 | = render :partial => 'submission_box' |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | %hr/ |
|
16 | 16 | |
|
17 | 17 | - if Configuration.show_tasks_to?(@user) |
|
18 | 18 | %table.info |
|
19 | 19 | %tr.info-head |
|
20 | 20 | %th |
|
21 | 21 | %th Tasks |
|
22 | 22 | %th # of sub(s) |
|
23 | 23 | %th Results |
|
24 | 24 | = render :partial => 'problem', :collection => @problems |
|
25 | 25 | |
|
26 | 26 | %hr/ |
|
27 | 27 | |
|
28 | - %p | |
|
29 | - %b Note: | |
|
30 | - We currently have problems synchronizing | |
|
31 | - the time stamps between grading machines. | |
|
32 | - You will see weird time stamps during the practice session. |
@@ -56,49 +56,49 | |||
|
56 | 56 | <td> |
|
57 | 57 | <%= select(:test_request, |
|
58 | 58 | :submission_number, |
|
59 | 59 | ((1..@submissions[0].number).collect {|n| [n,n]}).reverse) %> |
|
60 | 60 | </td> |
|
61 | 61 | </tr> |
|
62 | 62 | <tr> |
|
63 | 63 | <td>Input data:</td> |
|
64 | 64 | <td> |
|
65 | 65 | <%= f.file_field :input_file %> |
|
66 | 66 | </td> |
|
67 | 67 | <td> |
|
68 | 68 | (combined size should not exceed 2MB) |
|
69 | 69 | </td> |
|
70 | 70 | </tr> |
|
71 | 71 | <tr> |
|
72 | 72 | <td> |
|
73 | 73 | Additional file<sup><span style="color:red">*</span></sup>: |
|
74 | 74 | </td> |
|
75 | 75 | <td> |
|
76 | 76 | <%= f.file_field :additional_file %> |
|
77 | 77 | </td> |
|
78 | 78 | <td> |
|
79 | 79 | <small> |
|
80 |
- * This option works <u>only</u> for task |
|
|
80 | + * This option works <u>only</u> for task beads. | |
|
81 | 81 | You can use this to submit <tt>questions.txt</tt>.<br/> |
|
82 | 82 | The file shall be copied to the execution directory before your program runs. |
|
83 | 83 | </small> |
|
84 | 84 | </td> |
|
85 | 85 | </tr> |
|
86 | 86 | <tr> |
|
87 | 87 | <td colspan="2"> |
|
88 | 88 | <%= submit_tag 'submit' %> |
|
89 | 89 | </td> |
|
90 | 90 | </tr> |
|
91 | 91 | </table> |
|
92 | 92 | <% end %> |
|
93 | 93 | </div> |
|
94 | 94 | <% end %> |
|
95 | 95 | |
|
96 | 96 | <h3>Previous requests</h3> |
|
97 | 97 | |
|
98 | 98 | <table class="info"> |
|
99 | 99 | <tr class="info-head"> |
|
100 | 100 | <th>at</th> |
|
101 | 101 | <th>problem</th> |
|
102 | 102 | <th>sub #</th> |
|
103 | 103 | <th>status</th> |
|
104 | 104 | <th>output (first 2kb)</th> |
You need to be logged in to leave comments.
Login now