Description:
fix allow admin to submit to any problem
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r682:405106fcdb33 - - 7 files changed: 17 inserted, 5 deleted
@@ -86,7 +86,7 | |||
|
86 | 86 | render :action => 'list' and return |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | - if @submission.valid? | |
|
89 | + if @submission.valid?(@current_user) | |
|
90 | 90 | if @submission.save == false |
|
91 | 91 | flash[:notice] = 'Error saving your submission' |
|
92 | 92 | elsif Task.create(:submission_id => @submission.id, |
@@ -52,6 +52,11 | |||
|
52 | 52 | def direct_edit_problem |
|
53 | 53 | @problem = Problem.find(params[:problem_id]) |
|
54 | 54 | @source = '' |
|
55 | + if (params[:user_id]) | |
|
56 | + u = User.find(params[:user_id]) | |
|
57 | + @submission = Submission.find_last_by_user_and_problem(u.id,@problem.id) | |
|
58 | + @source = @submission.source.to_s if @submission and @submission.source | |
|
59 | + end | |
|
55 | 60 | render 'edit' |
|
56 | 61 | end |
|
57 | 62 |
@@ -147,8 +147,12 | |||
|
147 | 147 | return if self.source==nil |
|
148 | 148 | if self.problem==nil |
|
149 | 149 | errors.add('problem',"must be specified.") |
|
150 | - elsif (!self.problem.available) and (self.new_record?) | |
|
151 | - errors.add('problem',"must be valid.") | |
|
150 | + else | |
|
151 | + #admin always have right | |
|
152 | + return if self.user.admin? | |
|
153 | + | |
|
154 | + #check if user has the right to submit the problem | |
|
155 | + errors.add('problem',"must be valid.") if (!self.user.available_problem.include?(self.problem)) and (self.new_record?) | |
|
152 | 156 | end |
|
153 | 157 | end |
|
154 | 158 |
@@ -292,6 +292,7 | |||
|
292 | 292 | return true |
|
293 | 293 | end |
|
294 | 294 | |
|
295 | + #get a list of available problem | |
|
295 | 296 | def available_problems |
|
296 | 297 | if not GraderConfiguration.multicontests? |
|
297 | 298 | if GraderConfiguration.use_problem_group? |
@@ -44,7 +44,7 | |||
|
44 | 44 | = problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1 |
|
45 | 45 | = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem |
|
46 | 46 | %td.text-right= problem.full_score #in_place_editor_field :problem, :full_score, {}, :rows=>1 |
|
47 | - %td= link_to "Submit", direct_edit_problem_submissions_path(problem), class: 'btn btn-xs btn-primary' | |
|
47 | + %td= link_to "Submit", direct_edit_problem_submissions_path(problem,@current_user.id), class: 'btn btn-xs btn-primary' | |
|
48 | 48 | %td= problem.date_added |
|
49 | 49 | %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}") |
|
50 | 50 | %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}") |
@@ -11,6 +11,7 | |||
|
11 | 11 | .col-md-8 |
|
12 | 12 | %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'} |
|
13 | 13 | .col-md-4 |
|
14 | + - # submission form | |
|
14 | 15 | = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do |
|
15 | 16 | |
|
16 | 17 | = hidden_field_tag 'editor_text', @source |
@@ -25,6 +26,7 | |||
|
25 | 26 | .form-group |
|
26 | 27 | = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit', |
|
27 | 28 | data: {confirm: "Submitting this source code for task #{@problem.long_name}?"} |
|
29 | + - # latest submission status | |
|
28 | 30 | .panel.panel-info |
|
29 | 31 | .panel-heading |
|
30 | 32 | Latest Submission Status |
@@ -73,7 +73,7 | |||
|
73 | 73 | end |
|
74 | 74 | collection do |
|
75 | 75 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
|
76 | - get 'direct_edit_problem/:problem_id', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' | |
|
76 | + get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' | |
|
77 | 77 | get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status' |
|
78 | 78 | end |
|
79 | 79 | end |
You need to be logged in to leave comments.
Login now