app/controllers/review_mapping_controller.rb
def assign_quiz_dynamically
    begin
      assignment = Assignment.find(params[:assignment_id])
      reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first
      if ResponseMap.where(reviewed_object_id: params[:questionnaire_id], reviewer_id: params[:participant_id]).first
        flash[:error] = "You have already taken that quiz."
      else
        @map = QuizResponseMap.new
        @map.reviewee_id = Questionnaire.find(params[:questionnaire_id]).instructor_id
        @map.reviewer_id = params[:participant_id]
        @map.reviewed_object_id = Questionnaire.find_by(instructor_id: @map.reviewee_id).id
        @map.save
      end
    rescue Exception => e
      flash[:alert] = e.nil? ? $ERROR_INFO : e
    end
    redirect_to student_quizzes_path(id: reviewer.id)
  end
# assigns the quiz dynamically to the participant
assigns the quiz dynamically to the participant
assigns the quiz dynamically to the participant
def assign_quiz_dynamically
    begin
      assignment = Assignment.find(params[:assignment_id])
      reviewer = AssignmentParticipant.where(user_id: params[:reviewer_id], parent_id: assignment.id).first
      if ResponseMap.where(reviewed_object_id: params[:questionnaire_id], reviewer_id: params[:participant_id]).first
        flash[:error] = "You have already taken that quiz."
      else
        @map = QuizResponseMap.new
        @map.reviewee_id = Questionnaire.find(params[:questionnaire_id]).instructor_id
        @map.reviewer_id = params[:participant_id]
        @map.reviewed_object_id = Questionnaire.find_by(instructor_id: @map.reviewee_id).id
        @map.save
      end
    rescue Exception => e
      flash[:alert] = e.nil? ? $ERROR_INFO : e
    end
    redirect_to student_quizzes_path(id: reviewer.id)
  end
def assign_quiz_dynamically begin assignment = Assignment . find ( params [ :assignment_id ] ) reviewer = AssignmentParticipant . where ( user_id : params [ :reviewer_id ] , parent_id : assignment . id ) . first if ResponseMap . where ( reviewed_object_id : params [ :questionnaire_id ] , reviewer_id : params [ :participant_id ] ) . first flash [ :error ] = "You have already taken that quiz." else @map = QuizResponseMap . new @map . reviewee_id = Questionnaire . find ( params [ :questionnaire_id ] ) . instructor_id @map . reviewer_id = params [ :participant_id ] @map . reviewed_object_id = Questionnaire . find_by ( instructor_id : @map . reviewee_id ) . id @map . save end rescue Exception => e flash [ :alert ] = e . nil? ? $ERROR_INFO : e end redirect_to student_quizzes_path ( id : reviewer . id ) end
assigns the quiz dynamically to the participant
assigns the quiz dynamically to the participant