diff --git a/lib/test_request_helper.rb b/lib/test_request_helper.rb --- a/lib/test_request_helper.rb +++ b/lib/test_request_helper.rb @@ -27,8 +27,10 @@ # The program would see this file only if it is copied # to the sandbox directory later. The run script should do it. # - cmd = "cp #{test_request.input_file_name}.files/* #{grading_room}" - system(cmd) + if FileTest.exists?("#{test_request.input_file_name}.files") + cmd = "cp #{test_request.input_file_name}.files/* #{grading_room}" + system(cmd) + end grading_room end diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -46,7 +46,7 @@ (1..(problem.runs.length-1)).each do |k| log "grade run #{k}" run = problem.runs[k] - run_score = 0 + run_score = nil run_comment = '' run_comment_short = '' run.tests.each do |test_num| @@ -59,27 +59,25 @@ result_file = File.new(result_file_name, "r") result_file_lines = result_file.readlines if result_file_lines.length>=2 - run_score = run_score + result_file_lines[1].to_i + current_run_score = result_file_lines[1].to_i run_comment += result_file_lines[0] run_comment_short += char_comment(result_file_lines[0].chomp) else + current_run_score = 0 run_comment += "result file for test #{test_num} error\n" run_comment_short += RUN_ERROR_MARK log "Error in #{test_num}/result!" end + + # the score of this run should be the minimum of the score for + # each test case + if (run_score==nil) or (run_score>current_run_score) + run_score = current_run_score + end result_file.close end end - # find total score for this run - run_total_score = 0 - problem = Problem.get_instance - run.tests.each { |test_num| run_total_score += problem.get_score(test_num) } - - if run_total_score!=run_score # fail in some test cases, fail the run - run_score = 0 - end - run_result_file = File.new("result-#{k}", "w") run_result_file.write run_score run_result_file.write "\n" diff --git a/templates/all_tests.cfg.erb b/templates/all_tests.cfg.erb --- a/templates/all_tests.cfg.erb +++ b/templates/all_tests.cfg.erb @@ -13,7 +13,7 @@ <% if testrun.length==1 %> scores 10 <% else %> - scores 10 <% (testrun.length-1).times do %>,0 <% end %> + scores 10 <% (testrun.length-1).times do %>,10 <% end %> <% end %> end <% end %> diff --git a/test/data/ev/test_normal/test_cases/all_tests.cfg b/test/data/ev/test_normal/test_cases/all_tests.cfg --- a/test/data/ev/test_normal/test_cases/all_tests.cfg +++ b/test/data/ev/test_normal/test_cases/all_tests.cfg @@ -7,14 +7,14 @@ run 1 do tests 1, 2 - scores 10, 20 + scores 30, 30 time_limits 1, 2 mem_limits 5, 6 end run 2 do tests 3, 4, 5, 6, 7 - score_each 10 + score_each 50 time_limit_each 3 mem_limit_each 3 end @@ -24,16 +24,17 @@ end test 8 do - score 30 + score 55 time_limit 3 mem_limit 10 end test 9 do - score 15 + score 55 end test 10 do + score 55 time_limit 1 end end