You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
spec/lib/parser_spec.rb fails on context "quizzes" it "parses". The correct_answer_id is not set for questions with correct answers.
The problem seems to originate in the resolve_question_correct_answers method of parser.rb in the following line:
if self.context[:answer_references][question_reference_identifier] && (a = self.context[:answer_references][question_reference_identifier][correct_answer_reference]) && a.save
Prior to Rails 4.1.0, the save command appears localized to a, which is an Answer instance. In Rails 4.1.0 and later, this save appears to ripple back through the ancestors and saves the entire survey.
I'm not yet clear why this happens, as I could not find anything in the release notes that directly suggest this behavior.
In any case, context[:survey].save in method_missing fails to save the changes to correct_answer_id as context[:survey] has already been persisted (:autosave is not explicity set to true in the chain of parents). In 4.0.x, context[:survey] would be saved for the first time and correct_answer_id would be properly saved.
Also, there is a spelling error in resolve_question_correct_answers; "idenitifer" instead of "identifier". This does not affect functionality.
The text was updated successfully, but these errors were encountered:
kjayma
added a commit
to kjayma/surveyor
that referenced
this issue
Aug 10, 2014
Changes made to correct_answer_id in resolve_question_correct_answer
are not being saved in Rails 4.1. Workaround is
to save the question immediately after the correct answer is saved.
Note that autosave: false is not same as not declaring :autosave. When the :autosave option is not present then new association records are saved but the updated association records are not saved.
spec/lib/parser_spec.rb fails on context "quizzes" it "parses". The correct_answer_id is not set for questions with correct answers.
The problem seems to originate in the resolve_question_correct_answers method of parser.rb in the following line:
if self.context[:answer_references][question_reference_identifier] && (a = self.context[:answer_references][question_reference_identifier][correct_answer_reference]) && a.save
Prior to Rails 4.1.0, the save command appears localized to a, which is an Answer instance. In Rails 4.1.0 and later, this save appears to ripple back through the ancestors and saves the entire survey.
I'm not yet clear why this happens, as I could not find anything in the release notes that directly suggest this behavior.
In any case, context[:survey].save in method_missing fails to save the changes to correct_answer_id as context[:survey] has already been persisted (:autosave is not explicity set to true in the chain of parents). In 4.0.x, context[:survey] would be saved for the first time and correct_answer_id would be properly saved.
Also, there is a spelling error in resolve_question_correct_answers; "idenitifer" instead of "identifier". This does not affect functionality.
The text was updated successfully, but these errors were encountered: