Description:
refactor to partials
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@62 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
r33:0fc0c11d6fb0 - - 7 files changed: 53 inserted, 58 deleted
@@ -0,0 +1,10 | |||||
|
|
1 | + <div><div><a href="#" onClick="n = this.parentNode.parentNode.lastChild; | ||
|
|
2 | + if(n.style.display == 'none') { n.style.display = 'block'; } | ||
|
|
3 | + 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/>') %> | ||
|
|
9 | + </div> | ||
|
|
10 | + </div></div> |
@@ -0,0 +1,11 | |||||
|
|
1 | + <div class="problist-each"> | ||
|
|
2 | + <div class="probname"> | ||
|
|
3 | + <%= "#{problem_counter + 1}: #{problem.full_name} (#{problem.name})" %> | ||
|
|
4 | + <%= link_to '[task description]', problem.url, :popup => true if (problem.url!=nil) and (problem.url!='') %> | ||
|
|
5 | + </div> | ||
|
|
6 | + <div class="subinfo"> | ||
|
|
7 | + <%= render :partial => 'submission', | ||
|
|
8 | + :locals => { :submission => @prob_submissions[problem_counter][:submission], | ||
|
|
9 | + :count => @prob_submissions[problem_counter][:count] } %> | ||
|
|
10 | + </div> | ||
|
|
11 | + </div> |
@@ -0,0 +1,16 | |||||
|
|
1 | + | ||
|
|
2 | + - if count==0 | ||
|
|
3 | + 0 submission | ||
|
|
4 | + - else | ||
|
|
5 | + = count | ||
|
|
6 | + submission(s). | ||
|
|
7 | + Last on | ||
|
|
8 | + = format_short_time(submission.submitted_at) | ||
|
|
9 | + = link_to('[source]',{:action => 'get_source', :id => submission.id}) | ||
|
|
10 | + %br/ | ||
|
|
11 | + - if submission!=nil and submission.graded_at!=nil | ||
|
|
12 | + = "Graded at #{format_short_time(submission.graded_at)}, " | ||
|
|
13 | + = "score: #{submission.points} " | ||
|
|
14 | + = " [" + submission.grader_comment + "]" | ||
|
|
15 | + %br/ | ||
|
|
16 | + = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message } |
@@ -0,0 +1,8 | |||||
|
|
1 | + <% form_tag({:action => 'submit'}, :multipart => true) do %> | ||
|
|
2 | + Problem: <%= select 'submission', 'problem_id', | ||
|
|
3 | + [['Specified in header','-1']] + | ||
|
|
4 | + @problems.collect {|p| [p.full_name, p.id]}, | ||
|
|
5 | + :selected => '-1' %> | ||
|
|
6 | + File: <%= file_field_tag 'file' %> | ||
|
|
7 | + <%= submit_tag 'Submit' %> | ||
|
|
8 | + <% end %> |
@@ -49,18 +49,18 | |||||
|
49 | else |
|
49 | else |
|
50 | flash[:notice] = 'Error viewing source' |
|
50 | flash[:notice] = 'Error viewing source' |
|
51 | end |
|
51 | end |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
|
54 | protected |
|
54 | protected |
|
55 | def prepare_list_information |
|
55 | def prepare_list_information |
|
56 | @problems = Problem.find_available_problems |
|
56 | @problems = Problem.find_available_problems |
|
57 | @prob_submissions = Array.new |
|
57 | @prob_submissions = Array.new |
|
58 | @user = User.find(session[:user_id]) |
|
58 | @user = User.find(session[:user_id]) |
|
59 | @problems.each do |p| |
|
59 | @problems.each do |p| |
|
60 | c, sub = Submission.find_by_user_and_problem(@user.id,p.id) |
|
60 | c, sub = Submission.find_by_user_and_problem(@user.id,p.id) |
|
61 |
- @prob_submissions << |
|
61 | + @prob_submissions << { :count => c, :submission => sub } |
|
62 | end |
|
62 | end |
|
63 | end |
|
63 | end |
|
64 |
|
64 | ||
|
65 | end |
|
65 | end |
|
66 |
|
66 |
@@ -1,45 +1,13 | |||||
|
1 | module MainHelper |
|
1 | module MainHelper |
|
2 |
|
2 | ||
|
3 | def format_short_time(time) |
|
3 | def format_short_time(time) |
|
4 | now = Time.now |
|
4 | now = Time.now |
|
5 | st = '' |
|
5 | st = '' |
|
6 | if (time.yday != now.yday) or |
|
6 | if (time.yday != now.yday) or |
|
7 | (time.year != now.year) |
|
7 | (time.year != now.year) |
|
8 | st = time.strftime("%x ") |
|
8 | st = time.strftime("%x ") |
|
9 | end |
|
9 | end |
|
10 | st + time.strftime("%X") |
|
10 | st + time.strftime("%X") |
|
11 | end |
|
11 | end |
|
12 |
|
12 | ||
|
13 | - def format_compiler_msg(sub) |
|
||
|
14 | - <<cmpmsg |
|
||
|
15 | - <div> |
|
||
|
16 | - <div><a href="#" onClick="n = this.parentNode.parentNode.lastChild; |
|
||
|
17 | - if(n.style.display == 'none') { n.style.display = 'block'; } |
|
||
|
18 | - else {n.style.display ='none'; } return false;"> |
|
||
|
19 | - Compiler message</a> (click to see)</div> |
|
||
|
20 | - <div style="display: none"> |
|
||
|
21 | - <div class="compilermsgbody" style="border: thin solid grey; margin: 2px"> |
|
||
|
22 | - #{h(sub.compiler_message).gsub(/\n/,'<br/>')} |
|
||
|
23 | - </div> |
|
||
|
24 | - </div></div> |
|
||
|
25 | - cmpmsg |
|
||
|
26 | - end |
|
||
|
27 | - |
|
||
|
28 | - def format_submission(sub, count) |
|
||
|
29 | - msg = "#{count} submission(s)." |
|
||
|
30 | - if count>0 |
|
||
|
31 | - msg = msg + "Last on " + |
|
||
|
32 | - format_short_time(sub.submitted_at) + ' ' + |
|
||
|
33 | - link_to('[source]',{:action => 'get_source', :id => sub.id}) |
|
||
|
34 | - end |
|
||
|
35 | - msg += "<br/>" |
|
||
|
36 | - if sub!=nil and sub.graded_at!=nil |
|
||
|
37 | - msg = msg + 'Graded at ' + format_short_time(sub.graded_at) + ', score: '+ |
|
||
|
38 | - sub.points.to_s + |
|
||
|
39 | - ' [' + sub.grader_comment + "]<br />" + |
|
||
|
40 | - format_compiler_msg(sub) |
|
||
|
41 | - end |
|
||
|
42 | - msg |
|
||
|
43 | - end |
|
||
|
44 | - |
|
||
|
45 | end |
|
13 | end |
@@ -1,40 +1,22 | |||||
|
1 | <div class="title">Hello <%=h @user.full_name %></div> |
|
1 | <div class="title">Hello <%=h @user.full_name %></div> |
|
2 | Current time is <%= format_short_time(Time.new) %>. |
|
2 | Current time is <%= format_short_time(Time.new) %>. |
|
3 |
|
3 | ||
|
4 | <div class="submitbox"> |
|
4 | <div class="submitbox"> |
|
5 | - |
|
5 | + <%= error_messages_for 'submission' %> |
|
6 | - <%= error_messages_for 'submission' %> |
|
6 | + <%= render :partial => 'submission_box' %> |
|
7 | - |
|
||
|
8 | - <% form_tag({:action => 'submit'}, :multipart => true) do %> |
|
||
|
9 | - Problem: <%= select 'submission', 'problem_id', |
|
||
|
10 | - [['Specified in header','-1']] + |
|
||
|
11 | - @problems.collect {|p| [p.full_name, p.id]}, |
|
||
|
12 | - :selected => '-1' %> |
|
||
|
13 | - File: <%= file_field_tag 'file' %> |
|
||
|
14 | - <%= submit_tag 'Submit' %> |
|
||
|
15 | - <% end %> |
|
||
|
16 | </div> |
|
7 | </div> |
|
17 |
|
8 | ||
|
18 | <hr/> |
|
9 | <hr/> |
|
19 |
|
10 | ||
|
20 | <p style="color: red"><%= flash[:notice] %></p> |
|
11 | <p style="color: red"><%= flash[:notice] %></p> |
|
21 |
|
12 | ||
|
22 | <div class="problist"> |
|
13 | <div class="problist"> |
|
23 | - <% i = 0 %> |
|
14 | + <%= render :partial => 'problem', :collection => @problems %> |
|
24 | - <% @problems.each do |p| %> |
|
||
|
25 | - <div class="problist-each"> |
|
||
|
26 | - <div class="probname"> |
|
||
|
27 | - <%= "#{i+1}: #{p.full_name} (#{p.name})" %> |
|
||
|
28 | - <%= link_to '[task description]', p.url, :popup => true if (p.url!=nil) and (p.url!='') %> |
|
||
|
29 | - </div> |
|
||
|
30 | - <div class="subinfo"> |
|
||
|
31 | - <%= format_submission(@prob_submissions[i][1], |
|
||
|
32 | - @prob_submissions[i][0]) %> |
|
||
|
33 | - </div> |
|
||
|
34 | - </div> |
|
||
|
35 | - <% i = i+1 %> |
|
||
|
36 | - <% end %> |
|
||
|
37 | </div> |
|
15 | </div> |
|
38 |
|
16 | ||
|
39 | <hr /> |
|
17 | <hr /> |
|
40 |
|
18 | ||
|
|
19 | + <div class="submitbox"> | ||
|
|
20 | + <%= render :partial => 'submission_box' %> | ||
|
|
21 | + </div> | ||
|
|
22 | + |
You need to be logged in to leave comments.
Login now