diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,8 +126,6 @@ thor (>= 0.14, < 2.0) jquery-tablesorter (1.26.1) railties (>= 3.2, < 6) - jquery-timepicker-addon-rails (1.4.1) - railties (>= 3.1) jquery-ui-rails (6.0.1) railties (>= 3.2.16) listen (3.1.5) @@ -285,7 +283,6 @@ jquery-countdown-rails jquery-rails jquery-tablesorter - jquery-timepicker-addon-rails jquery-ui-rails listen (>= 3.0.5, < 3.2) mail diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -73,7 +73,7 @@ @submission.submitted_at = Time.new.gmtime @submission.ip_address = request.remote_ip - if GraderConfiguration.time_limit_mode? and user.contest_finished? + if @current_user.admin? == false && GraderConfiguration.time_limit_mode? && @current_user.contest_finished? @submission.errors.add(:base,"The contest is over.") prepare_list_information render :action => 'list' and return diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -19,7 +19,7 @@ def current_score @problems = Problem.available_problems - if params[:group_id] + if params[:group_id] && params[:users] == 'group' @group = Group.find(params[:group_id]) @users = @group.users.where(enabled: true) else @@ -50,10 +50,12 @@ end #users - @users = if params[:users] == "all" then + @users = if params[:users] == "group" then + Group.find(params[:group_id]).users.all + elsif params[:users] == 'enabled' + User.includes(:contests).includes(:contest_stat).where(enabled: true) + else User.includes(:contests).includes(:contest_stat) - else - User.includes(:contests).includes(:contest_stat).where(enabled: true) end #set up range from param diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -95,7 +95,7 @@ def submission_authorization #admin always has privileged return true if @current_user.admin? - return true if @current_user.has_role?('TA') && (['show','download'].include? action_name) + return true if @current_user.has_role?('ta') && (['show','download'].include? action_name) sub = Submission.find(params[:id]) if @current_user.available_problems.include? sub.problem diff --git a/app/views/report/current_score.html.haml b/app/views/report/current_score.html.haml --- a/app/views/report/current_score.html.haml +++ b/app/views/report/current_score.html.haml @@ -1,11 +1,15 @@ .container-fluid %h1 Current Score = form_tag current_score_report_path, method: 'get' do - Show only users from this group + .radio-inline + = radio_button_tag 'users', 'all', (params[:users] == 'all') + = label_tag(:users_all,'Show all users') + %br + .radio-inline + = radio_button_tag 'users', 'group', (params[:users] == 'group') + = label_tag(:users_group, 'Show only users from this group') = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_id]), id: 'group_name',class: 'select2', style: 'width: 20em'; = submit_tag 'Apply',class: 'btn btn-default' %br - - = render "score_table" diff --git a/app/views/report/max_score.html.haml b/app/views/report/max_score.html.haml --- a/app/views/report/max_score.html.haml +++ b/app/views/report/max_score.html.haml @@ -39,6 +39,11 @@ %label = radio_button_tag 'users', 'enabled', (params[:users] == "enabled") Only enabled users + .radio + %label + = radio_button_tag 'users', 'group', (params[:users] == "group") + Only users from this group + = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_id]), id: 'group_name',class: 'select2', style: 'width: 20em'; .row .col-md-12 = button_tag 'Show', class: "btn btn-primary btn-large", value: "show" diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -10,76 +10,77 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_04_05_112919) do +ActiveRecord::Schema.define(version: 2020_08_13_083020) do - create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "announcements", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "author" - t.text "body", limit: 16777215 + t.text "body" t.boolean "published" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "frontpage", default: false t.boolean "contest_only", default: false t.string "title" t.string "notes" end - create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "contests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "title" t.boolean "enabled" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "name" end - create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "contests_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "contest_id" t.integer "problem_id" end - create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "contests_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "contest_id" t.integer "user_id" end - create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "countries", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end - create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| - t.text "body", limit: 16777215 + create_table "descriptions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + t.text "body" t.boolean "markdowned" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end - create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "grader_configurations", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "key" t.string "value_type" t.string "value" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.text "description", limit: 16777215 + t.datetime "created_at" + t.datetime "updated_at" + t.text "description" end - create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "grader_processes", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "host" t.integer "pid" t.string "mode" t.boolean "active" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "task_id" t.string "task_type" t.boolean "terminated" - t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" + t.index ["host", "pid"], name: "index_grader_processes_on_host_and_pid" end create_table "groups", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name" t.string "description" + t.boolean "enabled", default: true end create_table "groups_problems", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| @@ -97,13 +98,13 @@ create_table "heart_beats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.string "ip_address" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "status" t.index ["updated_at"], name: "index_heart_beats_on_updated_at" end - create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "languages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name", limit: 10 t.string "pretty_name" t.string "ext", limit: 10 @@ -113,23 +114,23 @@ create_table "logins", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.string "ip_address" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.index ["user_id"], name: "index_logins_on_user_id" end - create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "messages", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "sender_id" t.integer "receiver_id" t.integer "replying_message_id" - t.text "body", limit: 16777215 + t.text "body" t.boolean "replied" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end - create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| - t.string "name", limit: 100 + create_table "problems", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| + t.string "name", limit: 30 t.string "full_name" t.integer "full_score" t.date "date_added" @@ -150,42 +151,42 @@ t.index ["tag_id"], name: "index_problems_tags_on_tag_id" end - create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "rights", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name" t.string "controller" t.string "action" end - create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "rights_roles", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "right_id" t.integer "role_id" t.index ["role_id"], name: "index_rights_roles_on_role_id" end - create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "roles", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name" end - create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "roles_users", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "role_id" t.integer "user_id" t.index ["user_id"], name: "index_roles_users_on_user_id" end - create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "sessions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "session_id" - t.text "data", limit: 16777215 + t.text "data" t.datetime "updated_at" t.index ["session_id"], name: "index_sessions_on_session_id" t.index ["updated_at"], name: "index_sessions_on_updated_at" end - create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "sites", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "name" t.boolean "started" t.datetime "start_time" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "country_id" t.string "password" end @@ -193,11 +194,11 @@ create_table "submission_view_logs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.integer "submission_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end - create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "submissions", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.integer "problem_id" t.integer "language_id" @@ -205,10 +206,10 @@ t.binary "binary" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message", limit: 16777215 + t.text "compiler_message" t.datetime "graded_at" t.integer "points" - t.text "grader_comment", limit: 16777215 + t.text "grader_comment" t.integer "number" t.string "source_filename" t.float "max_runtime" @@ -228,7 +229,7 @@ t.datetime "updated_at", null: false end - create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "tasks", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "submission_id" t.datetime "created_at" t.integer "status" @@ -236,15 +237,15 @@ t.index ["submission_id"], name: "index_tasks_on_submission_id" end - create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "test_pairs", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "problem_id" - t.text "input", limit: 4294967295 - t.text "solution", limit: 4294967295 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.text "input", limit: 16777215 + t.text "solution", limit: 16777215 + t.datetime "created_at" + t.datetime "updated_at" end - create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "test_requests", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.integer "problem_id" t.integer "submission_id" @@ -252,13 +253,13 @@ t.string "output_file_name" t.string "running_stat" t.integer "status" - t.datetime "updated_at", null: false + t.datetime "updated_at" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message", limit: 16777215 + t.text "compiler_message" t.datetime "graded_at" t.string "grader_comment" - t.datetime "created_at", null: false + t.datetime "created_at" t.float "running_time" t.string "exit_status" t.integer "memory_usage" @@ -272,20 +273,20 @@ t.integer "score" t.text "input", limit: 4294967295 t.text "sol", limit: 4294967295 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.index ["problem_id"], name: "index_testcases_on_problem_id" end - create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "user_contest_stats", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.integer "user_id" t.datetime "started_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "forced_logout" end - create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| + create_table "users", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1", force: :cascade do |t| t.string "login", limit: 50 t.string "full_name" t.string "hashed_password" diff --git a/db/seeds.rb b/db/seeds.rb --- a/db/seeds.rb +++ b/db/seeds.rb @@ -225,7 +225,7 @@ end def seed_roles - Role.find_or_create_by(name: 'TA') + Role.find_or_create_by(name: 'ta') return if Role.find_by_name('admin') role = Role.create(:name => 'admin')