app/controllers/questionnaires_controller.rb
def save_new_questions(questionnaire_id)
    if params[:new_question]
      # The new_question array contains all the new questions
      # that should be saved to the database
      for question_key in params[:new_question].keys
        q = Question.new
        q.txt = params[:new_question][question_key]
        q.questionnaire_id = questionnaire_id
        q.type = params[:question_type][question_key][:type]
        q.seq = question_key.to_i
        if @questionnaire.type == "QuizQuestionnaire"
          q.weight = 1 # setting the weight to 1 for quiz questionnaire since the model validates this field
        end
        q.save unless q.txt.strip.empty?
      end
    end
  end
# save questions that have been added to a questionnaire
save questions that have been added to a questionnaire
save questions that have been added to a questionnaire
def save_new_questions(questionnaire_id)
    if params[:new_question]
      for question_key in params[:new_question].keys
        q = Question.new
        q.txt = params[:new_question][question_key]
        q.questionnaire_id = questionnaire_id
        q.type = params[:question_type][question_key][:type]
        q.seq = question_key.to_i
        if @questionnaire.type == "QuizQuestionnaire"
          q.weight = 1 
        end
        q.save unless q.txt.strip.empty?
      end
    end
  end
def save_new_questions ( questionnaire_id ) if params [ :new_question ] for question_key in params [ :new_question ] . keys q = Question . new q . txt = params [ :new_question ] [ question_key ] q . questionnaire_id = questionnaire_id q . type = params [ :question_type ] [ question_key ] [ :type ] q . seq = question_key . to_i if @questionnaire . type == "QuizQuestionnaire" q . weight = 1 end q . save unless q . txt . strip . empty? end end end
save questions that have been added to a questionnaire
save questions that have been added to a questionnaire
# The new_question array contains all the new questions # that should be saved to the database # setting the weight to 1 for quiz questionnaire since the model validates this field
questionnaire_id