Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other request types other than posting a grade #44

Open
velochy opened this issue Jul 9, 2015 · 1 comment
Open

Other request types other than posting a grade #44

velochy opened this issue Jul 9, 2015 · 1 comment

Comments

@velochy
Copy link

velochy commented Jul 9, 2015

The standard (http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html#_Toc330273035) specifies a few other types of interaction besides just posting the grade.
6.1.2 "readResult" for getting the grade from the LTI Consumer, for instance.

generating the message can be done with generate_request_xml setting operation to "readResult" but posting it with post_message will just yield "success" but not the actual grade

Currently, this can be worked around by calling the internal _post_patched_request directly but I feel this is more than somewhat hackish.

Would be happy to implement a fix to this if you explain how you want it in terms of architecture. My proposal would be to have post_message return either False when request fails but the response xml when it is successful, but there are quite a few other ways this issue could be approached.

@velochy
Copy link
Author

velochy commented Jul 11, 2015

For reference, a working readResult function using _post_patched_request:

xml = generate_request_xml(message_id, 'readResult', sourced_id, None)

(_, content) = _post_patched_request(
    PYLTI_CONFIG["consumers"],
    key,
    xml,
    session['lis_outcome_service_url'],
    'POST',
    'application/xml',
)
is_success = "<imsx_codeMajor>success</imsx_codeMajor>" in content

if not is_success:
    return None

from xml.etree import ElementTree
xml_tree = ElementTree.XML(content)

ns = {'ns0':'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'}
rscore = float(xml_tree.findtext('ns0:imsx_POXBody/ns0:readResultResponse/'+
               'ns0:result/ns0:resultScore/ns0:textString',None,ns))

return rscore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant