# HG changeset patch # User Nattee Niparnan # Date 2020-04-23 06:27:46 # Node ID 4eedd9c42b4851891efff3e66904c526ea8146ef # Parent 98303143aafa2424a05406aa173fc5cd11ae2aa5 add dump submission & octave diff --git a/dump_submission b/dump_submission new file mode 100755 --- /dev/null +++ b/dump_submission @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +require 'fileutils' + +ENVIRONMENT_DIRS = ['ev', 'ev-exam'] + +def config + Grader::Configuration.get_instance +end + +def usage + puts </// +USAGE +end + +if (ARGV.length == 0) + usage + exit(0) +end + +# load grader environment +GRADER_ENV = 'grading' +require File.join(File.dirname(__FILE__),'config/environment') + +# boot rails, to be able to rename the problem +RAILS_ENV = config.rails_env +require RAILS_ROOT + '/config/environment' + +prob_ids = ARGV.map{ |x| x.to_i} + + +prob_ids.each do |id| + p = Problem.find(id) + p.submissions.each do |s| + dir = "#{p.name}/#{s.user.login}/#{s.id}.#{s.language.ext}" + filename = "#{s.id}.#{s.language.ext}" + FileUtils.mkdir_p dir + File.write("#{dir}/#{filename}",s.source) + puts filename + end +end diff --git a/std-script/compile b/std-script/compile --- a/std-script/compile +++ b/std-script/compile @@ -32,6 +32,7 @@ PYTHON_CHECKER = "/usr/bin/pyflakes" PHP_INTERPRETER = "/usr/bin/php" HASKELL_COMPILER = "/usr/bin/ghc" +OCTAVE_INTERPRETER = "/usr/bin/octave" C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall" CPLUSPLUS_OPTIONS = "-O2 -s -std=c++11 -static -DCONTEST -lm -Wall" @@ -186,6 +187,18 @@ talk "COMPILE: compiling command [#{command}]" system(command, err: params[:message_file]) +when "octave" + command = "touch" + talk "COMPILE: compiling command [#{command}], log err to #{params[:message_file]}" + system(command, err: params[:message_file]) + File.open(params[:output_file],"w") do |out_file| + out_file.puts "#!#{OCTAVE_INTERPRETER}" + File.open(params[:source_file],"r").each do |line| + out_file.print line + end + end + File.chmod(0755, params[:output_file]) + else talk("COMPILE: ERROR: Invalid language specified!") open(params[:message_file],"w") do |f| diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -53,7 +53,7 @@ end language = ARGV[0] -if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" && language != "haskell" +if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" && language != "haskell" && language != "octave" log "JUDGE: You specified a language that is not supported: #{language}." exit(127) end diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -112,6 +112,7 @@ JAVA_OPTION = "-s set_robust_list -s futex -s clone -s getppid -s clone -s wait4 -p /usr/bin/ -p ./" RUBY_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /lib64/ -p /dev/urandom -p #{sandbox_dir}/#{program_name} -p #{sandbox_dir}/ -s set_robust_list -s sched_getaffinity -s clock_gettime -s sigaltstack -s pipe2 -s clone -s futex -s openat -s pipe -s getrandom" PYTHON_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /usr/bin/ -p /lib64/ -p /dev/urandom -p /usr/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -p /proc/sys/crypto/fips_enabled -p /proc/self/status -p /proc/mounts -p /var/lib/dpkg/status -s statfs -s set_robust_list -s openat -s sysinfo -s recvmsg -s connect -s socket -s sendto -s futex -s sigaltstack -s getrandom -E PYTHONNOUSERSITE=yes" +OCTAVE_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /usr/bin/ -p /lib64/ -p /dev/urandom -p /usr/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -p /proc/sys/crypto/fips_enabled -p /proc/self/status -p /proc/mounts -p /var/lib/dpkg/status -s statfs -s set_robust_list -s openat -s sysinfo -s recvmsg -s connect -s socket -s sendto -s futex -s sigaltstack -s getrandom -s prlimit64 -s execve -E PYTHONNOUSERSITE=yes" PHP_OPTION = "-p /usr/lib64/ -p/lib64/ -p /usr/bin/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p /usr/share/ -s setfsuid -s setfsgid -s openat -s set_robust_list -s futex -s clone -s socket -s connect" HASKELL_OPTION = "-s set_robust_list -s clock_gettime -s sysinfo -s timer_create -s timer_settime -s futex -s timer_delete" @@ -133,6 +134,8 @@ run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{[512 * 1024,mem_limit].max} #{HASKELL_OPTION} -i #{input_file_name} -o output.txt #{program_name} " when "php" run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{PHP_OPTION} -i #{input_file_name} -o output.txt /usr/bin/php -A -d -A memory_limit=#{mem_limit}k -A #{program_name} " + when "octave" + run_command = "#{problem_home}/script/box -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{OCTAVE_OPTION} -i #{input_file_name} -o output.txt /usr/bin/octave -A -W -A --no-gui #{program_name}" else # for c++, pascal, we do the normal checking run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} -i #{input_file_name} -o output.txt #{program_name} " end