Description:
updated graded_at fields for graded submissions
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r387:d79d1e42bcbb - - 1 file changed: 1 inserted, 0 deleted

@@ -1,47 +1,48
1 #!/usr/bin/env ruby
1 #!/usr/bin/env ruby
2
2
3 APP_PATH = File.expand_path('../../config/application', __FILE__)
3 APP_PATH = File.expand_path('../../config/application', __FILE__)
4 require File.expand_path('../../config/boot', __FILE__)
4 require File.expand_path('../../config/boot', __FILE__)
5 require APP_PATH
5 require APP_PATH
6
6
7 # set Rails.env here if desired
7 # set Rails.env here if desired
8 Rails.application.require_environment!
8 Rails.application.require_environment!
9
9
10 def main
10 def main
11 if ARGV.length != 1
11 if ARGV.length != 1
12 puts "Usage: contest_grade_prob.rb [problem_name]"
12 puts "Usage: contest_grade_prob.rb [problem_name]"
13 exit(0)
13 exit(0)
14 end
14 end
15
15
16 problem_name = ARGV[0]
16 problem_name = ARGV[0]
17 problem = Problem.where(:name => problem_name).first
17 problem = Problem.where(:name => problem_name).first
18 if !problem
18 if !problem
19 puts "Problem not found"
19 puts "Problem not found"
20 exit(0)
20 exit(0)
21 end
21 end
22
22
23 problem.full_score = 100
23 problem.full_score = 100
24 problem.save
24 problem.save
25
25
26 test_pair = TestPair.get_for(problem, true)
26 test_pair = TestPair.get_for(problem, true)
27
27
28 User.all.each do |u|
28 User.all.each do |u|
29 puts "#{u.login}:"
29 puts "#{u.login}:"
30 submissions = Submission.find_all_by_user_problem(u.id, problem.id)
30 submissions = Submission.find_all_by_user_problem(u.id, problem.id)
31 submissions.each do |sub|
31 submissions.each do |sub|
32 result = test_pair.grade(sub.output)
32 result = test_pair.grade(sub.output)
33 result2 = test_pair.grade(sub.source)
33 result2 = test_pair.grade(sub.source)
34 if result2[:score] > result[:score]
34 if result2[:score] > result[:score]
35 result = result2
35 result = result2
36 puts "Use source field (#{sub.id})"
36 puts "Use source field (#{sub.id})"
37 end
37 end
38
38
39 full_score = result[:full_score]
39 full_score = result[:full_score]
40 sub.points = result[:score]*100 / full_score
40 sub.points = result[:score]*100 / full_score
41 sub.grader_comment = result[:msg]
41 sub.grader_comment = result[:msg]
42 + sub.graded_at = Time.now.gmtime
42 sub.save
43 sub.save
43 end
44 end
44 end
45 end
45 end
46 end
46
47
47 main
48 main
You need to be logged in to leave comments. Login now