diff --git a/app/controllers/configurations_controller.rb b/app/controllers/configurations_controller.rb --- a/app/controllers/configurations_controller.rb +++ b/app/controllers/configurations_controller.rb @@ -24,6 +24,16 @@ end end + def set_exam_right + value = params[:value] || 'false' + GraderConfiguration.where(key: "right.bypass_agreement").update(value: value); + GraderConfiguration.where(key: "right.multiple_ip_login").update(value: value); + GraderConfiguration.where(key: "right.user_hall_of_fame").update(value: value); + GraderConfiguration.where(key: "right.user_view_submission ").update(value: value); + GraderConfiguration.where(key: "right.view_testcase ").update(value: value); + redirect_to :action => 'index' + end + private def configuration_params params.require(:grader_configuration).permit(:key,:value_type,:value,:description) diff --git a/app/views/configurations/index.html.haml b/app/views/configurations/index.html.haml --- a/app/views/configurations/index.html.haml +++ b/app/views/configurations/index.html.haml @@ -1,37 +1,48 @@ /- content_for :header do / = javascript_include_tag 'local_jquery' -%h1 System configuration +.container-fluid + .row + .col-md-12 + %h1 System configuration + .row + .col-md-12 + = link_to 'Set exam mode', set_exam_right_grader_configuration_index_path('false'), class: 'btn btn-warning' + = link_to 'Set practice mode', set_exam_right_grader_configuration_index_path('true'), class: 'btn btn-info' -- @group.each do |g| - %h2= g - %table.table.table-striped - %thead - %th{style: 'width: 25%'} Key - %th{style: 'width: 10%'}Type - %th{style: 'width: 15%'} Value - %th Description - - @configurations.each do |conf| - - next if conf.key[0...(conf.key.index('.'))] != g - - @grader_configuration = conf - %tr - %td - /= in_place_editor_field :grader_configuration, :key, {}, :rows=>1 - = @grader_configuration.key - %td - /= in_place_editor_field :grader_configuration, :value_type, {}, :rows=>1 - = @grader_configuration.value_type - %td - = best_in_place @grader_configuration, :value, ok_button: "ok", cancel_button: "cancel" - %td= conf.description + - @group.each do |g| + .row + .col-md-12 + %h2= g + %table.table.table-striped + %thead + %th{style: 'width: 25%'} Key + %th{style: 'width: 10%'}Type + %th{style: 'width: 15%'} Value + %th Description + - @configurations.each do |conf| + - next if conf.key[0...(conf.key.index('.'))] != g + - @grader_configuration = conf + %tr + %td + /= in_place_editor_field :grader_configuration, :key, {}, :rows=>1 + = @grader_configuration.key + %td + /= in_place_editor_field :grader_configuration, :value_type, {}, :rows=>1 + = @grader_configuration.value_type + %td + = best_in_place @grader_configuration, :value, ok_button: "ok", cancel_button: "cancel" + %td= conf.description -- if GraderConfiguration.config_cached? - %br/ - Your config is saved, but it does not automatically take effect. - %br/ - If you have one mongrel process running, you can - = link_to '[click]', :action => 'reload' - here to reload. - %br/ - If you have more than one process running, you should restart - them manually. + .row + .col-md-12 + - if GraderConfiguration.config_cached? + %br/ + Your config is saved, but it does not automatically take effect. + %br/ + If you have one mongrel process running, you can + = link_to '[click]', :action => 'reload' + here to reload. + %br/ + If you have more than one process running, you should restart + them manually. diff --git a/app/views/report/problem_hof.html.haml b/app/views/report/problem_hof.html.haml --- a/app/views/report/problem_hof.html.haml +++ b/app/views/report/problem_hof.html.haml @@ -12,8 +12,8 @@ .form-inline = select 'report', 'problem_id', - @problems.collect {|p| ["[#{p.name}] #{p.full_name}", report_problem_hof_url(p.id)]}, - {:selected => report_problem_hof_url(@problem)}, + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", problem_hof_report_path(p)]}, + {:selected => problem_hof_report_path(@problem)}, { class: 'select2 form-control' } %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: "#report_problem_id"}} Go diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -65,7 +65,11 @@ end end - resources :grader_configuration, controller: 'configurations' + resources :grader_configuration, controller: 'configurations' do + collection do + get 'set_exam_right(/:value)', action: 'set_exam_right', as: 'set_exam_right' + end + end resources :users do member do @@ -134,7 +138,7 @@ resource :report, only: [], controller: 'report' do get 'login' get 'multiple_login' - get 'problem_hof/:id', action: 'problem_hof' + get 'problem_hof(/:id)', action: 'problem_hof', as: 'problem_hof' get 'current_score(/:group_id)', action: 'current_score', as: 'current_score' get 'max_score' post 'show_max_score'