diff --git a/lib/submission_helper.rb b/lib/submission_helper.rb --- a/lib/submission_helper.rb +++ b/lib/submission_helper.rb @@ -55,21 +55,37 @@ result_fname = "#{test_result_dir}/result" comment_fname = "#{test_result_dir}/comment" if FileTest.exist?(result_fname) - result_file = File.open(result_fname) - result = result_file.readline.to_i - result_file.close - - comment_file = File.open(comment_fname) - comment = comment_file.readline.chomp - comment_file.close - + comment = "" + begin + result_file = File.open(result_fname) + result = result_file.readline.to_i + result_file.close + rescue + result = 0 + comment = "error reading result file." + end + + begin + comment_file = File.open(comment_fname) + comment += comment_file.readline.chomp + comment_file.close + rescue + comment += "" + end + return {:points => result, :comment => comment, :cmp_msg => cmp_msg} else - return {:points => 0, - :comment => 'compile error', - :cmp_msg => cmp_msg} + if FileTest.exist?("#{test_result_dir}/a.out") + return {:points => 0, + :comment => 'error during grading', + :cmp_msg => cmp_msg} + else + return {:points => 0, + :comment => 'compile error', + :cmp_msg => cmp_msg} + end end end diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -45,16 +45,17 @@ run.tests.each do |test_num| result_file_name = "#{test_num}/result" if not File.exists?(result_file_name) + run_comment += "result file for test #{test_num} not found\n" + run_comment_short += 'x' log "Cannot find the file #{test_num}/result!" - exit(127) + else + result_file = File.new(result_file_name, "r") + result_file_lines = result_file.readlines + run_score = run_score + result_file_lines[1].to_i + run_comment += result_file_lines[0] + run_comment_short += char_comment(result_file_lines[0]) + result_file.close end - - result_file = File.new(result_file_name, "r") - result_file_lines = result_file.readlines - run_score = run_score + result_file_lines[1].to_i - run_comment += result_file_lines[0] - run_comment_short += char_comment(result_file_lines[0]) - result_file.close end run_result_file = File.new("result-#{k}", "w") diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -16,6 +16,7 @@ def execute(command, error_message="") if not system(command) + log "ERROR: #{error_message}" puts "ERROR: #{error_message}" exit(127) end diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -132,6 +132,7 @@ log "Checking the output..." log check_command if not system(check_command) + log "Problem with check script" exit(127) end