-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save base response when radio button with other is used #613
base: MOODLE_404_STABLE
Are you sure you want to change the base?
Conversation
$onlyspaces = preg_match("/^[\s]*$/", $answer->value); | ||
if ($onlyspaces) { | ||
$answered = false; | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above code could be simplified to:
$answered = !empty($answer->value) || !preg_match("/^[\s]*$/", $answer->value);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case for answering "other" with no content?
$record->question_id = $this->question->id; | ||
$record->choice_id = $answer->choiceid; | ||
$record->response = clean_text($answer->value); | ||
$DB->insert_record('questionnaire_response_other', $record); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure this is what is desired. If the user didn't select a response, why would a response be saved? Please provide a test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments inline.
This PR fixes should fix 2 things.
Without this you when you are submitting
other
response containing only spaces no error occurs.There should be some kind of validation / error when
other
response contains only spaces.When submitting question with
other
response there was acontinue
(which applies to foreach / loop) if$answer->value
was empty or contained only spaces.It was skipping saving of original base choice.
So on report page there was no info what user selected / answered.
This commit inverts the logic so base save is always happening.