Description:
added problem identification from source filename git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@364 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

r167:e09937aa9f90 - - 1 file changed: 8 inserted, 3 deleted

@@ -92,30 +92,35
92 else
92 else
93 return nil
93 return nil
94 end
94 end
95 end
95 end
96 end
96 end
97
97
98 - def self.find_problem_in_source(source)
98 + def self.find_problem_in_source(source, source_filename="")
99 prob_opt = find_option_in_source(/^TASK:/,source)
99 prob_opt = find_option_in_source(/^TASK:/,source)
100 if problem = Problem.find_by_name(prob_opt)
100 if problem = Problem.find_by_name(prob_opt)
101 return problem
101 return problem
102 else
102 else
103 - return nil
103 + if source_filename
104 + return Problem.find_by_name(source_filename.split('.').first)
105 + else
106 + return nil
107 + end
104 end
108 end
105 end
109 end
106
110
107 def assign_problem
111 def assign_problem
108 if self.problem_id!=-1
112 if self.problem_id!=-1
109 begin
113 begin
110 self.problem = Problem.find(self.problem_id)
114 self.problem = Problem.find(self.problem_id)
111 rescue ActiveRecord::RecordNotFound
115 rescue ActiveRecord::RecordNotFound
112 self.problem = nil
116 self.problem = nil
113 end
117 end
114 else
118 else
115 - self.problem = Submission.find_problem_in_source(self.source)
119 + self.problem = Submission.find_problem_in_source(self.source,
120 + self.source_filename)
116 end
121 end
117 end
122 end
118
123
119 def assign_language
124 def assign_language
120 self.language = Submission.find_language_in_source(self.source,
125 self.language = Submission.find_language_in_source(self.source,
121 self.source_filename)
126 self.source_filename)
You need to be logged in to leave comments. Login now