Skip to content

Commit 4d611e8

Browse files
committed
fixed example script, added documentation
1 parent 4b65131 commit 4d611e8

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

examples/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# empty for now

examples/example_script.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
# An example script showing the functionality of the TinCan Python Library
1+
# An example script showing the functionality of the TinCanPython Library
22

33
import uuid
44
from resources import lrs_properties
5-
from tincan.remote_lrs import RemoteLRS
6-
from tincan.statement import Statement
7-
from tincan.agent import Agent
8-
from tincan.verb import Verb
9-
from tincan.activity import Activity
10-
from tincan.context import Context
11-
from tincan.language_map import LanguageMap
12-
from tincan.activity_definition import ActivityDefinition
13-
from tincan.documents import StateDocument
5+
from tincan import (
6+
RemoteLRS,
7+
Statement,
8+
Agent,
9+
Verb,
10+
Activity,
11+
Context,
12+
LanguageMap,
13+
ActivityDefinition,
14+
StateDocument,
15+
)
1416

1517
# construct an LRS
1618
print "constructing the LRS..."
@@ -41,7 +43,7 @@
4143
# construct the object of the statement
4244
print "constructing the Object..."
4345
object = Activity(
44-
id='http://tincanapi.com/TinCanPython/Test/Unit/0',
46+
id='http://tincanapi.com/TinCanPython/Example/0',
4547
definition=ActivityDefinition(
4648
name=LanguageMap({'en-US': 'TinCanPython Library'}),
4749
description=LanguageMap({'en-US': 'Use of, or interaction with, the TinCanPython Library'}),
@@ -55,7 +57,7 @@
5557
registration=uuid.uuid4(),
5658
instructor=Agent(
5759
name='Lord TinCan',
58-
mbox='mailto:tincanpython@tincanapi.com',
60+
mbox='mailto:lordtincan@tincanapi.com',
5961
),
6062
#language='en-US',
6163
)
@@ -88,7 +90,7 @@
8890
print "...done"
8991

9092
print "constructing new Statement from retrieved statement data..."
91-
ret_statement = Statement.from_json(response.data)
93+
ret_statement = response.content
9294
print "...done"
9395

9496
# now, using our old statement and our returned statement, we can send multiple statements
@@ -102,8 +104,8 @@
102104

103105
# we can query our statements using an object
104106
# constructing the query object with common fields
105-
# note: more information about queries can be found in the xAPI spec
106-
# https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements
107+
# note: more information about queries can be found in the API documentation:
108+
# docs/build/html/tincan.html#module-tincan.remote_lrs
107109
query = {
108110
"agent": actor,
109111
"verb": verb,

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[metadata]
2-
description-file = README.md
2+
description-file = README.md

test/languagemap_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ def mapVerificationHelper(self, lmap):
132132

133133
if __name__ == '__main__':
134134
suite = unittest.TestLoader().loadTestsFromTestCase(LanguageMapTest)
135-
unittest.TextTestRunner(verbosity=2).run(suite)
135+
unittest.TextTestRunner(verbosity=2).run(suite)

test/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ def assertSerializeDeserialize(self, obj, version=None):
4747
orig_dict = obj.__dict__
4848
clone_dict = clone.__dict__
4949

50-
self.assertEqual(orig_dict, clone_dict)
50+
self.assertEqual(orig_dict, clone_dict)

tincan/remote_lrs.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,26 @@ def query_statements(self, query):
282282
:type query: dict
283283
:return: LRS Response object with the returned StatementsResult object as content
284284
:rtype: :class:`tincan.lrs_response.LRSResponse`
285+
286+
.. note::
287+
Optional query parameters are\n
288+
**statementId:** (*str*) ID of the Statement to fetch\n
289+
**voidedStatementId:** (*str*) ID of the voided Statement to fetch\n
290+
**agent:** (*Agent* |*Group*) Filter to return Statements for which the specified Agent or Group is the Actor\n
291+
**verb:** (*Verb id IRI*) Filter to return Statements matching the verb id\n
292+
**activity:** (*Activity id IRI*) Filter to return Statements for which the specified Activity is the Object\n
293+
**registration:** (*UUID*) Filter to return Statements matching the specified registration ID\n
294+
**related_activities:** (*bool*) Include Statements for which the Object, Context Activities or any Sub-Statement
295+
properties match the specified Activity\n
296+
**related_agents:** (*bool*) Include Statements for which the Actor, Object, Authority, Instructor, Team, or
297+
any Sub-Statement properties match the specified Agent\n
298+
**since:** (*datetime*) Filter to return Statements stored since the specified datetime\n
299+
**until:** (*datetime*) Filter to return Statements stored at or before the specified datetime\n
300+
**limit:** (*positive int*) Allow <limit> Statements to be returned. 0 indicates the maximum supported by the LRS\n
301+
**format:** (*str* {"ids"|"exact"|"canonical"}) Manipulates how the LRS handles importing and returning the statements\n
302+
**attachments:** (*bool*) If true, the LRS will use multipart responses and include all attachment data per Statement returned.
303+
Otherwise, application/json is used and no attachment information will be returned\n
304+
**ascending:** (*bool*) If true, the LRS will return results in ascending order of stored time (oldest first)\n
285305
"""
286306
params = {}
287307

0 commit comments

Comments
 (0)