Description:
add get_latest_submission_status for submission
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r581:11a43c5a5a46 - - 5 files changed: 49 inserted, 2 deleted
@@ -0,0 +1,26 | |||
|
1 | + | |
|
2 | + - if submission.nil? | |
|
3 | + = "-" | |
|
4 | + - else | |
|
5 | + - if submission.graded_at.nil? | |
|
6 | + =t 'main.submitted_at' | |
|
7 | + = format_short_time(submission.submitted_at.localtime) | |
|
8 | + - else | |
|
9 | + = t 'main.graded_at' | |
|
10 | + = "#{format_short_time(submission.graded_at.localtime)}, " | |
|
11 | + - if GraderConfiguration['ui.show_score'] | |
|
12 | + = t 'main.score' | |
|
13 | + = "#{(submission.points*100/submission.problem.full_score).to_i} " | |
|
14 | + = " [" | |
|
15 | + %tt | |
|
16 | + = submission.grader_comment | |
|
17 | + = "]" | |
|
18 | + - if GraderConfiguration.show_grading_result | |
|
19 | + = " | " | |
|
20 | + = link_to '[detailed result]', :action => 'result', :id => submission.id | |
|
21 | + = " | " | |
|
22 | + = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true}) | |
|
23 | + = " | " | |
|
24 | + = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id}) | |
|
25 | + //= " | " | |
|
26 | + //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id) |
@@ -0,0 +1,2 | |||
|
1 | + :javascript | |
|
2 | + $("#latest_status").html("#{j render({partial: 'submission_short', locals: {submission: @submission, problem_name: @problem.name}})}") |
@@ -1,17 +1,27 | |||
|
1 | 1 | class SourcesController < ApplicationController |
|
2 | 2 | before_filter :authenticate |
|
3 | 3 | |
|
4 | 4 | def direct_edit |
|
5 | 5 | @problem = Problem.find(params[:pid]) |
|
6 | 6 | @source = '' |
|
7 | 7 | end |
|
8 | 8 | |
|
9 | 9 | def direct_edit_submission |
|
10 | 10 | @submission = Submission.find(params[:sid]) |
|
11 | 11 | @source = @submission.source.to_s |
|
12 | 12 | @problem = @submission.problem |
|
13 | 13 | @lang_id = @submission.language.id |
|
14 | 14 | render 'direct_edit' |
|
15 | 15 | end |
|
16 | 16 | |
|
17 | + def get_latest_submission_status | |
|
18 | + @problem = Problem.find(params[:pid]) | |
|
19 | + @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) | |
|
20 | + puts User.find(params[:uid]).login | |
|
21 | + puts Problem.find(params[:pid]).name | |
|
22 | + puts 'nil' unless @submission | |
|
23 | + respond_to do |format| | |
|
24 | + format.js | |
|
25 | + end | |
|
26 | + end | |
|
17 | 27 | end |
@@ -1,27 +1,34 | |||
|
1 | 1 | %h2 Live submit |
|
2 | 2 | %br |
|
3 | 3 | |
|
4 | 4 | %textarea#text_haha{style: "display:none"}~ @source |
|
5 | 5 | .container |
|
6 | 6 | .row |
|
7 | 7 | .col-md-12 |
|
8 | 8 | .alert.alert-info |
|
9 | 9 | Write your code in the following box, choose language, and click submit button when finished |
|
10 | 10 | .row |
|
11 |
- .col-md- |
|
|
11 | + .col-md-8 | |
|
12 | 12 | %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'} |
|
13 |
- .col-md- |
|
|
13 | + .col-md-4 | |
|
14 | 14 | = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do |
|
15 | 15 | |
|
16 | 16 | = hidden_field_tag 'editor_text', @source |
|
17 | 17 | = hidden_field_tag 'submission[problem_id]', @problem.id |
|
18 | 18 | .form-group |
|
19 | 19 | = label_tag "Task:" |
|
20 | 20 | = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true |
|
21 | 21 | |
|
22 | 22 | .form-group |
|
23 | 23 | = label_tag 'Language' |
|
24 | 24 | = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px" |
|
25 | 25 | .form-group |
|
26 | 26 | = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit', |
|
27 | 27 | data: {confirm: "Submitting this source code for task #{@problem.long_name}?"} |
|
28 | + .panel.panel-info | |
|
29 | + .panel-heading | |
|
30 | + Latest Submission Status | |
|
31 | + .panel-body | |
|
32 | + - if @submission | |
|
33 | + = render :partial => 'submission_short', | |
|
34 | + :locals => {:submission => @submission, :problem_name => @problem.name } |
@@ -13,49 +13,51 | |||
|
13 | 13 | end |
|
14 | 14 | end |
|
15 | 15 | |
|
16 | 16 | resources :problems do |
|
17 | 17 | member do |
|
18 | 18 | get 'toggle' |
|
19 | 19 | get 'toggle_test' |
|
20 | 20 | end |
|
21 | 21 | collection do |
|
22 | 22 | get 'turn_all_off' |
|
23 | 23 | get 'turn_all_on' |
|
24 | 24 | get 'import' |
|
25 | 25 | get 'manage' |
|
26 | 26 | end |
|
27 | 27 | end |
|
28 | 28 | |
|
29 | 29 | resources :grader_configuration, controller: 'configurations' |
|
30 | 30 | |
|
31 | 31 | resources :users do |
|
32 | 32 | member do |
|
33 | 33 | get 'toggle_activate', 'toggle_enable' |
|
34 | 34 | end |
|
35 | 35 | end |
|
36 | 36 | |
|
37 | + #source code edit | |
|
37 | 38 | get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' |
|
38 | 39 | get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' |
|
40 | + get 'sources/get_latest_submission_status/:uid/:pid', to: 'sources#get_latest_submission_status', as: 'get_latest_submission_status' | |
|
39 | 41 | |
|
40 | 42 | |
|
41 | 43 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
42 | 44 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
43 | 45 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
44 | 46 | |
|
45 | 47 | #main |
|
46 | 48 | get "main/list" |
|
47 | 49 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
48 | 50 | |
|
49 | 51 | #report |
|
50 | 52 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
51 | 53 | get "report/login" |
|
52 | 54 | |
|
53 | 55 | #grader |
|
54 | 56 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
55 | 57 | |
|
56 | 58 | # See how all your routes lay out with "rake routes" |
|
57 | 59 | |
|
58 | 60 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
59 | 61 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
60 | 62 | match ':controller(/:action(/:id))(.:format)' |
|
61 | 63 | end |
You need to be logged in to leave comments.
Login now