def post(params, answer_sheet)
      questions_indexed = @questions.index_by {|q| q.id}
      
      # loop over form values
      params ||= {}
      params.each do |question_id, response|
        next if questions_indexed[question_id.to_i].nil? # the rare case where a question was removed after the app was opened.
        # update each question with the posted response
        questions_indexed[question_id.to_i].set_response(posted_values(response), answer_sheet)
      end
    end
def post(params, answer_sheet)
      questions_indexed = @questions.index_by {|q| q.id}
      
      # loop over form values
      params ||= {}
      params.each do |question_id, response|
        next if questions_indexed[question_id.to_i].nil? # the rare case where a question was removed after the app was opened.
        # update each question with the posted response
        questions_indexed[question_id.to_i].set_response(posted_values(response), answer_sheet)
      end
    end
associate answers from database with a set of elements
 update with responses from form