Description:
add remove_all in groups consolidate submissions viewing from grader/task
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r680:4ce0b8696d06 - - 9 files changed: 35 inserted, 138 deleted

@@ -1,43 +1,27
1 class GradersController < ApplicationController
1 class GradersController < ApplicationController
2
2
3 - before_filter :admin_authorization, except: [ :submission ]
3 + before_filter :admin_authorization
4 - before_filter(only: [:submission]) {
5 - #check if authenticated
6 - return false unless authenticate
7 -
8 - #admin always has privileged
9 - if @current_user.admin?
10 - return true
11 - end
12 -
13 - if GraderConfiguration["right.user_view_submission"] and Submission.find(params[:id]).problem.available?
14 - return true
15 - else
16 - unauthorized_redirect
17 - return false
18 - end
19 - }
20
4
21 verify :method => :post, :only => ['clear_all',
5 verify :method => :post, :only => ['clear_all',
22 'start_exam',
6 'start_exam',
23 'start_grading',
7 'start_grading',
24 'stop_all',
8 'stop_all',
25 'clear_terminated'],
9 'clear_terminated'],
26 :redirect_to => {:action => 'index'}
10 :redirect_to => {:action => 'index'}
27
11
28 def index
12 def index
29 redirect_to :action => 'list'
13 redirect_to :action => 'list'
30 end
14 end
31
15
32 def list
16 def list
33 @grader_processes = GraderProcess.find_running_graders
17 @grader_processes = GraderProcess.find_running_graders
34 @stalled_processes = GraderProcess.find_stalled_process
18 @stalled_processes = GraderProcess.find_stalled_process
35
19
36 @terminated_processes = GraderProcess.find_terminated_graders
20 @terminated_processes = GraderProcess.find_terminated_graders
37
21
38 @last_task = Task.last
22 @last_task = Task.last
39 @last_test_request = TestRequest.last
23 @last_test_request = TestRequest.last
40 @submission = Submission.order("id desc").limit(20)
24 @submission = Submission.order("id desc").limit(20)
41 @backlog_submission = Submission.where('graded_at is null')
25 @backlog_submission = Submission.where('graded_at is null')
42 end
26 end
43
27
@@ -56,67 +40,48
56
40
57 def clear_all
41 def clear_all
58 GraderProcess.all.each do |p|
42 GraderProcess.all.each do |p|
59 p.destroy
43 p.destroy
60 end
44 end
61 redirect_to :action => 'list'
45 redirect_to :action => 'list'
62 end
46 end
63
47
64 def view
48 def view
65 if params[:type]=='Task'
49 if params[:type]=='Task'
66 redirect_to :action => 'task', :id => params[:id]
50 redirect_to :action => 'task', :id => params[:id]
67 else
51 else
68 redirect_to :action => 'test_request', :id => params[:id]
52 redirect_to :action => 'test_request', :id => params[:id]
69 end
53 end
70 end
54 end
71
55
72 def test_request
56 def test_request
73 @test_request = TestRequest.find(params[:id])
57 @test_request = TestRequest.find(params[:id])
74 end
58 end
75
59
76 def task
60 def task
77 @task = Task.find(params[:id])
61 @task = Task.find(params[:id])
78 end
62 end
79
63
80 - def submission
81 - @submission = Submission.find(params[:id])
82 - formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true )
83 - lexer = case @submission.language.name
84 - when "c" then Rouge::Lexers::C.new
85 - when "cpp" then Rouge::Lexers::Cpp.new
86 - when "pas" then Rouge::Lexers::Pas.new
87 - when "ruby" then Rouge::Lexers::Ruby.new
88 - when "python" then Rouge::Lexers::Python.new
89 - when "java" then Rouge::Lexers::Java.new
90 - when "php" then Rouge::Lexers::PHP.new
91 - end
92 - @formatted_code = formatter.format(lexer.lex(@submission.source))
93 - @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight')
94 -
95 - user = User.find(session[:user_id])
96 - SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
97 -
98 - end
99
64
100 # various grader controls
65 # various grader controls
101
66
102 def stop
67 def stop
103 grader_proc = GraderProcess.find(params[:id])
68 grader_proc = GraderProcess.find(params[:id])
104 GraderScript.stop_grader(grader_proc.pid)
69 GraderScript.stop_grader(grader_proc.pid)
105 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
70 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
106 redirect_to :action => 'list'
71 redirect_to :action => 'list'
107 end
72 end
108
73
109 def stop_all
74 def stop_all
110 GraderScript.stop_graders(GraderProcess.find_running_graders +
75 GraderScript.stop_graders(GraderProcess.find_running_graders +
111 GraderProcess.find_stalled_process)
76 GraderProcess.find_stalled_process)
112 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
77 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
113 redirect_to :action => 'list'
78 redirect_to :action => 'list'
114 end
79 end
115
80
116 def start_grading
81 def start_grading
117 GraderScript.start_grader('grading')
82 GraderScript.start_grader('grading')
118 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
83 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
119 redirect_to :action => 'list'
84 redirect_to :action => 'list'
120 end
85 end
121
86
122 def start_exam
87 def start_exam
@@ -1,28 +1,28
1 class GroupsController < ApplicationController
1 class GroupsController < ApplicationController
2 before_action :set_group, only: [:show, :edit, :update, :destroy,
2 before_action :set_group, only: [:show, :edit, :update, :destroy,
3 - :add_user, :remove_user,
3 + :add_user, :remove_user,:remove_all_user,
4 - :add_problem, :remove_problem,
4 + :add_problem, :remove_problem,:remove_all_problem,
5 ]
5 ]
6 before_action :authenticate, :admin_authorization
6 before_action :authenticate, :admin_authorization
7
7
8 # GET /groups
8 # GET /groups
9 def index
9 def index
10 @groups = Group.all
10 @groups = Group.all
11 end
11 end
12
12
13 # GET /groups/1
13 # GET /groups/1
14 def show
14 def show
15 end
15 end
16
16
17 # GET /groups/new
17 # GET /groups/new
18 def new
18 def new
19 @group = Group.new
19 @group = Group.new
20 end
20 end
21
21
22 # GET /groups/1/edit
22 # GET /groups/1/edit
23 def edit
23 def edit
24 end
24 end
25
25
26 # POST /groups
26 # POST /groups
27 def create
27 def create
28 @group = Group.new(group_params)
28 @group = Group.new(group_params)
@@ -34,48 +34,58
34 end
34 end
35 end
35 end
36
36
37 # PATCH/PUT /groups/1
37 # PATCH/PUT /groups/1
38 def update
38 def update
39 if @group.update(group_params)
39 if @group.update(group_params)
40 redirect_to @group, notice: 'Group was successfully updated.'
40 redirect_to @group, notice: 'Group was successfully updated.'
41 else
41 else
42 render :edit
42 render :edit
43 end
43 end
44 end
44 end
45
45
46 # DELETE /groups/1
46 # DELETE /groups/1
47 def destroy
47 def destroy
48 @group.destroy
48 @group.destroy
49 redirect_to groups_url, notice: 'Group was successfully destroyed.'
49 redirect_to groups_url, notice: 'Group was successfully destroyed.'
50 end
50 end
51
51
52 def remove_user
52 def remove_user
53 user = User.find(params[:user_id])
53 user = User.find(params[:user_id])
54 @group.users.delete(user)
54 @group.users.delete(user)
55 redirect_to group_path(@group), flash: {success: "User #{user.login} was removed from the group #{@group.name}"}
55 redirect_to group_path(@group), flash: {success: "User #{user.login} was removed from the group #{@group.name}"}
56 end
56 end
57
57
58 + def remove_all_user
59 + @group.users.clear
60 + redirect_to group_path(@group), alert: 'All users removed'
61 + end
62 +
63 + def remove_all_problem
64 + @group.problems.clear
65 + redirect_to group_path(@group), alert: 'All problems removed'
66 + end
67 +
58 def add_user
68 def add_user
59 user = User.find(params[:user_id])
69 user = User.find(params[:user_id])
60 begin
70 begin
61 @group.users << user
71 @group.users << user
62 redirect_to group_path(@group), flash: { success: "User #{user.login} was add to the group #{@group.name}"}
72 redirect_to group_path(@group), flash: { success: "User #{user.login} was add to the group #{@group.name}"}
63 rescue => e
73 rescue => e
64 redirect_to group_path(@group), alert: e.message
74 redirect_to group_path(@group), alert: e.message
65 end
75 end
66 end
76 end
67
77
68 def remove_problem
78 def remove_problem
69 problem = Problem.find(params[:problem_id])
79 problem = Problem.find(params[:problem_id])
70 @group.problems.delete(problem)
80 @group.problems.delete(problem)
71 redirect_to group_path(@group), flash: {success: "Problem #{problem.name} was removed from the group #{@group.name}" }
81 redirect_to group_path(@group), flash: {success: "Problem #{problem.name} was removed from the group #{@group.name}" }
72 end
82 end
73
83
74 def add_problem
84 def add_problem
75 problem = Problem.find(params[:problem_id])
85 problem = Problem.find(params[:problem_id])
76 begin
86 begin
77 @group.problems << problem
87 @group.problems << problem
78 redirect_to group_path(@group), flash: {success: "Problem #{problem.name} was add to the group #{@group.name}" }
88 redirect_to group_path(@group), flash: {success: "Problem #{problem.name} was add to the group #{@group.name}" }
79 rescue => e
89 rescue => e
80 redirect_to group_path(@group), alert: e.message
90 redirect_to group_path(@group), alert: e.message
81 end
91 end
@@ -5,49 +5,49
5 def index
5 def index
6 redirect_to :action => 'list'
6 redirect_to :action => 'list'
7 end
7 end
8
8
9 def list
9 def list
10 @problems = @user.available_problems
10 @problems = @user.available_problems
11 end
11 end
12
12
13 # this has contest-wide access control
13 # this has contest-wide access control
14 def view
14 def view
15 base_name = params[:file]
15 base_name = params[:file]
16 base_filename = File.basename("#{base_name}.#{params[:ext]}")
16 base_filename = File.basename("#{base_name}.#{params[:ext]}")
17 filename = "#{Problem.download_file_basedir}/#{base_filename}"
17 filename = "#{Problem.download_file_basedir}/#{base_filename}"
18
18
19 if !FileTest.exists?(filename)
19 if !FileTest.exists?(filename)
20 redirect_to :action => 'index' and return
20 redirect_to :action => 'index' and return
21 end
21 end
22
22
23 send_file_to_user(filename, base_filename)
23 send_file_to_user(filename, base_filename)
24 end
24 end
25
25
26 # this has problem-level access control
26 # this has problem-level access control
27 def download
27 def download
28 problem = Problem.find(params[:id])
28 problem = Problem.find(params[:id])
29 - if !problem or !problem.available or !@user.can_view_problem? problem
29 + unless @current_user.can_view_problem? problem
30 redirect_to :action => 'index' and return
30 redirect_to :action => 'index' and return
31 end
31 end
32
32
33 base_name = params[:file]
33 base_name = params[:file]
34 base_filename = File.basename("#{base_name}.#{params[:ext]}")
34 base_filename = File.basename("#{base_name}.#{params[:ext]}")
35 filename = "#{Problem.download_file_basedir}/#{params[:id]}/#{base_filename}"
35 filename = "#{Problem.download_file_basedir}/#{params[:id]}/#{base_filename}"
36 puts "SENDING: #{filename}"
36 puts "SENDING: #{filename}"
37
37
38 if !FileTest.exists?(filename)
38 if !FileTest.exists?(filename)
39 redirect_to :action => 'index' and return
39 redirect_to :action => 'index' and return
40 end
40 end
41
41
42 puts "SENDING: #{filename}"
42 puts "SENDING: #{filename}"
43
43
44 send_file_to_user(filename, base_filename)
44 send_file_to_user(filename, base_filename)
45 end
45 end
46
46
47 protected
47 protected
48
48
49 def send_file_to_user(filename, base_filename)
49 def send_file_to_user(filename, base_filename)
50 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
50 if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE
51 response.headers['Content-Type'] = "application/force-download"
51 response.headers['Content-Type'] = "application/force-download"
52 response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
52 response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\""
53 response.headers["X-Sendfile"] = filename
53 response.headers["X-Sendfile"] = filename
@@ -318,53 +318,50
318 def available_problems_in_group
318 def available_problems_in_group
319 problem = []
319 problem = []
320 self.groups.each do |group|
320 self.groups.each do |group|
321 group.problems.where(available: true).each { |p| problem << p }
321 group.problems.where(available: true).each { |p| problem << p }
322 end
322 end
323 problem.uniq!
323 problem.uniq!
324 if problem
324 if problem
325 problem.sort! do |a,b|
325 problem.sort! do |a,b|
326 case
326 case
327 when a.date_added < b.date_added
327 when a.date_added < b.date_added
328 1
328 1
329 when a.date_added > b.date_added
329 when a.date_added > b.date_added
330 -1
330 -1
331 else
331 else
332 a.name <=> b.name
332 a.name <=> b.name
333 end
333 end
334 end
334 end
335 return problem
335 return problem
336 else
336 else
337 return []
337 return []
338 end
338 end
339 end
339 end
340
340
341 def can_view_problem?(problem)
341 def can_view_problem?(problem)
342 - if not GraderConfiguration.multicontests?
342 + return true if admin?
343 - return problem.available
343 + return available_problems.include? problem
344 - else
345 - return problem_in_user_contests? problem
346 - end
347 end
344 end
348
345
349 def self.clear_last_login
346 def self.clear_last_login
350 User.update_all(:last_ip => nil)
347 User.update_all(:last_ip => nil)
351 end
348 end
352
349
353 protected
350 protected
354 def encrypt_new_password
351 def encrypt_new_password
355 return if password.blank?
352 return if password.blank?
356 self.salt = (10+rand(90)).to_s
353 self.salt = (10+rand(90)).to_s
357 self.hashed_password = User.encrypt(self.password,self.salt)
354 self.hashed_password = User.encrypt(self.password,self.salt)
358 end
355 end
359
356
360 def assign_default_site
357 def assign_default_site
361 # have to catch error when migrating (because self.site is not available).
358 # have to catch error when migrating (because self.site is not available).
362 begin
359 begin
363 if self.site==nil
360 if self.site==nil
364 self.site = Site.find_by_name('default')
361 self.site = Site.find_by_name('default')
365 if self.site==nil
362 if self.site==nil
366 self.site = Site.find(1) # when 'default has be renamed'
363 self.site = Site.find(1) # when 'default has be renamed'
367 end
364 end
368 end
365 end
369 rescue
366 rescue
370 end
367 end
@@ -1,15 +1,15
1 %h1= "Task: #{@task.id}"
1 %h1= "Task: #{@task.id}"
2
2
3 %p
3 %p
4 User:
4 User:
5 = "#{@task.submission.user.login}"
5 = "#{@task.submission.user.login}"
6 %br/
6 %br/
7 Status:
7 Status:
8 = "#{@task.status_str} (at #{format_short_time(@task.updated_at)})"
8 = "#{@task.status_str} (at #{format_short_time(@task.updated_at)})"
9 %br/
9 %br/
10 = "Submission: #{@task.submission_id}"
10 = "Submission: #{@task.submission_id}"
11 - if @task.submission !=nil
11 - if @task.submission !=nil
12 - = link_to '[view submission]', :action => 'submission', :id => @task.submission.id
12 + = link_to '[view submission]', submission_path( @task.submission.id )
13 %br/
13 %br/
14 = "Submitted at: #{format_short_time(@task.created_at)}"
14 = "Submitted at: #{format_short_time(@task.created_at)}"
15 %br/
15 %br/
@@ -1,72 +1,73
1 %p
1 %p
2 %b Name:
2 %b Name:
3 = @group.name
3 = @group.name
4 %p
4 %p
5 %b Description:
5 %b Description:
6 = @group.description
6 = @group.description
7
7
8 %br
8 %br
9 = link_to 'Edit', edit_group_path(@group)
9 = link_to 'Edit', edit_group_path(@group)
10 \|
10 \|
11 = link_to 'Back', groups_path
11 = link_to 'Back', groups_path
12
12
13 .row
13 .row
14 - %h1 Group details
14 + .col-md-12
15 + %h1 Group details
15 .row
16 .row
16 .col-md-6
17 .col-md-6
17 .panel.panel-default
18 .panel.panel-default
18 .panel-heading
19 .panel-heading
19 .panel-title Users in this group
20 .panel-title Users in this group
20 .panel-body
21 .panel-body
21 =form_tag add_user_group_path(@group), class: 'form-inline' do
22 =form_tag add_user_group_path(@group), class: 'form-inline' do
22 .form-group
23 .form-group
23 =label_tag :user_id, "User"
24 =label_tag :user_id, "User"
24 =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2'
25 =select_tag :user_id, options_from_collection_for_select(User.all,'id','full_name'), class: 'select2'
25 =submit_tag "Add",class: 'btn btn-primary'
26 =submit_tag "Add",class: 'btn btn-primary'
26
27
27
28
28 %table.table.table-hover
29 %table.table.table-hover
29 %thead
30 %thead
30 %tr
31 %tr
31 %th Login
32 %th Login
32 %th Full name
33 %th Full name
33 %th Remark
34 %th Remark
34 - %th
35 + %th= link_to 'Remove All', remove_all_user_group_path(@group), method: :delete, :data => { :confirm => "Remove ALL USERS from group?" }, class: 'btn btn-danger btn-sm'
35
36
36 %tbody
37 %tbody
37 - @group.users.each do |user|
38 - @group.users.each do |user|
38 %tr
39 %tr
39 %td= user.login
40 %td= user.login
40 %td= user.full_name
41 %td= user.full_name
41 %td= user.remark
42 %td= user.remark
42 - %td= link_to 'Remove', remove_user_group_path(@group,user), :method => :delete, :data => { :confirm => "Remove #{user.full_name}?" }, class: 'btn btn-danger'
43 + %td= link_to 'Remove', remove_user_group_path(@group,user), :method => :delete, :data => { :confirm => "Remove #{user.full_name}?" }, class: 'btn btn-danger btn-sm'
43 .col-md-6
44 .col-md-6
44 .panel.panel-default
45 .panel.panel-default
45 .panel-heading
46 .panel-heading
46 .panel-title Problems
47 .panel-title Problems
47 .panel-body
48 .panel-body
48
49
49 =form_tag add_problem_group_path(@group), class: 'form-inline' do
50 =form_tag add_problem_group_path(@group), class: 'form-inline' do
50 .form-group
51 .form-group
51 =label_tag :problem_id, "Problem"
52 =label_tag :problem_id, "Problem"
52 =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2'
53 =select_tag :problem_id, options_from_collection_for_select(Problem.all,'id','full_name'), class: 'select2'
53 =submit_tag "Add",class: 'btn btn-primary'
54 =submit_tag "Add",class: 'btn btn-primary'
54
55
55
56
56 %table.table.table-hover
57 %table.table.table-hover
57 %thead
58 %thead
58 %tr
59 %tr
59 %th name
60 %th name
60 %th Full name
61 %th Full name
61 %th Full score
62 %th Full score
62 - %th
63 + %th= link_to 'Remove All', remove_all_problem_group_path(@group), method: :delete, :data => { :confirm => "Remove ALL PROBLEMS from group?" }, class: 'btn btn-danger btn-sm'
63
64
64 %tbody
65 %tbody
65 - @group.problems.each do |problem|
66 - @group.problems.each do |problem|
66 %tr
67 %tr
67 %td= problem.name
68 %td= problem.name
68 %td= problem.full_name
69 %td= problem.full_name
69 %td= problem.full_score
70 %td= problem.full_score
70 - %td= link_to 'Remove', remove_problem_group_path(@group,problem), :method => :delete, :data => { :confirm => "Remove #{problem.full_name}?" }, class: 'btn btn-danger'
71 + %td= link_to 'Remove', remove_problem_group_path(@group,problem), :method => :delete, :data => { :confirm => "Remove #{problem.full_name}?" }, class: 'btn btn-danger btn-sm'
71
72
72
73
@@ -1,54 +1,60
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
25 + Submit
26 + %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Admin can always submit to any problem' } [?]
24 %th Date added
27 %th Date added
25 %th.text-center
28 %th.text-center
26 Avail?
29 Avail?
27 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
30 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?]
28 %th.text-center
31 %th.text-center
29 View Data?
32 View Data?
30 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user view the testcase of this problem?' } [?]
33 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user view the testcase of this problem?' } [?]
31 %th.text-center
34 %th.text-center
32 Test?
35 Test?
33 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
36 %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?]
34 - if GraderConfiguration.multicontests?
37 - if GraderConfiguration.multicontests?
35 %th Contests
38 %th Contests
36 - for problem in @problems
39 - for problem in @problems
37 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
40 %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
38 - @problem=problem
41 - @problem=problem
39 %td= problem.name #in_place_editor_field :problem, :name, {}, :rows=>1
42 %td= problem.name #in_place_editor_field :problem, :name, {}, :rows=>1
40 - %td= problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
43 + %td
44 + = 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
41 %td.text-right= problem.full_score #in_place_editor_field :problem, :full_score, {}, :rows=>1
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'
42 %td= problem.date_added
48 %td= problem.date_added
43 %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}")
49 %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}")
44 %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}")
50 %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}")
45 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_path(@problem), "problem-test-#{@problem.id}")
51 %td= toggle_button(@problem.test_allowed?, toggle_test_problem_path(@problem), "problem-test-#{@problem.id}")
46 - if GraderConfiguration.multicontests?
52 - if GraderConfiguration.multicontests?
47 %td
53 %td
48 = problem.contests.collect { |c| c.name }.join(', ')
54 = problem.contests.collect { |c| c.name }.join(', ')
49 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
55 %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block'
50 %td= link_to 'Show', {:action => 'show', :id => problem}, 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'
51 %td= link_to 'Edit', {:action => 'edit', :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'
52 %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :delete, class: 'btn btn-danger 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'
53 %br/
59 %br/
54 = link_to '[New problem]', :action => 'new'
60 = link_to '[New problem]', :action => 'new'
@@ -14,50 +14,55
14 member do
14 member do
15 get 'toggle','toggle_front'
15 get 'toggle','toggle_front'
16 end
16 end
17 end
17 end
18
18
19 resources :problems do
19 resources :problems do
20 member do
20 member do
21 get 'toggle'
21 get 'toggle'
22 get 'toggle_test'
22 get 'toggle_test'
23 get 'toggle_view_testcase'
23 get 'toggle_view_testcase'
24 get 'stat'
24 get 'stat'
25 end
25 end
26 collection do
26 collection do
27 get 'turn_all_off'
27 get 'turn_all_off'
28 get 'turn_all_on'
28 get 'turn_all_on'
29 get 'import'
29 get 'import'
30 get 'manage'
30 get 'manage'
31 end
31 end
32 end
32 end
33
33
34 resources :groups do
34 resources :groups do
35 member do
35 member do
36 post 'add_user', to: 'groups#add_user', as: 'add_user'
36 post 'add_user', to: 'groups#add_user', as: 'add_user'
37 delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user'
37 delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user'
38 + delete 'remove_all_user', to: 'groups#remove_all_user', as: 'remove_all_user'
38 post 'add_problem', to: 'groups#add_problem', as: 'add_problem'
39 post 'add_problem', to: 'groups#add_problem', as: 'add_problem'
39 delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem'
40 delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem'
41 + delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem'
42 + end
43 + collection do
44 +
40 end
45 end
41 end
46 end
42
47
43 resources :testcases, only: [] do
48 resources :testcases, only: [] do
44 member do
49 member do
45 get 'download_input'
50 get 'download_input'
46 get 'download_sol'
51 get 'download_sol'
47 end
52 end
48 collection do
53 collection do
49 get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem'
54 get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem'
50 end
55 end
51 end
56 end
52
57
53 resources :grader_configuration, controller: 'configurations'
58 resources :grader_configuration, controller: 'configurations'
54
59
55 resources :users do
60 resources :users do
56 member do
61 member do
57 get 'toggle_activate', 'toggle_enable'
62 get 'toggle_activate', 'toggle_enable'
58 get 'stat'
63 get 'stat'
59 end
64 end
60 end
65 end
61
66
62 resources :submissions do
67 resources :submissions do
63 member do
68 member do
deleted file
You need to be logged in to leave comments. Login now