Description:
add remove_all in groups
consolidate submissions viewing from grader/task
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r680:4ce0b8696d06 - - 9 files changed: 35 inserted, 138 deleted
@@ -1,22 +1,6 | |||
|
1 | 1 | class GradersController < ApplicationController |
|
2 | 2 | |
|
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 | - } | |
|
3 | + before_filter :admin_authorization | |
|
20 | 4 | |
|
21 | 5 | verify :method => :post, :only => ['clear_all', |
|
22 | 6 | 'start_exam', |
@@ -77,25 +61,6 | |||
|
77 | 61 | @task = Task.find(params[:id]) |
|
78 | 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 | 65 | # various grader controls |
|
101 | 66 |
@@ -1,7 +1,7 | |||
|
1 | 1 | class GroupsController < ApplicationController |
|
2 | 2 | before_action :set_group, only: [:show, :edit, :update, :destroy, |
|
3 | - :add_user, :remove_user, | |
|
4 | - :add_problem, :remove_problem, | |
|
3 | + :add_user, :remove_user,:remove_all_user, | |
|
4 | + :add_problem, :remove_problem,:remove_all_problem, | |
|
5 | 5 | ] |
|
6 | 6 | before_action :authenticate, :admin_authorization |
|
7 | 7 | |
@@ -55,6 +55,16 | |||
|
55 | 55 | redirect_to group_path(@group), flash: {success: "User #{user.login} was removed from the group #{@group.name}"} |
|
56 | 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 | 68 | def add_user |
|
59 | 69 | user = User.find(params[:user_id]) |
|
60 | 70 | begin |
@@ -26,7 +26,7 | |||
|
26 | 26 | # this has problem-level access control |
|
27 | 27 | def download |
|
28 | 28 | problem = Problem.find(params[:id]) |
|
29 |
- |
|
|
29 | + unless @current_user.can_view_problem? problem | |
|
30 | 30 | redirect_to :action => 'index' and return |
|
31 | 31 | end |
|
32 | 32 |
@@ -339,11 +339,8 | |||
|
339 | 339 | end |
|
340 | 340 | |
|
341 | 341 | def can_view_problem?(problem) |
|
342 | - if not GraderConfiguration.multicontests? | |
|
343 | - return problem.available | |
|
344 | - else | |
|
345 | - return problem_in_user_contests? problem | |
|
346 | - end | |
|
342 | + return true if admin? | |
|
343 | + return available_problems.include? problem | |
|
347 | 344 | end |
|
348 | 345 | |
|
349 | 346 | def self.clear_last_login |
@@ -9,7 +9,7 | |||
|
9 | 9 | %br/ |
|
10 | 10 | = "Submission: #{@task.submission_id}" |
|
11 | 11 | - if @task.submission !=nil |
|
12 |
- = link_to '[view submission]', |
|
|
12 | + = link_to '[view submission]', submission_path( @task.submission.id ) | |
|
13 | 13 | %br/ |
|
14 | 14 | = "Submitted at: #{format_short_time(@task.created_at)}" |
|
15 | 15 | %br/ |
@@ -11,7 +11,8 | |||
|
11 | 11 | = link_to 'Back', groups_path |
|
12 | 12 | |
|
13 | 13 | .row |
|
14 | - %h1 Group details | |
|
14 | + .col-md-12 | |
|
15 | + %h1 Group details | |
|
15 | 16 | .row |
|
16 | 17 | .col-md-6 |
|
17 | 18 | .panel.panel-default |
@@ -31,7 +32,7 | |||
|
31 | 32 | %th Login |
|
32 | 33 | %th Full name |
|
33 | 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 | 37 | %tbody |
|
37 | 38 | - @group.users.each do |user| |
@@ -39,7 +40,7 | |||
|
39 | 40 | %td= user.login |
|
40 | 41 | %td= user.full_name |
|
41 | 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 | 44 | .col-md-6 |
|
44 | 45 | .panel.panel-default |
|
45 | 46 | .panel-heading |
@@ -59,7 +60,7 | |||
|
59 | 60 | %th name |
|
60 | 61 | %th Full name |
|
61 | 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 | 65 | %tbody |
|
65 | 66 | - @group.problems.each do |problem| |
@@ -67,6 +68,6 | |||
|
67 | 68 | %td= problem.name |
|
68 | 69 | %td= problem.full_name |
|
69 | 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 |
@@ -21,6 +21,9 | |||
|
21 | 21 | %th Name |
|
22 | 22 | %th Full name |
|
23 | 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 | 27 | %th Date added |
|
25 | 28 | %th.text-center |
|
26 | 29 | Avail? |
@@ -37,8 +40,11 | |||
|
37 | 40 | %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"} |
|
38 | 41 | - @problem=problem |
|
39 | 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 | 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 | 48 | %td= problem.date_added |
|
43 | 49 | %td= toggle_button(@problem.available?, toggle_problem_path(@problem), "problem-avail-#{@problem.id}") |
|
44 | 50 | %td= toggle_button(@problem.view_testcase?, toggle_view_testcase_problem_path(@problem), "problem-view-testcase-#{@problem.id}") |
@@ -35,8 +35,13 | |||
|
35 | 35 | member do |
|
36 | 36 | post 'add_user', to: 'groups#add_user', as: 'add_user' |
|
37 | 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 | 39 | post 'add_problem', to: 'groups#add_problem', as: 'add_problem' |
|
39 | 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 | 45 | end |
|
41 | 46 | end |
|
42 | 47 |
deleted file |
You need to be logged in to leave comments.
Login now