# HG changeset patch # User Nattee Niparnan # Date 2014-08-12 08:44:55 # Node ID 5c6f0b732e70f777c7b2464b57e1a43d2db03a7a # Parent 8026f5b1cfcacaa7c83785576d3d3e42c05141a2 handle the case when problem id or submission id is null. Grader will simply skip such request. Add more report on console (for command line grading) (mercurial grafted from d233105d3965c5368c9b33125f390e39b25f910e) diff --git a/grader b/grader --- a/grader +++ b/grader @@ -358,7 +358,7 @@ begin submission = Submission.find(sub_id.to_i) rescue ActiveRecord::RecordNotFound - puts "Record not found" + puts "Submission #{sub_id} not found" submission = nil end diff --git a/lib/engine.rb b/lib/engine.rb --- a/lib/engine.rb +++ b/lib/engine.rb @@ -36,35 +36,35 @@ user = submission.user problem = submission.problem - # TODO: will have to create real exception for this - if user==nil or problem == nil - @reporter.report_error(submission,"Grading error: problem with submission") - #raise "engine: user or problem is nil" - end - - # TODO: this is another hack so that output only task can be judged - if submission.language!=nil - language = submission.language.name - lang_ext = submission.language.ext - else - language = 'c' - lang_ext = 'c' - end + begin + # TODO: will have to create real exception for this + if user==nil or problem == nil + @reporter.report_error(submission,"Grading error: problem with submission") + raise "engine: user or problem is nil" + end - # This is needed because older version of std-scripts/compile - # only look for c++. - if language == 'cpp' - language = 'c++' - end + # TODO: this is another hack so that output only task can be judged + if submission.language!=nil + language = submission.language.name + lang_ext = submission.language.ext + else + language = 'c' + lang_ext = 'c' + end - # COMMENT: should it be only source.ext? - if problem!=nil - source_name = "#{problem.name}.#{lang_ext}" - else - source_name = "source.#{lang_ext}" - end + # This is needed because older version of std-scripts/compile + # only look for c++. + if language == 'cpp' + language = 'c++' + end - begin + # COMMENT: should it be only source.ext? + if problem!=nil + source_name = "#{problem.name}.#{lang_ext}" + else + source_name = "source.#{lang_ext}" + end + grading_dir = @room_maker.produce_grading_room(submission) @room_maker.save_source(submission,source_name) problem_home = @room_maker.find_problem_home(submission) @@ -74,8 +74,7 @@ if !FileTest.exist?(problem_home) puts "PROBLEM DIR: #{problem_home}" - puts "No test data. (check problem dir)" - raise "No test data." + raise "engine: No test data." end dinit = DirInit::Manager.new(problem_home) @@ -97,6 +96,7 @@ rescue RuntimeError => msg @reporter.report_error(submission, msg) + puts "ERROR: #{msg}" ensure @room_maker.clean_up(submission) @@ -131,7 +131,7 @@ script_dir = "#{problem_home}/script" std_script_dir = get_std_script_dir - raise "std-script directory not found" if !FileTest.exist?(std_script_dir) + raise "engine: std-script directory not found" if !FileTest.exist?(std_script_dir) scripts = Dir[std_script_dir + '/*']