# HG changeset patch # User Nattee Niparnan # Date 2022-02-05 15:43:45 # Node ID 9a927c70d5aa4c7013c7fc6f8bc24ade39697cc5 # Parent ef5cd5528b8da4cd6490aa27b97a90084794d2ed allow ta to set model submission diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,7 +132,7 @@ end def has_role?(role) - self.roles.where(name: role).count > 0 + self.roles.where(name: [role,'admin']).count > 0 end def email_for_editing diff --git a/app/views/report/_task_hof.html.haml b/app/views/report/_task_hof.html.haml --- a/app/views/report/_task_hof.html.haml +++ b/app/views/report/_task_hof.html.haml @@ -54,12 +54,14 @@ %table.table.table-hover %thead %tr - %th #Sub + %th #Sub (lang) %th Author %tbody - @model_subs.each do |sub| %tr - %td= link_to "##{sub.id}", submission_path(sub) + %td + = link_to "##{sub.id}", submission_path(sub) + = "(#{sub.language.pretty_name})" %td= sub.user.full_name .col-md-8 - if @best 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 @@ -22,8 +22,9 @@ /=render partial: 'all_time_hof' Please select a problem. - else - %h1 [#{Problem.find(params[:id]).name}] #{Problem.find(params[:id]).full_name} - -# %h2 Submission History - -# =render partial: 'application/bar_graph', locals: { histogram: @histogram } + %h1 + [#{Problem.find(params[:id]).name}] #{Problem.find(params[:id]).full_name} + - if @current_user.has_role?('ta') + %a{href:stat_problem_path(@problem)} (stat) =render partial: 'task_hof' diff --git a/app/views/submissions/show.html.haml b/app/views/submissions/show.html.haml --- a/app/views/submissions/show.html.haml +++ b/app/views/submissions/show.html.haml @@ -94,9 +94,9 @@ %strong Grading Task Status %td = @task.status_str if @task - - if session[:admin] + - if @current_user.admin? = link_to "rejudge", rejudge_submission_path, data: {remote: true}, class: 'btn btn-info btn-xs' - - if session[:admin] + - if @current_user.has_role?('ta') %tr %td.text-right %strong IP @@ -107,11 +107,11 @@ %td - if @submission.tag_model? YES - - if session[:admin] + - if @current_user.has_role?('ta') = link_to "remove model status", set_tag_submission_path(@submission, tag: :default), class: 'btn btn-warning btn-xs' - else No - - if session[:admin] + - if @current_user.has_role?('ta') = link_to "set as model solution", set_tag_submission_path(@submission, tag: :model), class: 'btn btn-success btn-xs'