Description:
update views -- styling git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@114 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

r51:1f6cfc6a5b62 - - 11 files changed: 116 inserted, 63 deleted

@@ -0,0 +1,13
1 +
2 + - if submission==nil
3 + = "-"
4 + - else
5 + - if submission.graded_at==nil
6 + Submitted at
7 + = format_short_time(submission.submitted_at)
8 + - else
9 + = "Graded at #{format_short_time(submission.graded_at)}, "
10 + = "score: #{submission.points} "
11 + = " [" + submission.grader_comment + "]"
12 + = " | "
13 + = link_to('[source]',{:action => 'get_source', :id => submission.id})
@@ -0,0 +1,24
1 + .title
2 + Hello
3 + =h @user.full_name
4 +
5 + Current time is
6 + = format_short_time(Time.new)
7 + %br/
8 +
9 + .task-menu
10 + Tasks:
11 + - @problems.each do |problem|
12 + = link_to problem.name, :action => 'submission', :id => problem.name
13 +
14 + - if @submissions!=nil
15 + %table.info
16 + %tr.info-head
17 + %th.info Sub #
18 + %th.info Time
19 + %th.info Source
20 + %th.info Results
21 + %th.info{:width => "300px"}
22 + Compiler message
23 + = render :partial => 'submission', :collection => @submissions
24 +
@@ -43,24 +43,36
43 submission = Submission.find(params[:id])
43 submission = Submission.find(params[:id])
44 if submission.user_id == session[:user_id]
44 if submission.user_id == session[:user_id]
45 fname = submission.problem.name + '.' + submission.language.ext
45 fname = submission.problem.name + '.' + submission.language.ext
46 send_data(submission.source,
46 send_data(submission.source,
47 {:filename => fname,
47 {:filename => fname,
48 :type => 'text/plain'})
48 :type => 'text/plain'})
49 else
49 else
50 flash[:notice] = 'Error viewing source'
50 flash[:notice] = 'Error viewing source'
51 redirect_to :action => 'list'
51 redirect_to :action => 'list'
52 end
52 end
53 end
53 end
54
54
55 + def submission
56 + @user = User.find(session[:user_id])
57 + @problems = Problem.find_available_problems
58 + if params[:id]==nil
59 + @problem = nil
60 + @submissions = nil
61 + else
62 + @problem = Problem.find_by_name(params[:id])
63 + @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
64 + end
65 + end
66 +
55 protected
67 protected
56 def prepare_list_information
68 def prepare_list_information
57 @problems = Problem.find_available_problems
69 @problems = Problem.find_available_problems
58 @prob_submissions = Array.new
70 @prob_submissions = Array.new
59 @user = User.find(session[:user_id])
71 @user = User.find(session[:user_id])
60 @problems.each do |p|
72 @problems.each do |p|
61 sub = Submission.find_last_by_user_and_problem(@user.id,p.id)
73 sub = Submission.find_last_by_user_and_problem(@user.id,p.id)
62 if sub!=nil
74 if sub!=nil
63 @prob_submissions << { :count => sub.number, :submission => sub }
75 @prob_submissions << { :count => sub.number, :submission => sub }
64 else
76 else
65 @prob_submissions << { :count => 0, :submission => nil }
77 @prob_submissions << { :count => 0, :submission => nil }
66 end
78 end
@@ -1,21 +1,22
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, '[Test]', 'test', 'index'
11 append_to menu_items, '[Test]', 'test', 'index'
11
12
12 # admin menu
13 # admin menu
13 if (user!=nil) and (user.admin?)
14 if (user!=nil) and (user.admin?)
14 append_to menu_items, '[Problem admin]', 'problems', 'index'
15 append_to menu_items, '[Problem admin]', 'problems', 'index'
15 append_to menu_items, '[User admin]', 'user_admin', 'index'
16 append_to menu_items, '[User admin]', 'user_admin', 'index'
16 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
17 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
17 end
18 end
18
19
19 # general options
20 # general options
20 append_to menu_items, '[Settings]', 'users', 'index'
21 append_to menu_items, '[Settings]', 'users', 'index'
21 append_to menu_items, '[Log out]', 'main', 'login'
22 append_to menu_items, '[Log out]', 'main', 'login'
@@ -40,24 +40,32
40 submissions
40 submissions
41 end
41 end
42
42
43 def self.find_by_user_problem_number(user_id, problem_id, number)
43 def self.find_by_user_problem_number(user_id, problem_id, number)
44 Submission.find(:first,
44 Submission.find(:first,
45 :conditions => {
45 :conditions => {
46 :user_id => user_id,
46 :user_id => user_id,
47 :problem_id => problem_id,
47 :problem_id => problem_id,
48 :number => number
48 :number => number
49 })
49 })
50 end
50 end
51
51
52 + def self.find_all_by_user_problem(user_id, problem_id)
53 + Submission.find(:all,
54 + :conditions => {
55 + :user_id => user_id,
56 + :problem_id => problem_id,
57 + })
58 + end
59 +
52 protected
60 protected
53
61
54 def self.find_option_in_source(option, source)
62 def self.find_option_in_source(option, source)
55 if source==nil
63 if source==nil
56 return nil
64 return nil
57 end
65 end
58 i = 0
66 i = 0
59 source.each_line do |s|
67 source.each_line do |s|
60 if s =~ option
68 if s =~ option
61 words = s.split
69 words = s.split
62 return words[1]
70 return words[1]
63 end
71 end
@@ -1,10 +1,15
1 - <div><div><a href="#" onClick="n = this.parentNode.parentNode.lastChild;
1 +
2 + <% if compiler_message==nil or compiler_message=='' %>
3 + No message
4 + <% else %>
5 + <div><div><a href="#" onClick="n = this.parentNode.parentNode.lastChild;
2 if(n.style.display == 'none') { n.style.display = 'block'; }
6 if(n.style.display == 'none') { n.style.display = 'block'; }
3 else {n.style.display ='none'; } return false;">
7 else {n.style.display ='none'; } return false;">
4 - Compiler message</a> (click to see)
8 + (click to see)</a>
5 - </div>
6 - <div style="display: none">
7 - <div class="compilermsgbody" style="border: thin solid grey; margin: 2px">
8 - <%=h(compiler_message).gsub(/\n/,'<br/>') %>
9 </div>
9 </div>
10 - </div></div>
10 + <div style="display: none">
11 + <div class="compilermsgbody" style="border: thin solid grey; margin: 2px">
12 + <%=h(compiler_message).gsub(/\n/,'<br/>') %>
13 + </div>
14 + </div></div>
15 + <% end %>
@@ -1,16 +1,16
1 <tr class="info-<%= (problem_counter%2==0) ? "even" : "odd" %>">
1 <tr class="info-<%= (problem_counter%2==0) ? "even" : "odd" %>">
2 <td class="info">
2 <td class="info">
3 <%= "#{problem_counter + 1}" %>
3 <%= "#{problem_counter + 1}" %>
4 </td>
4 </td>
5 <td class="info">
5 <td class="info">
6 <%= "#{problem.full_name} (#{problem.name})" %>
6 <%= "#{problem.full_name} (#{problem.name})" %>
7 <%= link_to '[desc]', problem.url, :popup => true if (problem.url!=nil) and (problem.url!='') %>
7 <%= link_to '[desc]', problem.url, :popup => true if (problem.url!=nil) and (problem.url!='') %>
8 </td>
8 </td>
9 <td class="info" align="center">
9 <td class="info" align="center">
10 <%= @prob_submissions[problem_counter][:count] %>
10 <%= @prob_submissions[problem_counter][:count] %>
11 </td>
11 </td>
12 <td class="info">
12 <td class="info">
13 - <%= render :partial => 'submission',
13 + <%= render :partial => 'submission_short',
14 :locals => { :submission => @prob_submissions[problem_counter][:submission]} %>
14 :locals => { :submission => @prob_submissions[problem_counter][:submission]} %>
15 </td>
15 </td>
16 </tr>
16 </tr>
@@ -1,13 +1,14
1
1
2 - - if submission==nil
2 + %tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")}
3 - = "-"
3 + %td.info{:align => "center"}
4 - - else
4 + = submission_counter+1
5 - - if submission.graded_at==nil
5 + %td.info= format_short_time(submission.submitted_at)
6 - Submitted at
6 + %td.info= link_to('[source]',{:action => 'get_source', :id => submission.id})
7 - = format_short_time(submission.submitted_at)
7 + %td.info
8 - - else
8 + - if submission.graded_at!=nil
9 - = "Graded at #{format_short_time(submission.graded_at)}, "
9 + = "Graded at #{format_short_time(submission.graded_at)}."
10 - = "score: #{submission.points} "
10 + %br/
11 - = " [" + submission.grader_comment + "]"
11 + = "Score: #{submission.points} "
12 - = " | "
12 + = " [" + submission.grader_comment + "]"
13 - = link_to('[source]',{:action => 'get_source', :id => submission.id})
13 + %td.info
14 + = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message }
@@ -1,11 +1,11
1 - %tr.test-request
1 + %tr{:class => (test_request_counter%2==0) ? "info-even" : "info-odd"}
2 - %td= test_request_counter +1
2 + %td.info= test_request_counter +1
3 - %td= test_request.problem.full_name
3 + %td.info= test_request.problem.full_name
4 - %td= test_request.submission.number
4 + %td.info= test_request.submission.number
5 - %td= test_request.status_str
5 + %td.info= test_request.status_str
6 - %td= test_request.running_stat or ''
6 + %td.info= test_request.running_stat or ''
7 - %td
7 + %td.info
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.info= test_request.grader_comment or ''
11 - %td= test_request.compiler_message or ''
11 + %td.info= test_request.compiler_message or ''
@@ -30,44 +30,44
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]}) %>
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 border="1">
58 + <table class="info">
59 - <tr>
59 + <tr class="info-head">
60 - <th></td>
60 + <th class="info"></td>
61 - <th>problem</th>
61 + <th class="info">problem</th>
62 - <th>#</th>
62 + <th class="info">#</th>
63 - <th>status</th>
63 + <th class="info">status</th>
64 - <th>running stat</th>
64 + <th class="info">running stat</th>
65 - <th>output (first 2kb)</th>
65 + <th class="info">output (first 2kb)</th>
66 - <th>grading comment</th>
66 + <th class="info">grading comment</th>
67 - <th>compiler message</th>
67 + <th class="info">compiler message</th>
68 </tr>
68 </tr>
69 - <%= render :partial => 'test_request', :collection => @user.test_requests %>
69 + <%= render :partial => 'test_request', :collection => @user.test_requests %>
70 </table>
70 </table>
71
71
72 <% end %>
72 <% end %>
73
73
@@ -1,70 +1,49
1 p {
1 p {
2 font-size: 12px;
2 font-size: 12px;
3 }
3 }
4
4
5 div.title {
5 div.title {
6 font-size: 20px;
6 font-size: 20px;
7 font-weight: bold;
7 font-weight: bold;
8 background: lightgreen;
8 background: lightgreen;
9 padding: 2px;
9 padding: 2px;
10 }
10 }
11
11
12 - div.problist-each {
13 - margin-top: 2px;
14 - margin-bottom: 2px
15 - }
16 -
17 div.userbar {
12 div.userbar {
18 border-top: thin solid grey;
13 border-top: thin solid grey;
19 border-bottom: thin solid grey;
14 border-bottom: thin solid grey;
20 text-align: right;
15 text-align: right;
21 font-size: 12px;
16 font-size: 12px;
22 }
17 }
23
18
24 - div.probname {
25 - background-color: #eeeeee;
26 - font-weight: bold;
27 - padding: 2px;
28 - border: 1px solid black;
29 - }
30 -
31 - div.subinfo {
32 - margin-left: 20px;
33 - margin-top: 2px;
34 - border-bottom: thin solid grey;
35 - border-left: thin solid grey;
36 - font-size: 12px;
37 - }
38 -
39 div.compilermsgbody {
19 div.compilermsgbody {
40 font-family: monospace;
20 font-family: monospace;
41 }
21 }
42
22
43 div.submitbox {
23 div.submitbox {
44 border: thin solid black;
24 border: thin solid black;
45 padding: 5px;
25 padding: 5px;
46 color: white;
26 color: white;
47 background-color: #777777;
27 background-color: #777777;
48 font-weight: bold;
28 font-weight: bold;
29 + font-size: 13px;
49 }
30 }
50
31
51 -
52 table.uinfo {
32 table.uinfo {
53 border-collapse: collapse;
33 border-collapse: collapse;
54 border: 1px solid black;
34 border: 1px solid black;
55 font-size: 13px;
35 font-size: 13px;
56 }
36 }
57
37
58 -
59 td.uinfo {
38 td.uinfo {
60 vertical-align: top;
39 vertical-align: top;
61 border: 1px solid black;
40 border: 1px solid black;
62 padding: 5px;
41 padding: 5px;
63 }
42 }
64
43
65 th.uinfo {
44 th.uinfo {
66 background: lightgreen;
45 background: lightgreen;
67 vertical-align: top;
46 vertical-align: top;
68 text-align: right;
47 text-align: right;
69 border: 1px solid black;
48 border: 1px solid black;
70 padding: 5px;
49 padding: 5px;
@@ -83,12 +62,22
83 tr.info-head {
62 tr.info-head {
84 background: #777777;
63 background: #777777;
85 color: white;
64 color: white;
86 }
65 }
87
66
88 tr.info-odd {
67 tr.info-odd {
89 background: #dddddd;
68 background: #dddddd;
90 }
69 }
91
70
92 tr.info-even {
71 tr.info-even {
93 background: #eeeeee;
72 background: #eeeeee;
94 }
73 }
74 +
75 + div.task-menu {
76 + text-align: center;
77 + font-size: 13px;
78 + font-weight: bold;
79 + border-top: 1px solid black;
80 + border-bottom: 1px solid black;
81 + margin-top: 2px;
82 + margin-bottom: 4px;
83 + }
You need to be logged in to leave comments. Login now