Description:
fix various bugs, save output, save comment git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@21 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

r8:4a121cdd0baf - - 3 files changed: 6 inserted, 7 deleted

@@ -25,27 +25,25
25 all_score = 0
25 all_score = 0
26 all_comment = ''
26 all_comment = ''
27 (1..(problem.runs.length-1)).each do |k|
27 (1..(problem.runs.length-1)).each do |k|
28 run = problem.runs[k]
28 run = problem.runs[k]
29 run_score = 0
29 run_score = 0
30 run_comment = ''
30 run_comment = ''
31 + run_comment_short = ''
31 run.tests.each do |test_num|
32 run.tests.each do |test_num|
32 result_file_name = "#{test_num}/result"
33 result_file_name = "#{test_num}/result"
33 if not File.exists?(result_file_name)
34 if not File.exists?(result_file_name)
34 puts "Cannot find the file #{test_num}/result!"
35 puts "Cannot find the file #{test_num}/result!"
35 exit(127)
36 exit(127)
36 end
37 end
37
38
38 result_file = File.new(result_file_name, "r")
39 result_file = File.new(result_file_name, "r")
39 result_file_lines = result_file.readlines
40 result_file_lines = result_file.readlines
40 run_score = run_score + result_file_lines[1].to_i
41 run_score = run_score + result_file_lines[1].to_i
41 - # run_comment += char_comment(result_file_lines[0])
42 + run_comment += result_file_lines[0]
42 - result_file_lines.each do |l|
43 + run_comment_short += char_comment(result_file_lines[0])
43 - run_comment += l
44 - end
45 - run_comment += "----\n"
46 result_file.close
44 result_file.close
47 end
45 end
48
46
49 run_result_file = File.new("result-#{k}", "w")
47 run_result_file = File.new("result-#{k}", "w")
50 run_result_file.write run_score
48 run_result_file.write run_score
51 run_result_file.write "\n"
49 run_result_file.write "\n"
@@ -53,13 +51,13
53
51
54 run_comment_file = File.new("comment-#{k}", "w")
52 run_comment_file = File.new("comment-#{k}", "w")
55 run_comment_file.write "#{run_comment}\n"
53 run_comment_file.write "#{run_comment}\n"
56 run_comment_file.close
54 run_comment_file.close
57
55
58 all_score = all_score + run_score
56 all_score = all_score + run_score
59 - all_comment += run_comment
57 + all_comment += run_comment_short
60 end
58 end
61
59
62 result_file = File.new("result", "w")
60 result_file = File.new("result", "w")
63 result_file.write all_score
61 result_file.write all_score
64 result_file.write "\n"
62 result_file.write "\n"
65 result_file.close
63 result_file.close
@@ -93,12 +93,13
93 puts
93 puts
94 execute("cp #{test_result_dir}/a.out #{sandbox_dir}", "Cannot copy the compiled program into #{sandbox_dir}")
94 execute("cp #{test_result_dir}/a.out #{sandbox_dir}", "Cannot copy the compiled program into #{sandbox_dir}")
95 execute("#{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script")
95 execute("#{problem_home}/script/run #{language} #{test_num}", "Error occured during execution of the run script")
96 execute("mkdir #{test_result_dir}/#{test_num}", "Cannot create directory #{test_result_dir}/#{test_num}")
96 execute("mkdir #{test_result_dir}/#{test_num}", "Cannot create directory #{test_result_dir}/#{test_num}")
97 execute("mv #{sandbox_dir}/result #{test_result_dir}/#{test_num}", "Cannot copy the result file into #{test_result_dir}/#{test_num}")
97 execute("mv #{sandbox_dir}/result #{test_result_dir}/#{test_num}", "Cannot copy the result file into #{test_result_dir}/#{test_num}")
98 execute("mv #{sandbox_dir}/comment #{test_result_dir}/#{test_num}", "Cannot copy the comment file into #{test_result_dir}/#{test_num}")
98 execute("mv #{sandbox_dir}/comment #{test_result_dir}/#{test_num}", "Cannot copy the comment file into #{test_result_dir}/#{test_num}")
99 + execute("mv #{sandbox_dir}/output.txt #{test_result_dir}/#{test_num}", "Cannot copy the output file into #{test_result_dir}/#{test_num}")
99 execute("rm -Rf #{sandbox_dir}/*", "Cannot clear #{sandbox_dir}")
100 execute("rm -Rf #{sandbox_dir}/*", "Cannot clear #{sandbox_dir}")
100 end
101 end
101
102
102 # Grade
103 # Grade
103 puts
104 puts
104 puts "Grading..."
105 puts "Grading..."
@@ -66,13 +66,13
66 result_file.write points.to_s.strip
66 result_file.write points.to_s.strip
67 result_file.write "\n"
67 result_file.write "\n"
68 result_file.write time_elapsed.strip
68 result_file.write time_elapsed.strip
69 result_file.write "\n"
69 result_file.write "\n"
70 result_file.close
70 result_file.close
71 `rm run_result`
71 `rm run_result`
72 - `rm output.txt`
72 + # `rm output.txt` --- keep the output
73
73
74 comment_file.write comment
74 comment_file.write comment
75 comment_file.write "--run-result--\n"
75 comment_file.write "--run-result--\n"
76 run_result.each do |l|
76 run_result.each do |l|
77 comment_file.write l
77 comment_file.write l
78 end
78 end
You need to be logged in to leave comments. Login now