Description:
fixed submission bug: forgot to set problem attribute in case that the problem is set in the submission code.
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@100 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
r48:0bbd9fb65914 - - 1 file changed: 2 inserted, 0 deleted
@@ -98,23 +98,25 | |||||
|
98 |
|
98 | ||
|
99 | def must_have_valid_problem |
|
99 | def must_have_valid_problem |
|
100 | return if self.source==nil |
|
100 | return if self.source==nil |
|
101 | if self.problem_id!=-1 |
|
101 | if self.problem_id!=-1 |
|
102 | problem = Problem.find(self.problem_id) |
|
102 | problem = Problem.find(self.problem_id) |
|
103 | else |
|
103 | else |
|
104 | problem = Submission.find_problem_in_source(self.source) |
|
104 | problem = Submission.find_problem_in_source(self.source) |
|
105 | end |
|
105 | end |
|
106 | if problem==nil |
|
106 | if problem==nil |
|
107 | errors.add_to_base("must specify problem") |
|
107 | errors.add_to_base("must specify problem") |
|
108 | elsif !problem.available |
|
108 | elsif !problem.available |
|
109 | errors.add_to_base("must specify valid problem") |
|
109 | errors.add_to_base("must specify valid problem") |
|
|
110 | + else | ||
|
|
111 | + self.problem = problem | ||
|
110 | end |
|
112 | end |
|
111 | end |
|
113 | end |
|
112 |
|
114 | ||
|
113 | # callbacks |
|
115 | # callbacks |
|
114 | def assign_latest_number_if_new_recond |
|
116 | def assign_latest_number_if_new_recond |
|
115 | return if !self.new_record? |
|
117 | return if !self.new_record? |
|
116 | latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id) |
|
118 | latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id) |
|
117 | self.number = (latest==nil) ? 1 : latest.number + 1; |
|
119 | self.number = (latest==nil) ? 1 : latest.number + 1; |
|
118 | end |
|
120 | end |
|
119 |
|
121 | ||
|
120 | end |
|
122 | end |
You need to be logged in to leave comments.
Login now