app/controllers/response_controller.rb
# Prepare the parameters when student clicks "Edit"
Prepare the parameters when student clicks "Edit"
Prepare the parameters when student clicks " Edit "
def edit
    @header = "Edit"
    @next_action = "update"
    @return = params[:return]
    @response = Response.find(params[:id])
    @map = @response.map
    @contributor = @map.contributor
    set_all_responses
    if @prev.present?
      @sorted = @review_scores.sort {|m1, m2| (m1.version_num and m2.version_num) ? m2.version_num <=> m1.version_num : (m1.version_num ? -1 : 1) }
      @largest_version_num = @sorted[0]
    end
    @modified_object = @response.response_id
    set_content
    @review_scores = []
    @questions.each do |question|
      @review_scores << Answer.where(response_id: @response.response_id, question_id:  question.id).first
    end
    render action: 'response'
  end
def edit @header = "Edit" @next_action = "update" @return = params [ :return ] @response = Response . find ( params [ :id ] ) @map = @response . map @contributor = @map . contributor set_all_responses if @prev . present? @sorted = @review_scores . sort { | m1 , m2 | ( m1 . version_num and m2 . version_num ) ? m2 . version_num <=> m1 . version_num : ( m1 . version_num ? - 1 : 1 ) } @largest_version_num = @sorted [ 0 ] end @modified_object = @response . response_id set_content @review_scores = [ ] @questions . each do | question | @review_scores << Answer . where ( response_id : @response . response_id , question_id : question . id ) . first end render action : 'response' end
Prepare the parameters when student clicks "Edit"
Prepare the parameters when student clicks " Edit "
# set more handy variables for the view