Description:
add warning for check
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@22 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r9:8595e5379ca6 - - 2 files changed: 32 inserted, 0 deleted
@@ -116,45 +116,73 | |||
|
116 | 116 | if (ARGV.length >= 1) and (ARGV[0]=='stop') |
|
117 | 117 | stop_grader |
|
118 | 118 | puts "stop file created" |
|
119 | 119 | exit(0) |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | if check_stopfile |
|
123 | 123 | puts "stop file exists" |
|
124 | 124 | clear_stopfile |
|
125 | 125 | exit(0) |
|
126 | 126 | end |
|
127 | 127 | |
|
128 | + grader_mode = 'queue' | |
|
128 | 129 | if ARGV.length >= 1 |
|
129 | 130 | GRADER_ENV = ARGV[0] |
|
131 | + if ARGV.length >=2 | |
|
132 | + grader_mode = ARGV[1] | |
|
133 | + end | |
|
130 | 134 | else |
|
131 | 135 | GRADER_ENV = 'exam' |
|
132 | 136 | end |
|
133 | 137 | |
|
134 | 138 | puts "environment: #{GRADER_ENV}" |
|
135 | 139 | require File.dirname(__FILE__) + "/environment.rb" |
|
136 | 140 | |
|
137 | 141 | #main program |
|
138 | 142 | talk 'Reading rails environment' |
|
139 | 143 | |
|
140 | 144 | RAILS_ENV = 'development' |
|
141 | 145 | require RAILS_APP_DIR + '/config/environment' |
|
142 | 146 | |
|
147 | + case grader_mode | |
|
148 | + when "queue" | |
|
143 | 149 | talk 'Grader queue' |
|
144 | 150 | while true |
|
145 | 151 | if check_stopfile # created by calling grader stop |
|
146 | 152 | clear_stopfile |
|
147 | 153 | puts "stopped" |
|
148 | 154 | exit(0) |
|
149 | 155 | end |
|
150 | 156 | |
|
151 | 157 | task = Task.find(:first, :order => 'created_at') |
|
152 | 158 | if task!=nil |
|
153 | 159 | grade(task.submission_id) |
|
154 | 160 | task.destroy |
|
155 | 161 | else |
|
156 | 162 | sleep(1) |
|
157 | 163 | end |
|
158 | 164 | end |
|
159 | 165 | |
|
166 | + when "prob" | |
|
167 | + prob = Problem.find_by_name(ARGV[2]) | |
|
168 | + if prob==nil | |
|
169 | + puts "cannot find problem: #{ARGV[2]}" | |
|
170 | + exit(0) | |
|
171 | + end | |
|
172 | + users = User.find(:all) | |
|
173 | + users.each do |u| | |
|
174 | + puts "user: #{u.login}" | |
|
175 | + last_sub = Submission.find(:first, | |
|
176 | + :conditions => "user_id = #{u.id} and " + | |
|
177 | + "problem_id = #{prob.id}", | |
|
178 | + :order => 'submitted_at DESC') | |
|
179 | + if last_sub!=nil | |
|
180 | + grade(last_sub.id) | |
|
181 | + end | |
|
182 | + end | |
|
183 | + end | |
|
160 | 184 | |
|
185 | + | |
|
186 | + | |
|
187 | + | |
|
188 | + |
@@ -35,24 +35,28 | |||
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | report_wrong = lambda { |
|
38 | 38 | result_file.write "Incorrect\n" |
|
39 | 39 | result_file.write "0\n" |
|
40 | 40 | result_file.close |
|
41 | 41 | exit(0) |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | ################## |
|
45 | 45 | # Your code here # |
|
46 | 46 | ################## |
|
47 | + | |
|
48 | + puts "YOU HAVE TO EDIT THE CHECKING CODE HERE: #{__FILE__}" | |
|
49 | + exit(127) | |
|
50 | + | |
|
47 | 51 | num_pattern = /^[0-9]*/ |
|
48 | 52 | if (output_file_content =~ num_pattern) == nil |
|
49 | 53 | report_wrong.call |
|
50 | 54 | end |
|
51 | 55 | |
|
52 | 56 | output_i = output_file_content.to_i |
|
53 | 57 | answer_i = answer_file_content.to_i |
|
54 | 58 | |
|
55 | 59 | if output_i == answer_i |
|
56 | 60 | report_correct.call |
|
57 | 61 | else |
|
58 | 62 | report_wrong.call |
You need to be logged in to leave comments.
Login now