Description:
[web] fixing ticket #10 git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@142 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r65:7c52d3ded481 - - 5 files changed: 14 inserted, 14 deleted

@@ -1,34 +1,44
1 # Methods added to this helper will be available to all templates in the application.
1 # Methods added to this helper will be available to all templates in the application.
2 module ApplicationHelper
2 module ApplicationHelper
3
3
4 def user_header
4 def user_header
5 menu_items = ''
5 menu_items = ''
6 user = User.find(session[:user_id])
6 user = User.find(session[:user_id])
7
7
8 # main page
8 # main page
9 append_to menu_items, '[Main]', 'main', 'list'
9 append_to menu_items, '[Main]', 'main', 'list'
10 append_to menu_items, '[Submissions]', 'main', 'submission'
10 append_to menu_items, '[Submissions]', 'main', 'submission'
11 append_to menu_items, '[Test]', 'test', 'index'
11 append_to menu_items, '[Test]', 'test', 'index'
12
12
13 # admin menu
13 # admin menu
14 if (user!=nil) and (user.admin?)
14 if (user!=nil) and (user.admin?)
15 append_to menu_items, '[Problem admin]', 'problems', 'index'
15 append_to menu_items, '[Problem admin]', 'problems', 'index'
16 append_to menu_items, '[User admin]', 'user_admin', 'index'
16 append_to menu_items, '[User admin]', 'user_admin', 'index'
17 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
17 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
18 end
18 end
19
19
20 # general options
20 # general options
21 append_to menu_items, '[Settings]', 'users', 'index'
21 append_to menu_items, '[Settings]', 'users', 'index'
22 append_to menu_items, '[Log out]', 'main', 'login'
22 append_to menu_items, '[Log out]', 'main', 'login'
23
23
24 menu_items
24 menu_items
25 end
25 end
26
26
27 def append_to(option,label, controller, action)
27 def append_to(option,label, controller, action)
28 option << ' ' if option!=''
28 option << ' ' if option!=''
29 option << link_to_unless_current(label,
29 option << link_to_unless_current(label,
30 :controller => controller,
30 :controller => controller,
31 :action => action)
31 :action => action)
32 end
32 end
33
33
34 + def format_short_time(time)
35 + now = Time.now
36 + st = ''
37 + if (time.yday != now.yday) or
38 + (time.year != now.year)
39 + st = time.strftime("%x ")
34 end
40 end
41 + st + time.strftime("%X")
42 + end
43 +
44 + end
@@ -1,13 +1,3
1 module MainHelper
1 module MainHelper
2
2
3 - def format_short_time(time)
4 - now = Time.now
5 - st = ''
6 - if (time.yday != now.yday) or
7 - (time.year != now.year)
8 - st = time.strftime("%x ")
9 end
3 end
10 - st + time.strftime("%X")
11 - end
12 -
13 - end
@@ -1,15 +1,15
1
1
2 <% if compiler_message==nil or compiler_message=='' %>
2 <% if compiler_message==nil or compiler_message=='' %>
3 No message
3 No message
4 <% else %>
4 <% else %>
5 <div><div><a href="#" onClick="n = this.parentNode.parentNode.lastChild;
5 <div><div><a href="#" onClick="n = this.parentNode.parentNode.lastChild;
6 if(n.style.display == 'none') { n.style.display = 'block'; }
6 if(n.style.display == 'none') { n.style.display = 'block'; }
7 else {n.style.display ='none'; } return false;">
7 else {n.style.display ='none'; } return false;">
8 (click to see)</a>
8 (click to see)</a>
9 </div>
9 </div>
10 <div style="display: none">
10 <div style="display: none">
11 <div class="compilermsgbody" style="border: thin solid grey; margin: 2px">
11 <div class="compilermsgbody" style="border: thin solid grey; margin: 2px">
12 - <%=h(compiler_message).gsub(/\n/,'<br/>') %>
12 + <%=simple_format(compiler_message) %>
13 </div>
13 </div>
14 </div></div>
14 </div></div>
15 <% end %>
15 <% end %>
@@ -1,11 +1,11
1 %tr{:class => (test_request_counter%2==0) ? "info-even" : "info-odd"}
1 %tr{:class => (test_request_counter%2==0) ? "info-even" : "info-odd"}
2 - %td= test_request_counter +1
2 + %td= format_short_time(test_request.submitted_at)
3 %td= test_request.problem.full_name
3 %td= test_request.problem.full_name
4 %td= test_request.submission.number
4 %td= test_request.submission.number
5 %td= test_request.status_str
5 %td= test_request.status_str
6 %td= simple_format((test_request.running_stat or ''))
6 %td= simple_format((test_request.running_stat or ''))
7 %td
7 %td
8 - if test_request.output_file_name!=nil
8 - if test_request.output_file_name!=nil
9 = link_to '[output]', :action => 'read', :id => test_request.id
9 = link_to '[output]', :action => 'read', :id => test_request.id
10 %td= test_request.grader_comment or ''
10 %td= test_request.grader_comment or ''
11 %td= simple_format((test_request.compiler_message or ''))
11 %td= simple_format((test_request.compiler_message or ''))
@@ -12,62 +12,62
12 };
12 };
13 function updateSubmissionList() {
13 function updateSubmissionList() {
14 currentProb = document.getElementById("test_request_problem_id").value;
14 currentProb = document.getElementById("test_request_problem_id").value;
15 count = submissionCount[currentProb];
15 count = submissionCount[currentProb];
16 submissionSelect = document.getElementById("test_request_submission_number");
16 submissionSelect = document.getElementById("test_request_submission_number");
17 submissionSelect.options.length = 0;
17 submissionSelect.options.length = 0;
18 for(i=0; i<count; i++) {
18 for(i=0; i<count; i++) {
19 submissionSelect.options[i] = new Option(""+(i+1),""+(i+1),false,false);
19 submissionSelect.options[i] = new Option(""+(i+1),""+(i+1),false,false);
20 }
20 }
21 }
21 }
22 </script>
22 </script>
23
23
24 <% form_for :test_request, nil,
24 <% form_for :test_request, nil,
25 :url => { :action => 'submit'},
25 :url => { :action => 'submit'},
26 :html => { :multipart => true } do |f| %>
26 :html => { :multipart => true } do |f| %>
27 <table>
27 <table>
28 <tr>
28 <tr>
29 <td>Task:</td>
29 <td>Task:</td>
30 <td>
30 <td>
31 <%= select(:test_request,
31 <%= select(:test_request,
32 :problem_id,
32 :problem_id,
33 @problems.collect {|p| [p.name, p.id]}, {},
33 @problems.collect {|p| [p.name, p.id]}, {},
34 { :onclick => "updateSubmissionList();" }) %>
34 { :onclick => "updateSubmissionList();" }) %>
35 </td>
35 </td>
36 </tr>
36 </tr>
37 <tr>
37 <tr>
38 <td>Submission:</td>
38 <td>Submission:</td>
39 <td>
39 <td>
40 <%= select(:test_request,
40 <%= select(:test_request,
41 :submission_number,
41 :submission_number,
42 ((1..@submissions[0].number).collect {|n| [n,n]}).reverse) %>
42 ((1..@submissions[0].number).collect {|n| [n,n]}).reverse) %>
43 </td>
43 </td>
44 </tr>
44 </tr>
45 <tr>
45 <tr>
46 <td>Input data:</td>
46 <td>Input data:</td>
47 <td><%= f.file_field :input_file %></td>
47 <td><%= f.file_field :input_file %></td>
48 <tr>
48 <tr>
49 <td colspan="2">
49 <td colspan="2">
50 <%= submit_tag 'submit' %>
50 <%= submit_tag 'submit' %>
51 </td>
51 </td>
52 </tr>
52 </tr>
53 </table>
53 </table>
54 <% end %>
54 <% end %>
55
55
56 <h3>Previous requests</h3>
56 <h3>Previous requests</h3>
57
57
58 <table class="info">
58 <table class="info">
59 <tr class="info-head">
59 <tr class="info-head">
60 - <th></td>
60 + <th>at</th>
61 <th>problem</th>
61 <th>problem</th>
62 - <th>#</th>
62 + <th>sub #</th>
63 <th>status</th>
63 <th>status</th>
64 <th>running stat</th>
64 <th>running stat</th>
65 <th>output (first 2kb)</th>
65 <th>output (first 2kb)</th>
66 <th>grading comment</th>
66 <th>grading comment</th>
67 <th>compiler message</th>
67 <th>compiler message</th>
68 </tr>
68 </tr>
69 <%= render :partial => 'test_request', :collection => @test_requests %>
69 <%= render :partial => 'test_request', :collection => @test_requests %>
70 </table>
70 </table>
71
71
72 <% end %>
72 <% end %>
73
73
You need to be logged in to leave comments. Login now