# HG changeset patch # User Nattee Niparnan # Date 2017-03-10 01:43:21 # Node ID 6431e2ef4265d3af8b71544163d33d9e16c9d189 # Parent 39e4a808eb769ca7020e2415916fe659b1ac7dd0 reorder submission and remove duplicate code for submission 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 @@ -124,23 +124,6 @@ end end - def submission - @user = User.find(session[:user_id]) - @problems = @user.available_problems - if params[:id]==nil - @problem = nil - @submissions = nil - else - @problem = Problem.find_by_id(params[:id]) - if (@problem == nil) or (not @problem.available) - redirect_to :action => 'list' - flash[:notice] = 'Error: submissions for that problem are not viewable.' - return - end - @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) - end - end - def result if !GraderConfiguration.show_grading_result redirect_to :action => 'list' and return 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 @@ -19,7 +19,7 @@ flash[:notice] = 'Error: submissions for that problem are not viewable.' return end - @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) + @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id).order(id: :desc) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -28,7 +28,7 @@ result = content_tag(:ul,left_menu.html_safe,class: 'nav navbar-nav') + content_tag(:ul,right_menu.html_safe,class: 'nav navbar-nav navbar-right') end - def add_menu(title, controller, action,html_option = {}) + def add_menu(title, controller, action, html_option = {}) link_option = {controller: controller, action: action} html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) content_tag(:li, link_to(title,link_option),html_option) diff --git a/app/views/application/_submission.html.haml b/app/views/application/_submission.html.haml --- a/app/views/application/_submission.html.haml +++ b/app/views/application/_submission.html.haml @@ -1,8 +1,8 @@ %tr %td{:align => "center"} - = submission_counter+1 - %td{:align => "center"} + = submission.number + %td.text-right = link_to "##{submission.id}", submission_path(submission.id) %td = l submission.submitted_at, format: :long 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 @@ -12,15 +12,16 @@ MAIN .collapse.navbar-collapse#navbar-collapse %ul.nav.navbar-nav + / submission - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user)) - //= add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') %li.dropdown %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} = "#{I18n.t 'menu.submissions'}" %span.caret %ul.dropdown-menu - = add_menu("View", 'main', 'submission') + = add_menu("View", 'submissions', 'index') = add_menu("Self Test", 'test', 'index') + / hall of fame - if GraderConfiguration['right.user_hall_of_fame'] = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') / display MODE button (with countdown in contest mode) diff --git a/app/views/main/submission.html.haml b/app/views/main/submission.html.haml deleted file mode 100644 --- a/app/views/main/submission.html.haml +++ /dev/null @@ -1,31 +0,0 @@ -= user_title_bar(@user) - -.panel.panel-info - .panel-heading - Select Problems - .panel-body - .form-inline - = select 'submission', - 'problem_id', - @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]}, - { selected: (@problem ? main_submission_url(@problem) : -1) }, - { class: 'select2 form-control'} - %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: '#submission_problem_id'}} Go - -- if @problem!=nil - %h2= "Task: #{@problem.full_name} (#{@problem.name})" - -- if @submissions!=nil - - if @submissions.length>0 - %table.table - %thead - %th No. - %th # - %th At - %th Source - %th Result - %th{:width => "300px"} Compiler message - %th - = render :partial => 'submission', :collection => @submissions - - else - No submission diff --git a/app/views/submissions/index.html.haml b/app/views/submissions/index.html.haml --- a/app/views/submissions/index.html.haml +++ b/app/views/submissions/index.html.haml @@ -18,7 +18,7 @@ %table.table %thead %th No. - %th # + %th.text-right # %th At %th Source %th Result