Description:
* add forgotten toggle file * main/submission changed to bootstrap
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r559:2e5e11be6cae - - 9 files changed: 91 inserted, 9 deleted

@@ -0,0 +1,6
1 + $ ->
2 + $("#submission_problem_go").on 'click', (event) ->
3 + url = $("#submission_problem_id").val()
4 + if (url)
5 + window.location = url
6 +
@@ -0,0 +1,46
1 + - content_for :head do
2 + = stylesheet_link_tag 'problems'
3 + %h1 Listing problems
4 + %p
5 + = link_to 'New problem', new_problem_path, class: 'btn btn-default btn-sm'
6 + = link_to 'Manage problems', { action: 'manage'}, class: 'btn btn-default btn-sm'
7 + = link_to 'Import problems', {:action => 'import'}, class: 'btn btn-default btn-sm'
8 + = link_to 'Turn off all problems', {:action => 'turn_all_off'}, class: 'btn btn-default btn-sm'
9 + = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm'
10 + .submitbox
11 + = form_tag :action => 'quick_create' do
12 + %b Quick New:
13 + %label{:for => "problem_name"} Name
14 + = text_field 'problem', 'name'
15 + |
16 + %label{:for => "problem_full_name"} Full name
17 + = text_field 'problem', 'full_name'
18 + = submit_tag "Create"
19 + %table.table.table-condensed.table-hover
20 + %thead
21 + %th Name
22 + %th Full name
23 + %th Full score
24 + %th Date added
25 + %th Avail?
26 + %th Test?
27 + - if GraderConfiguration.multicontests?
28 + %th Contests
29 + - for problem in @problems
30 + %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
31 + - @problem=problem
32 + %td= in_place_editor_field :problem, :name, {}, :rows=>1
33 + %td= in_place_editor_field :problem, :full_name, {}, :rows=>1
34 + %td= in_place_editor_field :problem, :full_score, {}, :rows=>1
35 + %td= problem.date_added
36 + %td{}= link_to (@problem.available? ? "Yes" : "No"), url_for(controller: :problems, action: :toggle, id: @problem), { class: "btn btn-block btn-sm btn-#{(@problem.available? ? 'success' : 'default')} ajax-toggle", id: "prob-#{@problem.id}-avail", data: {remote: true, method: 'post' } }
37 + %td= problem.test_allowed
38 + - if GraderConfiguration.multicontests?
39 + %td
40 + = problem.contests.collect { |c| c.name }.join(', ')
41 + %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-primary btn-sm'
42 + %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-primary btn-sm'
43 + %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-primary btn-sm'
44 + %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-sm'
45 + %br/
46 + = link_to '[New problem]', :action => 'new'
@@ -0,0 +1,12
1 + :plain
2 + b = $("#prob-#{@problem.id}-avail");
3 + b.removeClass('btn-default');
4 + b.removeClass('btn-success');
5 + b.removeClass('btn-warning');
6 + b.addClass("btn-#{@problem.available? ? 'success' : 'default'}");
7 + b.text("#{@problem.available? ? 'Yes' : 'No'}");
8 + r = $("#prob-#{@problem.id}");
9 + r.removeClass('success');
10 + r.removeClass('danger');
11 + r.addClass("#{@problem.available? ? 'success' : 'danger'}");
12 +
@@ -1,15 +1,14
1 1 #js for announcement
2 2 $ ->
3 3 $('.ajax-toggle').on 'click', (event) ->
4 - console.log event.target.id
5 4 target = $(event.target)
6 5 target.removeClass 'btn-default'
7 6 target.removeClass 'btn-success'
8 7 target.addClass 'btn-warning'
9 8 target.text '...'
10 9 return
11 10
12 11 $(document).ajaxError (event, jqxhr, settings, exception) ->
13 12 if jqxhr.status
14 13 alert 'We\'re sorry, but something went wrong (' + jqxhr.status + ')'
15 14 return
@@ -102,50 +102,50
102 102 :type => 'text/plain'})
103 103 else
104 104 flash[:notice] = 'Error viewing source'
105 105 redirect_to :action => 'list'
106 106 end
107 107 end
108 108
109 109 def compiler_msg
110 110 @submission = Submission.find(params[:id])
111 111 if @submission.user_id == session[:user_id]
112 112 render :action => 'compiler_msg', :layout => 'empty'
113 113 else
114 114 flash[:notice] = 'Error viewing source'
115 115 redirect_to :action => 'list'
116 116 end
117 117 end
118 118
119 119 def submission
120 120 @user = User.find(session[:user_id])
121 121 @problems = @user.available_problems
122 122 if params[:id]==nil
123 123 @problem = nil
124 124 @submissions = nil
125 125 else
126 - @problem = Problem.find_by_name(params[:id])
127 - if not @problem.available
126 + @problem = Problem.find_by_id(params[:id])
127 + if (@problem == nil) or (not @problem.available)
128 128 redirect_to :action => 'list'
129 129 flash[:notice] = 'Error: submissions for that problem are not viewable.'
130 130 return
131 131 end
132 132 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
133 133 end
134 134 end
135 135
136 136 def result
137 137 if !GraderConfiguration.show_grading_result
138 138 redirect_to :action => 'list' and return
139 139 end
140 140 @user = User.find(session[:user_id])
141 141 @submission = Submission.find(params[:id])
142 142 if @submission.user!=@user
143 143 flash[:notice] = 'You are not allowed to view result of other users.'
144 144 redirect_to :action => 'list' and return
145 145 end
146 146 prepare_grading_result(@submission)
147 147 end
148 148
149 149 def load_output
150 150 if !GraderConfiguration.show_grading_result or params[:num]==nil
151 151 redirect_to :action => 'list' and return
@@ -86,48 +86,60
86 86 def format_short_time(time)
87 87 now = Time.now.gmtime
88 88 st = ''
89 89 if (time.yday != now.yday) or
90 90 (time.year != now.year)
91 91 st = time.strftime("%x ")
92 92 end
93 93 st + time.strftime("%X")
94 94 end
95 95
96 96 def format_short_duration(duration)
97 97 return '' if duration==nil
98 98 d = duration.to_f
99 99 return Time.at(d).gmtime.strftime("%X")
100 100 end
101 101
102 102 def read_textfile(fname,max_size=2048)
103 103 begin
104 104 File.open(fname).read(max_size)
105 105 rescue
106 106 nil
107 107 end
108 108 end
109 109
110 + def problem_select(problems, options = {})
111 + prefix = options[:with_specific_in_header] ? [[(t 'main.specified_in_header'),'-1']] : []
112 + selected = options[:selected] || (options[:with_specific_in_header] ? -1 : nil)
113 + puts "selected = #{selected} hehe"
114 + html_options = {class: 'select2 form-control'}
115 + html_options[:id] = options[:id]if options[:id]
116 + select 'submission',
117 + 'problem_id', prefix + problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},
118 + (selected ? { selected: "#{selected}"} : {} ),
119 + html_options
120 + end
121 +
110 122 def user_title_bar(user)
111 123 header = ''
112 124 time_left = ''
113 125
114 126 #
115 127 # if the contest is over
116 128 if GraderConfiguration.time_limit_mode?
117 129 if user.contest_finished?
118 130 header = <<CONTEST_OVER
119 131 <tr><td colspan="2" align="center">
120 132 <span class="contest-over-msg">THE CONTEST IS OVER</span>
121 133 </td></tr>
122 134 CONTEST_OVER
123 135 end
124 136 if !user.contest_started?
125 137 time_left = "&nbsp;&nbsp;" + (t 'title_bar.contest_not_started')
126 138 else
127 139 time_left = "&nbsp;&nbsp;" + (t 'title_bar.remaining_time') +
128 140 " #{format_short_duration(user.contest_time_left)}"
129 141 end
130 142 end
131 143
132 144 #
133 145 # if the contest is in the anaysis mode
@@ -1,20 +1,20
1 1 = form_tag({:action => 'submit'}, :multipart => true, class: 'form-inline') do
2 2 - if @submission and @submission.errors.any?
3 3 #error_explanation
4 4 .alert.alert-danger
5 5 %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:"
6 6 %ul
7 7 - @submission.errors.full_messages.each do |msg|
8 8 %li= msg
9 9 .form-group
10 10 = label_tag :submission, 'Problem:'
11 - = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2 form-control' }
11 + = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, {:selected => '-1'}, { class: 'select2 form-control' }
12 12 .form-group
13 13 = label_tag :file, 'File:'
14 14 .input-group
15 15 %span.input-group-btn
16 16 %span.btn.btn-default.btn-file
17 17 Browse
18 18 = file_field_tag 'file'
19 19 = text_field_tag '' , nil, {readonly: true, class: 'form-control'}
20 20 = submit_tag 'Submit', class: 'btn btn-default'
@@ -1,25 +1,31
1 1 = user_title_bar(@user)
2 2
3 - .task-menu
4 - Task List
5 - %br/
6 - - @problems.each do |problem|
7 - = link_to problem.name, :action => 'submission', :id => problem.name
3 + .panel.panel-info
4 + .panel-heading
5 + Select Problems
6 + .panel-body
7 + .form-inline
8 + = select 'submission',
9 + 'problem_id',
10 + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]},
11 + {:selected => '-1'},
12 + { class: 'select2 form-control' }
13 + %button.btn.btn-primary.btn-sm#submission_problem_go Go
8 14
9 15 - if @problem!=nil
10 16 %h2= "Task: #{@problem.full_name} (#{@problem.name})"
11 17
12 18 - if @submissions!=nil
13 19 - if @submissions.length>0
14 20 %table.info
15 21 %tr.info-head
16 22 %th.info No.
17 23 %th.info #
18 24 %th.info At
19 25 %th.info Source
20 26 %th.info Result
21 27 %th.info{:width => "300px"}
22 28 Compiler message
23 29 = render :partial => 'submission', :collection => @submissions
24 30 - else
25 31 No submission
@@ -1,29 +1,30
1 1 CafeGrader::Application.routes.draw do
2 2 root :to => 'main#login'
3 3
4 4 get "report/login"
5 5
6 6 resources :contests
7 7
8 8 resources :announcements
9 9 match 'announcements/toggle/:id' => 'announcements#toggle'
10 10
11 11 resources :sites
12 12
13 13 resources :problem
14 14
15 15 resources :grader_configuration, controller: 'configurations'
16 16
17 17 match 'tasks/view/:file.:ext' => 'tasks#view'
18 18 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
19 19 match 'heartbeat/:id/edit' => 'heartbeat#edit'
20 20
21 21 #main
22 22 get "main/list"
23 + get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
23 24
24 25 # See how all your routes lay out with "rake routes"
25 26
26 27 # This is a legacy wild controller route that's not recommended for RESTful applications.
27 28 # Note: This route will make all actions in every controller accessible via GET requests.
28 29 match ':controller(/:action(/:id))(.:format)'
29 30 end
You need to be logged in to leave comments. Login now