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
@@ -25,42 +25,41 | |||||
|
25 | def self.clear |
|
25 | def self.clear |
|
26 | @@configurations = nil |
|
26 | @@configurations = nil |
|
27 | end |
|
27 | end |
|
28 |
|
28 | ||
|
29 | # |
|
29 | # |
|
30 | # View decision |
|
30 | # View decision |
|
31 | # |
|
31 | # |
|
32 | def self.show_submitbox_to?(user) |
|
32 | def self.show_submitbox_to?(user) |
|
33 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
33 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
34 | return false if mode=='analysis' |
|
34 | return false if mode=='analysis' |
|
35 | if (mode=='contest') |
|
35 | if (mode=='contest') |
|
36 | return false if (user.site!=nil) and |
|
36 | return false if (user.site!=nil) and |
|
37 |
- ((user.site.started |
|
37 | + ((user.site.started!=true) or (user.site.finished?)) |
|
38 | end |
|
38 | end |
|
39 | return true |
|
39 | return true |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | def self.show_tasks_to?(user) |
|
42 | def self.show_tasks_to?(user) |
|
43 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
43 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
44 | if (mode=='contest') |
|
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 | end |
|
46 | end |
|
47 | return true |
|
47 | return true |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | def self.allow_test_request(user) |
|
50 | def self.allow_test_request(user) |
|
51 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
51 | mode = get(SYSTEM_MODE_CONF_KEY) |
|
52 | if (mode=='contest') |
|
52 | if (mode=='contest') |
|
53 |
- return false if (user.site!=nil) and ((user.site.started |
|
53 | + return false if (user.site!=nil) and ((user.site.started!=true) or (user.site.time_left < 30.minutes)) |
|
54 | - (user.site.time_left < 30.minutes)) |
|
||
|
55 | end |
|
54 | end |
|
56 | return false if mode=='analysis' |
|
55 | return false if mode=='analysis' |
|
57 | return true |
|
56 | return true |
|
58 | end |
|
57 | end |
|
59 |
|
58 | ||
|
60 | protected |
|
59 | protected |
|
61 | def self.read_config |
|
60 | def self.read_config |
|
62 | @@configurations = {} |
|
61 | @@configurations = {} |
|
63 | Configuration.find(:all).each do |conf| |
|
62 | Configuration.find(:all).each do |conf| |
|
64 | key = conf.key |
|
63 | key = conf.key |
|
65 | val = conf.value |
|
64 | val = conf.value |
|
66 | case conf.value_type |
|
65 | case conf.value_type |
@@ -5,26 +5,31 | |||||
|
5 |
|
5 | ||
|
6 | def clear_start_time_if_not_started |
|
6 | def clear_start_time_if_not_started |
|
7 | if !self.started |
|
7 | if !self.started |
|
8 | self.start_time = nil |
|
8 | self.start_time = nil |
|
9 | end |
|
9 | end |
|
10 | end |
|
10 | end |
|
11 |
|
11 | ||
|
12 | def time_left |
|
12 | def time_left |
|
13 | contest_time = Configuration['contest.time_limit'] |
|
13 | contest_time = Configuration['contest.time_limit'] |
|
14 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
14 | if tmatch = /(\d+):(\d+)/.match(contest_time) |
|
15 | h = tmatch[1].to_i |
|
15 | h = tmatch[1].to_i |
|
16 | m = tmatch[2].to_i |
|
16 | m = tmatch[2].to_i |
|
17 | - finish_time = self.start_time + h.hour + m.minute |
|
17 | + |
|
18 | current_time = Time.now.gmtime |
|
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 | if current_time > finish_time |
|
25 | if current_time > finish_time |
|
21 | return current_time - current_time |
|
26 | return current_time - current_time |
|
22 | else |
|
27 | else |
|
23 | finish_time - current_time |
|
28 | finish_time - current_time |
|
24 | end |
|
29 | end |
|
25 | else |
|
30 | else |
|
26 | nil |
|
31 | nil |
|
27 | end |
|
32 | end |
|
28 | end |
|
33 | end |
|
29 |
|
34 | ||
|
30 | def finished? |
|
35 | def finished? |
@@ -16,17 +16,12 | |||||
|
16 |
|
16 | ||
|
17 | - if Configuration.show_tasks_to?(@user) |
|
17 | - if Configuration.show_tasks_to?(@user) |
|
18 | %table.info |
|
18 | %table.info |
|
19 | %tr.info-head |
|
19 | %tr.info-head |
|
20 | %th |
|
20 | %th |
|
21 | %th Tasks |
|
21 | %th Tasks |
|
22 | %th # of sub(s) |
|
22 | %th # of sub(s) |
|
23 | %th Results |
|
23 | %th Results |
|
24 | = render :partial => 'problem', :collection => @problems |
|
24 | = render :partial => 'problem', :collection => @problems |
|
25 |
|
25 | ||
|
26 | %hr/ |
|
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. |
|
@@ -68,25 +68,25 | |||||
|
68 | (combined size should not exceed 2MB) |
|
68 | (combined size should not exceed 2MB) |
|
69 | </td> |
|
69 | </td> |
|
70 | </tr> |
|
70 | </tr> |
|
71 | <tr> |
|
71 | <tr> |
|
72 | <td> |
|
72 | <td> |
|
73 | Additional file<sup><span style="color:red">*</span></sup>: |
|
73 | Additional file<sup><span style="color:red">*</span></sup>: |
|
74 | </td> |
|
74 | </td> |
|
75 | <td> |
|
75 | <td> |
|
76 | <%= f.file_field :additional_file %> |
|
76 | <%= f.file_field :additional_file %> |
|
77 | </td> |
|
77 | </td> |
|
78 | <td> |
|
78 | <td> |
|
79 | <small> |
|
79 | <small> |
|
80 |
- * This option works <u>only</u> for task |
|
80 | + * This option works <u>only</u> for task beads. |
|
81 | You can use this to submit <tt>questions.txt</tt>.<br/> |
|
81 | You can use this to submit <tt>questions.txt</tt>.<br/> |
|
82 | The file shall be copied to the execution directory before your program runs. |
|
82 | The file shall be copied to the execution directory before your program runs. |
|
83 | </small> |
|
83 | </small> |
|
84 | </td> |
|
84 | </td> |
|
85 | </tr> |
|
85 | </tr> |
|
86 | <tr> |
|
86 | <tr> |
|
87 | <td colspan="2"> |
|
87 | <td colspan="2"> |
|
88 | <%= submit_tag 'submit' %> |
|
88 | <%= submit_tag 'submit' %> |
|
89 | </td> |
|
89 | </td> |
|
90 | </tr> |
|
90 | </tr> |
|
91 | </table> |
|
91 | </table> |
|
92 | <% end %> |
|
92 | <% end %> |
You need to be logged in to leave comments.
Login now