Description:
add feature check maximum score in submission ranges
available in the [result] admin menu.
A user can enter a range of submissions id and the maximum score per each user,problem
among the submission ranges will be reported
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r397:94216ffe57fe - - 3 files changed: 39 inserted, 6 deleted
@@ -126,18 +126,39 | |||||
|
126 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
126 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
127 | @scorearray = Array.new |
|
127 | @scorearray = Array.new |
|
128 | @users.each do |u| |
|
128 | @users.each do |u| |
|
129 | ustat = Array.new |
|
129 | ustat = Array.new |
|
130 | ustat[0] = u |
|
130 | ustat[0] = u |
|
131 | @problems.each do |p| |
|
131 | @problems.each do |p| |
|
132 |
- |
|
132 | + sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
133 |
- |
|
133 | + if (sub!=nil) and (sub.points!=nil) |
|
134 |
- |
|
134 | + ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
135 | - else |
|
135 | + else |
|
136 |
- |
|
136 | + ustat << [0,false] |
|
137 | - end |
|
137 | + end |
|
|
138 | + end | ||
|
|
139 | + @scorearray << ustat | ||
|
|
140 | + end | ||
|
|
141 | + end | ||
|
|
142 | + | ||
|
|
143 | + def user_stat_max | ||
|
|
144 | + @problems = Problem.find_available_problems | ||
|
|
145 | + @users = User.find(:all, :include => [:contests, :contest_stat]) | ||
|
|
146 | + @scorearray = Array.new | ||
|
|
147 | + #set up range from param | ||
|
|
148 | + since_id = params.fetch(:since_id, 0).to_i | ||
|
|
149 | + until_id = params.fetch(:until_id, 0).to_i | ||
|
|
150 | + @users.each do |u| | ||
|
|
151 | + ustat = Array.new | ||
|
|
152 | + ustat[0] = u | ||
|
|
153 | + @problems.each do |p| | ||
|
|
154 | + max_points = 0 | ||
|
|
155 | + Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| | ||
|
|
156 | + max_points = sub.points if sub and sub.points and (sub.points > max_points) | ||
|
|
157 | + end | ||
|
|
158 | + ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] | ||
|
138 | end |
|
159 | end |
|
139 | @scorearray << ustat |
|
160 | @scorearray << ustat |
|
140 | end |
|
161 | end |
|
141 | end |
|
162 | end |
|
142 |
|
163 | ||
|
143 | def import |
|
164 | def import |
@@ -31,12 +31,19 | |||||
|
31 | "WHERE subs.user_id = submissions.user_id AND " + |
|
31 | "WHERE subs.user_id = submissions.user_id AND " + |
|
32 | "problem_id = " + problem_id.to_s + " " + |
|
32 | "problem_id = " + problem_id.to_s + " " + |
|
33 | "GROUP BY user_id) " + |
|
33 | "GROUP BY user_id) " + |
|
34 | "ORDER BY user_id") |
|
34 | "ORDER BY user_id") |
|
35 | end |
|
35 | end |
|
36 |
|
36 | ||
|
|
37 | + def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id) | ||
|
|
38 | + records = Submission.where(problem_id: problem_id,user_id: user_id) | ||
|
|
39 | + records = records.where('id >= ?',since_id) if since_id > 0 | ||
|
|
40 | + records = records.where('id <= ?',until_id) if until_id > 0 | ||
|
|
41 | + records.all | ||
|
|
42 | + end | ||
|
|
43 | + | ||
|
37 | def self.find_last_for_all_available_problems(user_id) |
|
44 | def self.find_last_for_all_available_problems(user_id) |
|
38 | submissions = Array.new |
|
45 | submissions = Array.new |
|
39 | problems = Problem.find_available_problems |
|
46 | problems = Problem.find_available_problems |
|
40 | problems.each do |problem| |
|
47 | problems.each do |problem| |
|
41 | sub = Submission.find_last_by_user_and_problem(user_id, problem.id) |
|
48 | sub = Submission.find_last_by_user_and_problem(user_id, problem.id) |
|
42 | submissions << sub if sub!=nil |
|
49 | submissions << sub if sub!=nil |
@@ -1,7 +1,12 | |||||
|
1 | <h1>User grading results</h1> |
|
1 | <h1>User grading results</h1> |
|
|
2 | + <h2>Show scores from latest submission</h2> | ||
|
|
3 | + | ||
|
|
4 | + <%= render 'submission_range' %> | ||
|
|
5 | + | ||
|
|
6 | + <p>Latest scores</p> | ||
|
2 |
|
7 | ||
|
3 | <table class="info"> |
|
8 | <table class="info"> |
|
4 | <tr class="info-head"> |
|
9 | <tr class="info-head"> |
|
5 | <th>User</th> |
|
10 | <th>User</th> |
|
6 | <th>Name</th> |
|
11 | <th>Name</th> |
|
7 | <th>Activated?</th> |
|
12 | <th>Activated?</th> |
You need to be logged in to leave comments.
Login now