Show More
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program...
Commit Description:
add option -A <opt> to box. This options allow more argument to be explicitly passed to the program We have to use this because if the argument we wish to pass to the program is option (in -? format), box will intepret it as its option and failed accordingly. be noted that, by the definition of getopt, these options will be put after original argument (check the code for more info)
References:
File last commit:
Show/Diff file:
Action:
lib/submission_helper.rb | 152 lines | 4.2 KiB | text/x-ruby | RubyLexer |
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 module Grader
class SubmissionRoomMaker
def initialize
@config = Grader::Configuration.get_instance
end
def produce_grading_room(submission)
user = submission.user
problem = submission.problem
grading_room = "#{@config.user_result_dir}/" +
"#{user.login}/#{problem.name}/#{submission.id}"
FileUtils.mkdir_p(grading_room)
grading_room
end
def find_problem_home(submission)
problem = submission.problem
"#{@config.problems_dir}/#{problem.name}"
end
def save_source(submission,source_name)
dir = self.produce_grading_room(submission)
f = File.open("#{dir}/#{source_name}","w")
f.write(submission.source)
f.close
end
def clean_up(submission)
end
end
class SubmissionReporter
Jittat Fakcharoenphol
added grading report
r92 def initialize(options={})
options = {:dry_run => false, :result_collector => nil}.merge(options)
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 @config = Grader::Configuration.get_instance
Jittat Fakcharoenphol
added grading report
r92 @dry_run = options[:dry_run]
@result_collector = options[:result_collector]
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 end
def report(sub,test_result_dir)
Jittat Fakcharoenphol
added grading report
r92 result = read_result(test_result_dir)
if @result_collector
Jittat Fakcharoenphol
sends whole submission to result collecter in submission reporter, instead of just user and problem
r123 @result_collector.save(sub,
Jittat Fakcharoenphol
added grading report
r92 result)
end
save_result(sub,result)
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 end
def report_error(sub,msg)
save_result(sub,{:points => 0,
:comment => "Grading error: #{msg}" })
end
protected
def read_result(test_result_dir)
cmp_msg_fname = "#{test_result_dir}/compiler_message"
jittat
[grader] fixed the case when result file is ill-formatted...
r34 if FileTest.exist?(cmp_msg_fname)
cmp_file = File.open(cmp_msg_fname)
cmp_msg = cmp_file.read
cmp_file.close
else
cmp_msg = ""
end
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23
result_fname = "#{test_result_dir}/result"
add run_stat checking
r160 comment_fname = "#{test_result_dir}/comment"
runstat_fname = "#{test_result_dir}/run_stat"
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 if FileTest.exist?(result_fname)
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 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
add run_stat checking
r160 begin
runstat_file = File.open(runstat_fname)
max_runtime = runstat_file.readline.to_f
peak_memory = runstat_file.readline.to_i
rescue
max_runtime = -1
peak_memory = -1
end
return {points: result,
comment: comment,
cmp_msg: cmp_msg,
max_runtime: max_runtime,
peak_memory: peak_memory
}
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 else
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 if FileTest.exist?("#{test_result_dir}/a.out")
return {:points => 0,
:comment => 'error during grading',
:cmp_msg => cmp_msg}
else
return {:points => 0,
jittat
[grader] fixed bug #6 and #9...
r37 :comment => 'compilation error',
jittat
[grader] report error when the check script crashed (i.e., when the result file is not found, while the compilation is okay)...
r30 :cmp_msg => cmp_msg}
end
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 end
end
def save_result(submission,result)
problem = submission.problem
jittat
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@237 6386c4cd-e34a-4fa8-8920-d93eb39b512e
r56 submission.graded_at = Time.now.gmtime
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 points = result[:points]
submission.points = points
comment = @config.report_comment(result[:comment])
jittat
[grader] change messages...
r58
add run_stat checking
r160 submission.peak_memory = result[:peak_memory]
submission.max_runtime = result[:max_runtime]
submission.effective_code_length =submission.source.length
jittat
[grader] change messages...
r58 #
# TODO: FIX THIS MESSAGE
#
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 if problem == nil
submission.grader_comment = 'PASSED: ' + comment + '(problem is nil)'
elsif points == problem.full_score
jittat
[grader] change messages...
r58 #submission.grader_comment = 'PASSED: ' + comment
submission.grader_comment = comment
jittat
[grader] fixed bug #6 and #9...
r37 elsif result[:comment].chomp =~ /^[\[\]P]+$/
submission.grader_comment = 'PASSED: ' + comment + '(inconsistent score)'
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 else
jittat
[grader] change messages...
r58 #submission.grader_comment = 'FAILED: ' + comment
submission.grader_comment = comment
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 end
submission.compiler_message = result[:cmp_msg] or ''
Jittat Fakcharoenphol
added --dry option to grader prob mode
r91
if not @dry_run
submission.save
end
jittat
[grader] [MERGED] Merged new-arch-branch changes 74:105 into the trunk...
r23 end
end
end