diff --git a/grader b/grader --- a/grader +++ b/grader @@ -125,8 +125,12 @@ exit(0) end +grader_mode = 'queue' if ARGV.length >= 1 GRADER_ENV = ARGV[0] + if ARGV.length >=2 + grader_mode = ARGV[1] + end else GRADER_ENV = 'exam' end @@ -140,21 +144,45 @@ RAILS_ENV = 'development' require RAILS_APP_DIR + '/config/environment' -talk 'Grader queue' -while true - if check_stopfile # created by calling grader stop - clear_stopfile - puts "stopped" +case grader_mode +when "queue" + talk 'Grader queue' + while true + if check_stopfile # created by calling grader stop + clear_stopfile + puts "stopped" + exit(0) + end + + task = Task.find(:first, :order => 'created_at') + if task!=nil + grade(task.submission_id) + task.destroy + else + sleep(1) + end + end + +when "prob" + prob = Problem.find_by_name(ARGV[2]) + if prob==nil + puts "cannot find problem: #{ARGV[2]}" exit(0) end - - task = Task.find(:first, :order => 'created_at') - if task!=nil - grade(task.submission_id) - task.destroy - else - sleep(1) + users = User.find(:all) + users.each do |u| + puts "user: #{u.login}" + last_sub = Submission.find(:first, + :conditions => "user_id = #{u.id} and " + + "problem_id = #{prob.id}", + :order => 'submitted_at DESC') + if last_sub!=nil + grade(last_sub.id) + end end end + + + diff --git a/std-script/check b/std-script/check --- a/std-script/check +++ b/std-script/check @@ -44,6 +44,10 @@ ################## # Your code here # ################## + +puts "YOU HAVE TO EDIT THE CHECKING CODE HERE: #{__FILE__}" +exit(127) + num_pattern = /^[0-9]*/ if (output_file_content =~ num_pattern) == nil report_wrong.call