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:
Stella Rouzi
2014-11-12 13:43:02 +02:00
2 changed files with 17 additions and 1 deletions

View File

@@ -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.' }

View File

@@ -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
});