Description:
add tags
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r700:757ebc0ccd63 - - 7 files changed: 56 inserted, 29 deleted

@@ -116,191 +116,195
116
116
117 def destroy
117 def destroy
118 p = Problem.find(params[:id]).destroy
118 p = Problem.find(params[:id]).destroy
119 redirect_to action: :index
119 redirect_to action: :index
120 end
120 end
121
121
122 def toggle
122 def toggle
123 @problem = Problem.find(params[:id])
123 @problem = Problem.find(params[:id])
124 @problem.update_attributes(available: !(@problem.available) )
124 @problem.update_attributes(available: !(@problem.available) )
125 respond_to do |format|
125 respond_to do |format|
126 format.js { }
126 format.js { }
127 end
127 end
128 end
128 end
129
129
130 def toggle_test
130 def toggle_test
131 @problem = Problem.find(params[:id])
131 @problem = Problem.find(params[:id])
132 @problem.update_attributes(test_allowed: !(@problem.test_allowed?) )
132 @problem.update_attributes(test_allowed: !(@problem.test_allowed?) )
133 respond_to do |format|
133 respond_to do |format|
134 format.js { }
134 format.js { }
135 end
135 end
136 end
136 end
137
137
138 def toggle_view_testcase
138 def toggle_view_testcase
139 @problem = Problem.find(params[:id])
139 @problem = Problem.find(params[:id])
140 @problem.update_attributes(view_testcase: !(@problem.view_testcase?) )
140 @problem.update_attributes(view_testcase: !(@problem.view_testcase?) )
141 respond_to do |format|
141 respond_to do |format|
142 format.js { }
142 format.js { }
143 end
143 end
144 end
144 end
145
145
146 def turn_all_off
146 def turn_all_off
147 Problem.available.all.each do |problem|
147 Problem.available.all.each do |problem|
148 problem.available = false
148 problem.available = false
149 problem.save
149 problem.save
150 end
150 end
151 redirect_to action: :index
151 redirect_to action: :index
152 end
152 end
153
153
154 def turn_all_on
154 def turn_all_on
155 Problem.where.not(available: true).each do |problem|
155 Problem.where.not(available: true).each do |problem|
156 problem.available = true
156 problem.available = true
157 problem.save
157 problem.save
158 end
158 end
159 redirect_to action: :index
159 redirect_to action: :index
160 end
160 end
161
161
162 def stat
162 def stat
163 @problem = Problem.find(params[:id])
163 @problem = Problem.find(params[:id])
164 unless @problem.available or session[:admin]
164 unless @problem.available or session[:admin]
165 redirect_to :controller => 'main', :action => 'list'
165 redirect_to :controller => 'main', :action => 'list'
166 return
166 return
167 end
167 end
168 @submissions = Submission.includes(:user).includes(:language).where(problem_id: params[:id]).order(:user_id,:id)
168 @submissions = Submission.includes(:user).includes(:language).where(problem_id: params[:id]).order(:user_id,:id)
169
169
170 #stat summary
170 #stat summary
171 range =65
171 range =65
172 @histogram = { data: Array.new(range,0), summary: {} }
172 @histogram = { data: Array.new(range,0), summary: {} }
173 user = Hash.new(0)
173 user = Hash.new(0)
174 @submissions.find_each do |sub|
174 @submissions.find_each do |sub|
175 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
175 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
176 @histogram[:data][d.to_i] += 1 if d < range
176 @histogram[:data][d.to_i] += 1 if d < range
177 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
177 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
178 end
178 end
179 @histogram[:summary][:max] = [@histogram[:data].max,1].max
179 @histogram[:summary][:max] = [@histogram[:data].max,1].max
180
180
181 @summary = { attempt: user.count, solve: 0 }
181 @summary = { attempt: user.count, solve: 0 }
182 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
182 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
183 end
183 end
184
184
185 def manage
185 def manage
186 @problems = Problem.order(date_added: :desc)
186 @problems = Problem.order(date_added: :desc)
187 end
187 end
188
188
189 def do_manage
189 def do_manage
190 if params.has_key? 'change_date_added'
190 if params.has_key? 'change_date_added'
191 change_date_added
191 change_date_added
192 elsif params.has_key? 'add_to_contest'
192 elsif params.has_key? 'add_to_contest'
193 add_to_contest
193 add_to_contest
194 elsif params.has_key? 'enable_problem'
194 elsif params.has_key? 'enable_problem'
195 set_available(true)
195 set_available(true)
196 elsif params.has_key? 'disable_problem'
196 elsif params.has_key? 'disable_problem'
197 set_available(false)
197 set_available(false)
198 elsif params.has_key? 'add_group'
198 elsif params.has_key? 'add_group'
199 group = Group.find(params[:group_id])
199 group = Group.find(params[:group_id])
200 ok = []
200 ok = []
201 failed = []
201 failed = []
202 get_problems_from_params.each do |p|
202 get_problems_from_params.each do |p|
203 begin
203 begin
204 group.problems << p
204 group.problems << p
205 ok << p.full_name
205 ok << p.full_name
206 rescue => e
206 rescue => e
207 failed << p.full_name
207 failed << p.full_name
208 end
208 end
209 end
209 end
210 flash[:success] = "The following problems are added to the group #{group.name}: " + ok.join(', ') if ok.count > 0
210 flash[:success] = "The following problems are added to the group #{group.name}: " + ok.join(', ') if ok.count > 0
211 flash[:alert] = "The following problems are already in the group #{group.name}: " + failed.join(', ') if failed.count > 0
211 flash[:alert] = "The following problems are already in the group #{group.name}: " + failed.join(', ') if failed.count > 0
212 + elsif params.has_key? 'add_tags'
213 + get_problems_from_params.each do |p|
214 + p.tag_ids += params[:tag_ids]
215 + end
212 end
216 end
213
217
214 redirect_to :action => 'manage'
218 redirect_to :action => 'manage'
215 end
219 end
216
220
217 def import
221 def import
218 @allow_test_pair_import = allow_test_pair_import?
222 @allow_test_pair_import = allow_test_pair_import?
219 end
223 end
220
224
221 def do_import
225 def do_import
222 old_problem = Problem.find_by_name(params[:name])
226 old_problem = Problem.find_by_name(params[:name])
223 if !allow_test_pair_import? and params.has_key? :import_to_db
227 if !allow_test_pair_import? and params.has_key? :import_to_db
224 params.delete :import_to_db
228 params.delete :import_to_db
225 end
229 end
226 @problem, import_log = Problem.create_from_import_form_params(params,
230 @problem, import_log = Problem.create_from_import_form_params(params,
227 old_problem)
231 old_problem)
228
232
229 if !@problem.errors.empty?
233 if !@problem.errors.empty?
230 render :action => 'import' and return
234 render :action => 'import' and return
231 end
235 end
232
236
233 if old_problem!=nil
237 if old_problem!=nil
234 flash[:notice] = "The test data has been replaced for problem #{@problem.name}"
238 flash[:notice] = "The test data has been replaced for problem #{@problem.name}"
235 end
239 end
236 @log = import_log
240 @log = import_log
237 end
241 end
238
242
239 def remove_contest
243 def remove_contest
240 problem = Problem.find(params[:id])
244 problem = Problem.find(params[:id])
241 contest = Contest.find(params[:contest_id])
245 contest = Contest.find(params[:contest_id])
242 if problem!=nil and contest!=nil
246 if problem!=nil and contest!=nil
243 problem.contests.delete(contest)
247 problem.contests.delete(contest)
244 end
248 end
245 redirect_to :action => 'manage'
249 redirect_to :action => 'manage'
246 end
250 end
247
251
248 ##################################
252 ##################################
249 protected
253 protected
250
254
251 def allow_test_pair_import?
255 def allow_test_pair_import?
252 if defined? ALLOW_TEST_PAIR_IMPORT
256 if defined? ALLOW_TEST_PAIR_IMPORT
253 return ALLOW_TEST_PAIR_IMPORT
257 return ALLOW_TEST_PAIR_IMPORT
254 else
258 else
255 return false
259 return false
256 end
260 end
257 end
261 end
258
262
259 def change_date_added
263 def change_date_added
260 problems = get_problems_from_params
264 problems = get_problems_from_params
261 date = Date.parse(params[:date_added])
265 date = Date.parse(params[:date_added])
262 problems.each do |p|
266 problems.each do |p|
263 p.date_added = date
267 p.date_added = date
264 p.save
268 p.save
265 end
269 end
266 end
270 end
267
271
268 def add_to_contest
272 def add_to_contest
269 problems = get_problems_from_params
273 problems = get_problems_from_params
270 contest = Contest.find(params[:contest][:id])
274 contest = Contest.find(params[:contest][:id])
271 if contest!=nil and contest.enabled
275 if contest!=nil and contest.enabled
272 problems.each do |p|
276 problems.each do |p|
273 p.contests << contest
277 p.contests << contest
274 end
278 end
275 end
279 end
276 end
280 end
277
281
278 def set_available(avail)
282 def set_available(avail)
279 problems = get_problems_from_params
283 problems = get_problems_from_params
280 problems.each do |p|
284 problems.each do |p|
281 p.available = avail
285 p.available = avail
282 p.save
286 p.save
283 end
287 end
284 end
288 end
285
289
286 def get_problems_from_params
290 def get_problems_from_params
287 problems = []
291 problems = []
288 params.keys.each do |k|
292 params.keys.each do |k|
289 if k.index('prob-')==0
293 if k.index('prob-')==0
290 name, id, order = k.split('-')
294 name, id, order = k.split('-')
291 problems << Problem.find(id)
295 problems << Problem.find(id)
292 end
296 end
293 end
297 end
294 problems
298 problems
295 end
299 end
296
300
297 def get_problems_stat
301 def get_problems_stat
298 end
302 end
299
303
300 private
304 private
301
305
302 def problem_params
306 def problem_params
303 - params.require(:problem).permit(:name, :full_name, :full_score, :date_added, :available, :test_allowed,:output_only, :url, :description)
307 + params.require(:problem).permit(:name, :full_name, :full_score, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[])
304 end
308 end
305
309
306 end
310 end
@@ -1,58 +1,60
1 class TagsController < ApplicationController
1 class TagsController < ApplicationController
2 before_action :set_tag, only: [:show, :edit, :update, :destroy]
2 before_action :set_tag, only: [:show, :edit, :update, :destroy]
3
3
4 # GET /tags
4 # GET /tags
5 def index
5 def index
6 @tags = Tag.all
6 @tags = Tag.all
7 end
7 end
8
8
9 # GET /tags/1
9 # GET /tags/1
10 def show
10 def show
11 end
11 end
12
12
13 # GET /tags/new
13 # GET /tags/new
14 def new
14 def new
15 @tag = Tag.new
15 @tag = Tag.new
16 end
16 end
17
17
18 # GET /tags/1/edit
18 # GET /tags/1/edit
19 def edit
19 def edit
20 end
20 end
21
21
22 # POST /tags
22 # POST /tags
23 def create
23 def create
24 @tag = Tag.new(tag_params)
24 @tag = Tag.new(tag_params)
25
25
26 if @tag.save
26 if @tag.save
27 redirect_to @tag, notice: 'Tag was successfully created.'
27 redirect_to @tag, notice: 'Tag was successfully created.'
28 else
28 else
29 render :new
29 render :new
30 end
30 end
31 end
31 end
32
32
33 # PATCH/PUT /tags/1
33 # PATCH/PUT /tags/1
34 def update
34 def update
35 if @tag.update(tag_params)
35 if @tag.update(tag_params)
36 redirect_to @tag, notice: 'Tag was successfully updated.'
36 redirect_to @tag, notice: 'Tag was successfully updated.'
37 else
37 else
38 render :edit
38 render :edit
39 end
39 end
40 end
40 end
41
41
42 # DELETE /tags/1
42 # DELETE /tags/1
43 def destroy
43 def destroy
44 + #remove any association
45 + ProblemTag.where(tag_id: @tag.id).destroy_all
44 @tag.destroy
46 @tag.destroy
45 redirect_to tags_url, notice: 'Tag was successfully destroyed.'
47 redirect_to tags_url, notice: 'Tag was successfully destroyed.'
46 end
48 end
47
49
48 private
50 private
49 # Use callbacks to share common setup or constraints between actions.
51 # Use callbacks to share common setup or constraints between actions.
50 def set_tag
52 def set_tag
51 @tag = Tag.find(params[:id])
53 @tag = Tag.find(params[:id])
52 end
54 end
53
55
54 # Only allow a trusted parameter "white list" through.
56 # Only allow a trusted parameter "white list" through.
55 def tag_params
57 def tag_params
56 params.require(:tag).permit(:name, :description, :public)
58 params.require(:tag).permit(:name, :description, :public)
57 end
59 end
58 end
60 end
@@ -1,94 +1,95
1 %header.navbar.navbar-default.navbar-fixed-top
1 %header.navbar.navbar-default.navbar-fixed-top
2 %nav
2 %nav
3 .container-fluid
3 .container-fluid
4 .navbar-header
4 .navbar-header
5 %button.navbar-toggle.collapsed{ data: {toggle: 'collapse', target: '#navbar-collapse'} }
5 %button.navbar-toggle.collapsed{ data: {toggle: 'collapse', target: '#navbar-collapse'} }
6 %span.sr-only Togggle Navigation
6 %span.sr-only Togggle Navigation
7 %span.icon-bar
7 %span.icon-bar
8 %span.icon-bar
8 %span.icon-bar
9 %span.icon-bar
9 %span.icon-bar
10 %a.navbar-brand{href: main_list_path}
10 %a.navbar-brand{href: main_list_path}
11 %span.glyphicon.glyphicon-home
11 %span.glyphicon.glyphicon-home
12 MAIN
12 MAIN
13 .collapse.navbar-collapse#navbar-collapse
13 .collapse.navbar-collapse#navbar-collapse
14 %ul.nav.navbar-nav
14 %ul.nav.navbar-nav
15 / submission
15 / submission
16 - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user))
16 - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user))
17 %li.dropdown
17 %li.dropdown
18 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
18 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
19 = "#{I18n.t 'menu.submissions'}"
19 = "#{I18n.t 'menu.submissions'}"
20 %span.caret
20 %span.caret
21 %ul.dropdown-menu
21 %ul.dropdown-menu
22 = add_menu("View", 'submissions', 'index')
22 = add_menu("View", 'submissions', 'index')
23 = add_menu("Self Test", 'test', 'index')
23 = add_menu("Self Test", 'test', 'index')
24 / hall of fame
24 / hall of fame
25 - if GraderConfiguration['right.user_hall_of_fame']
25 - if GraderConfiguration['right.user_hall_of_fame']
26 = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
26 = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
27 / display MODE button (with countdown in contest mode)
27 / display MODE button (with countdown in contest mode)
28 - if GraderConfiguration.analysis_mode?
28 - if GraderConfiguration.analysis_mode?
29 %div.navbar-btn.btn.btn-success#countdown= "ANALYSIS MODE"
29 %div.navbar-btn.btn.btn-success#countdown= "ANALYSIS MODE"
30 - elsif GraderConfiguration.time_limit_mode?
30 - elsif GraderConfiguration.time_limit_mode?
31 - if @current_user.contest_finished?
31 - if @current_user.contest_finished?
32 %div.navbar-btn.btn.btn-danger#countdown= "Contest is over"
32 %div.navbar-btn.btn.btn-danger#countdown= "Contest is over"
33 - elsif !@current_user.contest_started?
33 - elsif !@current_user.contest_started?
34 %div.navbar-btn.btn.btn-primary#countdown= (t 'title_bar.contest_not_started')
34 %div.navbar-btn.btn.btn-primary#countdown= (t 'title_bar.contest_not_started')
35 - else
35 - else
36 %div.navbar-btn.btn.btn-primary#countdown asdf
36 %div.navbar-btn.btn.btn-primary#countdown asdf
37 :javascript
37 :javascript
38 $("#countdown").countdown({until: "+#{@current_user.contest_time_left.to_i}s", layout: 'Time left: {hnn}:{mnn}:{snn}'});
38 $("#countdown").countdown({until: "+#{@current_user.contest_time_left.to_i}s", layout: 'Time left: {hnn}:{mnn}:{snn}'});
39 / admin section
39 / admin section
40 - if (@current_user!=nil) and (session[:admin])
40 - if (@current_user!=nil) and (session[:admin])
41 / management
41 / management
42 %li.dropdown
42 %li.dropdown
43 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
43 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
44 Manage
44 Manage
45 %span.caret
45 %span.caret
46 %ul.dropdown-menu
46 %ul.dropdown-menu
47 = add_menu( 'Announcements', 'announcements', 'index')
47 = add_menu( 'Announcements', 'announcements', 'index')
48 = add_menu( 'Problems', 'problems', 'index')
48 = add_menu( 'Problems', 'problems', 'index')
49 + = add_menu( 'Tags', 'tags', 'index')
49 = add_menu( 'Users', 'user_admin', 'index')
50 = add_menu( 'Users', 'user_admin', 'index')
50 = add_menu( 'User Groups', 'groups', 'index')
51 = add_menu( 'User Groups', 'groups', 'index')
51 = add_menu( 'Graders', 'graders', 'list')
52 = add_menu( 'Graders', 'graders', 'list')
52 = add_menu( 'Message ', 'messages', 'console')
53 = add_menu( 'Message ', 'messages', 'console')
53 %li.divider{role: 'separator'}
54 %li.divider{role: 'separator'}
54 = add_menu( 'System config', 'configurations', 'index')
55 = add_menu( 'System config', 'configurations', 'index')
55 %li.divider{role: 'separator'}
56 %li.divider{role: 'separator'}
56 = add_menu( 'Sites', 'sites', 'index')
57 = add_menu( 'Sites', 'sites', 'index')
57 = add_menu( 'Contests', 'contest_management', 'index')
58 = add_menu( 'Contests', 'contest_management', 'index')
58 / report
59 / report
59 %li.dropdown
60 %li.dropdown
60 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
61 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
61 Report
62 Report
62 %span.caret
63 %span.caret
63 %ul.dropdown-menu
64 %ul.dropdown-menu
64 = add_menu( 'Current Score', 'report', 'current_score')
65 = add_menu( 'Current Score', 'report', 'current_score')
65 = add_menu( 'Score Report', 'report', 'max_score')
66 = add_menu( 'Score Report', 'report', 'max_score')
66 = add_menu( 'Report', 'report', 'multiple_login')
67 = add_menu( 'Report', 'report', 'multiple_login')
67 - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0
68 - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0
68 =link_to "#{ungraded} backlogs!",
69 =link_to "#{ungraded} backlogs!",
69 grader_list_path,
70 grader_list_path,
70 class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission'
71 class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission'
71
72
72 %ul.nav.navbar-nav.navbar-right
73 %ul.nav.navbar-nav.navbar-right
73 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
74 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
74 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
75 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
75 - if GraderConfiguration['system.user_setting_enabled']
76 - if GraderConfiguration['system.user_setting_enabled']
76 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
77 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
77 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{@current_user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}})
78 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{@current_user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}})
78
79
79 /
80 /
80 - if (@current_user!=nil) and (session[:admin])
81 - if (@current_user!=nil) and (session[:admin])
81 %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar
82 %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar
82 .container-fluid
83 .container-fluid
83 .collapse.navbar-collapse
84 .collapse.navbar-collapse
84 %ul.nav.navbar-nav
85 %ul.nav.navbar-nav
85 = add_menu( '[Announcements]', 'announcements', 'index')
86 = add_menu( '[Announcements]', 'announcements', 'index')
86 = add_menu( '[Msg console]', 'messages', 'console')
87 = add_menu( '[Msg console]', 'messages', 'console')
87 = add_menu( '[Problems]', 'problems', 'index')
88 = add_menu( '[Problems]', 'problems', 'index')
88 = add_menu( '[Users]', 'user_admin', 'index')
89 = add_menu( '[Users]', 'user_admin', 'index')
89 = add_menu( '[Results]', 'user_admin', 'user_stat')
90 = add_menu( '[Results]', 'user_admin', 'user_stat')
90 = add_menu( '[Report]', 'report', 'multiple_login')
91 = add_menu( '[Report]', 'report', 'multiple_login')
91 = add_menu( '[Graders]', 'graders', 'list')
92 = add_menu( '[Graders]', 'graders', 'list')
92 = add_menu( '[Contests]', 'contest_management', 'index')
93 = add_menu( '[Contests]', 'contest_management', 'index')
93 = add_menu( '[Sites]', 'sites', 'index')
94 = add_menu( '[Sites]', 'sites', 'index')
94 = add_menu( '[System config]', 'configurations', 'index')
95 = add_menu( '[System config]', 'configurations', 'index')
@@ -1,52 +1,55
1 = error_messages_for 'problem'
1 = error_messages_for 'problem'
2 / [form:problem]
2 / [form:problem]
3 .form-group
3 .form-group
4 %label{:for => "problem_name"} Name
4 %label{:for => "problem_name"} Name
5 = text_field 'problem', 'name', class: 'form-control'
5 = text_field 'problem', 'name', class: 'form-control'
6 %small
6 %small
7 Do not directly edit the problem name, unless you know what you are doing. If you want to change the name, use the name change button in the problem management menu instead.
7 Do not directly edit the problem name, unless you know what you are doing. If you want to change the name, use the name change button in the problem management menu instead.
8 .form-group
8 .form-group
9 %label{:for => "problem_full_name"} Full name
9 %label{:for => "problem_full_name"} Full name
10 = text_field 'problem', 'full_name', class: 'form-control'
10 = text_field 'problem', 'full_name', class: 'form-control'
11 .form-group
11 .form-group
12 %label{:for => "problem_full_score"} Full score
12 %label{:for => "problem_full_score"} Full score
13 = text_field 'problem', 'full_score', class: 'form-control'
13 = text_field 'problem', 'full_score', class: 'form-control'
14 .form-group
14 .form-group
15 + %label{:for => "problem_full_score"} Tags
16 + = collection_select(:problem, :tag_ids, Tag.all, :id, :name, {}, {multiple: true, class: 'form-control select2'})
17 + .form-group
15 %label{:for => "problem_date_added"} Date added
18 %label{:for => "problem_date_added"} Date added
16 = date_select 'problem', 'date_added', class: 'form-control'
19 = date_select 'problem', 'date_added', class: 'form-control'
17 - # TODO: these should be put in model Problem, but I can't think of
20 - # TODO: these should be put in model Problem, but I can't think of
18 - # nice default values for them. These values look fine only
21 - # nice default values for them. These values look fine only
19 - # in this case (of lazily adding new problems).
22 - # in this case (of lazily adding new problems).
20 - @problem.available = true if @problem!=nil and @problem.available==nil
23 - @problem.available = true if @problem!=nil and @problem.available==nil
21 - @problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil
24 - @problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil
22 - @problem.output_only = false if @problem!=nil and @problem.output_only==nil
25 - @problem.output_only = false if @problem!=nil and @problem.output_only==nil
23 .checkbox
26 .checkbox
24 %label{:for => "problem_available"}
27 %label{:for => "problem_available"}
25 = check_box :problem, :available
28 = check_box :problem, :available
26 Available?
29 Available?
27 .checkbox
30 .checkbox
28 %label{:for => "problem_test_allowed"}
31 %label{:for => "problem_test_allowed"}
29 = check_box :problem, :test_allowed
32 = check_box :problem, :test_allowed
30 Test allowed?
33 Test allowed?
31 .checkbox
34 .checkbox
32 %label{:for => "problem_output_only"}
35 %label{:for => "problem_output_only"}
33 = check_box :problem, :output_only
36 = check_box :problem, :output_only
34 Output only?
37 Output only?
35 = error_messages_for 'description'
38 = error_messages_for 'description'
36 .form-group
39 .form-group
37 %label{:for => "description_body"} Description
40 %label{:for => "description_body"} Description
38 %br/
41 %br/
39 = text_area :description, :body, :rows => 10, :cols => 80,class: 'form-control'
42 = text_area :description, :body, :rows => 10, :cols => 80,class: 'form-control'
40 .form-group
43 .form-group
41 %label{:for => "description_markdowned"} Markdowned?
44 %label{:for => "description_markdowned"} Markdowned?
42 = select "description", |
45 = select "description", |
43 "markdowned", |
46 "markdowned", |
44 [['True',true],['False',false]], |
47 [['True',true],['False',false]], |
45 {:selected => (@description) ? @description.markdowned : false } |
48 {:selected => (@description) ? @description.markdowned : false } |
46 .form-group
49 .form-group
47 %label{:for => "problem_url"} URL
50 %label{:for => "problem_url"} URL
48 %br/
51 %br/
49 = text_field 'problem', 'url',class: 'form-control'
52 = text_field 'problem', 'url',class: 'form-control'
50 %p
53 %p
51 Task PDF #{file_field_tag 'file'}
54 Task PDF #{file_field_tag 'file'}
52 / [eoform:problem]
55 / [eoform:problem]
@@ -1,60 +1,65
1 - content_for :head do
1 - content_for :head do
2 = stylesheet_link_tag 'problems'
2 = stylesheet_link_tag 'problems'
3 %h1 Problems
3 %h1 Problems
4 %p
4 %p
5 = link_to 'Import problems', {:action => 'import'}, class: 'btn btn-success btn-sm'
5 = link_to 'Import problems', {:action => 'import'}, class: 'btn btn-success btn-sm'
6 = link_to 'New problem', new_problem_path, class: 'btn btn-success btn-sm'
6 = link_to 'New problem', new_problem_path, class: 'btn btn-success btn-sm'
7 = link_to 'Bulk Manage', { action: 'manage'}, class: 'btn btn-info btn-sm'
7 = link_to 'Bulk Manage', { action: 'manage'}, class: 'btn btn-info btn-sm'
8 = link_to 'Turn off all problems', {:action => 'turn_all_off'}, class: 'btn btn-default btn-sm'
8 = link_to 'Turn off all problems', {:action => 'turn_all_off'}, class: 'btn btn-default btn-sm'
9 = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm'
9 = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm'
10 .submitbox
10 .submitbox
11 = form_tag :action => 'quick_create' do
11 = form_tag :action => 'quick_create' do
12 %b Quick New:
12 %b Quick New:
13 %label{:for => "problem_name"} Name
13 %label{:for => "problem_name"} Name
14 = text_field 'problem', 'name'
14 = text_field 'problem', 'name'
15 |
15 |
16 %label{:for => "problem_full_name"} Full name
16 %label{:for => "problem_full_name"} Full name
17 = text_field 'problem', 'full_name'
17 = text_field 'problem', 'full_name'
18 = submit_tag "Create"
18 = submit_tag "Create"
19 %table.table.table-condense.table-hover
19 %table.table.table-condense.table-hover
20 %thead
20 %thead
21 %th Name
21 %th Name
22 %th Full name
22 %th Full name
23 %th.text-right Full score
23 %th.text-right Full score
24 + %th Tags
24 %th
25 %th
25 Submit
26 Submit
26 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Admin can always submit to any problem' } [?]
27 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Admin can always submit to any problem' } [?]
27 %th Date added
28 %th Date added
28 %th.text-center
29 %th.text-center
29 Avail?
30 Avail?
30 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
31 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
31 %th.text-center
32 %th.text-center
32 View Data?
33 View Data?
33 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user view the testcase of this problem?' } [?]
34 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user view the testcase of this problem?' } [?]
34 %th.text-center
35 %th.text-center
35 Test?
36 Test?
36 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
37 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
37 - if GraderConfiguration.multicontests?
38 - if GraderConfiguration.multicontests?
38 %th Contests
39 %th Contests
39 - for problem in @problems
40 - for problem in @problems
40 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
41 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
41 - @problem=problem
42 - @problem=problem
42 %td= problem.name #in_place_editor_field :problem, :name, {}, :rows=>1
43 %td= problem.name #in_place_editor_field :problem, :name, {}, :rows=>1
43 %td
44 %td
44 = problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
45 = problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
45 = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem
46 = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem
46 %td.text-right= problem.full_score #in_place_editor_field :problem, :full_score, {}, :rows=>1
47 %td.text-right= problem.full_score #in_place_editor_field :problem, :full_score, {}, :rows=>1
48 + %td
49 + - problem.tags.each do |t|
50 + - #%button.btn.btn-default.btn-xs= t.name
51 + %span.label.label-default= t.name
47 %td= link_to "Submit", direct_edit_problem_submissions_path(problem,@current_user.id), class: 'btn btn-xs btn-primary'
52 %td= link_to "Submit", direct_edit_problem_submissions_path(problem,@current_user.id), class: 'btn btn-xs btn-primary'
48 %td= problem.date_added
53 %td= problem.date_added
49 %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}")
54 %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}")
50 %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}")
55 %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}")
51 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_path(@problem), "problem-test-#{@problem.id}")
56 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_path(@problem), "problem-test-#{@problem.id}")
52 - if GraderConfiguration.multicontests?
57 - if GraderConfiguration.multicontests?
53 %td
58 %td
54 = problem.contests.collect { |c| c.name }.join(', ')
59 = problem.contests.collect { |c| c.name }.join(', ')
55 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
60 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
56 %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block'
61 %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block'
57 %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block'
62 %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block'
58 %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :delete, class: 'btn btn-danger btn-xs btn-block'
63 %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :delete, class: 'btn btn-danger btn-xs btn-block'
59 %br/
64 %br/
60 = link_to '[New problem]', :action => 'new'
65 = link_to '[New problem]', :action => 'new'
@@ -1,107 +1,118
1 - content_for :head do
1 - content_for :head do
2 = stylesheet_link_tag 'problems'
2 = stylesheet_link_tag 'problems'
3 = javascript_include_tag 'local_jquery'
3 = javascript_include_tag 'local_jquery'
4
4
5 :javascript
5 :javascript
6 $(document).ready( function() {
6 $(document).ready( function() {
7 function shiftclick(start,stop,value) {
7 function shiftclick(start,stop,value) {
8 $('tr input').each( function(id,input) {
8 $('tr input').each( function(id,input) {
9 var $input=$(input);
9 var $input=$(input);
10 var iid=parseInt($input.attr('id').split('-')[2]);
10 var iid=parseInt($input.attr('id').split('-')[2]);
11 if(iid>=start&&iid<=stop){
11 if(iid>=start&&iid<=stop){
12 $input.prop('checked',value)
12 $input.prop('checked',value)
13 }
13 }
14 });
14 });
15 }
15 }
16
16
17 $('tr input').click( function(e) {
17 $('tr input').click( function(e) {
18 if (e.shiftKey) {
18 if (e.shiftKey) {
19 stop = parseInt($(this).attr('id').split('-')[2]);
19 stop = parseInt($(this).attr('id').split('-')[2]);
20 var orig_stop = stop
20 var orig_stop = stop
21 if (typeof start !== 'undefined') {
21 if (typeof start !== 'undefined') {
22 if (start > stop) {
22 if (start > stop) {
23 var tmp = start;
23 var tmp = start;
24 start = stop;
24 start = stop;
25 stop = tmp;
25 stop = tmp;
26 }
26 }
27 shiftclick(start,stop,$(this).is(':checked') )
27 shiftclick(start,stop,$(this).is(':checked') )
28 }
28 }
29 start = orig_stop
29 start = orig_stop
30 } else {
30 } else {
31 start = parseInt($(this).attr('id').split('-')[2]);
31 start = parseInt($(this).attr('id').split('-')[2]);
32 }
32 }
33 });
33 });
34 });
34 });
35
35
36
36
37 %h1 Manage problems
37 %h1 Manage problems
38
38
39 %p= link_to '[Back to problem list]', problems_path
39 %p= link_to '[Back to problem list]', problems_path
40
40
41 = form_tag :action=>'do_manage' do
41 = form_tag :action=>'do_manage' do
42 .panel.panel-primary
42 .panel.panel-primary
43 .panel-heading
43 .panel-heading
44 Action
44 Action
45 .panel-body
45 .panel-body
46 .submit-box
46 .submit-box
47 What do you want to do to the selected problem?
47 What do you want to do to the selected problem?
48 %br/
48 %br/
49 (You can shift-click to select a range of problems)
49 (You can shift-click to select a range of problems)
50 %ul.form-inline
50 %ul.form-inline
51 %li
51 %li
52 - Change date added to
52 + Change "Date added" to
53 .input-group.date
53 .input-group.date
54 = text_field_tag :date_added, class: 'form-control'
54 = text_field_tag :date_added, class: 'form-control'
55 %span.input-group-addon
55 %span.input-group-addon
56 %span.glyphicon.glyphicon-calendar
56 %span.glyphicon.glyphicon-calendar
57 -# = select_date Date.current, :prefix => 'date_added'
57 -# = select_date Date.current, :prefix => 'date_added'
58 &nbsp;&nbsp;&nbsp;
58 &nbsp;&nbsp;&nbsp;
59 = submit_tag 'Change', :name => 'change_date_added', class: 'btn btn-primary btn-sm'
59 = submit_tag 'Change', :name => 'change_date_added', class: 'btn btn-primary btn-sm'
60 %li
60 %li
61 - Set available to
61 + Set "Available" to
62 = submit_tag 'True', :name => 'enable_problem', class: 'btn btn-primary btn-sm'
62 = submit_tag 'True', :name => 'enable_problem', class: 'btn btn-primary btn-sm'
63 = submit_tag 'False', :name => 'disable_problem', class: 'btn btn-primary btn-sm'
63 = submit_tag 'False', :name => 'disable_problem', class: 'btn btn-primary btn-sm'
64
64
65 - if GraderConfiguration.multicontests?
65 - if GraderConfiguration.multicontests?
66 %li
66 %li
67 - Add to
67 + Add selected problems to contest
68 = select("contest","id",Contest.all.collect {|c| [c.title, c.id]})
68 = select("contest","id",Contest.all.collect {|c| [c.title, c.id]})
69 = submit_tag 'Add', :name => 'add_to_contest', class: 'btn btn-primary btn-sm'
69 = submit_tag 'Add', :name => 'add_to_contest', class: 'btn btn-primary btn-sm'
70 %li
70 %li
71 - Add problems to group
71 + Add selected problems to user group
72 = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_name]), id: 'group_name',class: 'select2'
72 = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_name]), id: 'group_name',class: 'select2'
73 - = submit_tag 'Add', name: 'add_group', class: 'btn btn-default'
73 + = submit_tag 'Add', name: 'add_group', class: 'btn btn-primary'
74 -
74 + %li
75 + Add the following tags to the selected problems
76 + = select_tag "tag_ids", options_from_collection_for_select( Tag.all, 'id','name'), id: 'tags_name',class: 'select2', multiple: true, data: {placeholder: 'Select tags by clicking', width: "200px"}
77 + = submit_tag 'Add', name: 'add_tags', class: 'btn btn-primary'
75
78
76 - %table.table.table-hover
79 + %table.table.table-hover.datatable
77 - %tr{style: "text-align: left;"}
80 + %thead
78 - %th= check_box_tag 'select_all'
81 + %tr{style: "text-align: left;"}
79 - %th Name
82 + %th= check_box_tag 'select_all'
80 - %th Full name
83 + %th Name
81 - %th Available
84 + %th Full name
82 - %th Date added
85 + %th Tags
83 - - if GraderConfiguration.multicontests?
86 + %th Available
84 - %th Contests
87 + %th Date added
88 + - if GraderConfiguration.multicontests?
89 + %th Contests
85
90
86 - - num = 0
91 + %tbody
87 - - for problem in @problems
92 + - num = 0
88 - - num += 1
93 + - for problem in @problems
89 - %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"}
94 + - num += 1
90 - %td= check_box_tag "prob-#{problem.id}-#{num}"
95 + %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"}
91 - %td= problem.name
96 + %td= check_box_tag "prob-#{problem.id}-#{num}"
92 - %td= problem.full_name
97 + %td= problem.name
93 - %td= problem.available
98 + %td= problem.full_name
94 - %td= problem.date_added
95 - - if GraderConfiguration.multicontests?
96 %td
99 %td
97 - - problem.contests.each do |contest|
100 + - problem.tags.each do |t|
98 - = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
101 + %span.label.label-default= t.name
102 + %td= problem.available
103 + %td= problem.date_added
104 + - if GraderConfiguration.multicontests?
105 + %td
106 + - problem.contests.each do |contest|
107 + = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
99
108
100 :javascript
109 :javascript
101 $('.input-group.date').datetimepicker({
110 $('.input-group.date').datetimepicker({
102 format: 'DD/MMM/YYYY',
111 format: 'DD/MMM/YYYY',
103 showTodayButton: true,
112 showTodayButton: true,
104 widgetPositioning: {horizontal: 'auto', vertical: 'bottom'},
113 widgetPositioning: {horizontal: 'auto', vertical: 'bottom'},
105
114
106 });
115 });
107 -
116 + $('.datatable').DataTable({
117 + paging: false
118 + });
@@ -1,35 +1,36
1 %h1 Editing site
1 %h1 Editing site
2 = error_messages_for :site
2 = error_messages_for :site
3 = form_for(@site) do |f|
3 = form_for(@site) do |f|
4 .row
4 .row
5 .col-md-4
5 .col-md-4
6 .form-group.field
6 .form-group.field
7 = f.label :name, "Name"
7 = f.label :name, "Name"
8 = f.text_field :name, class: 'form-control'
8 = f.text_field :name, class: 'form-control'
9 .form-group.field
9 .form-group.field
10 = f.label :password, "Password"
10 = f.label :password, "Password"
11 = f.text_field :password, class: 'form-control'
11 = f.text_field :password, class: 'form-control'
12 .form-group.field
12 .form-group.field
13 = f.label :started, "Started"
13 = f.label :started, "Started"
14 = f.check_box :started, class: 'form-control'
14 = f.check_box :started, class: 'form-control'
15 .form-group.field
15 .form-group.field
16 = f.label :start_time, "Start time"
16 = f.label :start_time, "Start time"
17 -# = f.datetime_select :start_time, :include_blank => true
17 -# = f.datetime_select :start_time, :include_blank => true
18 .input-group.date
18 .input-group.date
19 = f.text_field :start_time, class:'form-control' , value: (@site.start_time ? @site.start_time.strftime('%d/%b/%Y %H:%M') : '')
19 = f.text_field :start_time, class:'form-control' , value: (@site.start_time ? @site.start_time.strftime('%d/%b/%Y %H:%M') : '')
20 %span.input-group-addon
20 %span.input-group-addon
21 %span.glyphicon.glyphicon-calendar
21 %span.glyphicon.glyphicon-calendar
22 .actions
22 .actions
23 = f.submit "Update", class: 'btn btn-primary'
23 = f.submit "Update", class: 'btn btn-primary'
24 .col-md-8
24 .col-md-8
25
25
26 = link_to 'Show', @site
26 = link_to 'Show', @site
27 |
27 |
28 = link_to 'Back', sites_path
28 = link_to 'Back', sites_path
29
29
30
30
31 :javascript
31 :javascript
32 $('.input-group.date').datetimepicker({
32 $('.input-group.date').datetimepicker({
33 format: 'DD/MMM/YYYY HH:mm',
33 format: 'DD/MMM/YYYY HH:mm',
34 + showTodayButton: true,
34 });
35 });
35
36
You need to be logged in to leave comments. Login now