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