# HG changeset patch # User Nattee Niparnan # Date 2016-07-11 02:39:00 # Node ID 47e6e54a036ad7e2c0c5b8fe6a59b39e742d0d09 # Parent 8640c8596caae016ed997aa6af5f1677ef7f08fa - add problem manage toggle test interface - remove old erb file diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -127,6 +127,14 @@ end end + def toggle_test + @problem = Problem.find(params[:id]) + @problem.update_attributes(test_allowed: !(@problem.test_allowed?) ) + respond_to do |format| + format.js { } + end + end + def turn_all_off Problem.find(:all, :conditions => "available = 1").each do |problem| diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -41,9 +41,12 @@ %ul.dropdown-menu = add_menu( 'Results', 'user_admin', 'user_stat') = add_menu( 'Report', 'report', 'multiple_login') - %button.navbar-btn.btn.btn-default.btn-warning - hahaha - + - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 + =link_to "#{ungraded} backlogs!", + grader_list_path, + class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission' + =link_to 'Contest Mode, time remain: 00:20:33',grader_list_path, + class: 'navbar-btn btn btn-primary' %ul.nav.navbar-nav.navbar-right = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') diff --git a/app/views/problems/index.html.haml b/app/views/problems/index.html.haml --- a/app/views/problems/index.html.haml +++ b/app/views/problems/index.html.haml @@ -20,10 +20,14 @@ %thead %th Name %th Full name - %th Full score + %th.text-right Full score %th Date added - %th Avail? - %th Test? + %th.text-center + Avail? + %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?] + %th.text-center + Test? + %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?] - if GraderConfiguration.multicontests? %th Contests - for problem in @problems @@ -31,11 +35,10 @@ - @problem=problem %td= in_place_editor_field :problem, :name, {}, :rows=>1 %td= in_place_editor_field :problem, :full_name, {}, :rows=>1 - %td= in_place_editor_field :problem, :full_score, {}, :rows=>1 + %td.text-right= in_place_editor_field :problem, :full_score, {}, :rows=>1 %td= problem.date_added - %td= toggle_button(@problem.available?, url_for(controller: :problems, action: :toggle, id: @problem), "problem-avail-#{@problem.id}") - //%td{}= link_to (@problem.available? ? "Yes" : "No"), url_for(controller: :problems, action: :toggle, id: @problem), { class: "btn btn-block btn-sm btn-#{(@problem.available? ? 'success' : 'default')} ajax-toggle", id: "problem-avail-#{@problem.id}", data: {remote: true, method: 'post' } } - %td= problem.test_allowed + %td= toggle_button(@problem.available?, toggle_problem_url(@problem), "problem-avail-#{@problem.id}") + %td= toggle_button(@problem.test_allowed?, toggle_test_problem_url(@problem), "problem-test-#{@problem.id}") - if GraderConfiguration.multicontests? %td = problem.contests.collect { |c| c.name }.join(', ') diff --git a/app/views/problems/list.html.erb b/app/views/problems/list.html.erb deleted file mode 100644 --- a/app/views/problems/list.html.erb +++ /dev/null @@ -1,66 +0,0 @@ -<% content_for :head do %> - <%= stylesheet_link_tag 'problems' %> -<% end %> - -

Listing problems

- -

-<%= link_to '[New problem]', :action => 'new' %> -<%= link_to '[Manage problems]', :action => 'manage' %> -<%= link_to '[Import problems]', :action => 'import' %> -<%= link_to '[Turn off all problems]', :action => 'turn_all_off' %> -<%= link_to '[Turn on all problems]', :action => 'turn_all_on' %> -

