def check_replace_result_response(response):
 if (response.status_code != 200):
  log.error('Outcome service response: Unexpected status code %s', response.status_code)
  return False
 try:
  xml = response.content
  root = etree.fromstring(xml)
 except etree.ParseError as ex:
  log.error('Outcome service response: Failed to parse XML: %s\n %s', ex, xml)
  return False
 major_codes = root.xpath('//ns:imsx_codeMajor', namespaces={'ns': 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'})
 if (len(major_codes) != 1):
  log.error('Outcome service response: Expected exactly one imsx_codeMajor field in response. Received %s', major_codes)
  return False
 if (major_codes[0].text != 'success'):
  log.error('Outcome service response: Unexpected major code: %s.', major_codes[0].text)
  return False
 return True

def check_replace_result_response ( response ) : if ( response . status_code != 200 ) : log . error ( 'Outcome service response: Unexpected status code %s' , response . status_code ) return False try : xml = response . content root = etree . fromstring ( xml ) except etree . ParseError as ex : log . error ( 'Outcome service response: Failed to parse XML: %s\n %s' , ex , xml ) return False major_codes = root . xpath ( '//ns:imsx_codeMajor' , namespaces = { 'ns' : 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0' } ) if ( len ( major_codes ) != 1 ) : log . error ( 'Outcome service response: Expected exactly one imsx_codeMajor field in response. Received %s' , major_codes ) return False if ( major_codes [ 0 ] . text != 'success' ) : log . error ( 'Outcome service response: Unexpected major code: %s.' , major_codes [ 0 ] . text ) return False return True
parse the response sent by the lti consumer after an score update message has been processed .