Description:
changed test request uploaded dir to data/test_request/input
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@86 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r38:d108852b6289 - - 2 files changed: 4 inserted, 2 deleted
@@ -32,26 +32,27 | |||||
|
32 | test_request.submission = |
|
32 | test_request.submission = |
|
33 | Submission.find_by_user_problem_number(user.id, |
|
33 | Submission.find_by_user_problem_number(user.id, |
|
34 | problem.id, |
|
34 | problem.id, |
|
35 | params[:submission_number]) |
|
35 | params[:submission_number]) |
|
36 | test_request.input_file_name = save_input_file(params[:input_file], user, problem) |
|
36 | test_request.input_file_name = save_input_file(params[:input_file], user, problem) |
|
37 | test_request.submitted_at = Time.new |
|
37 | test_request.submitted_at = Time.new |
|
38 | test_request.status_inqueue |
|
38 | test_request.status_inqueue |
|
39 | test_request |
|
39 | test_request |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | protected |
|
42 | protected |
|
43 | def self.input_file_name(user,problem) |
|
43 | def self.input_file_name(user,problem) |
|
|
44 | + problem_name = (problem!=nil) ? problem.name : "" | ||
|
44 | begin |
|
45 | begin |
|
45 |
- tmpname = |
|
46 | + tmpname = TEST_REQUEST_INPUT_FILE_DIR + "/#{user.login}/#{problem_name}/#{rand(10000)}" |
|
46 | end while File.exists?(tmpname) |
|
47 | end while File.exists?(tmpname) |
|
47 | tmpname |
|
48 | tmpname |
|
48 | end |
|
49 | end |
|
49 |
|
50 | ||
|
50 | def self.save_input_file(tempfile, user, problem) |
|
51 | def self.save_input_file(tempfile, user, problem) |
|
51 | new_file_name = input_file_name(user,problem) |
|
52 | new_file_name = input_file_name(user,problem) |
|
52 | dirname = File.dirname(new_file_name) |
|
53 | dirname = File.dirname(new_file_name) |
|
53 | FileUtils.mkdir_p(File.dirname(new_file_name)) if !File.exists?(dirname) |
|
54 | FileUtils.mkdir_p(File.dirname(new_file_name)) if !File.exists?(dirname) |
|
54 | if tempfile.instance_of?(Tempfile) |
|
55 | if tempfile.instance_of?(Tempfile) |
|
55 | tempfile.close |
|
56 | tempfile.close |
|
56 | FileUtils.move(tempfile.path,new_file_name) |
|
57 | FileUtils.move(tempfile.path,new_file_name) |
|
57 | else |
|
58 | else |
@@ -50,13 +50,14 | |||||
|
50 | # inflect.plural /^(ox)$/i, '\1en' |
|
50 | # inflect.plural /^(ox)$/i, '\1en' |
|
51 | # inflect.singular /^(ox)en/i, '\1' |
|
51 | # inflect.singular /^(ox)en/i, '\1' |
|
52 | # inflect.irregular 'person', 'people' |
|
52 | # inflect.irregular 'person', 'people' |
|
53 | # inflect.uncountable %w( fish sheep ) |
|
53 | # inflect.uncountable %w( fish sheep ) |
|
54 | # end |
|
54 | # end |
|
55 |
|
55 | ||
|
56 | # Add new mime types for use in respond_to blocks: |
|
56 | # Add new mime types for use in respond_to blocks: |
|
57 | # Mime::Type.register "text/richtext", :rtf |
|
57 | # Mime::Type.register "text/richtext", :rtf |
|
58 | # Mime::Type.register "application/x-mobile", :mobile |
|
58 | # Mime::Type.register "application/x-mobile", :mobile |
|
59 |
|
59 | ||
|
60 | # Include your application configuration below |
|
60 | # Include your application configuration below |
|
61 |
|
61 | ||
|
62 |
- |
|
62 | + TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
|
63 | + TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
You need to be logged in to leave comments.
Login now