- -
- <%= form_tag :action => 'quick_create' do %> - Quick New: - - <%= text_field 'problem', 'name' %> | - - <%= text_field 'problem', 'full_name' %> - <%= submit_tag "Create" %> - <% end %> -
- - - - - - - - - - <% if GraderConfiguration.multicontests? %> - - <% end %> - - -<% for problem in @problems %> - "> - <% @problem=problem %> - - - - - - - - <% if GraderConfiguration.multicontests? %> - - <% end %> - - - - - - - -<% end %> -
NameFull nameFull scoreDate addedAvail?Test?Contests
<%= in_place_editor_field :problem, :name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %><%= problem.date_added %><%= problem.available %><%= problem.test_allowed %> - <%= problem.contests.collect { |c| c.name }.join(', ') %> - <%= link_to '[Toggle]', {:action => 'toggle', :id => problem.id }, :remote => true %><%= link_to '[Stat]', :action => 'stat', :id => problem.id %><%= link_to '[Show]', :action => 'show', :id => problem %><%= link_to '[Edit]', :action => 'edit', :id => problem %><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %>
- -
- -<%= link_to '[New problem]', :action => 'new' %> diff --git a/app/views/user_admin/list.html.erb b/app/views/user_admin/list.html.erb deleted file mode 100644 --- a/app/views/user_admin/list.html.erb +++ /dev/null @@ -1,89 +0,0 @@ -

Listing users

- -
- Quick add - <%= form_tag :action => 'create' do %> - - - - - - - - - - - - - - - - -
<%= text_field 'user', 'login', :size => 10 %><%= text_field 'user', 'full_name', :size => 30 %><%= password_field 'user', 'password', :size => 10 %><%= password_field 'user', 'password_confirmation', :size => 10 %><%= email_field 'user', 'email', :size => 15 %><%= submit_tag "Create" %>
- <% end %> -
- Import from site management - <%= form_tag({:action => 'import'}, :multipart => true) do %> - File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> - <% end %> -
- What else: - <%= link_to '[New user]', :action => 'new' %> - <%= link_to '[New list of users]', :action => 'new_list' %> - <%= link_to '[View administrators]', :action => 'admin' %> - <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> - <%= link_to '[View active users]', :action => 'active' %> - <%= link_to '[Mass mailing]', :action => 'mass_mailing' %> - <% if GraderConfiguration.multicontests? %> -
Multi-contest: - <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> - View users in: - <% @contests.each do |contest| %> - <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> - <% end %> - <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> - <% end %> -
- -Total <%= @user_count %> users | -<% if !@paginated %> - Display all users. - <%= link_to '[show in pages]', :action => 'list', :page => '1' %> -<% else %> - Display in pages. - <%= link_to '[display all]', :action => 'list', :page => 'all' %> | - <%= will_paginate @users, :container => false %> -<% end %> - - - <% for column in User.content_columns %> - <% if !@hidden_columns.index(column.name) %> - - <% end %> - <% end %> - - - - - - -<% for user in @users %> - "> - - <% for column in User.content_columns %> - <% if !@hidden_columns.index(column.name) and column.name != 'login' %> - - <% end %> - <% end %> - - - - - -<% end %> -
<%= column.human_name %>
<%= link_to user.login, controller: :users, :action => 'profile', :id => user %><%=h user.send(column.name) %><%= link_to 'Clear IP', {:action => 'clear_last_ip', :id => user, :page=>params[:page]}, :confirm => 'This will reset last logging in ip of the user, are you sure?' %><%= link_to 'Show', :action => 'show', :id => user %><%= link_to 'Edit', :action => 'edit', :id => user %><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %>
- -
- -<%= link_to '[New user]', :action => 'new' %> -<%= link_to '[New list of users]', :action => 'new_list' %> diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,6 @@ root :to => 'main#login' - resources :contests resources :sites @@ -14,10 +13,10 @@ end end - resources :problems do member do get 'toggle' + get 'toggle_test' end collection do get 'turn_all_off' @@ -35,10 +34,6 @@ end end - #resources :sources do - # collection do - # end - #end get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' @@ -55,6 +50,9 @@ get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' get "report/login" + #grader + get 'graders/list', to: 'graders#list', as: 'grader_list' + # See how all your routes lay out with "rake routes" # This is a legacy wild controller route that's not recommended for RESTful applications.