Description:
[web] uploading output-only submission
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@189 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
r100:2ce8f9387085 - - 2 files changed: 8 inserted, 0 deleted
@@ -41,49 +41,53 | |||
|
41 | 41 | |
|
42 | 42 | if user.site!=nil and user.site.finished? |
|
43 | 43 | @submission.errors.add_to_base "The contest is over." |
|
44 | 44 | prepare_list_information |
|
45 | 45 | render :action => 'list' and return |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | if @submission.valid? |
|
49 | 49 | if @submission.save == false |
|
50 | 50 | flash[:notice] = 'Error saving your submission' |
|
51 | 51 | elsif Task.create(:submission_id => @submission.id, |
|
52 | 52 | :status => Task::STATUS_INQUEUE) == false |
|
53 | 53 | flash[:notice] = 'Error adding your submission to task queue' |
|
54 | 54 | end |
|
55 | 55 | else |
|
56 | 56 | prepare_list_information |
|
57 | 57 | render :action => 'list' and return |
|
58 | 58 | end |
|
59 | 59 | redirect_to :action => 'list' |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def source |
|
63 | 63 | submission = Submission.find(params[:id]) |
|
64 | 64 | if submission.user_id == session[:user_id] |
|
65 | + if submission.problem.output_only | |
|
66 | + fname = submission.source_filename | |
|
67 | + else | |
|
65 | 68 | fname = submission.problem.name + '.' + submission.language.ext |
|
69 | + end | |
|
66 | 70 | send_data(submission.source, |
|
67 | 71 | {:filename => fname, |
|
68 | 72 | :type => 'text/plain'}) |
|
69 | 73 | else |
|
70 | 74 | flash[:notice] = 'Error viewing source' |
|
71 | 75 | redirect_to :action => 'list' |
|
72 | 76 | end |
|
73 | 77 | end |
|
74 | 78 | |
|
75 | 79 | def compiler_msg |
|
76 | 80 | @submission = Submission.find(params[:id]) |
|
77 | 81 | if @submission.user_id == session[:user_id] |
|
78 | 82 | render :action => 'compiler_msg', :layout => 'empty' |
|
79 | 83 | else |
|
80 | 84 | flash[:notice] = 'Error viewing source' |
|
81 | 85 | redirect_to :action => 'list' |
|
82 | 86 | end |
|
83 | 87 | end |
|
84 | 88 | |
|
85 | 89 | def submission |
|
86 | 90 | @user = User.find(session[:user_id]) |
|
87 | 91 | @problems = Problem.find_available_problems |
|
88 | 92 | if params[:id]==nil |
|
89 | 93 | @problem = nil |
@@ -78,27 +78,31 | |||
|
78 | 78 | |
|
79 | 79 | def destroy |
|
80 | 80 | Problem.find(params[:id]).destroy |
|
81 | 81 | redirect_to :action => 'list' |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def toggle_avail |
|
85 | 85 | problem = Problem.find(params[:id]) |
|
86 | 86 | problem.available = !(problem.available) |
|
87 | 87 | problem.save |
|
88 | 88 | redirect_to :action => 'list' |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | def turn_all_off |
|
92 | 92 | Problem.find(:all, |
|
93 | 93 | :conditions => "available = 1").each do |problem| |
|
94 | 94 | problem.available = false |
|
95 | 95 | problem.save |
|
96 | 96 | end |
|
97 | 97 | redirect_to :action => 'list' |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def stat |
|
101 | 101 | @problem = Problem.find(params[:id]) |
|
102 | + if !@problem.available | |
|
103 | + redirect_to :controller => 'main', :action => 'list' | |
|
104 | + else | |
|
102 | 105 | @submissions = Submission.find_all_last_by_problem(params[:id]) |
|
103 | 106 | end |
|
104 | 107 | end |
|
108 | + end |
You need to be logged in to leave comments.
Login now