# HG changeset patch # User jittat # Date 2008-03-06 04:00:23 # Node ID b5c26b86e7d29a6c94e44047b474d3a3c383e7cd # Parent 7df73373290be5d51ba3e1aeb158eb9e8d05761f added problem_name to TestRequest and moved name_of to protected git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@88 6386c4cd-e34a-4fa8-8920-d93eb39b512e diff --git a/app/models/test_request.rb b/app/models/test_request.rb --- a/app/models/test_request.rb +++ b/app/models/test_request.rb @@ -6,9 +6,11 @@ # determined. However, to be more flexible, we have to ensure that # it works as well with problem=nil. In this case, we shall provide # a "default" execution environment for it. This can be done -# seamlessly by using TestRequest#name_of when retrieving the name -# of the problem: name_of would return problem.name when -# problem!=nil and it would return "default" when problem=nil. +# seamlessly by using TestRequest#problem_name or +# TestRequest#name_of(problem) when retrieving the name of the +# problem: #name_of would return problem.name when problem!=nil and +# it would return "default" when problem=nil, #problem_name just +# call #name_of. # require 'fileutils' @@ -52,6 +54,12 @@ test_request end + def problem_name + TestRequest.name_of(self.problem) + end + + protected + def self.name_of(problem) if problem!=nil problem.name @@ -60,7 +68,6 @@ end end - protected def self.input_file_name(user,problem) problem_name = TestRequest.name_of(problem) begin