app/controllers/questionnaires_controller.rb
def create_questionnaire
    @questionnaire = Object.const_get(params[:questionnaire][:type]).new(questionnaire_params)

    # TODO: check for Quiz Questionnaire?
    if @questionnaire.type == "QuizQuestionnaire" # checking if it is a quiz questionnaire
      participant_id = params[:pid] # creating a local variable to send as parameter to submitted content if it is a quiz questionnaire
      @questionnaire.min_question_score = 0
      @questionnaire.max_question_score = 1
      author_team = AssignmentTeam.team(Participant.find(participant_id))

      @questionnaire.instructor_id = author_team.id # for a team assignment, set the instructor id to the team_id

      @successful_create = true
      save

      save_choices @questionnaire.id

      flash[:note] = "The quiz was successfully created." if @successful_create == true
      redirect_to controller: 'submitted_content', action: 'edit', id: participant_id
    else # if it is not a quiz questionnaire
      @questionnaire.instructor_id = Ta.get_my_instructor(session[:user].id) if session[:user].role.name == "Teaching Assistant"
      save

      redirect_to controller: 'tree_display', action: 'list'
    end
  end
# Controller for Questionnaire objects
# A Questionnaire can be of several types (QuestionnaireType)
# Each Questionnaire contains zero or more questions (Question)
# Generally a questionnaire is associated with an assignment (Assignment)
Controller for Questionnaire objects
A Questionnaire can be of several types (QuestionnaireType)
Each Questionnaire contains zero or more questions (Question)
Generally a questionnaire is associated with an assignment (Assignment)
Controller for Questionnaire objects A Questionnaire can be of several types ( QuestionnaireType ) Each Questionnaire contains zero or more questions ( Question ) Generally a questionnaire is associated with an assignment ( Assignment )
def create_questionnaire
    @questionnaire = Object.const_get(params[:questionnaire][:type]).new(questionnaire_params)
    if @questionnaire.type == "QuizQuestionnaire" 
      participant_id = params[:pid] 
      @questionnaire.min_question_score = 0
      @questionnaire.max_question_score = 1
      author_team = AssignmentTeam.team(Participant.find(participant_id))
      @questionnaire.instructor_id = author_team.id 
      @successful_create = true
      save
      save_choices @questionnaire.id
      flash[:note] = "The quiz was successfully created." if @successful_create == true
      redirect_to controller: 'submitted_content', action: 'edit', id: participant_id
    else 
      @questionnaire.instructor_id = Ta.get_my_instructor(session[:user].id) if session[:user].role.name == "Teaching Assistant"
      save
      redirect_to controller: 'tree_display', action: 'list'
    end
  end
def create_questionnaire @questionnaire = Object . const_get ( params [ :questionnaire ] [ :type ] ) . new ( questionnaire_params ) if @questionnaire . type == "QuizQuestionnaire" participant_id = params [ :pid ] @questionnaire . min_question_score = 0 @questionnaire . max_question_score = 1 author_team = AssignmentTeam . team ( Participant . find ( participant_id ) ) @questionnaire . instructor_id = author_team . id @successful_create = true save save_choices @questionnaire . id flash [ :note ] = "The quiz was successfully created." if @successful_create == true redirect_to controller : 'submitted_content' , action : 'edit' , id : participant_id else @questionnaire . instructor_id = Ta . get_my_instructor ( session [ :user ] . id ) if session [ :user ] . role . name == "Teaching Assistant" save redirect_to controller : 'tree_display' , action : 'list' end end
Controller for Questionnaire objects
A Questionnaire can be of several types (QuestionnaireType)
Each Questionnaire contains zero or more questions (Question)
Generally a questionnaire is associated with an assignment (Assignment)
Controller for Questionnaire objects A Questionnaire can be of several types ( QuestionnaireType ) Each Questionnaire contains zero or more questions ( Question ) Generally a questionnaire is associated with an assignment ( Assignment )
# TODO: check for Quiz Questionnaire? # checking if it is a quiz questionnaire # creating a local variable to send as parameter to submitted content if it is a quiz questionnaire # for a team assignment, set the instructor id to the team_id # if it is not a quiz questionnaire