app/models/odk/response_parser.rb
# Checks if form ID and version were given, if form exists, and if version is correct
Checks if form ID and version were given, if form exists, and if version is correct
Checks if form ID and version were given if form exists and if version is correct
def lookup_and_check_form(id, version)
      raise SubmissionError, "no form id was given" if id.nil?
      raise FormVersionError, "form version must be specified" if version.nil?
      form = response.form = Form.where(mission: response.mission).find_by(id: id)
      raise SubmissionError, "form not found in this mission" if form.nil?
      raise FormStatusError, "form is a draft" if form.draft?
      raise FormStatusError, "form is paused" if form.paused?
      raise "xml submissions must be to versioned forms" if form.current_version.nil?
      if version.length == FormVersion::CODE_LENGTH
        code = version
        version_num = form.versions.find_by(code: code)&.number
        raise FormVersionError, "Form version code not found" if version_num.nil?
      else
        version_num = version
      end
      raise FormVersionError, "Form version is outdated" if version_num < form.minimum_version_number
    end
def lookup_and_check_form ( id , version ) raise SubmissionError , "no form id was given" if id . nil? raise FormVersionError , "form version must be specified" if version . nil? form = response . form = Form . where ( mission : response . mission ) . find_by ( id : id ) raise SubmissionError , "form not found in this mission" if form . nil? raise FormStatusError , "form is a draft" if form . draft? raise FormStatusError , "form is paused" if form . paused? raise "xml submissions must be to versioned forms" if form . current_version . nil? if version . length == FormVersion :: CODE_LENGTH code = version version_num = form . versions . find_by ( code : code ) &. number raise FormVersionError , "Form version code not found" if version_num . nil? else version_num = version end raise FormVersionError , "Form version is outdated" if version_num < form . minimum_version_number end
Checks if form ID and version were given, if form exists, and if version is correct
Checks if form ID and version were given if form exists and if version is correct
# This check for old 3-letter codes can be removed once we stop supporting them.
id
<not_specific>
version
<not_specific>