Description:
fix unintended branch
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r815:501db8f544da - - 23 files changed: 89 inserted, 181 deleted
@@ -0,0 +1,89 | |||||
|
|
1 | + def display_manual | ||
|
|
2 | + puts <<-USAGE | ||
|
|
3 | + subtask_score problem last_submision_id sub1_score,sub2_score,sub3_score,.... | ||
|
|
4 | + example: | ||
|
|
5 | + rails runner subtask_score.rb o64_may26_train 102983 10,15,18,18,39 | ||
|
|
6 | + USAGE | ||
|
|
7 | + end | ||
|
|
8 | + | ||
|
|
9 | + def process_options | ||
|
|
10 | + res = {} | ||
|
|
11 | + if ARGV.length == 0 | ||
|
|
12 | + display_manual | ||
|
|
13 | + exit(1) | ||
|
|
14 | + end | ||
|
|
15 | + | ||
|
|
16 | + res[:prob] = ARGV[0] | ||
|
|
17 | + res[:last_sub_id] = ARGV[1].to_i | ||
|
|
18 | + res[:score] = ARGV[2].split(',').map {|x| x.to_i} | ||
|
|
19 | + return res | ||
|
|
20 | + end | ||
|
|
21 | + | ||
|
|
22 | + def process_subtask(st) | ||
|
|
23 | + return true if /^P+$/.match(st) | ||
|
|
24 | + return false | ||
|
|
25 | + end | ||
|
|
26 | + | ||
|
|
27 | + def process_comment(st) | ||
|
|
28 | + res = [] | ||
|
|
29 | + loop do | ||
|
|
30 | + break if st.length == 0 | ||
|
|
31 | + if st[0] == '[' | ||
|
|
32 | + #subtask | ||
|
|
33 | + subtask = st.slice!(0..(st.index(']'))) | ||
|
|
34 | + res << process_subtask(subtask[1..-2]) | ||
|
|
35 | + else #not subtask | ||
|
|
36 | + res << process_subtask(st[0]) | ||
|
|
37 | + st.slice!(0) | ||
|
|
38 | + end | ||
|
|
39 | + end | ||
|
|
40 | + return res | ||
|
|
41 | + end | ||
|
|
42 | + | ||
|
|
43 | + options = process_options | ||
|
|
44 | + scoring = options[:score] | ||
|
|
45 | + puts "doing problem #{options[:prob]}" | ||
|
|
46 | + puts " consider only submission with id not more than #{options[:last_sub_id]}" | ||
|
|
47 | + scoring.each.with_index { |x,i| puts " subtask#{i}: #{x}" } | ||
|
|
48 | + | ||
|
|
49 | + res = {} | ||
|
|
50 | + | ||
|
|
51 | + p = Problem.where(name: options[:prob]).first | ||
|
|
52 | + unless p | ||
|
|
53 | + puts "Problem #{options[:prob]} not found" | ||
|
|
54 | + exit(2) | ||
|
|
55 | + end | ||
|
|
56 | + | ||
|
|
57 | + p.submissions.where('id <= ?',options[:last_sub_id]).order(:id).each do |sub| | ||
|
|
58 | + unless sub.graded_at | ||
|
|
59 | + puts "skip ungraded submission #{sub.id}" | ||
|
|
60 | + next | ||
|
|
61 | + end | ||
|
|
62 | + if sub.grader_comment == "compilation error" | ||
|
|
63 | + puts "skip uncompilable submission #{sub.id}" | ||
|
|
64 | + next | ||
|
|
65 | + end | ||
|
|
66 | + | ||
|
|
67 | + comment = sub.grader_comment.clone | ||
|
|
68 | + comment_result = process_comment(comment) | ||
|
|
69 | + if comment_result.length != scoring.length | ||
|
|
70 | + puts "ERROR!!! subtask of submission #{sub.id} does not match scoring input" | ||
|
|
71 | + end | ||
|
|
72 | + | ||
|
|
73 | + puts "processing submission #{sub.id} with comment = #{sub.grader_comment} result is #{comment_result}" | ||
|
|
74 | + current = res[sub.user.login] || [false] * scoring.length | ||
|
|
75 | + current.each.with_index do |x,i| | ||
|
|
76 | + if !x && comment_result[i] | ||
|
|
77 | + puts " user #{sub.user.login} just got subtask #{i+1} from this submission" | ||
|
|
78 | + current[i] = true | ||
|
|
79 | + end | ||
|
|
80 | + end | ||
|
|
81 | + res[sub.user.login] = current | ||
|
|
82 | + end | ||
|
|
83 | + | ||
|
|
84 | + puts "----summary-----" | ||
|
|
85 | + res.each do |u,r| | ||
|
|
86 | + score = scoring.clone | ||
|
|
87 | + r.each.with_index { |pass,i| score[i] = 0 unless pass } | ||
|
|
88 | + puts "#{u} #{score.sum} [#{score.join(',')}]" | ||
|
|
89 | + end |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
deleted file |
You need to be logged in to leave comments.
Login now