diff --git a/app/controllers/sources_controller.rb b/app/controllers/sources_controller.rb --- a/app/controllers/sources_controller.rb +++ b/app/controllers/sources_controller.rb @@ -14,4 +14,14 @@ render 'direct_edit' end + def get_latest_submission_status + @problem = Problem.find(params[:pid]) + @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) + puts User.find(params[:uid]).login + puts Problem.find(params[:pid]).name + puts 'nil' unless @submission + respond_to do |format| + format.js + end + end end diff --git a/app/views/application/_submission_short.html.haml b/app/views/application/_submission_short.html.haml new file mode 100644 --- /dev/null +++ b/app/views/application/_submission_short.html.haml @@ -0,0 +1,26 @@ + +- if submission.nil? + = "-" +- else + - if submission.graded_at.nil? + =t 'main.submitted_at' + = format_short_time(submission.submitted_at.localtime) + - else + = t 'main.graded_at' + = "#{format_short_time(submission.graded_at.localtime)}, " + - if GraderConfiguration['ui.show_score'] + = t 'main.score' + = "#{(submission.points*100/submission.problem.full_score).to_i} " + = " [" + %tt + = submission.grader_comment + = "]" + - if GraderConfiguration.show_grading_result + = " | " + = link_to '[detailed result]', :action => 'result', :id => submission.id + = " | " + = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true}) + = " | " + = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id}) + //= " | " + //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id) diff --git a/app/views/sources/direct_edit.html.haml b/app/views/sources/direct_edit.html.haml --- a/app/views/sources/direct_edit.html.haml +++ b/app/views/sources/direct_edit.html.haml @@ -8,9 +8,9 @@ .alert.alert-info Write your code in the following box, choose language, and click submit button when finished .row - .col-md-7 + .col-md-8 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'} - .col-md-5 + .col-md-4 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do = hidden_field_tag 'editor_text', @source @@ -25,3 +25,10 @@ .form-group = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit', data: {confirm: "Submitting this source code for task #{@problem.long_name}?"} + .panel.panel-info + .panel-heading + Latest Submission Status + .panel-body + - if @submission + = render :partial => 'submission_short', + :locals => {:submission => @submission, :problem_name => @problem.name } diff --git a/app/views/sources/get_latest_submission_status.js.haml b/app/views/sources/get_latest_submission_status.js.haml new file mode 100644 --- /dev/null +++ b/app/views/sources/get_latest_submission_status.js.haml @@ -0,0 +1,2 @@ +:javascript + $("#latest_status").html("#{j render({partial: 'submission_short', locals: {submission: @submission, problem_name: @problem.name}})}") diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -34,8 +34,10 @@ end end + #source code edit 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' + get 'sources/get_latest_submission_status/:uid/:pid', to: 'sources#get_latest_submission_status', as: 'get_latest_submission_status' match 'tasks/view/:file.:ext' => 'tasks#view'