本文整理汇总了Python中tincan.http_request.HTTPRequest.query_params["statementId"]方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPRequest.query_params["statementId"]方法的具体用法?Python HTTPRequest.query_params["statementId"]怎么用?Python HTTPRequest.query_params["statementId"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tincan.http_request.HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest.query_params["statementId"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_statement
# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import query_params["statementId"] [as 别名]
def save_statement(self, statement):
"""Save statement to LRS and update statement id if necessary
:param statement: Statement object to be saved
:type statement: :class:`tincan.statement.Statement`
:return: LRS Response object with the saved statement as content
:rtype: :class:`tincan.lrs_response.LRSResponse`
"""
if not isinstance(statement, Statement):
statement = Statement(statement)
request = HTTPRequest(
method="POST",
resource="statements"
)
if statement.id is not None:
request.method = "PUT"
request.query_params["statementId"] = statement.id
request.headers["Content-Type"] = "application/json"
request.content = statement.to_json(self.version)
lrs_response = self._send_request(request)
if lrs_response.success:
if statement.id is None:
statement.id = json.loads(lrs_response.data)[0]
lrs_response.content = statement
return lrs_response
示例2: retrieve_statement
# 需要导入模块: from tincan.http_request import HTTPRequest [as 别名]
# 或者: from tincan.http_request.HTTPRequest import query_params["statementId"] [as 别名]
def retrieve_statement(self, statement_id):
"""Retrieve a statement from the server from its id
:param statement_id: The UUID of the desired statement
:type statement_id: str | unicode
:return: LRS Response object with the retrieved statement as content
:rtype: :class:`tincan.lrs_response.LRSResponse`
"""
request = HTTPRequest(
method="GET",
resource="statements"
)
request.query_params["statementId"] = statement_id
lrs_response = self._send_request(request)
if lrs_response.success:
lrs_response.content = Statement.from_json(lrs_response.data)
return lrs_response