Description:
new default config file git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@25 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r12:dd4ebb184900 - - 1 file changed: 2 inserted, 2 deleted

@@ -50,65 +50,65
50 :comment => comment,
50 :comment => comment,
51 :cmp_msg => cmp_msg}
51 :cmp_msg => cmp_msg}
52 else
52 else
53 return {:points => 0,
53 return {:points => 0,
54 :comment => 'compile error',
54 :comment => 'compile error',
55 :cmp_msg => cmp_msg}
55 :cmp_msg => cmp_msg}
56 end
56 end
57 end
57 end
58
58
59 def save_result(submission,result)
59 def save_result(submission,result)
60 problem = Problem.find(submission.problem_id)
60 problem = Problem.find(submission.problem_id)
61 submission.graded_at = Time.now
61 submission.graded_at = Time.now
62 submission.points = result[:points]
62 submission.points = result[:points]
63 if submission.points == problem.full_score
63 if submission.points == problem.full_score
64 submission.grader_comment = 'PASSED: ' + report_comment(result[:comment])
64 submission.grader_comment = 'PASSED: ' + report_comment(result[:comment])
65 else
65 else
66 submission.grader_comment = 'FAILED: ' + report_comment(result[:comment])
66 submission.grader_comment = 'FAILED: ' + report_comment(result[:comment])
67 end
67 end
68 submission.compiler_message = result[:cmp_msg]
68 submission.compiler_message = result[:cmp_msg]
69 submission.save
69 submission.save
70 end
70 end
71
71
72 def copy_script(problem_home)
72 def copy_script(problem_home)
73 script_dir = "#{problem_home}/script"
73 script_dir = "#{problem_home}/script"
74 - std_script_dir = File.dirname(__FILE__) + '/std-scripts'
74 + std_script_dir = File.dirname(__FILE__) + '/std-script'
75 scripts = Dir[std_script_dir + '/*']
75 scripts = Dir[std_script_dir + '/*']
76
76
77 copied = []
77 copied = []
78
78
79 scripts.each do |s|
79 scripts.each do |s|
80 fname = File.basename(s)
80 fname = File.basename(s)
81 if !FileTest.exist?("#{script_dir}/#{fname}")
81 if !FileTest.exist?("#{script_dir}/#{fname}")
82 copied << fname
82 copied << fname
83 system("cp #{s} #{script_dir}")
83 system("cp #{s} #{script_dir}")
84 end
84 end
85 end
85 end
86
86
87 return copied
87 return copied
88 end
88 end
89
89
90 - def clear_script(problem_home,log)
90 + def clear_script(log,problem_home)
91 log.each do |s|
91 log.each do |s|
92 system("rm #{problem_home}/script/#{s}")
92 system("rm #{problem_home}/script/#{s}")
93 end
93 end
94 end
94 end
95
95
96 def grade(submission_id)
96 def grade(submission_id)
97 current_dir = `pwd`.chomp
97 current_dir = `pwd`.chomp
98
98
99 sub = Submission.find(submission_id)
99 sub = Submission.find(submission_id)
100 user = sub.user
100 user = sub.user
101 problem = sub.problem
101 problem = sub.problem
102
102
103 language = sub.language.name
103 language = sub.language.name
104 lang_ext = sub.language.ext
104 lang_ext = sub.language.ext
105 # FIX THIS
105 # FIX THIS
106 talk 'some hack on language'
106 talk 'some hack on language'
107 if language == 'cpp'
107 if language == 'cpp'
108 language = 'c++'
108 language = 'c++'
109 end
109 end
110
110
111 user_dir = "#{USER_RESULT_DIR}/#{user.login}"
111 user_dir = "#{USER_RESULT_DIR}/#{user.login}"
112 Dir.mkdir(user_dir) if !FileTest.exist?(user_dir)
112 Dir.mkdir(user_dir) if !FileTest.exist?(user_dir)
113
113
114 problem_out_dir = "#{user_dir}/#{problem.name}"
114 problem_out_dir = "#{user_dir}/#{problem.name}"
You need to be logged in to leave comments. Login now