app/controllers/response_controller.rb
# Update the response and answers when student "edit" existing response
Update the response and answers when student "edit" existing response
Update the response and answers when student " edit " existing response
def update
    return unless action_allowed?
    @response = Response.find(params[:id])
    msg = ""
    begin
      @map = @response.map
      @response.update_attribute('additional_comment', params[:review][:comments])
      @questionnaire = set_questionnaire
      questions = sort_questions(@questionnaire.questions)
      create_answers(params, questions) unless params[:responses].nil? 
      if params['isSubmit'] && params['isSubmit'] == 'Yes'
        @response.update_attribute('is_submitted', true)
      else
      end
      @response.notify_instructor_on_difference if (@map.is_a? ReviewResponseMap) && @response.is_submitted && @response.significant_difference?
    rescue StandardError
      msg = "Your response was not saved. Cause:189 #{$ERROR_INFO}"
    end
    redirect_to controller: 'response', action: 'saving', id: @map.map_id, return: params[:return], msg: msg, save_options: params[:save_options]
  end
def update return unless action_allowed? @response = Response . find ( params [ :id ] ) msg = "" begin @map = @response . map @response . update_attribute ( 'additional_comment' , params [ :review ] [ :comments ] ) @questionnaire = set_questionnaire questions = sort_questions ( @questionnaire . questions ) create_answers ( params , questions ) unless params [ :responses ] . nil? if params [ 'isSubmit' ] && params [ 'isSubmit' ] == 'Yes' @response . update_attribute ( 'is_submitted' , true ) else end @response . notify_instructor_on_difference if ( @map . is_a? ReviewResponseMap ) && @response . is_submitted && @response . significant_difference? rescue StandardError msg = "Your response was not saved. Cause:189 #{$ERROR_INFO}" end redirect_to controller : 'response' , action : 'saving' , id : @map . map_id , return : params [ :return ] , msg : msg , save_options : params [ :save_options ] end
Update the response and answers when student "edit" existing response
Update the response and answers when student " edit " existing response
# the response to be updated # for some rubrics, there might be no questions but only file submission (Dr. Ayala's rubric) # this won't work, since the auto update click edit in the background and override the submit. Don't think this is necessary anyway # @response.update_attribute('is_submitted', false)