Show More
Commit Description:
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)...
Commit Description:
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)
File last commit:
Show/Diff file:
Action:
std-script/grade | 106 lines | 2.7 KiB | text/plain | TextLexer |
Jittat Fakcharoenphol
fixed grader to work with ruby 1.9
r137 #!/usr/bin/env ruby
jittat
import original files...
r0
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 CORRECT_MARK = 'P'
INCORRECT_MARK = '-'
TIMEOUT_MARK = 'T'
RUN_ERROR_MARK = 'x'
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}")
fp.close
end
end
jittat
import original files...
r0 def char_comment(comment)
jittat
[web] allow check script to inject the comment...
r40 if comment =~ /[Ii]ncorrect/
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 INCORRECT_MARK
jittat
import original files...
r0 elsif comment =~ /[Cc]orrect/
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 CORRECT_MARK
jittat
import original files...
r0 elsif comment =~ /[Tt]ime/
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 TIMEOUT_MARK
jittat
[web] allow check script to inject the comment...
r40 elsif res = /^[Cc]omment:(.*)$/.match(comment)
res[1]
jittat
import original files...
r0 else
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 RUN_ERROR_MARK # these are run time errors
jittat
import original files...
r0 end
end
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
load "#{problem_home}/test_cases/all_tests.cfg"
problem = Problem.get_instance
if problem.well_formed? == false
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 log "The problem specification is not well formed."
jittat
import original files...
r0 exit(127)
end
all_score = 0
all_comment = ''
(1..(problem.runs.length-1)).each do |k|
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 log "grade run #{k}"
jittat
import original files...
r0 run = problem.runs[k]
jittat
fixed test run scoring bug: now it takes the minimum of each test case's score...
r66 run_score = nil
jittat
import original files...
r0 run_comment = ''
jittat
fix various bugs, save output, save comment...
r8 run_comment_short = ''
jittat
import original files...
r0 run.tests.each do |test_num|
result_file_name = "#{test_num}/result"
if not File.exists?(result_file_name)
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 run_comment += "result file for test #{test_num} not found\n"
jittat
[grader] fixed: import_problem (error in erb calls), check_wrapper; better error handling -- will get 0 score for a particular test run that fails...
r31 run_comment_short += RUN_ERROR_MARK
jittat
Merged new-arch-branch changes 61:73 into the trunk...
r22 log "Cannot find the file #{test_num}/result!"
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 else
result_file = File.new(result_file_name, "r")
result_file_lines = result_file.readlines
jittat
[grader] fixed the case when result file is ill-formatted...
r34 if result_file_lines.length>=2
jittat
fixed test run scoring bug: now it takes the minimum of each test case's score...
r66 current_run_score = result_file_lines[1].to_i
jittat
[grader] fixed the case when result file is ill-formatted...
r34 run_comment += result_file_lines[0]
jittat
[web] allow check script to inject the comment...
r40 run_comment_short += char_comment(result_file_lines[0].chomp)
jittat
[grader] fixed the case when result file is ill-formatted...
r34 else
jittat
fixed test run scoring bug: now it takes the minimum of each test case's score...
r66 current_run_score = 0
jittat
[grader] fixed the case when result file is ill-formatted...
r34 run_comment += "result file for test #{test_num} error\n"
run_comment_short += RUN_ERROR_MARK
log "Error in #{test_num}/result!"
end
jittat
fixed test run scoring bug: now it takes the minimum of each test case's score...
r66
# 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
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 result_file.close
jittat
import original files...
r0 end
end
jittat
fix test run scoring bug...
r32
jittat
import original files...
r0 run_result_file = File.new("result-#{k}", "w")
run_result_file.write run_score
run_result_file.write "\n"
run_result_file.close
run_comment_file = File.new("comment-#{k}", "w")
run_comment_file.write "#{run_comment}\n"
run_comment_file.close
all_score = all_score + run_score
jittat
fix test run scoring bug...
r32
# append comment for test run with many test cases
if run.tests.length > 1
run_comment_short = '[' + run_comment_short + ']'
end
jittat
fix various bugs, save output, save comment...
r8 all_comment += run_comment_short
jittat
import original files...
r0 end
result_file = File.new("result", "w")
result_file.write all_score
result_file.write "\n"
result_file.close
comment_file = File.new("comment", "w")
comment_file.write "#{all_comment}\n"
comment_file.close