Description:
update Current time to properly use rails time
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r351:a14389fe8773 - - 1 file changed: 1 inserted, 1 deleted
@@ -20,114 +20,114 | |||||
|
20 | menu_items << "<br/>" |
|
20 | menu_items << "<br/>" |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | # main page |
|
23 | # main page |
|
24 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
24 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
25 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
25 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
26 |
|
26 | ||
|
27 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
27 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
28 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
28 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
29 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
29 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
30 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
30 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
31 | end |
|
31 | end |
|
32 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
32 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
33 |
|
33 | ||
|
34 | if GraderConfiguration['system.user_setting_enabled'] |
|
34 | if GraderConfiguration['system.user_setting_enabled'] |
|
35 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
35 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
36 | end |
|
36 | end |
|
37 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
37 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
38 |
|
38 | ||
|
39 | menu_items.html_safe |
|
39 | menu_items.html_safe |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | def append_to(option,label, controller, action) |
|
42 | def append_to(option,label, controller, action) |
|
43 | option << ' ' if option!='' |
|
43 | option << ' ' if option!='' |
|
44 | option << link_to_unless_current(label, |
|
44 | option << link_to_unless_current(label, |
|
45 | :controller => controller, |
|
45 | :controller => controller, |
|
46 | :action => action) |
|
46 | :action => action) |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def format_short_time(time) |
|
49 | def format_short_time(time) |
|
50 | now = Time.now.gmtime |
|
50 | now = Time.now.gmtime |
|
51 | st = '' |
|
51 | st = '' |
|
52 | if (time.yday != now.yday) or |
|
52 | if (time.yday != now.yday) or |
|
53 | (time.year != now.year) |
|
53 | (time.year != now.year) |
|
54 | st = time.strftime("%x ") |
|
54 | st = time.strftime("%x ") |
|
55 | end |
|
55 | end |
|
56 | st + time.strftime("%X") |
|
56 | st + time.strftime("%X") |
|
57 | end |
|
57 | end |
|
58 |
|
58 | ||
|
59 | def format_short_duration(duration) |
|
59 | def format_short_duration(duration) |
|
60 | return '' if duration==nil |
|
60 | return '' if duration==nil |
|
61 | d = duration.to_f |
|
61 | d = duration.to_f |
|
62 | return Time.at(d).gmtime.strftime("%X") |
|
62 | return Time.at(d).gmtime.strftime("%X") |
|
63 | end |
|
63 | end |
|
64 |
|
64 | ||
|
65 | def read_textfile(fname,max_size=2048) |
|
65 | def read_textfile(fname,max_size=2048) |
|
66 | begin |
|
66 | begin |
|
67 | File.open(fname).read(max_size) |
|
67 | File.open(fname).read(max_size) |
|
68 | rescue |
|
68 | rescue |
|
69 | nil |
|
69 | nil |
|
70 | end |
|
70 | end |
|
71 | end |
|
71 | end |
|
72 |
|
72 | ||
|
73 | def user_title_bar(user) |
|
73 | def user_title_bar(user) |
|
74 | header = '' |
|
74 | header = '' |
|
75 | time_left = '' |
|
75 | time_left = '' |
|
76 |
|
76 | ||
|
77 | # |
|
77 | # |
|
78 | # if the contest is over |
|
78 | # if the contest is over |
|
79 | if GraderConfiguration.time_limit_mode? |
|
79 | if GraderConfiguration.time_limit_mode? |
|
80 | if user.contest_finished? |
|
80 | if user.contest_finished? |
|
81 | header = <<CONTEST_OVER |
|
81 | header = <<CONTEST_OVER |
|
82 | <tr><td colspan="2" align="center"> |
|
82 | <tr><td colspan="2" align="center"> |
|
83 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
83 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
84 | </td></tr> |
|
84 | </td></tr> |
|
85 | CONTEST_OVER |
|
85 | CONTEST_OVER |
|
86 | end |
|
86 | end |
|
87 | if !user.contest_started? |
|
87 | if !user.contest_started? |
|
88 | time_left = " " + (t 'title_bar.contest_not_started') |
|
88 | time_left = " " + (t 'title_bar.contest_not_started') |
|
89 | else |
|
89 | else |
|
90 | time_left = " " + (t 'title_bar.remaining_time') + |
|
90 | time_left = " " + (t 'title_bar.remaining_time') + |
|
91 | " #{format_short_duration(user.contest_time_left)}" |
|
91 | " #{format_short_duration(user.contest_time_left)}" |
|
92 | end |
|
92 | end |
|
93 | end |
|
93 | end |
|
94 |
|
94 | ||
|
95 | # |
|
95 | # |
|
96 | # if the contest is in the anaysis mode |
|
96 | # if the contest is in the anaysis mode |
|
97 | if GraderConfiguration.analysis_mode? |
|
97 | if GraderConfiguration.analysis_mode? |
|
98 | header = <<ANALYSISMODE |
|
98 | header = <<ANALYSISMODE |
|
99 | <tr><td colspan="2" align="center"> |
|
99 | <tr><td colspan="2" align="center"> |
|
100 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
100 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
101 | </td></tr> |
|
101 | </td></tr> |
|
102 | ANALYSISMODE |
|
102 | ANALYSISMODE |
|
103 | end |
|
103 | end |
|
104 |
|
104 | ||
|
105 | contest_name = GraderConfiguration['contest.name'] |
|
105 | contest_name = GraderConfiguration['contest.name'] |
|
106 |
|
106 | ||
|
107 | # |
|
107 | # |
|
108 | # build real title bar |
|
108 | # build real title bar |
|
109 | result = <<TITLEBAR |
|
109 | result = <<TITLEBAR |
|
110 | <div class="title"> |
|
110 | <div class="title"> |
|
111 | <table> |
|
111 | <table> |
|
112 | #{header} |
|
112 | #{header} |
|
113 | <tr> |
|
113 | <tr> |
|
114 | <td class="left-col"> |
|
114 | <td class="left-col"> |
|
115 | #{user.full_name}<br/> |
|
115 | #{user.full_name}<br/> |
|
116 | - #{t 'title_bar.current_time'} #{format_short_time(Time.new)} |
|
116 | + #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
117 | #{time_left} |
|
117 | #{time_left} |
|
118 | <br/> |
|
118 | <br/> |
|
119 | </td> |
|
119 | </td> |
|
120 | <td class="right-col">#{contest_name}</td> |
|
120 | <td class="right-col">#{contest_name}</td> |
|
121 | </tr> |
|
121 | </tr> |
|
122 | </table> |
|
122 | </table> |
|
123 | </div> |
|
123 | </div> |
|
124 | TITLEBAR |
|
124 | TITLEBAR |
|
125 | result.html_safe |
|
125 | result.html_safe |
|
126 | end |
|
126 | end |
|
127 |
|
127 | ||
|
128 | def markdown(text) |
|
128 | def markdown(text) |
|
129 | markdown = RDiscount.new(text) |
|
129 | markdown = RDiscount.new(text) |
|
130 | markdown.to_html.html_safe |
|
130 | markdown.to_html.html_safe |
|
131 | end |
|
131 | end |
|
132 |
|
132 | ||
|
133 | end |
|
133 | end |
You need to be logged in to leave comments.
Login now