def generate_replace_result_xml(result_sourcedid, score):
 elem = ElementMaker(nsmap={None: 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'})
 xml = elem.imsx_POXEnvelopeRequest(elem.imsx_POXHeader(elem.imsx_POXRequestHeaderInfo(elem.imsx_version('V1.0'), elem.imsx_messageIdentifier(str(uuid.uuid4())))), elem.imsx_POXBody(elem.replaceResultRequest(elem.resultRecord(elem.sourcedGUID(elem.sourcedId(result_sourcedid)), elem.result(elem.resultScore(elem.language('en'), elem.textString(str(score))))))))
 return etree.tostring(xml, xml_declaration=True, encoding='UTF-8')

def generate_replace_result_xml ( result_sourcedid , score ) : elem = ElementMaker ( nsmap = { None : 'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0' } ) xml = elem . imsx_POXEnvelopeRequest ( elem . imsx_POXHeader ( elem . imsx_POXRequestHeaderInfo ( elem . imsx_version ( 'V1.0' ) , elem . imsx_messageIdentifier ( str ( uuid . uuid4 ( ) ) ) ) ) , elem . imsx_POXBody ( elem . replaceResultRequest ( elem . resultRecord ( elem . sourcedGUID ( elem . sourcedId ( result_sourcedid ) ) , elem . result ( elem . resultScore ( elem . language ( 'en' ) , elem . textString ( str ( score ) ) ) ) ) ) ) ) return etree . tostring ( xml , xml_declaration = True , encoding = 'UTF-8' )
create the xml document that contains the new score to be sent to the lti consumer .