mirror of
https://github.com/openSUSE/osem.git
synced 2026-04-27 18:36:00 -04:00
Merge pull request #531 from differentreality/questions_fixed_answers_for_yes_no
Do not require answers if it is a yes or no question.
This commit is contained in:
@@ -20,6 +20,10 @@ module Admin
|
||||
@question.conference_id = @conference.id
|
||||
authorize! :create, @question
|
||||
|
||||
if @question.question_type_id == QuestionType.find_by(title: 'Yes/No').id
|
||||
@question.answers = [Answer.find_by(title: 'Yes'), Answer.find_by(title: 'No')]
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @conference.save
|
||||
format.html { redirect_to admin_conference_questions_path, notice: 'Question was successfully created.' }
|
||||
|
||||
@@ -5,6 +5,18 @@
|
||||
= f.input :question_type
|
||||
= f.input :global, label: 'Make Global',
|
||||
hint: '(Global questions are available for selection to all conferences)'
|
||||
.col-md-6
|
||||
.col-md-6.hidden{id: 'answers_col'}
|
||||
= dynamic_association :answers, 'Answers', f,
|
||||
hint: 'Insert your answers in the order you want them to appear'
|
||||
|
||||
:javascript
|
||||
$("#question_question_type_id").change(function () {
|
||||
|
||||
var selected_type = $(this).find('option:selected').text();
|
||||
|
||||
if (selected_type == 'Yes/No')
|
||||
$('#answers_col').addClass('hidden');
|
||||
else
|
||||
$('#answers_col').removeClass('hidden');
|
||||
end
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user