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

r880:31e27f513ce9 - - 9 files changed: 191 inserted, 160 deleted

@@ -139,24 +139,27
139 range =65
139 range =65
140 @histogram = { data: Array.new(range,0), summary: {} }
140 @histogram = { data: Array.new(range,0), summary: {} }
141 user = Hash.new(0)
141 user = Hash.new(0)
142 @submissions.find_each do |sub|
142 @submissions.find_each do |sub|
143 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
143 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
144 @histogram[:data][d.to_i] += 1 if d < range
144 @histogram[:data][d.to_i] += 1 if d < range
145 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
145 user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max
146 end
146 end
147 @histogram[:summary][:max] = [@histogram[:data].max,1].max
147 @histogram[:summary][:max] = [@histogram[:data].max,1].max
148
148
149 @summary = { attempt: user.count, solve: 0 }
149 @summary = { attempt: user.count, solve: 0 }
150 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
150 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
151 +
152 + #for new graph
153 + @chart_dataset = @problem.get_jschart_history.to_json.html_safe
151 end
154 end
152
155
153 def manage
156 def manage
154 @problems = Problem.order(date_added: :desc)
157 @problems = Problem.order(date_added: :desc)
155 end
158 end
156
159
157 def do_manage
160 def do_manage
158 if params.has_key? 'change_date_added' and params[:date_added].strip.empty? == false
161 if params.has_key? 'change_date_added' and params[:date_added].strip.empty? == false
159 change_date_added
162 change_date_added
160 elsif params.has_key? 'add_to_contest'
163 elsif params.has_key? 'add_to_contest'
161 add_to_contest
164 add_to_contest
162 elsif params.has_key? 'enable_problem'
165 elsif params.has_key? 'enable_problem'
@@ -239,34 +239,35
239
239
240 #model submisssion
240 #model submisssion
241 @model_subs = Submission.where(problem: @problem,tag: Submission.tags[:model])
241 @model_subs = Submission.where(problem: @problem,tag: Submission.tags[:model])
242
242
243
243
244 #calculate best submission
244 #calculate best submission
245 @by_lang = {} #aggregrate by language
245 @by_lang = {} #aggregrate by language
246
246
247 range =65
247 range =65
248 #@histogram = { data: Array.new(range,0), summary: {} }
248 #@histogram = { data: Array.new(range,0), summary: {} }
249 @summary = {count: 0, solve: 0, attempt: 0}
249 @summary = {count: 0, solve: 0, attempt: 0}
250 user = Hash.new(0)
250 user = Hash.new(0)
251 - Submission.where(problem_id: @problem.id).find_each do |sub|
251 + Submission.where(problem_id: @problem.id).includes(:language).each do |sub|
252 #histogram
252 #histogram
253 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
253 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
254 #@histogram[:data][d.to_i] += 1 if d < range
254 #@histogram[:data][d.to_i] += 1 if d < range
255
255
256 next unless sub.points
256 next unless sub.points
257 @summary[:count] += 1
257 @summary[:count] += 1
258 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
258 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
259
259
260 - lang = Language.find_by_id(sub.language_id)
260 + #lang = Language.find_by_id(sub.language_id)
261 + lang = sub.language
261 next unless lang
262 next unless lang
262 next unless sub.points >= @problem.full_score
263 next unless sub.points >= @problem.full_score
263
264
264 #initialize
265 #initialize
265 unless @by_lang.has_key?(lang.pretty_name)
266 unless @by_lang.has_key?(lang.pretty_name)
266 @by_lang[lang.pretty_name] = {
267 @by_lang[lang.pretty_name] = {
267 runtime: { avail: false, value: 2**30-1 },
268 runtime: { avail: false, value: 2**30-1 },
268 memory: { avail: false, value: 2**30-1 },
269 memory: { avail: false, value: 2**30-1 },
269 length: { avail: false, value: 2**30-1 },
270 length: { avail: false, value: 2**30-1 },
270 first: { avail: false, value: DateTime.new(3000,1,1) }
271 first: { avail: false, value: DateTime.new(3000,1,1) }
271 }
272 }
272 end
273 end
@@ -121,45 +121,39
121 user.save
121 user.save
122 send_new_password_email(user)
122 send_new_password_email(user)
123 flash[:notice] = 'New password has been mailed to you.'
123 flash[:notice] = 'New password has been mailed to you.'
124 end
124 end
125 else
125 else
126 flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
126 flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
127 end
127 end
128 redirect_to :action => 'forget'
128 redirect_to :action => 'forget'
129 end
129 end
130
130
131 def stat
131 def stat
132 @user = User.find(params[:id])
132 @user = User.find(params[:id])
133 - @submission = Submission.joins(:problem).where(user_id: params[:id])
133 + @submission = Submission.joins(:problem).includes(:problem).includes(:language).where(user_id: params[:id])
134 @submission = @submission.where('problems.available = true') unless current_user.admin?
134 @submission = @submission.where('problems.available = true') unless current_user.admin?
135
135
136 - range = 120
137 - @histogram = { data: Array.new(range,0), summary: {} }
138 @summary = {count: 0, solve: 0, attempt: 0}
136 @summary = {count: 0, solve: 0, attempt: 0}
139 problem = Hash.new(0)
137 problem = Hash.new(0)
140
138
141 @submission.find_each do |sub|
139 @submission.find_each do |sub|
142 - #histogram
143 - d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
144 - @histogram[:data][d.to_i] += 1 if d < range
145 -
146 @summary[:count] += 1
140 @summary[:count] += 1
147 next unless sub.problem
141 next unless sub.problem
148 problem[sub.problem] = [problem[sub.problem], ( (sub.try(:points) || 0) >= sub.problem.full_score) ? 1 : 0].max
142 problem[sub.problem] = [problem[sub.problem], ( (sub.try(:points) || 0) >= sub.problem.full_score) ? 1 : 0].max
149 end
143 end
150
144
151 - @histogram[:summary][:max] = [@histogram[:data].max,1].max
152 @summary[:attempt] = problem.count
145 @summary[:attempt] = problem.count
153 problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
146 problem.each_value { |v| @summary[:solve] += 1 if v == 1 }
147 + @chart_dataset = @user.get_jschart_user_sub_history.to_json.html_safe
154 end
148 end
155
149
156 def toggle_activate
150 def toggle_activate
157 @user = User.find(params[:id])
151 @user = User.find(params[:id])
158 @user.update_attributes( activated: !@user.activated? )
152 @user.update_attributes( activated: !@user.activated? )
159 respond_to do |format|
153 respond_to do |format|
160 format.js { render partial: 'toggle_button',
154 format.js { render partial: 'toggle_button',
161 locals: {button_id: "#toggle_activate_user_#{@user.id}",button_on: @user.activated? } }
155 locals: {button_id: "#toggle_activate_user_#{@user.id}",button_on: @user.activated? } }
162 end
156 end
163 end
157 end
164
158
165 def toggle_enable
159 def toggle_enable
@@ -305,24 +305,39
305
305
306 #check if the user has the right to view that problem
306 #check if the user has the right to view that problem
307 #this also consider group based problem policy
307 #this also consider group based problem policy
308 def can_view_problem?(problem)
308 def can_view_problem?(problem)
309 return true if admin?
309 return true if admin?
310 return available_problems.include? problem
310 return available_problems.include? problem
311 end
311 end
312
312
313 def self.clear_last_login
313 def self.clear_last_login
314 User.update_all(:last_ip => nil)
314 User.update_all(:last_ip => nil)
315 end
315 end
316
316
317 + def get_jschart_user_sub_history
318 + start = 4.month.ago.beginning_of_day
319 + start_date = start.to_date
320 + count = Submission.where(user: self).where('submitted_at >= ?', start).group('DATE(submitted_at)').count
321 + i = 0
322 + label = []
323 + value = []
324 + while (start_date + i < Time.zone.now.to_date)
325 + label << (start_date+i).strftime("%d-%b")
326 + value << (count[start_date+i] || 0)
327 + i+=1
328 + end
329 + return {labels: label,datasets: [label:'sub',data: value, backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgb(75, 192, 192)']}
330 + end
331 +
317 #create multiple user, one per lines of input
332 #create multiple user, one per lines of input
318 def self.create_from_list(lines)
333 def self.create_from_list(lines)
319 error_logins = []
334 error_logins = []
320 first_error = nil
335 first_error = nil
321 created_users = []
336 created_users = []
322
337
323 lines.split("\n").each do |line|
338 lines.split("\n").each do |line|
324 #split with large limit, this will cause consecutive ',' to be result in a blank
339 #split with large limit, this will cause consecutive ',' to be result in a blank
325 items = line.chomp.split(',',1000)
340 items = line.chomp.split(',',1000)
326 if items.length>=2
341 if items.length>=2
327 login = items[0]
342 login = items[0]
328 full_name = items[1]
343 full_name = items[1]
@@ -1,32 +1,32
1 - if submission.nil?
1 - if submission.nil?
2 = "-"
2 = "-"
3 - else
3 - else
4 - if local_assigns[:show_id]
4 - if local_assigns[:show_id]
5 .row
5 .row
6 - .col-3.text-secondary
6 + .col-3.fw-bold
7 - Sub ID:
7 + Sub ID
8 - %strong.col-9= submission.id
8 + .col-9.text-secondary-x= submission.id
9 - unless submission.graded_at
9 - unless submission.graded_at
10 .row
10 .row
11 - .col-3.text-secondary= t 'main.submitted_at'
11 + .col-3.fw-bold= t 'main.submitted_at'
12 - %strong.col-9= format_full_time_ago(submission.submitted_at.localtime)
12 + .col-9.text-secondary-x= format_full_time_ago(submission.submitted_at.localtime)
13 - else
13 - else
14 .row
14 .row
15 - .col-3.text-secondary= t 'main.graded_at'
15 + .col-3.fw-bold= t 'main.graded_at'
16 - %strong.col-9= format_full_time_ago(submission.graded_at.localtime)
16 + .col-9.text-secondary-x= format_full_time_ago(submission.graded_at.localtime)
17 - if GraderConfiguration['ui.show_score']
17 - if GraderConfiguration['ui.show_score']
18 .row
18 .row
19 - .col-3.text-secondary=t 'main.score'
19 + .col-3.fw-bold=t 'main.score'
20 - %strong.col-9
20 + .col-9.text-secondary-x
21 = (submission.points*100/submission.problem.full_score).to_i
21 = (submission.points*100/submission.problem.full_score).to_i
22 %tt.grader-comment
22 %tt.grader-comment
23 = " [#{submission.grader_comment}]"
23 = " [#{submission.grader_comment}]"
24 - if local_assigns[:show_button]
24 - if local_assigns[:show_button]
25 - if submission.graded_at
25 - if submission.graded_at
26 - if GraderConfiguration.show_grading_result
26 - if GraderConfiguration.show_grading_result
27 = link_to '[detailed result]', :action => 'result', :id => submission.id
27 = link_to '[detailed result]', :action => 'result', :id => submission.id
28 = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission), {popup: true,remote: true,class: 'btn btn-sm btn-info'}
28 = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission), {popup: true,remote: true,class: 'btn btn-sm btn-info'}
29 = link_to "#{t 'main.src_link'}",download_submission_path(submission), class: 'btn btn-sm btn-info'
29 = link_to "#{t 'main.src_link'}",download_submission_path(submission), class: 'btn btn-sm btn-info'
30 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(submission.problem.id), class: 'btn btn-sm btn-info'
30 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(submission.problem.id), class: 'btn btn-sm btn-info'
31 - if GraderConfiguration.show_testcase
31 - if GraderConfiguration.show_testcase
32 = link_to "testcases", show_problem_testcases_path(submission.problem.id), class: 'btn btn-sm btn-info'
32 = link_to "testcases", show_problem_testcases_path(submission.problem.id), class: 'btn btn-sm btn-info'
@@ -1,61 +1,39
1 - content_for :head do
1 - content_for :head do
2 = stylesheet_link_tag 'problems'
2 = stylesheet_link_tag 'problems'
3 = javascript_include_tag 'local_jquery'
3 = javascript_include_tag 'local_jquery'
4
4
5 - :javascript
6 - $(document).ready( function() {
7 - function shiftclick(start,stop,value) {
8 - $('tr input').each( function(id,input) {
9 - var $input=$(input);
10 - var iid=parseInt($input.attr('id').split('-')[2]);
11 - if(iid>=start&&iid<=stop){
12 - $input.prop('checked',value)
13 - }
14 - });
15 - }
16 -
17 - $('tr input').click( function(e) {
18 - if (e.shiftKey) {
19 - stop = parseInt($(this).attr('id').split('-')[2]);
20 - var orig_stop = stop
21 - if (typeof start !== 'undefined') {
22 - if (start > stop) {
23 - var tmp = start;
24 - start = stop;
25 - stop = tmp;
26 - }
27 - shiftclick(start,stop,$(this).is(':checked') )
28 - }
29 - start = orig_stop
30 - } else {
31 - start = parseInt($(this).attr('id').split('-')[2]);
32 - }
33 - });
34 - });
35
5
36
6
37 %h1 Manage problems
7 %h1 Manage problems
38
8
39 %p= link_to '[Back to problem list]', problems_path
9 %p= link_to '[Back to problem list]', problems_path
40
10
41 - = form_tag :action=>'do_manage' do
11 + = form_with url: do_manage_problems_path do |f|
42 - .panel.panel-primary
12 + .card.border-primary.mb-2
43 - .panel-heading
13 + .card-header.text-bg-primary.border-primary
44 Action
14 Action
45 - .panel-body
15 + .card-body
46 .submit-box
16 .submit-box
47 What do you want to do to the selected problem?
17 What do you want to do to the selected problem?
48 %br/
18 %br/
49 (You can shift-click to select a range of problems)
19 (You can shift-click to select a range of problems)
20 + .row
21 + .col-md-auto
22 + = f.check_box :change_date_added, class: 'form-check-input'
23 + .col-md-auto
24 + .form-check-label
25 + Change "Date added" to
26 + .col-md-auto
27 +
50 %ul.form-inline
28 %ul.form-inline
51 %li
29 %li
52 Change "Date added" to
30 Change "Date added" to
53 .input-group.date
31 .input-group.date
54 = text_field_tag :date_added, class: 'form-control'
32 = text_field_tag :date_added, class: 'form-control'
55 %span.input-group-addon
33 %span.input-group-addon
56 %span.glyphicon.glyphicon-calendar
34 %span.glyphicon.glyphicon-calendar
57 -# = select_date Date.current, :prefix => 'date_added'
35 -# = select_date Date.current, :prefix => 'date_added'
58 &nbsp;&nbsp;&nbsp;
36 &nbsp;&nbsp;&nbsp;
59 = submit_tag 'Change', :name => 'change_date_added', class: 'btn btn-primary btn-sm'
37 = submit_tag 'Change', :name => 'change_date_added', class: 'btn btn-primary btn-sm'
60 %li
38 %li
61 Set "Available" to
39 Set "Available" to
@@ -98,22 +76,54
98 %td= problem.full_name
76 %td= problem.full_name
99 %td
77 %td
100 - problem.tags.each do |t|
78 - problem.tags.each do |t|
101 %span.label.label-default= t.name
79 %span.label.label-default= t.name
102 %td= problem.available
80 %td= problem.available
103 %td= problem.date_added
81 %td= problem.date_added
104 - if GraderConfiguration.multicontests?
82 - if GraderConfiguration.multicontests?
105 %td
83 %td
106 - problem.contests.each do |contest|
84 - problem.contests.each do |contest|
107 = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
85 = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
108
86
109 :javascript
87 :javascript
110 - $('.input-group.date').datetimepicker({
88 +
111 - format: 'DD/MMM/YYYY',
89 + $(document).on('import-map-loaded', function() {
112 - showTodayButton: true,
90 + function shiftclick(start,stop,value) {
113 - locale: 'en',
91 + $('tr input').each( function(id,input) {
114 - widgetPositioning: {horizontal: 'auto', vertical: 'bottom'},
92 + var $input=$(input);
93 + var iid=parseInt($input.attr('id').split('-')[2]);
94 + if(iid>=start&&iid<=stop){
95 + $input.prop('checked',value)
96 + }
97 + });
98 + }
115
99
100 + $('tr input').click( function(e) {
101 + if (e.shiftKey) {
102 + stop = parseInt($(this).attr('id').split('-')[2]);
103 + var orig_stop = stop
104 + if (typeof start !== 'undefined') {
105 + if (start > stop) {
106 + var tmp = start;
107 + start = stop;
108 + stop = tmp;
109 + }
110 + shiftclick(start,stop,$(this).is(':checked') )
111 + }
112 + start = orig_stop
113 + } else {
114 + start = parseInt($(this).attr('id').split('-')[2]);
115 + }
116 + });
117 +
118 + $('.input-group.date').datetimepicker({
119 + format: 'DD/MMM/YYYY',
120 + showTodayButton: true,
121 + locale: 'en',
122 + widgetPositioning: {horizontal: 'auto', vertical: 'bottom'},
123 +
124 + });
125 +
126 + $('.datatable').DataTable({
127 + paging: false
128 + });
116 });
129 });
117 - $('.datatable').DataTable({
118 - paging: false
119 - });
@@ -1,40 +1,46
1 :css
1 :css
2 .fix-width {
2 .fix-width {
3 font-family: "Consolas, Monaco, Droid Sans Mono,Mono, Monospace,Courier"
3 font-family: "Consolas, Monaco, Droid Sans Mono,Mono, Monospace,Courier"
4 }
4 }
5
5
6 %h1 Problem stat: #{@problem.name}
6 %h1 Problem stat: #{@problem.name}
7 - %h2 Overview
7 +
8 + .row.mb-3
9 + .col-md-8
10 + .card
11 + .card-body
12 + %h2.card-title Submission History
13 + %canvas#chart{height: '50px'}
8
14
9 - .row
15 + .col-md-4
10 - .col-md-2
16 + .card
11 - %strong Name:
17 + .card-body
12 - .col-md-10
18 + %h2.card-title General Info
13 - = @problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
19 + .row
14 - = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, @problem
20 + .col-sm-6
15 - .row
21 + Name
16 - .col-md-2.strong
22 + .col-sm-6
17 - %strong Submissions:
23 + = @problem.full_name #in_place_editor_field :problem, :full_name, {}, :rows=>1
18 - .col-md-10
24 + = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, @problem
19 - = @submissions.count
25 + .row
20 - .row
26 + .col-sm-6
21 - .col-md-2.strong
27 + Subs
22 - %strong Solved/Attemped User
28 + .col-sm-6
23 - .col-md-10
29 + = @submissions.count
24 - #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
30 + .row
25 -
31 + .col-sm-6
26 -
32 + Solved/Attempted User
27 - %h2 Submissions Count
33 + .col-sm-6
28 - = render partial: 'application/bar_graph', locals: { histogram: @histogram }
34 + #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
29
35
30 %h2 Submissions
36 %h2 Submissions
31 - if @submissions and @submissions.count > 0
37 - if @submissions and @submissions.count > 0
32 %table#main_table.table.table-condensed.table-striped
38 %table#main_table.table.table-condensed.table-striped
33 %thead
39 %thead
34 %tr
40 %tr
35 %th ID
41 %th ID
36 %th Login
42 %th Login
37 %th Name
43 %th Name
38 %th Submitted_at
44 %th Submitted_at
39 %th language
45 %th language
40 %th Points
46 %th Points
@@ -49,15 +55,36
49 %td= link_to sub.id, submission_path(sub)
55 %td= link_to sub.id, submission_path(sub)
50 %td= link_to sub.user.login, stat_user_path(sub.user)
56 %td= link_to sub.user.login, stat_user_path(sub.user)
51 %td= sub.user.full_name
57 %td= sub.user.full_name
52 %td{data: {order: sub.submitted_at}}= time_ago_in_words(sub.submitted_at) + " ago"
58 %td{data: {order: sub.submitted_at}}= time_ago_in_words(sub.submitted_at) + " ago"
53 %td= sub.language.name
59 %td= sub.language.name
54 %td= sub.points
60 %td= sub.points
55 %td.fix-width= sub.grader_comment
61 %td.fix-width= sub.grader_comment
56 %td= sub.ip_address
62 %td= sub.ip_address
57 - else
63 - else
58 No submission
64 No submission
59
65
60 :javascript
66 :javascript
61 - $("#main_table").DataTable({
67 + $(document).on('import-map-loaded',(e) => {
62 - paging: false
68 + //init datatable
69 + $("#main_table").DataTable({
70 + paging: false
71 + });
72 +
73 + //history graph
74 + data = #{@chart_dataset}
75 + config = {
76 + type: 'bar',
77 + data: data,
78 + options: {
79 + plugins: {
80 + legend: {
81 + display: false
82 + },
83 + },
84 + }
85 + }
86 + Chart.defaults.font.size = 15
87 + //Chart.defaults.font.family = 'Sarabun Light'
88 + chart = new Chart($('#chart'),config)
63 });
89 });
90 +
@@ -1,51 +1,55
1 - - content_for :header do
2 - = javascript_include_tag 'local_jquery'
3 -
4 - :javascript
5 - $(function () {
6 - $('#submission_table').tablesorter({widgets: ['zebra']});
7 - });
8
1
9 :css
2 :css
10 .fix-width {
3 .fix-width {
11 font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier;
4 font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier;
12 }
5 }
13
6
14 - %h1= @user.full_name
7 + %h1 User stats
8 + %h5.text-secondary= @user.login
9 +
10 + .row.my-3
11 + .col-md-8
12 + .card
13 + .card-body
14 + %h2.card-title Sub Info
15 + %canvas#chart{height: '50px'}
15
16
16 - <b>Login:</b> #{@user.login} <br/>
17 + .col-md-4
17 - <b>Full name:</b> #{@user.full_name} <br />
18 + .card
19 + .card-body
20 + %h2.card-title General Info
21 + .row
22 + .col-sm-6.fw-bold
23 + Login
24 + .col-sm-6
25 + = @user.login
26 + .row
27 + .col-sm-6.fw-bold
28 + Full name
29 + .col-sm-6
30 + = @user.full_name
31 + .row
32 + .col-sm-6.fw-bold
33 + Subs
34 + .col-sm-6
35 + = @summary[:count]
36 + .row
37 + .col-sm-6.fw-bold
38 + Solved/Attempted Problem
39 + .col-sm-6
40 + #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
18
41
19
42
20 - %h2 Problem Stat
43 + %table#main_table.table.table-striped
21 - %table.info
22 - %thead
23 - %tr.info-head
24 - %th Stat
25 - %th Value
26 - %tbody
27 - %tr{class: cycle('info-even','info-odd')}
28 - %td.info_param Submissions
29 - %td= @summary[:count]
30 - %tr{class: cycle('info-even','info-odd')}
31 - %td.info_param Solved/Attempted Problem
32 - %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
33 -
34 - %h2 Submission History
35 -
36 - =render partial: 'application/bar_graph', locals: {histogram: @histogram, param: {bar_width: 7}}
37 -
38 -
39 - %table#submission_table.table.table-striped
40 %thead
44 %thead
41 %tr
45 %tr
42 %th ID
46 %th ID
43 %th Problem code
47 %th Problem code
44 %th Problem full name
48 %th Problem full name
45 %th Language
49 %th Language
46 %th Submitted at
50 %th Submitted at
47 %th Result
51 %th Result
48 %th Score
52 %th Score
49 - if session[:admin]
53 - if session[:admin]
50 %th IP
54 %th IP
51 %tbody
55 %tbody
@@ -56,15 +60,36
56 %td= link_to s.problem.name, stat_problem_path(s.problem)
60 %td= link_to s.problem.name, stat_problem_path(s.problem)
57 %td= s.problem.full_name
61 %td= s.problem.full_name
58 %td= s.language.pretty_name
62 %td= s.language.pretty_name
59 %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago)
63 %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago)
60 %td.fix-width= s.grader_comment
64 %td.fix-width= s.grader_comment
61 %td= ( s.try(:points) ? (s.points*100/s.problem.full_score) : '' )
65 %td= ( s.try(:points) ? (s.points*100/s.problem.full_score) : '' )
62 - if session[:admin]
66 - if session[:admin]
63 %td= s.ip_address
67 %td= s.ip_address
64
68
65
69
66
70
67 :javascript
71 :javascript
68 - $("#submission_table").DataTable({
72 + $(document).on('import-map-loaded',(e) => {
69 - paging: false
73 + //init datatable
74 + $("#main_table").DataTable({
75 + paging: false
76 + });
77 +
78 + //history graph
79 + data = #{@chart_dataset}
80 + config = {
81 + type: 'bar',
82 + data: data,
83 + options: {
84 + plugins: {
85 + legend: {
86 + display: false
87 + },
88 + },
89 + }
90 + }
91 + Chart.defaults.font.size = 15
92 + //Chart.defaults.font.family = 'Sarabun Light'
93 + chart = new Chart($('#chart'),config)
70 });
94 });
95 +
deleted file
You need to be logged in to leave comments. Login now