Description:
added name_of to TestRequest for dealing with null problem
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@87 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
r39:7df73373290b - - 1 file changed: 22 inserted, 1 deleted
@@ -1,3 +1,16 | |||||
|
|
1 | + # | ||
|
|
2 | + # A TestRequest is a composition of submission with user's testdata. | ||
|
|
3 | + # | ||
|
|
4 | + # Note about TestRequest#problem: Usually, A TestRequest has to be | ||
|
|
5 | + # associated with a problem, so that execution environment can be | ||
|
|
6 | + # determined. However, to be more flexible, we have to ensure that | ||
|
|
7 | + # it works as well with problem=nil. In this case, we shall provide | ||
|
|
8 | + # a "default" execution environment for it. This can be done | ||
|
|
9 | + # seamlessly by using TestRequest#name_of when retrieving the name | ||
|
|
10 | + # of the problem: name_of would return problem.name when | ||
|
|
11 | + # problem!=nil and it would return "default" when problem=nil. | ||
|
|
12 | + # | ||
|
|
13 | + | ||
|
1 | require 'fileutils' |
|
14 | require 'fileutils' |
|
2 |
|
15 | ||
|
3 | class TestRequest < Task |
|
16 | class TestRequest < Task |
@@ -39,9 +52,17 | |||||
|
39 | test_request |
|
52 | test_request |
|
40 | end |
|
53 | end |
|
41 |
|
54 | ||
|
|
55 | + def self.name_of(problem) | ||
|
|
56 | + if problem!=nil | ||
|
|
57 | + problem.name | ||
|
|
58 | + else | ||
|
|
59 | + "default" | ||
|
|
60 | + end | ||
|
|
61 | + end | ||
|
|
62 | + | ||
|
42 | protected |
|
63 | protected |
|
43 | def self.input_file_name(user,problem) |
|
64 | def self.input_file_name(user,problem) |
|
44 | - problem_name = (problem!=nil) ? problem.name : "" |
|
65 | + problem_name = TestRequest.name_of(problem) |
|
45 | begin |
|
66 | begin |
|
46 | tmpname = TEST_REQUEST_INPUT_FILE_DIR + "/#{user.login}/#{problem_name}/#{rand(10000)}" |
|
67 | tmpname = TEST_REQUEST_INPUT_FILE_DIR + "/#{user.login}/#{problem_name}/#{rand(10000)}" |
|
47 | end while File.exists?(tmpname) |
|
68 | end while File.exists?(tmpname) |
You need to be logged in to leave comments.
Login now