Description:
[web] added compiler message and submission links to main/list
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@147 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
r70:d6fd1806794c - - 4 files changed: 25 inserted, 3 deleted
@@ -0,0 +1,6 | |||||
|
|
1 | + %h2= "Compiler message for submission \##{@submission.number}, task: #{@submission.problem.name}" | ||
|
|
2 | + %p | ||
|
|
3 | + - if @submission.compiler_message.chomp == '' | ||
|
|
4 | + no message | ||
|
|
5 | + - else | ||
|
|
6 | + = simple_format(@submission.compiler_message) |
@@ -18,61 +18,71 | |||||
|
18 | def list |
|
18 | def list |
|
19 | prepare_list_information |
|
19 | prepare_list_information |
|
20 | end |
|
20 | end |
|
21 |
|
21 | ||
|
22 | def submit |
|
22 | def submit |
|
23 | @submission = Submission.new(params[:submission]) |
|
23 | @submission = Submission.new(params[:submission]) |
|
24 | @submission.user_id = session[:user_id] |
|
24 | @submission.user_id = session[:user_id] |
|
25 | @submission.language_id = 0 |
|
25 | @submission.language_id = 0 |
|
26 | @submission.source = params['file'].read if params['file']!='' |
|
26 | @submission.source = params['file'].read if params['file']!='' |
|
27 | @submission.submitted_at = Time.new |
|
27 | @submission.submitted_at = Time.new |
|
28 | if @submission.valid? |
|
28 | if @submission.valid? |
|
29 | if @submission.save == false |
|
29 | if @submission.save == false |
|
30 | flash[:notice] = 'Error saving your submission' |
|
30 | flash[:notice] = 'Error saving your submission' |
|
31 | elsif Task.create(:submission_id => @submission.id, |
|
31 | elsif Task.create(:submission_id => @submission.id, |
|
32 | :status => Task::STATUS_INQUEUE) == false |
|
32 | :status => Task::STATUS_INQUEUE) == false |
|
33 | flash[:notice] = 'Error adding your submission to task queue' |
|
33 | flash[:notice] = 'Error adding your submission to task queue' |
|
34 | end |
|
34 | end |
|
35 | else |
|
35 | else |
|
36 | prepare_list_information |
|
36 | prepare_list_information |
|
37 | render :action => 'list' and return |
|
37 | render :action => 'list' and return |
|
38 | end |
|
38 | end |
|
39 | redirect_to :action => 'list' |
|
39 | redirect_to :action => 'list' |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 |
- def |
|
42 | + def source |
|
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 compiler_msg | ||
|
|
56 | + @submission = Submission.find(params[:id]) | ||
|
|
57 | + if @submission.user_id == session[:user_id] | ||
|
|
58 | + render :action => 'compiler_msg', :layout => 'empty' | ||
|
|
59 | + else | ||
|
|
60 | + flash[:notice] = 'Error viewing source' | ||
|
|
61 | + redirect_to :action => 'list' | ||
|
|
62 | + end | ||
|
|
63 | + end | ||
|
|
64 | + | ||
|
55 | def submission |
|
65 | def submission |
|
56 | @user = User.find(session[:user_id]) |
|
66 | @user = User.find(session[:user_id]) |
|
57 | @problems = Problem.find_available_problems |
|
67 | @problems = Problem.find_available_problems |
|
58 | if params[:id]==nil |
|
68 | if params[:id]==nil |
|
59 | @problem = nil |
|
69 | @problem = nil |
|
60 | @submissions = nil |
|
70 | @submissions = nil |
|
61 | else |
|
71 | else |
|
62 | @problem = Problem.find_by_name(params[:id]) |
|
72 | @problem = Problem.find_by_name(params[:id]) |
|
63 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
73 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
64 | end |
|
74 | end |
|
65 | end |
|
75 | end |
|
66 |
|
76 | ||
|
67 | protected |
|
77 | protected |
|
68 | def prepare_list_information |
|
78 | def prepare_list_information |
|
69 | @problems = Problem.find_available_problems |
|
79 | @problems = Problem.find_available_problems |
|
70 | @prob_submissions = Array.new |
|
80 | @prob_submissions = Array.new |
|
71 | @user = User.find(session[:user_id]) |
|
81 | @user = User.find(session[:user_id]) |
|
72 | @problems.each do |p| |
|
82 | @problems.each do |p| |
|
73 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
83 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
74 | if sub!=nil |
|
84 | if sub!=nil |
|
75 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
85 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
76 | else |
|
86 | else |
|
77 | @prob_submissions << { :count => 0, :submission => nil } |
|
87 | @prob_submissions << { :count => 0, :submission => nil } |
|
78 | end |
|
88 | end |
@@ -1,16 +1,18 | |||||
|
1 | <tr class="info-<%= (problem_counter%2==0) ? "even" : "odd" %>"> |
|
1 | <tr class="info-<%= (problem_counter%2==0) ? "even" : "odd" %>"> |
|
2 | <td> |
|
2 | <td> |
|
3 | <%= "#{problem_counter + 1}" %> |
|
3 | <%= "#{problem_counter + 1}" %> |
|
4 | </td> |
|
4 | </td> |
|
5 | <td> |
|
5 | <td> |
|
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 align="center"> |
|
9 | <td align="center"> |
|
10 | <%= @prob_submissions[problem_counter][:count] %> |
|
10 | <%= @prob_submissions[problem_counter][:count] %> |
|
11 | </td> |
|
11 | </td> |
|
12 | <td> |
|
12 | <td> |
|
13 | <%= render :partial => 'submission_short', |
|
13 | <%= render :partial => 'submission_short', |
|
14 | - :locals => { :submission => @prob_submissions[problem_counter][:submission]} %> |
|
14 | + :locals => { |
|
|
15 | + :submission => @prob_submissions[problem_counter][:submission], | ||
|
|
16 | + :problem_name => problem.name }%> | ||
|
15 | </td> |
|
17 | </td> |
|
16 | </tr> |
|
18 | </tr> |
@@ -1,13 +1,17 | |||||
|
1 |
|
1 | ||
|
2 | - if submission==nil |
|
2 | - if submission==nil |
|
3 | = "-" |
|
3 | = "-" |
|
4 | - else |
|
4 | - else |
|
5 | - if submission.graded_at==nil |
|
5 | - if submission.graded_at==nil |
|
6 | Submitted at |
|
6 | Submitted at |
|
7 | = format_short_time(submission.submitted_at) |
|
7 | = format_short_time(submission.submitted_at) |
|
8 | - else |
|
8 | - else |
|
9 | = "Graded at #{format_short_time(submission.graded_at)}, " |
|
9 | = "Graded at #{format_short_time(submission.graded_at)}, " |
|
10 | = "score: #{submission.points} " |
|
10 | = "score: #{submission.points} " |
|
11 | = " [" + submission.grader_comment + "]" |
|
11 | = " [" + submission.grader_comment + "]" |
|
12 | = " | " |
|
12 | = " | " |
|
13 |
- = link_to('[ |
|
13 | + = link_to('[msg]', {:action => 'compiler_msg', :id => submission.id}, {:popup => true}) |
|
|
14 | + = " | " | ||
|
|
15 | + = link_to('[source]',{:action => 'source', :id => submission.id}) | ||
|
|
16 | + = " | " | ||
|
|
17 | + = link_to '[submissions]', :action => 'submission', :id => problem_name |
You need to be logged in to leave comments.
Login now