Description:
still upgrading
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r753:9918c6e0c313 - - 6 files changed: 26 inserted, 17 deleted
@@ -57,32 +57,32 | |||
|
57 | 57 | end |
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def edit |
|
61 | 61 | @problem = Problem.find(params[:id]) |
|
62 | 62 | @description = @problem.description |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def update |
|
66 | 66 | @problem = Problem.find(params[:id]) |
|
67 | 67 | @description = @problem.description |
|
68 | 68 | if @description.nil? and params[:description][:body]!='' |
|
69 |
- @description = Description.new( |
|
|
69 | + @description = Description.new(description_params) | |
|
70 | 70 | if !@description.save |
|
71 | 71 | flash[:notice] = 'Error saving description' |
|
72 | 72 | render :action => 'edit' and return |
|
73 | 73 | end |
|
74 | 74 | @problem.description = @description |
|
75 | 75 | elsif @description |
|
76 |
- if !@description.update_attributes( |
|
|
76 | + if !@description.update_attributes(description_params) | |
|
77 | 77 | flash[:notice] = 'Error saving description' |
|
78 | 78 | render :action => 'edit' and return |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | if params[:file] and params[:file].content_type != 'application/pdf' |
|
82 | 82 | flash[:notice] = 'Error: Uploaded file is not PDF' |
|
83 | 83 | render :action => 'edit' and return |
|
84 | 84 | end |
|
85 | 85 | if @problem.update_attributes(problem_params) |
|
86 | 86 | flash[:notice] = 'Problem was successfully updated.' |
|
87 | 87 | unless params[:file] == nil or params[:file] == '' |
|
88 | 88 | flash[:notice] = 'Problem was successfully updated and a new PDF file is uploaded.' |
@@ -292,13 +292,17 | |||
|
292 | 292 | problems |
|
293 | 293 | end |
|
294 | 294 | |
|
295 | 295 | def get_problems_stat |
|
296 | 296 | end |
|
297 | 297 | |
|
298 | 298 | private |
|
299 | 299 | |
|
300 | 300 | def problem_params |
|
301 | 301 | params.require(:problem).permit(:name, :full_name, :full_score, :change_date_added, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[]) |
|
302 | 302 | end |
|
303 | 303 | |
|
304 | + def description_params | |
|
305 | + params.require(:description).permit(:body, :markdown) | |
|
306 | + end | |
|
307 | + | |
|
304 | 308 | end |
@@ -18,25 +18,25 | |||
|
18 | 18 | :class_name => "Message", |
|
19 | 19 | :foreign_key => "sender_id" |
|
20 | 20 | |
|
21 | 21 | has_many :replied_messages, -> { order(created_at: :desc) }, |
|
22 | 22 | :class_name => "Message", |
|
23 | 23 | :foreign_key => "receiver_id" |
|
24 | 24 | |
|
25 | 25 | has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy |
|
26 | 26 | |
|
27 | 27 | belongs_to :site |
|
28 | 28 | belongs_to :country |
|
29 | 29 | |
|
30 |
- has_and_belongs_to_many :contests, -> { order(:name) |
|
|
30 | + has_and_belongs_to_many :contests, -> { order(:name)} | |
|
31 | 31 | |
|
32 | 32 | scope :activated_users, -> {where activated: true} |
|
33 | 33 | |
|
34 | 34 | validates_presence_of :login |
|
35 | 35 | validates_uniqueness_of :login |
|
36 | 36 | validates_format_of :login, :with => /\A[\_A-Za-z0-9]+\z/ |
|
37 | 37 | validates_length_of :login, :within => 3..30 |
|
38 | 38 | |
|
39 | 39 | validates_presence_of :full_name |
|
40 | 40 | validates_length_of :full_name, :minimum => 1 |
|
41 | 41 | |
|
42 | 42 | validates_presence_of :password, :if => :password_required? |
@@ -164,25 +164,25 | |||
|
164 | 164 | end |
|
165 | 165 | end |
|
166 | 166 | else |
|
167 | 167 | return nil |
|
168 | 168 | end |
|
169 | 169 | end |
|
170 | 170 | |
|
171 | 171 | def contest_finished? |
|
172 | 172 | if GraderConfiguration.contest_mode? |
|
173 | 173 | return false if site==nil |
|
174 | 174 | return site.finished? |
|
175 | 175 | elsif GraderConfiguration.indv_contest_mode? |
|
176 |
- return false if self.contest_stat |
|
|
176 | + return false if self.contest_stat==nil | |
|
177 | 177 | return contest_time_left == 0 |
|
178 | 178 | else |
|
179 | 179 | return false |
|
180 | 180 | end |
|
181 | 181 | end |
|
182 | 182 | |
|
183 | 183 | def contest_started? |
|
184 | 184 | if GraderConfiguration.indv_contest_mode? |
|
185 | 185 | stat = self.contest_stat |
|
186 | 186 | return ((stat != nil) and (stat.started_at != nil)) |
|
187 | 187 | elsif GraderConfiguration.contest_mode? |
|
188 | 188 | return true if site==nil |
@@ -1,23 +1,24 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = stylesheet_link_tag 'problems' |
|
3 | 3 | |
|
4 | 4 | %h1 Import problems |
|
5 | 5 | |
|
6 | 6 | %p= link_to '[Back to problem list]', problems_path |
|
7 | 7 | |
|
8 | 8 | - if @problem and @problem.errors |
|
9 | 9 | =error_messages_for 'problem' |
|
10 | 10 | |
|
11 |
- = |
|
|
11 | + = simple_form_for :problem, url: do_import_problems_path, :multipart => true do |f| | |
|
12 | + | |
|
12 | 13 | .submitbox |
|
13 | 14 | %table |
|
14 | 15 | %tr |
|
15 | 16 | %td Name: |
|
16 | 17 | %td= text_field_tag 'name' |
|
17 | 18 | %tr |
|
18 | 19 | %td Full name: |
|
19 | 20 | %td |
|
20 | 21 | = text_field_tag 'full_name' |
|
21 | 22 | %span{:class => 'help'} Leave blank to use the same value as the name above. |
|
22 | 23 | %tr |
|
23 | 24 | %td Testdata file: |
@@ -1,15 +1,15 | |||
|
1 | 1 | %h1 Maximum score |
|
2 | 2 | |
|
3 |
- = form_tag |
|
|
3 | + = form_tag show_max_score_report_path | |
|
4 | 4 | .row |
|
5 | 5 | .col-md-4 |
|
6 | 6 | .panel.panel-primary |
|
7 | 7 | .panel-heading |
|
8 | 8 | Problems |
|
9 | 9 | .panel-body |
|
10 | 10 | %p |
|
11 | 11 | Select problem(s) that we wish to know the score. |
|
12 | 12 | = label_tag :problem_id, "Problems" |
|
13 | 13 | = select_tag 'problem_id[]', |
|
14 | 14 | options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},params[:problem_id]), |
|
15 | 15 | { class: 'select2 form-control', multiple: "true" } |
@@ -42,35 +42,36 | |||
|
42 | 42 | Latest Submission Status |
|
43 | 43 | = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission |
|
44 | 44 | .panel-body |
|
45 | 45 | %div#latest_status |
|
46 | 46 | - if @submission |
|
47 | 47 | = render :partial => 'submission_short', |
|
48 | 48 | :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id } |
|
49 | 49 | .row |
|
50 | 50 | .col-md-12 |
|
51 | 51 | %h2 Console |
|
52 | 52 | %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20} |
|
53 | 53 | |
|
54 | - .modal.fade#compiler{tabindex: -1,role: 'dialog'} | |
|
55 | - .modal-dialog.modal-lg{role:'document'} | |
|
56 | - .modal-content | |
|
57 |
- .modal- |
|
|
58 | - %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} | |
|
59 | - %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × | |
|
60 | - %h4 Compiler message | |
|
61 | - .modal-body | |
|
62 | - %pre#compiler_msg= @submission.compiler_message | |
|
63 | - .modal-footer | |
|
64 | - %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close | |
|
54 | + - if @submission | |
|
55 | + .modal.fade#compiler{tabindex: -1,role: 'dialog'} | |
|
56 | + .modal-dialog.modal-lg{role:'document'} | |
|
57 | + .modal-content | |
|
58 | + .modal-header | |
|
59 | + %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} | |
|
60 | + %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × | |
|
61 | + %h4 Compiler message | |
|
62 | + .modal-body | |
|
63 | + %pre#compiler_msg= @submission.compiler_message | |
|
64 | + .modal-footer | |
|
65 | + %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close | |
|
65 | 66 | |
|
66 | 67 | :javascript |
|
67 | 68 | $(document).ready(function() { |
|
68 | 69 | e = ace.edit("editor") |
|
69 | 70 | e.setValue($("#text_sourcecode").val()); |
|
70 | 71 | e.gotoLine(1); |
|
71 | 72 | $("#language_id").trigger('change'); |
|
72 | 73 | |
|
73 | 74 | $("#load_file").on('change',function(evt) { |
|
74 | 75 | var file = evt.target.files[0]; |
|
75 | 76 | var reader = new FileReader(); |
|
76 | 77 | reader.onload = function(theFile) { |
@@ -31,24 +31,25 | |||
|
31 | 31 | get 'toggle' |
|
32 | 32 | get 'toggle_test' |
|
33 | 33 | get 'toggle_view_testcase' |
|
34 | 34 | get 'stat' |
|
35 | 35 | end |
|
36 | 36 | collection do |
|
37 | 37 | get 'turn_all_off' |
|
38 | 38 | get 'turn_all_on' |
|
39 | 39 | get 'import' |
|
40 | 40 | get 'manage' |
|
41 | 41 | get 'quick_create' |
|
42 | 42 | post 'do_manage' |
|
43 | + post 'do_import' | |
|
43 | 44 | end |
|
44 | 45 | end |
|
45 | 46 | |
|
46 | 47 | resources :groups do |
|
47 | 48 | member do |
|
48 | 49 | post 'add_user', to: 'groups#add_user', as: 'add_user' |
|
49 | 50 | delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user' |
|
50 | 51 | delete 'remove_all_user', to: 'groups#remove_all_user', as: 'remove_all_user' |
|
51 | 52 | post 'add_problem', to: 'groups#add_problem', as: 'add_problem' |
|
52 | 53 | delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem' |
|
53 | 54 | delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem' |
|
54 | 55 | end |
@@ -72,24 +73,25 | |||
|
72 | 73 | resources :users do |
|
73 | 74 | member do |
|
74 | 75 | get 'toggle_activate', 'toggle_enable' |
|
75 | 76 | get 'stat' |
|
76 | 77 | end |
|
77 | 78 | end |
|
78 | 79 | |
|
79 | 80 | resources :submissions do |
|
80 | 81 | member do |
|
81 | 82 | get 'download' |
|
82 | 83 | get 'compiler_msg' |
|
83 | 84 | get 'rejudge' |
|
85 | + get 'source' | |
|
84 | 86 | end |
|
85 | 87 | collection do |
|
86 | 88 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
|
87 | 89 | get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' |
|
88 | 90 | get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status' |
|
89 | 91 | end |
|
90 | 92 | end |
|
91 | 93 | |
|
92 | 94 | |
|
93 | 95 | #user admin |
|
94 | 96 | resources :user_admin do |
|
95 | 97 | collection do |
@@ -106,24 +108,25 | |||
|
106 | 108 | match 'random_all_passwords', via: [:get, :post] |
|
107 | 109 | end |
|
108 | 110 | member do |
|
109 | 111 | get 'clear_last_ip' |
|
110 | 112 | end |
|
111 | 113 | end |
|
112 | 114 | |
|
113 | 115 | resources :contest_management, only: [:index] do |
|
114 | 116 | collection do |
|
115 | 117 | get 'user_stat' |
|
116 | 118 | get 'clear_stat' |
|
117 | 119 | get 'clear_all_stat' |
|
120 | + get 'change_contest_mode' | |
|
118 | 121 | end |
|
119 | 122 | end |
|
120 | 123 | |
|
121 | 124 | #get 'user_admin', to: 'user_admin#index' |
|
122 | 125 | #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin' |
|
123 | 126 | #post 'user_admin', to: 'user_admin#create' |
|
124 | 127 | #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy' |
|
125 | 128 | |
|
126 | 129 | #singular resource |
|
127 | 130 | #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly |
|
128 | 131 | #report |
|
129 | 132 | resource :report, only: [], controller: 'report' do |
You need to be logged in to leave comments.
Login now