Description:
- add problem toggle test js reponse (it was forgotten) - change score report to bootstrap-sortable
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r570:0b74eb4e28fa - - 8 files changed: 77 inserted, 25 deleted

@@ -0,0 +1,2
1 + = render partial: 'toggle_button',
2 + locals: {button_id: "#problem-test-#{@problem.id}",button_on: @problem.test_allowed?}
@@ -36,40 +36,44
36 36 # gem 'capistrano'
37 37
38 38 # To use debugger
39 39 # gem 'debugger'
40 40 #
41 41
42 42 #in-place editor
43 43 gem 'best_in_place', '~> 3.0.1'
44 44
45 45 # jquery addition
46 46 gem 'jquery-rails'
47 47 gem 'jquery-ui-sass-rails'
48 48 gem 'jquery-timepicker-addon-rails'
49 49 gem 'jquery-tablesorter'
50 50
51 51 #syntax highlighter
52 52 gem 'rouge'
53 53
54 54 #add bootstrap
55 55 gem 'bootstrap-sass', '~> 3.2.0'
56 56 gem 'bootstrap-switch-rails'
57 57 gem 'bootstrap-toggle-rails'
58 58 gem 'autoprefixer-rails'
59 59
60 + #bootstrap sortable
61 + gem 'momentjs-rails'
62 + gem 'rails_bootstrap_sortable'
63 +
64 + #ace editor
60 65 gem 'ace-rails-ap'
61 66
62 -
63 67 gem 'haml'
64 68 gem 'haml-rails'
65 69 gem 'mail'
66 70 gem 'rdiscount'
67 71 gem 'test-unit'
68 72 gem 'will_paginate', '~> 3.0.7'
69 73 gem 'dynamic_form'
70 74 gem 'in_place_editing'
71 75 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
72 76
73 77 group :test, :development do
74 78 gem 'rspec-rails', '~> 2.99.0'
75 79 end
@@ -69,69 +69,73
69 69 railties (>= 3.1, < 4.1)
70 70 hike (1.2.3)
71 71 i18n (0.7.0)
72 72 in_place_editing (1.2.0)
73 73 journey (1.0.4)
74 74 jquery-rails (3.1.2)
75 75 railties (>= 3.0, < 5.0)
76 76 thor (>= 0.14, < 2.0)
77 77 jquery-tablesorter (1.13.4)
78 78 railties (>= 3.1, < 5)
79 79 jquery-timepicker-addon-rails (1.4.1)
80 80 railties (>= 3.1)
81 81 jquery-ui-rails (4.0.3)
82 82 jquery-rails
83 83 railties (>= 3.1.0)
84 84 jquery-ui-sass-rails (4.0.3.0)
85 85 jquery-rails
86 86 jquery-ui-rails (= 4.0.3)
87 87 railties (>= 3.1.0)
88 88 json (1.8.2)
89 89 mail (2.5.4)
90 90 mime-types (~> 1.16)
91 91 treetop (~> 1.4.8)
92 92 mime-types (1.25.1)
93 + momentjs-rails (2.11.1)
94 + railties (>= 3.1)
93 95 multi_json (1.10.1)
94 96 mysql2 (0.3.20)
95 97 polyglot (0.3.5)
96 98 power_assert (0.2.2)
97 99 prototype-rails (3.2.1)
98 100 rails (~> 3.2)
99 101 rack (1.4.5)
100 102 rack-cache (1.2)
101 103 rack (>= 0.4)
102 104 rack-ssl (1.3.4)
103 105 rack
104 106 rack-test (0.6.3)
105 107 rack (>= 1.0)
106 108 rails (3.2.21)
107 109 actionmailer (= 3.2.21)
108 110 actionpack (= 3.2.21)
109 111 activerecord (= 3.2.21)
110 112 activeresource (= 3.2.21)
111 113 activesupport (= 3.2.21)
112 114 bundler (~> 1.0)
113 115 railties (= 3.2.21)
116 + rails_bootstrap_sortable (2.0.0)
117 + momentjs-rails (~> 2, >= 2.8.3)
114 118 railties (3.2.21)
115 119 actionpack (= 3.2.21)
116 120 activesupport (= 3.2.21)
117 121 rack-ssl (~> 1.3.2)
118 122 rake (>= 0.8.7)
119 123 rdoc (~> 3.4)
120 124 thor (>= 0.14.6, < 2.0)
121 125 rake (10.4.2)
122 126 rdiscount (2.1.8)
123 127 rdoc (3.12.2)
124 128 json (~> 1.4)
125 129 rouge (1.8.0)
126 130 rspec-collection_matchers (1.1.2)
127 131 rspec-expectations (>= 2.99.0.beta1)
128 132 rspec-core (2.99.2)
129 133 rspec-expectations (2.99.2)
130 134 diff-lcs (>= 1.1.3, < 2.0)
131 135 rspec-mocks (2.99.3)
132 136 rspec-rails (2.99.0)
133 137 actionpack (>= 3.0)
134 138 activemodel (>= 3.0)
135 139 activesupport (>= 3.0)
136 140 railties (>= 3.0)
137 141 rspec-collection_matchers
@@ -162,36 +166,38
162 166 execjs (>= 0.3.0)
163 167 json (>= 1.8.0)
164 168 will_paginate (3.0.7)
165 169
166 170 PLATFORMS
167 171 ruby
168 172
169 173 DEPENDENCIES
170 174 ace-rails-ap
171 175 autoprefixer-rails
172 176 best_in_place (~> 3.0.1)
173 177 bootstrap-sass (~> 3.2.0)
174 178 bootstrap-switch-rails
175 179 bootstrap-toggle-rails
176 180 coffee-rails (~> 3.2.2)
177 181 dynamic_form
178 182 haml
179 183 haml-rails
180 184 in_place_editing
181 185 jquery-rails
182 186 jquery-tablesorter
183 187 jquery-timepicker-addon-rails
184 188 jquery-ui-sass-rails
185 189 mail
190 + momentjs-rails
186 191 mysql2
187 192 prototype-rails
188 193 rails (= 3.2.21)
194 + rails_bootstrap_sortable
189 195 rdiscount
190 196 rouge
191 197 rspec-rails (~> 2.99.0)
192 198 sass-rails (~> 3.2.6)
193 199 select2-rails
194 200 test-unit
195 201 uglifier
196 202 verification!
197 203 will_paginate (~> 3.0.7)
@@ -1,35 +1,35
1 1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 2 // listed below.
3 3 //
4 4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 6 //
7 7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 8 // the compiled file.
9 9 //
10 10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 11 // GO AFTER THE REQUIRES BELOW.
12 12 //
13 13 //= require jquery
14 14 //= require jquery_ujs
15 15 //= require jquery.ui.all
16 16 //= require bootstrap-sprockets
17 - //x= require bootstrap-switch
18 - //= require bootstrap-toggle
17 + //= require moment
18 + //= require bootstrap-sortable
19 19 //= require select2
20 20 //= require custom
21 21 //= require ace-rails-ap
22 22 //= require ace/mode-c_cpp
23 23 //= require ace/mode-ruby
24 24 //= require ace/mode-pascal
25 25 //= require ace/mode-javascript
26 26 //= require ace/mode-java
27 27 //= require ace/theme-merbivore
28 28
29 29
30 30 // since this is after blank line, it is not downloaded
31 31 //x= require prototype
32 32 //x= require prototype_ujs
33 33 //x= require effects
34 34 //x= require dragdrop
35 35 //x= require controls
@@ -16,32 +16,32
16 16 #$(".bootstrap-switch").bootstrapSwitch()
17 17 $(".bootstrap-toggle").bootstrapToggle()
18 18 $('.btn-file :file').on 'fileselect', (event, numFiles, label) ->
19 19 input = $(this).parents('.input-group').find(':text')
20 20 log = if numFiles > 1 then numFiles + ' files selected' else label
21 21 if input.length
22 22 input.val log
23 23 else
24 24 if log
25 25 alert log
26 26 return
27 27 $(".go-button").on 'click', (event) ->
28 28 link = $(this).attr("data-source")
29 29 url = $(link).val()
30 30 if url
31 31 window.location.href = url
32 32 return
33 33 $('.ajax-toggle').on 'click', (event) ->
34 34 target = $(event.target)
35 35 target.removeClass 'btn-default'
36 36 target.removeClass 'btn-success'
37 37 target.addClass 'btn-warning'
38 38 target.text '...'
39 39 return
40 -
40 +
41 41 #ace editor
42 42 e = ace.edit("editor")
43 43 e.setTheme('ace/theme/merbivore')
44 44 e.getSession().setTabSize(2)
45 45 e.getSession().setUseSoftTabs(true)
46 46
47 47 return
@@ -11,48 +11,49
11 11 * file per style scope.
12 12 *
13 13 // bootstrap says that we should not do this, but @import each file instead
14 14 # *= require_tree .
15 15 # *= require_self
16 16 */
17 17
18 18 @import jquery.ui.all
19 19 @import jquery.ui.core
20 20 @import jquery.ui.core
21 21 @import jquery.ui.theme
22 22 @import jquery.ui.datepicker
23 23 @import jquery.ui.slider
24 24 @import jquery-ui-timepicker-addon
25 25 @import jquery-tablesorter/theme.metro-dark
26 26 @import tablesorter-theme.cafe
27 27
28 28 //bootstrap
29 29 @import bootstrap-sprockets
30 30 @import bootstrap
31 31 @import select2
32 32 @import select2-bootstrap
33 33 //@import bootstrap3-switch
34 34 @import bootstrap-toggle
35 + @import bootstrap-sortable
35 36
36 37 //bootstrap navbar color (from)
37 38 $bgDefault : #19197b
38 39 $bgHighlight : #06064b
39 40 $colDefault : #8e8eb4
40 41 $colHighlight : #ffffff
41 42 $dropDown : false
42 43 .navbar-default
43 44 background-color: $bgDefault
44 45 border-color: $bgHighlight
45 46 .navbar-brand
46 47 color: $colDefault
47 48 &:hover, &:focus
48 49 color: $colHighlight
49 50 .navbar-text
50 51 color: $colDefault
51 52 .navbar-nav
52 53 > li
53 54 > a
54 55 color: $colDefault
55 56 &:hover, &:focus
56 57 color: $colHighlight
57 58 @if $dropDown
58 59 > .dropdown-menu
@@ -84,75 +85,87
84 85 background-color: $bgHighlight
85 86 .icon-bar
86 87 background-color: $colDefault
87 88 .navbar-collapse,
88 89 .navbar-form
89 90 border-color: $colDefault
90 91 .navbar-link
91 92 color: $colDefault
92 93 &:hover
93 94 color: $colHighlight
94 95 @media (max-width: 767px)
95 96 .navbar-default .navbar-nav .open .dropdown-menu
96 97 > li > a
97 98 color: $colDefault
98 99 &:hover, &:focus
99 100 color: $colHighlight
100 101 > .active
101 102 > a, > a:hover, > a:focus
102 103 color: $colHighlight
103 104 background-color: $bgHighlight
104 105
105 106 .secondnavbar
106 107 top: 50px
107 108
109 +
110 + // --------------- bootstrap file upload ----------------------
108 111 .btn-file
109 112 position: relative
110 113 overflow: hidden
111 114
112 115 .btn-file input[type=file]
113 116 position: absolute
114 117 top: 0
115 118 right: 0
116 119 min-width: 100%
117 120 min-height: 100%
118 121 font-size: 100px
119 122 text-align: right
120 123 filter: alpha(opacity=0)
121 124 opacity: 0
122 125 outline: none
123 126 background: white
124 127 cursor: inherit
125 128 display: block
126 129
127 130 body
128 131 background: white image-url("topbg.jpg") repeat-x top center
129 132 //font-size: 13px
130 133 //font-family: Tahoma, "sans-serif"
131 134 margin: 10px
132 135 padding: 10px
133 - padding-top: 40px
136 + padding-top: 60px
134 137
138 + // ------------------ bootstrap sortable --------------------
139 + table.sortable th
140 + padding-right: 20px !important
141 + span.sign
142 + right: -15px !important
143 + &.text-right
144 + padding-left: 20px !important
145 + padding-right: 8px !important
146 + &:after, span.sign
147 + left: -15px !important
135 148
136 149 input
137 150 font-family: Tahoma, "sans-serif"
138 151
139 152
140 153 h1
141 154 font-size: 24px
142 155 color: #334488
143 156 line-height: 2em
144 157
145 158
146 159 h2
147 160 font-size: 18px
148 161 color: #5566bb
149 162 line-height: 1.5em
150 163
151 164
152 165 hr
153 166 border-top: 1px solid #dddddd
154 167 border-bottom: 1px solid #eeeeee
155 168
156 169
157 170 //#a
158 171 // color: #6666cc
@@ -1,38 +1,68
1 1 class ReportController < ApplicationController
2 2
3 3 before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize]
4 4
5 5 before_filter(only: [:problem_hof]) { |c|
6 6 return false unless authenticate
7 7
8 8 if GraderConfiguration["right.user_view_submission"]
9 9 return true;
10 10 end
11 11
12 12 admin_authorization
13 13 }
14 14
15 + def score
16 + if params[:commit] == 'download csv'
17 + @problems = Problem.all
18 + else
19 + @problems = Problem.find_available_problems
20 + end
21 + @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true)
22 + @scorearray = Array.new
23 + @users.each do |u|
24 + ustat = Array.new
25 + ustat[0] = u
26 + @problems.each do |p|
27 + sub = Submission.find_last_by_user_and_problem(u.id,p.id)
28 + if (sub!=nil) and (sub.points!=nil) and p and p.full_score
29 + ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
30 + else
31 + ustat << [0,false]
32 + end
33 + end
34 + @scorearray << ustat
35 + end
36 + if params[:commit] == 'download csv' then
37 + csv = gen_csv_from_scorearray(@scorearray,@problems)
38 + send_data csv, filename: 'last_score.csv'
39 + else
40 + render template: 'user_admin/user_stat'
41 + end
42 +
43 + end
44 +
15 45 def login_stat
16 46 @logins = Array.new
17 47
18 48 date_and_time = '%Y-%m-%d %H:%M'
19 49 begin
20 50 md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
21 51 @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
22 52 rescue
23 53 @since_time = DateTime.new(1000,1,1)
24 54 end
25 55 begin
26 56 md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
27 57 @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
28 58 rescue
29 59 @until_time = DateTime.new(3000,1,1)
30 60 end
31 61
32 62 User.all.each do |user|
33 63 @logins << { id: user.id,
34 64 login: user.login,
35 65 full_name: user.full_name,
36 66 count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
37 67 user.id,@since_time,@until_time)
38 68 .count(:id),
@@ -52,54 +82,49
52 82
53 83 def submission_stat
54 84
55 85 date_and_time = '%Y-%m-%d %H:%M'
56 86 begin
57 87 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
58 88 rescue
59 89 @since_time = DateTime.new(1000,1,1)
60 90 end
61 91 begin
62 92 @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
63 93 rescue
64 94 @until_time = DateTime.new(3000,1,1)
65 95 end
66 96
67 97 @submissions = {}
68 98
69 99 User.find_each do |user|
70 100 @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } }
71 101 end
72 102
73 103 Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s|
74 104 if @submissions[s.user_id]
75 105 if not @submissions[s.user_id][:sub].has_key?(s.problem_id)
76 - a = nil
77 - begin
78 - a = Problem.find(s.problem_id)
79 - rescue
80 - a = nil
81 - end
106 + a = Problem.find_by_id(s.problem_id)
82 107 @submissions[s.user_id][:sub][s.problem_id] =
83 108 { prob_name: (a ? a.full_name : '(NULL)'),
84 109 sub_ids: [s.id] }
85 110 else
86 111 @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id
87 112 end
88 113 @submissions[s.user_id][:count] += 1
89 114 end
90 115 end
91 116 end
92 117
93 118 def problem_hof
94 119 # gen problem list
95 120 @user = User.find(session[:user_id])
96 121 @problems = @user.available_problems
97 122
98 123 # get selected problems or the default
99 124 if params[:id]
100 125 begin
101 126 @problem = Problem.available.find(params[:id])
102 127 rescue
103 128 redirect_to action: :problem_hof
104 129 flash[:notice] = 'Error: submissions for that problem are not viewable.'
105 130 return
@@ -1,59 +1,61
1 - - content_for :header do
2 - = javascript_include_tag 'local_jquery'
3 - = stylesheet_link_tag 'tablesorter-theme.cafe'
1 + /- content_for :header do
2 + / = javascript_include_tag 'local_jquery'
3 + / = stylesheet_link_tag 'tablesorter-theme.cafe'
4 4
5 5 %script{:type=>"text/javascript"}
6 6 $(function () {
7 7 $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
8 8 $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
9 - $('#my_table').tablesorter({widgets: ['zebra']});
9 + /$('#my_table').tablesorter({widgets: ['zebra']});
10 10 });
11 11
12 12 %h1 User grading results
13 13 %h2= params[:action] == 'user_stat' ? "Show scores from latest submission" : "Show max scores in submission range"
14 14
15 15
16 16 - if @problem and @problem.errors
17 17 =error_messages_for 'problem'
18 18
19 19 = render partial: 'submission_range'
20 20
21 21 - if params[:action] == 'user_stat'
22 22 %h3 Latest score
23 23 = link_to '[download csv with all problems]', controller: :user_admin, action: :user_stat, commit: 'download csv'
24 24 - else
25 25 %h3 Max score
26 26 = link_to '[Show only latest submissions]', controller: :user_admin, action: :user_stat
27 27 = link_to '[download csv with all problems]', controller: :user_admin, action: :user_stat_max, commit: 'download csv'
28 28
29 - %table.tablesorter-cafe#my_table
29 + %table.table.sortable.table-striped.table-bordered
30 30 %thead
31 31 %tr
32 - %th User
32 + %th Login
33 33 %th Name
34 34 %th Activated?
35 - %th Logged in
35 + %th Logged_in
36 36 %th Contest(s)
37 37 %th Remark
38 38 - @problems.each do |p|
39 - %th= p.name
40 - %th Total
41 - %th Passed
39 + %th.text-right= p.name
40 + %th.text-right Total
41 + %th.text-right Passed
42 42 %tbody
43 43 - @scorearray.each do |sc|
44 - %tr{class: cycle('info-even','info-odd')}
44 + %tr
45 45 - total,num_passed = 0,0
46 46 - sc.each_index do |i|
47 47 - if i == 0
48 48 %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i]
49 49 %td= sc[i].full_name
50 50 %td= sc[i].activated
51 51 %td= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no'
52 52 %td= sc[i].contests.collect {|c| c.name}.join(', ')
53 53 %td= sc[i].remark
54 54 - else
55 - %td= sc[i][0]
55 + %td.text-right= sc[i][0]
56 56 - total += sc[i][0]
57 57 - num_passed += 1 if sc[i][1]
58 - %td= total
59 - %td= num_passed
58 + %td.text-right= total
59 + %td.text-right= num_passed
60 + :javascript
61 + $.bootstrapSortable(true,'reversed')
You need to be logged in to leave comments. Login now