Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r511:d90a3f1b39d0 - - 8 files changed: 102 inserted, 35 deleted
@@ -0,0 +1,34 | |||
|
1 | + :css | |
|
2 | + .fix-width { | |
|
3 | + font-family: "Consolas, Monaco, Droid Sans Mono,Mono, Monospace,Courier" | |
|
4 | + } | |
|
5 | + | |
|
6 | + %h1 Problem stat: #{@problem.name} | |
|
7 | + %h2 Overview | |
|
8 | + | |
|
9 | + %h2 Submissions | |
|
10 | + - if @submissions and @submissions.count > 0 | |
|
11 | + %table.info#main_table | |
|
12 | + %thead | |
|
13 | + %tr.info-head | |
|
14 | + %th ID | |
|
15 | + %th Login | |
|
16 | + %th Name | |
|
17 | + %th Submitted_at | |
|
18 | + %th Points | |
|
19 | + %th comment | |
|
20 | + %tbody | |
|
21 | + - row_odd,curr = true,'' | |
|
22 | + - @submissions.each do |sub| | |
|
23 | + - next unless sub.user | |
|
24 | + - row_odd,curr = !row_odd, sub.user if curr != sub.user | |
|
25 | + %tr{class: row_odd ? "info-odd" : "info-even"} | |
|
26 | + %td= link_to sub.id, controller: 'graders', action: 'submission', id: sub.id | |
|
27 | + %td= link_to sub.user.login, controller: :users, action: :profile, id: sub.user.id | |
|
28 | + %td= sub.user.full_name | |
|
29 | + %td= time_ago_in_words(sub.submitted_at) + " ago" | |
|
30 | + %td= sub.points | |
|
31 | + %td.fix-width= sub.grader_comment | |
|
32 | + - else | |
|
33 | + No submission | |
|
34 | + |
@@ -131,7 +131,7 | |||
|
131 | 131 | if !@problem.available |
|
132 | 132 | redirect_to :controller => 'main', :action => 'list' |
|
133 | 133 | else |
|
134 |
- @submissions = Submission. |
|
|
134 | + @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id) | |
|
135 | 135 | end |
|
136 | 136 | end |
|
137 | 137 |
@@ -1,5 +1,8 | |||
|
1 | + require 'csv' | |
|
2 | + | |
|
1 | 3 | class UserAdminController < ApplicationController |
|
2 | 4 | |
|
5 | + | |
|
3 | 6 | include MailHelperMethods |
|
4 | 7 | |
|
5 | 8 | before_filter :admin_authorization |
@@ -122,7 +125,11 | |||
|
122 | 125 | end |
|
123 | 126 | |
|
124 | 127 | def user_stat |
|
128 | + if params[:commit] == 'download csv' | |
|
129 | + @problems = Problem.all | |
|
130 | + else | |
|
125 | 131 | @problems = Problem.find_available_problems |
|
132 | + end | |
|
126 | 133 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
127 | 134 | @scorearray = Array.new |
|
128 | 135 | @users.each do |u| |
@@ -138,10 +145,21 | |||
|
138 | 145 | end |
|
139 | 146 | @scorearray << ustat |
|
140 | 147 | end |
|
148 | + | |
|
149 | + if params[:commit] == 'download csv' then | |
|
150 | + csv = gen_csv_from_scorearray(@scorearray,@problems) | |
|
151 | + send_data csv, filename: 'last_score.csv' | |
|
152 | + else | |
|
153 | + render template: 'user_admin/user_stat' | |
|
154 | + end | |
|
141 | 155 | end |
|
142 | 156 | |
|
143 | 157 | def user_stat_max |
|
158 | + if params[:commit] == 'download csv' | |
|
159 | + @problems = Problem.all | |
|
160 | + else | |
|
144 | 161 | @problems = Problem.find_available_problems |
|
162 | + end | |
|
145 | 163 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
146 | 164 | @scorearray = Array.new |
|
147 | 165 | #set up range from param |
@@ -160,8 +178,13 | |||
|
160 | 178 | @scorearray << ustat |
|
161 | 179 | end |
|
162 | 180 | |
|
181 | + if params[:commit] == 'download csv' then | |
|
182 | + csv = gen_csv_from_scorearray(@scorearray,@problems) | |
|
183 | + send_data csv, filename: 'max_score.csv' | |
|
184 | + else | |
|
163 | 185 | render template: 'user_admin/user_stat' |
|
164 | 186 | end |
|
187 | + end | |
|
165 | 188 | |
|
166 | 189 | def import |
|
167 | 190 | if params[:file]=='' |
@@ -475,4 +498,35 | |||
|
475 | 498 | end |
|
476 | 499 | return [@contest, @users] |
|
477 | 500 | end |
|
501 | + | |
|
502 | + def gen_csv_from_scorearray(scorearray,problem) | |
|
503 | + CSV.generate do |csv| | |
|
504 | + #add header | |
|
505 | + header = ['User','Name', 'Activated?', 'Logged in', 'Contest'] | |
|
506 | + problem.each { |p| header << p.name } | |
|
507 | + header += ['Total','Passed'] | |
|
508 | + csv << header | |
|
509 | + #add data | |
|
510 | + scorearray.each do |sc| | |
|
511 | + total = num_passed = 0 | |
|
512 | + row = Array.new | |
|
513 | + sc.each_index do |i| | |
|
514 | + if i == 0 | |
|
515 | + row << sc[i].login | |
|
516 | + row << sc[i].full_name | |
|
517 | + row << sc[i].activated | |
|
518 | + row << (sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no') | |
|
519 | + row << sc[i].contests.collect {|c| c.name}.join(', ') | |
|
520 | + else | |
|
521 | + row << sc[i][0] | |
|
522 | + total += sc[i][0] | |
|
523 | + num_passed += 1 if sc[i][1] | |
|
478 | 524 | end |
|
525 | + end | |
|
526 | + row << total | |
|
527 | + row << num_passed | |
|
528 | + csv << row | |
|
529 | + end | |
|
530 | + end | |
|
531 | + end | |
|
532 | + end |
@@ -25,7 +25,7 | |||
|
25 | 25 | |
|
26 | 26 | def self.find_all_last_by_problem(problem_id) |
|
27 | 27 | # need to put in SQL command, maybe there's a better way |
|
28 | - Submission.find_by_sql("SELECT * FROM submissions " + | |
|
28 | + Submission.includes(:user).find_by_sql("SELECT * FROM submissions " + | |
|
29 | 29 | "WHERE id = " + |
|
30 | 30 | "(SELECT MAX(id) FROM submissions AS subs " + |
|
31 | 31 | "WHERE subs.user_id = submissions.user_id AND " + |
@@ -3,7 +3,10 | |||
|
3 | 3 | <%= "#{problem_counter+1}" %> |
|
4 | 4 | </td> |
|
5 | 5 | <td> |
|
6 |
- <%= " |
|
|
6 | + <%= "#{problem.name}"%> | |
|
7 | + </td> | |
|
8 | + <td> | |
|
9 | + <%= "#{problem.full_name}" %> | |
|
7 | 10 | <%= link_to_description_if_any "[#{t 'main.problem_desc'}]", problem %> |
|
8 | 11 | </td> |
|
9 | 12 | <td align="center"> |
@@ -25,7 +25,8 | |||
|
25 | 25 | %table.info |
|
26 | 26 | %tr.info-head |
|
27 | 27 | %th |
|
28 | - %th Tasks | |
|
28 | + %th Tasks name | |
|
29 | + %th Full name | |
|
29 | 30 | %th # of sub(s) |
|
30 | 31 | %th Results |
|
31 | 32 | = render :partial => 'problem', :collection => @problems |
@@ -37,7 +38,8 | |||
|
37 | 38 | %table.info |
|
38 | 39 | %tr.info-head |
|
39 | 40 | %th |
|
40 | - %th Tasks | |
|
41 | + %th Tasks name | |
|
42 | + %th Full name | |
|
41 | 43 | %th # of sub(s) |
|
42 | 44 | %th Results |
|
43 | 45 | = render :partial => 'problem', :collection => cp[:problems] |
@@ -19,9 +19,12 | |||
|
19 | 19 | = render partial: 'submission_range' |
|
20 | 20 | |
|
21 | 21 |
- if params[:action] == 'user_stat' |
|
22 |
- |
|
|
22 | + %h3 Latest score | |
|
23 | + = link_to '[download csv with all problems]', controller: :user_admin, action: :user_stat, commit: 'download csv' | |
|
23 | 24 | - else |
|
25 | + %h3 Max score | |
|
24 | 26 | = link_to '[Show only latest submissions]', controller: :user_admin, action: :user_stat |
|
27 | + = link_to '[download csv with all problems]', controller: :user_admin, action: :user_stat_max, commit: 'download csv' | |
|
25 | 28 | |
|
26 | 29 | %table.tablesorter-cafe#my_table |
|
27 | 30 | %thead |
deleted file |
You need to be logged in to leave comments.
Login now