def post_grade2(self, grade, user=None, comment=''):
        """
        Post grade to LTI consumer using REST/JSON
        URL munging will is related to:
        https://openedx.atlassian.net/browse/PLAT-281

        :param: grade: 0 <= grade <= 1
        :return: True if post successful and grade valid
        :exception: LTIPostMessageException if call failed
        """
        content_type = 'application/vnd.ims.lis.v2.result+json'
        if user is None:
            user = self.user_id
        lti2_url = self.response_url.replace(
            "/grade_handler",
            "/lti_2_0_result_rest_handler/user/{}".format(user))
        score = float(grade)
        if 0 <= score <= 1.0:
            body = json.dumps({
                "@context": "http://purl.imsglobal.org/ctx/lis/v2/Result",
                "@type": "Result",
                "resultScore": score,
                "comment": comment
            })
            ret = post_message2(self._consumers(), self.key, lti2_url, body,
                                method='PUT',
                                content_type=content_type)
            if not ret:
                raise LTIPostMessageException("Post Message Failed")
            return True

        return False
def post_grade2 ( self , grade , user = None , comment = '' ) : content_type = 'application/vnd.ims.lis.v2.result+json' if user is None : user = self . user_id lti2_url = self . response_url . replace ( "/grade_handler" , "/lti_2_0_result_rest_handler/user/{}" . format ( user ) ) score = float ( grade ) if 0 <= score <= 1.0 : body = json . dumps ( { "@context" : "http://purl.imsglobal.org/ctx/lis/v2/Result" , "@type" : "Result" , "resultScore" : score , "comment" : comment } ) ret = post_message2 ( self . _consumers ( ) , self . key , lti2_url , body , method = 'PUT' , content_type = content_type ) if not ret : raise LTIPostMessageException ( "Post Message Failed" ) return True return False
Post grade to LTI consumer using REST/JSON
        URL munging will is related to:
        https://openedx.atlassian.net/browse/PLAT-281

        :param: grade: 0 <= grade <= 1
        :return: True if post successful and grade valid
        :exception: LTIPostMessageException if call failed