Description:
add get_latest_submission_status for submission
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

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 class SourcesController < ApplicationController
1 class SourcesController < ApplicationController
2 before_filter :authenticate
2 before_filter :authenticate
3
3
4 def direct_edit
4 def direct_edit
5 @problem = Problem.find(params[:pid])
5 @problem = Problem.find(params[:pid])
6 @source = ''
6 @source = ''
7 end
7 end
8
8
9 def direct_edit_submission
9 def direct_edit_submission
10 @submission = Submission.find(params[:sid])
10 @submission = Submission.find(params[:sid])
11 @source = @submission.source.to_s
11 @source = @submission.source.to_s
12 @problem = @submission.problem
12 @problem = @submission.problem
13 @lang_id = @submission.language.id
13 @lang_id = @submission.language.id
14 render 'direct_edit'
14 render 'direct_edit'
15 end
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 end
27 end
@@ -1,27 +1,34
1 %h2 Live submit
1 %h2 Live submit
2 %br
2 %br
3
3
4 %textarea#text_haha{style: "display:none"}~ @source
4 %textarea#text_haha{style: "display:none"}~ @source
5 .container
5 .container
6 .row
6 .row
7 .col-md-12
7 .col-md-12
8 .alert.alert-info
8 .alert.alert-info
9 Write your code in the following box, choose language, and click submit button when finished
9 Write your code in the following box, choose language, and click submit button when finished
10 .row
10 .row
11 - .col-md-7
11 + .col-md-8
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
13 - .col-md-5
13 + .col-md-4
14 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
14 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
15
15
16 = hidden_field_tag 'editor_text', @source
16 = hidden_field_tag 'editor_text', @source
17 = hidden_field_tag 'submission[problem_id]', @problem.id
17 = hidden_field_tag 'submission[problem_id]', @problem.id
18 .form-group
18 .form-group
19 = label_tag "Task:"
19 = label_tag "Task:"
20 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
20 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
21
21
22 .form-group
22 .form-group
23 = label_tag 'Language'
23 = label_tag 'Language'
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"
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 .form-group
25 .form-group
26 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
26 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
27 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
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 end
13 end
14 end
14 end
15
15
16 resources :problems do
16 resources :problems do
17 member do
17 member do
18 get 'toggle'
18 get 'toggle'
19 get 'toggle_test'
19 get 'toggle_test'
20 end
20 end
21 collection do
21 collection do
22 get 'turn_all_off'
22 get 'turn_all_off'
23 get 'turn_all_on'
23 get 'turn_all_on'
24 get 'import'
24 get 'import'
25 get 'manage'
25 get 'manage'
26 end
26 end
27 end
27 end
28
28
29 resources :grader_configuration, controller: 'configurations'
29 resources :grader_configuration, controller: 'configurations'
30
30
31 resources :users do
31 resources :users do
32 member do
32 member do
33 get 'toggle_activate', 'toggle_enable'
33 get 'toggle_activate', 'toggle_enable'
34 end
34 end
35 end
35 end
36
36
37 + #source code edit
37 get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit'
38 get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit'
38 get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission'
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 match 'tasks/view/:file.:ext' => 'tasks#view'
43 match 'tasks/view/:file.:ext' => 'tasks#view'
42 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
44 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
43 match 'heartbeat/:id/edit' => 'heartbeat#edit'
45 match 'heartbeat/:id/edit' => 'heartbeat#edit'
44
46
45 #main
47 #main
46 get "main/list"
48 get "main/list"
47 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
49 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
48
50
49 #report
51 #report
50 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
52 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
51 get "report/login"
53 get "report/login"
52
54
53 #grader
55 #grader
54 get 'graders/list', to: 'graders#list', as: 'grader_list'
56 get 'graders/list', to: 'graders#list', as: 'grader_list'
55
57
56 # See how all your routes lay out with "rake routes"
58 # See how all your routes lay out with "rake routes"
57
59
58 # This is a legacy wild controller route that's not recommended for RESTful applications.
60 # This is a legacy wild controller route that's not recommended for RESTful applications.
59 # Note: This route will make all actions in every controller accessible via GET requests.
61 # Note: This route will make all actions in every controller accessible via GET requests.
60 match ':controller(/:action(/:id))(.:format)'
62 match ':controller(/:action(/:id))(.:format)'
61 end
63 end
You need to be logged in to leave comments. Login now