code
stringlengths
1
1.73M
language
stringclasses
1 value
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
module GraderEngineHelperMethods def clear_sandbox config = Grader::Configuration.get_instance clear_cmd = "rm -rf #{config.test_sandbox_dir}/*" system(clear_cmd) end def init_sandbox config = Grader::Configuration.get_instance clear_sandbox Dir.mkdir config.user_result_dir cp_cmd = ...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby def stop_grader File.open(File.dirname(__FILE__) + '/stop','w').close end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + '/stop') end def clear_stopfile system("rm " + File.dirname(__FILE__) + '/stop') end def config Grader::Configuration.get_instance end def log_file_name co...
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' def input_filename(dir,i) "#{dir}/input-#{i}.txt" end def answer_filename(dir,i) "#{dir}/answer-#{i}....
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' def input_filename(dir,i) "#{dir}/input-#{i}.txt" end def answer_filename(dir,i) "#{dir}/answer-#{i}....
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby 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("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby 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 def char_comment(comment) if comment =~ /[iI]ncorrec...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby 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("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) if (result=/^(.*)r(.*)u(.*)s/.matc...
Ruby
#!/usr/bin/ruby 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("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby 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 def char_comment(comment) if comment =~ /[iI]ncorrec...
Ruby
#!/usr/bin/ruby 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("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) if (result=/^(.*)r(.*)u(.*)s/.matc...
Ruby
class DSLNode def DSLNode.scalar_attr(*names) names.each do |name| define_method name do |*a| if a.length == 0 instance_variable_get( "@#{name}" ) else instance_variable_set( "@#{name}", a[0] ) end end end end def DSLNode.array_attr(*names) ...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby def stop_grader File.open(File.dirname(__FILE__) + '/stop','w').close end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + '/stop') end def clear_stopfile system("rm " + File.dirname(__FILE__) + '/stop') end def config Grader::Configuration.get_instance end def log_file_name co...
Ruby
# # A runner drives the engine into various tasks. # module Grader class Runner def initialize(engine, grader_process=nil) @engine = engine @grader_process = grader_process end def grade_oldest_task task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) if task!=nil ...
Ruby
module Grader # This singleton class holds basic configurations for grader. When # running in each mode, grader uses resources from different # directories and outputs differently. Usually the attributes name # are descriptive; below we explain more on each attributes. class Configuration # Rails' envi...
Ruby
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.na...
Ruby
module Grader class Initializer def self.run(&block) config = Grader::Configuration.get_instance yield config end end end
Ruby
require File.join(File.dirname(__FILE__), 'configuration') require File.join(File.dirname(__FILE__), 'initializer') require File.join(File.dirname(__FILE__), 'submission_helper') require File.join(File.dirname(__FILE__), 'test_request_helper') require File.join(File.dirname(__FILE__), 'engine') require File.join(Fil...
Ruby
# # This part contains various test_request helpers for interfacing # with Grader::Engine. There are TestRequestRoomMaker and # TestRequestReporter. module Grader # # A TestRequestRoomMaker is a helper object for Engine # - finds grading room: in user_result_dir/(user)/test_request/ ... # - prepare problem c...
Ruby
require 'fileutils' module Grader # # A grader engine grades a submission, against anything: a test # data, or a user submitted test data. It uses two helpers objects: # room_maker and reporter. # class Engine attr_writer :room_maker attr_writer :reporter def initialize(room_maker=nil, ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
module GraderEngineHelperMethods def clear_sandbox config = Grader::Configuration.get_instance clear_cmd = "rm -rf #{config.test_sandbox_dir}/*" system(clear_cmd) end def init_sandbox config = Grader::Configuration.get_instance clear_sandbox FileUtils.mkdir_p config.user_result_dir c...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' require File.join(File.dirname(__FILE__),'lib/import_helper') def input_filename(dir,i) "#{dir}/input-#{...
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' require File.join(File.dirname(__FILE__),'lib/import_helper') def input_filename(dir,i) "#{dir}/input-#{...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby 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("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' 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}...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby 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("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) # puts "TIME: #{t}" if (result=...
Ruby
#!/usr/bin/ruby 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("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' 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}...
Ruby
#!/usr/bin/ruby 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("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) # puts "TIME: #{t}" if (result=...
Ruby
class DSLNode def DSLNode.scalar_attr(*names) names.each do |name| define_method name do |*a| if a.length == 0 instance_variable_get( "@#{name}" ) else instance_variable_set( "@#{name}", a[0] ) end end end end def DSLNode.array_attr(*names) ...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
# # A runner drives the engine into various tasks. # module Grader class Runner def initialize(engine, grader_process=nil) @engine = engine @grader_process = grader_process end def grade_oldest_task task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) if task!=nil ...
Ruby
module Grader # This singleton class holds basic configurations for grader. When # running in each mode, grader uses resources from different # directories and outputs differently. Usually the attributes name # are descriptive; below we explain more on each attributes. class Configuration # Rails' envi...
Ruby
def filter_filename_for_testrun(testrun, filename_list) l = [] regex = Regexp.new("^(#{testrun}[a-z]*|#{testrun}-.*)$") filename_list.each do |filename| if regex.match(filename) l << filename end end l end def build_testrun_info(num_testruns, input_filename_list) info = [] num_testcases = ...
Ruby
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.na...
Ruby
module Grader class Initializer def self.run(&block) config = Grader::Configuration.get_instance yield config end end end
Ruby
require File.join(File.dirname(__FILE__), 'configuration') require File.join(File.dirname(__FILE__), 'initializer') require File.join(File.dirname(__FILE__), 'submission_helper') require File.join(File.dirname(__FILE__), 'test_request_helper') require File.join(File.dirname(__FILE__), 'engine') require File.join(Fil...
Ruby
# # This part contains various test_request helpers for interfacing # with Grader::Engine. There are TestRequestRoomMaker and # TestRequestReporter. module Grader # # A TestRequestRoomMaker is a helper object for Engine # - finds grading room: in user_result_dir/(user)/test_request/ ... # - prepare problem c...
Ruby
require 'fileutils' module Grader # # A grader engine grades a submission, against anything: a test # data, or a user submitted test data. It uses two helpers objects: # room_maker and reporter. # class Engine attr_writer :room_maker attr_writer :reporter def initialize(room_maker=nil, ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
module GraderEngineHelperMethods def clear_sandbox config = Grader::Configuration.get_instance clear_cmd = "rm -rf #{config.test_sandbox_dir}/*" system(clear_cmd) end def init_sandbox config = Grader::Configuration.get_instance clear_sandbox FileUtils.mkdir_p config.user_result_dir c...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/env ruby ENVIRONMENT_DIRS = ['ev', 'ev-exam'] def config Grader::Configuration.get_instance end def rename_problem(old_problem_name, new_problem_name) if valid_problem_name(new_problem_name) puts "Bad new problem name: #{new_problem_name}" return end problem = Problem.find_by_name(old_pr...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
#!/usr/bin/ruby require 'erb' require 'fileutils' require File.join(File.dirname(__FILE__),'lib/import_helper') JUDGE_ENVIRONMENTS = [:grading, :exam] ENV_INFO = { :grading => { :ev_dir => 'ev', :raw_prefix => '', }, :exam => { :ev_dir => 'ev-exam', :raw_prefix => 'ex.', } } def input_filena...
Ruby