Description:
checks solution by lines
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r384:7f104b042855 - - 1 file changed: 9 inserted, 3 deleted

@@ -278,56 +278,62
278
278
279 if !problem or !problem.available
279 if !problem or !problem.available
280 flash[:notice] = 'Error: problem is not available'
280 flash[:notice] = 'Error: problem is not available'
281 redirect_to :action => 'list' and return
281 redirect_to :action => 'list' and return
282 end
282 end
283
283
284 @current_problem = problem
284 @current_problem = problem
285 test_pair = TestPair.get_for(problem, false)
285 test_pair = TestPair.get_for(problem, false)
286 if (params['output_file']) and (params['output_file']!='')
286 if (params['output_file']) and (params['output_file']!='')
287 output = params['output_file'].read
287 output = params['output_file'].read
288
288
289 @grading_result = grade(output, test_pair.solution)
289 @grading_result = grade(output, test_pair.solution)
290 prepare_list_information
290 prepare_list_information
291 render :action => 'list' and return
291 render :action => 'list' and return
292 else
292 else
293 flash[:notice] = 'Error: output file errors'
293 flash[:notice] = 'Error: output file errors'
294 prepare_list_information
294 prepare_list_information
295 render :action => 'list' and return
295 render :action => 'list' and return
296 end
296 end
297 end
297 end
298
298
299 protected
299 protected
300
300
301 def grade(output, solution)
301 def grade(output, solution)
302 - out_items = output.split
302 + out_items = output.split("\n")
303 - sol_items = solution.split
303 + sol_items = solution.split("\n")
304 res = ''
304 res = ''
305 f = 0
305 f = 0
306 s = 0
306 s = 0
307 sol_items.length.times do |i|
307 sol_items.length.times do |i|
308 f += 1
308 f += 1
309 - if out_items[i] == sol_items[i]
309 + si = sol_items[i].chomp
310 + if out_items[i]
311 + oi = out_items[i].chomp
312 + else
313 + oi = ''
314 + end
315 + if oi == si
310 res = res + 'P'
316 res = res + 'P'
311 s += 1
317 s += 1
312 else
318 else
313 res = res + '-'
319 res = res + '-'
314 end
320 end
315 end
321 end
316 return { :score => s, :full_score => f, :msg => res }
322 return { :score => s, :full_score => f, :msg => res }
317 end
323 end
318
324
319 def prepare_announcements(recent=nil)
325 def prepare_announcements(recent=nil)
320 if GraderConfiguration.show_tasks_to?(@user)
326 if GraderConfiguration.show_tasks_to?(@user)
321 @announcements = Announcement.find_published(true)
327 @announcements = Announcement.find_published(true)
322 else
328 else
323 @announcements = Announcement.find_published
329 @announcements = Announcement.find_published
324 end
330 end
325 if recent!=nil
331 if recent!=nil
326 recent_id = recent.to_i
332 recent_id = recent.to_i
327 @announcements = @announcements.find_all { |a| a.id > recent_id }
333 @announcements = @announcements.find_all { |a| a.id > recent_id }
328 end
334 end
329 end
335 end
330
336
331 def prepare_timeout_information(problems)
337 def prepare_timeout_information(problems)
332 @submission_timeouts = {}
338 @submission_timeouts = {}
333 problems.each do |problem|
339 problems.each do |problem|
You need to be logged in to leave comments. Login now