tincan package

Submodules

tincan.about module

class tincan.about.About(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

Stores info about this installation of tincan.

Parameters:
  • version (list of unicode) – The versions supported. This attribute is required.
  • extensions (tincan.Extensions) – Custom user data. This attribute is optional.
__init__(*args, **kwargs)
extensions

Extensions for About

Setter:Tries to convert to tincan.Extensions. If None is provided,

sets to an empty tincan.Extensions dict. :setter type: tincan.Extensions | dict | None :rtype: tincan.Extensions

version

Version for About

Setter:Sets the version. If None is provided, defaults to

[tincan.Version.latest]. If a string is provided, makes a 1-element list containing the string. :setter type: list | tuple | str | unicode | None :rtype: list

tincan.activity module

class tincan.activity.Activity(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase, tincan.statement_targetable.StatementTargetable

__init__(*args, **kwargs)
definition

Definition for Activity

Setter:Tries to convert to tincan.ActivityDefinition
Setter type:tincan.ActivityDefinition
Return type:tincan.ActivityDefinition
id

Id for Activity

Setter:Sets the id
Setter type:unicode
Return type:unicode
object_type

Object type for Activity. Will always be “Activity”

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.activity_definition module

class tincan.activity_definition.ActivityDefinition(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
choices

Choices for Activity Definition

Setter:Tries to convert to tincan.InteractionComponentList
Setter type:tincan.InteractionComponentList
Return type:tincan.InteractionComponentList
correct_responses_pattern

Correct responses pattern for Activity Definition

Setter:Sets the correct responses pattern
Setter type:list
Return type:list
description

Description for Activity Definition

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
extensions

Extensions for Activity Definition

Setter:Tries to convert to tincan.Extensions
Setter type:tincan.Extensions
Return type:tincan.Extensions
interaction_type

Interaction type for Activity Definition. Must be a value in interaction_types

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
more_info

More info for Activity Definition

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
name

Name for Activity Definition

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
scale

Scale for Activity Definition

Setter:Tries to convert to tincan.InteractionComponentList
Setter type:tincan.InteractionComponentList
Return type:tincan.InteractionComponentList
source

Source for Activity Definition

Setter:Tries to convert to tincan.InteractionComponentList
Setter type:tincan.InteractionComponentList
Return type:tincan.InteractionComponentList
steps

Steps for Activity Definition

Setter:Tries to convert to tincan.InteractionComponentList
Setter type:tincan.InteractionComponentList
Return type:tincan.InteractionComponentList
target

Target for Activity Definition

Setter:Tries to convert to tincan.InteractionComponentList
Setter type:tincan.InteractionComponentList
Return type:tincan.InteractionComponentList
type

Type for Activity Definition

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.activity_list module

class tincan.activity_list.ActivityList(*args, **kwargs)

Bases: tincan.typed_list.TypedList

tincan.agent module

class tincan.agent.Agent(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
account

Account for Agent

Setter:Tries to convert to tincan.AgentAccount
Setter type:tincan.AgentAccount
Return type:tincan.AgentAccount
mbox

Mbox for Agent

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
mbox_sha1sum

Mbox_sha1sum for Agent

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
name

Name for Agent

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
object_type

Object Type for Agent. Will always be ‘Agent’

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
openid

Openid for Agent

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.agent_account module

class tincan.agent_account.AgentAccount(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
home_page

Homepage for Account

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
name

Name for Account

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.agent_list module

class tincan.agent_list.AgentList(*args, **kwargs)

Bases: tincan.typed_list.TypedList

tincan.attachment module

class tincan.attachment.Attachment(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
content_type

Content type for Attachment

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
description

Description for Attachment

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
display

Display for Attachment

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
fileurl

File URL for Attachment

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
length

Usage type for Attachment

Setter:Tries to convert to long
Setter type:int | long
Return type:long
sha2

Sha2 for Attachment

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
usage_type

Usage type for Attachment

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.attachment_list module

class tincan.attachment_list.AttachmentList(*args, **kwargs)

Bases: tincan.typed_list.TypedList

tincan.base module

class tincan.base.Base(*args, **kwargs)

Bases: object

__init__(*args, **kwargs)

Initializes an object by checking the provided arguments against lists defined in the individual class. If required properties are defined, this method will set them to None by default. Optional properties will be ignored if they are not provided. The class may provide custom setters for properties, in which case those setters (see __setattr__ below).

tincan.context module

class tincan.context.Context(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
context_activities

Context Activities for Context

Setter:Tries to convert to tincan.ContextActivities
Setter type:tincan.ContextActivities
Return type:tincan.ContextActivities
extensions

Extensions for Context

Setter:Tries to convert to tincan.Extensions
Setter type:tincan.Extensions
Return type:tincan.Extensions
instructor

Instructor for Context

Setter:Tries to convert to tincan.Agent or tincan.Group
Setter type:tincan.Agent | tincan.Group
Return type:tincan.Agent | tincan.Group
language

Language for Context

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
platform

Platform for Context

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
registration

Registration for Context

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
revision

Revision for Context

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
statement

Statement for Context

Setter:Tries to convert to tincan.StatementRef
Setter type:tincan.StatementRef
Return type:tincan.StatementRef
team

Team for Context

Setter:Tries to convert to tincan.Group
Setter type:tincan.Group
Return type:tincan.Group

tincan.context_activities module

class tincan.context_activities.ContextActivities(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
category

Category for Context Activities

Setter:Tries to convert to tincan.ActivityList
Setter type:tincan.ActivityList
Return type:tincan.ActivityList
grouping

Grouping for Context Activities

Setter:Tries to convert to tincan.ActivityList
Setter type:tincan.ActivityList
Return type:tincan.ActivityList
other

Other for Context Activities

Setter:Tries to convert to tincan.ActivityList
Setter type:tincan.ActivityList
Return type:tincan.ActivityList
parent

Parent for Context Activities

Setter:Tries to convert to tincan.ActivityList
Setter type:tincan.ActivityList
Return type:tincan.ActivityList

tincan.extensions module

class tincan.extensions.Extensions(*args, **kwargs)

Bases: dict, tincan.serializable_base.SerializableBase

Contains domain-specific custom data.

Can be created from a dict, another tincan.Extensions, or from args and kwargs.

Use this like a regular Python dict.

__init__(*args, **kwargs)

tincan.group module

class tincan.group.Group(*args, **kwargs)

Bases: tincan.agent.Agent

__init__(*args, **kwargs)
addmember(value)

Adds a single member to this group’s list of members. Tries to convert to tincan.Agent

Parameters:value (tincan.Agent) – The member to add to this group
member

Members for Group

Setter:Tries to convert to tincan.AgentList
Setter type:tincan.AgentList
Return type:tincan.AgentList
object_type

Object type for Group. Will always be “Group”

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.http_request module

class tincan.http_request.HTTPRequest(*args, **kwargs)

Bases: tincan.base.Base

Creates a new HTTPRequest object, either from a dict, another object, or from kwargs

Parameters:
  • method (unicode) – Method for the HTTP connection (“GET”, “POST”, “DELETE”, etc.)
  • resource (unicode) – Resource for the LRS HTTP connection (“about”, “statements”, “activities/state”, etc.)
  • headers (dict(unicode:unicode)) – Headers for the HTTP connection (“If-Match”, “Content-Type”, etc.)
  • query_params (dict(unicode:unicode)) – Query parameters for the HTTP connection (“registration”, “since”, “statementId”, etc.)
  • content (unicode) – Content body for the HTTP connection. Valid json string.
  • ignore404 (bool) – True if this request should consider a 404 response successful, False otherwise
__init__(*args, **kwargs)
content

Content body for the HTTP connection. Valid json string.

Setter:Tries to convert to unicode
Setter type:str | unicode
Return type:unicode
headers

Headers for the HTTP connection (“If-Match”, “Content-Type”, etc.)

Setter:Accepts a dict or an object
Setter type:dict
Return type:dict
ignore404

True if this request should consider a 404 response successful, False otherwise

Setter:Tries to convert to boolean
Setter type:bool
Return type:bool
method

Method for the HTTP connection (“GET”, “POST”, “DELETE”, etc.)

Setter:Tries to convert to unicode
Setter type:str | unicode
Return type:unicode
query_params

Query parameters for the HTTP connection (“registration”, “since”, “statementId”, etc.)

Setter:Accepts a dict or an object
Setter type:dict
Return type:dict
resource

Resource for the LRS HTTP connection (“about”, “statements”, “activities/state”, etc.)

Setter:Tries to convert to unicode
Setter type:str | unicode
Return type:unicode

tincan.interaction_component module

class tincan.interaction_component.InteractionComponent(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
description

Description for Agent

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
id

Id for Agent

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.interaction_component_list module

class tincan.interaction_component_list.InteractionComponentList(*args, **kwargs)

Bases: tincan.typed_list.TypedList

tincan.language_map module

class tincan.language_map.LanguageMap(*args, **kwargs)

Bases: dict, tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)

Initializes a LanguageMap with the given mapping

This constructor will first check the arguments for flatness to avoid nested languagemaps (which are invalid) and then call the base dict constructor

tincan.lrs_response module

class tincan.lrs_response.LRSResponse(*args, **kwargs)

Bases: tincan.base.Base

Creates a new LRSResponse object, either from a dict, another object, or from kwargs

Parameters:
  • success (bool) – True if the LRS return a successful status (sometimes includes 404), False otherwise
  • request (HTTPRequest) – HTTPRequest object that was sent to the LRS
  • response (HTTPResponse) – HTTPResponse object that was received from the LRS
  • data (unicode) – Body of the HTTPResponse
  • content – Parsed content received from the LRS
__init__(*args, **kwargs)
content

Parsed content received from the LRS

data
request

The HTTPRequest object that was sent to the LRS

Setter:Tries to convert to an HTTPRequest object
Setter type:tincan.http_request.HTTPRequest
Return type:tincan.http_request.HTTPRequest
response

The HTTPResponse object that was sent to the LRS

Setter:Must be an HTTPResponse object
Setter type:httplib.HTTPResponse
Return type:httplib.HTTPResponse
success

The LRSResponse’s success. True if the LRS return a successful status (sometimes includes 404), False otherwise.

Setter:Tries to convert to boolean
Setter type:bool
Return type:bool

tincan.remote_lrs module

class tincan.remote_lrs.RemoteLRS(*args, **kwargs)

Bases: tincan.base.Base

__init__(*args, **kwargs)

RemoteLRS Constructor

Parameters:
  • endpoint (str | unicode) – lrs endpoint
  • version (str | unicode) – Version used for lrs communication
  • username (str | unicode) – Username for lrs. Used to build the authentication string.
  • password (str | unicode) – Password for lrs. Used to build the authentication string.
  • auth (str | unicode) – Authentication string
about()

Gets about response from LRS

Returns:LRS Response object with the returned LRS about object as content
Return type:tincan.lrs_response.LRSResponse
auth

Authority being used for remote LRS communication

Setter:Tries to convert to unicode.
Setter type:str | unicode
Return type:unicode
clear_state(activity, agent, registration=None)

Clear state(s) with specified activity and agent

Parameters:
  • activity (tincan.activity.Activity) – Activity object of state(s) to be deleted
  • agent (tincan.agent.Agent) – Agent object of state(s) to be deleted
  • registration (str | unicode) – registration UUID of state(s) to be deleted
Returns:

LRS Response object

Return type:

tincan.lrs_response.LRSResponse

delete_activity_profile(profile)

Delete activity profile doc from LRS

Parameters:profile (tincan.documents.activity_profile_document.ActivityProfileDocument) – Activity profile document to be deleted
Returns:LRS Response object
Return type:tincan.lrs_response.LRSResponse
delete_agent_profile(profile)

Delete agent profile doc from LRS

Parameters:profile (tincan.documents.agent_profile_document.AgentProfileDocument) – Agent profile document to be deleted
Returns:LRS Response object
Return type:tincan.lrs_response.LRSResponse
delete_state(state)

Delete a specified state from the LRS

Parameters:state (tincan.documents.state_document.StateDocument) – State document to be deleted
Returns:LRS Response object
Return type:tincan.lrs_response.LRSResponse
endpoint

The endpoint of the Remote LRS

Setter:Tries to convert to unicode. Appends a “/” if necessary. Prepends http:// if necessary.
Setter type:str | unicode
Return type:unicode
get_endpoint_server_root()

Parses RemoteLRS object’s endpoint and returns its root

Returns:Root of the RemoteLRS object endpoint
Return type:unicode
more_statements(more_url)

Query the LRS for more statements

Parameters:more_url (str | unicode) – URL from a StatementsResult object used to retrieve more statements
Returns:LRS Response object with the returned StatementsResult object as content
Return type:tincan.lrs_response.LRSResponse
query_statements(query)

Query the LRS for statements with specified parameters

Parameters:query (dict) – Dictionary of query parameters and their values
Returns:LRS Response object with the returned StatementsResult object as content
Return type:tincan.lrs_response.LRSResponse

Note

Optional query parameters are

statementId: (str) ID of the Statement to fetch voidedStatementId: (str) ID of the voided Statement to fetch agent: (Agent |*Group*) Filter to return Statements for which the specified Agent or Group is the Actor **verb:** (*Verb id IRI*) Filter to return Statements matching the verb id **activity:** (*Activity id IRI*) Filter to return Statements for which the specified Activity is the Object **registration:** (*UUID*) Filter to return Statements matching the specified registration ID **related_activities:** (*bool*) Include Statements for which the Object, Context Activities or any Sub-Statement properties match the specified Activity **related_agents:** (*bool*) Include Statements for which the Actor, Object, Authority, Instructor, Team, or any Sub-Statement properties match the specified Agent **since:** (*datetime*) Filter to return Statements stored since the specified datetime **until:** (*datetime*) Filter to return Statements stored at or before the specified datetime **limit:** (*positive int*) Allow <limit> Statements to be returned. 0 indicates the maximum supported by the LRS **format:** (*str* {“ids”|“exact”|”canonical”}) Manipulates how the LRS handles importing and returning the statements attachments: (bool) If true, the LRS will use multipart responses and include all attachment data per Statement returned. Otherwise, application/json is used and no attachment information will be returned ascending: (bool) If true, the LRS will return results in ascending order of stored time (oldest first)
retrieve_activity_profile(activity, profile_id)

Retrieve activity profile with the specified parameters

Parameters:
  • activity (tincan.activity.Activity) – Activity object of the desired activity profile
  • profile_id (str | unicode) – UUID of the desired profile
Returns:

LRS Response object with an activity profile doc as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_activity_profile_ids(activity, since=None)

Retrieve activity profile id(s) with the specified parameters

Parameters:
  • activity (tincan.activity.Activity) – Activity object of desired activity profiles
  • since (str | unicode) – Retrieve activity profile id’s since this time
Returns:

LRS Response object with list of retrieved activity profile id’s as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_agent_profile(agent, profile_id)

Retrieve agent profile with the specified parameters

Parameters:
  • agent (tincan.agent.Agent) – Agent object of the desired agent profile
  • profile_id (str | unicode) – UUID of the desired agent profile
Returns:

LRS Response object with an agent profile doc as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_agent_profile_ids(agent, since=None)

Retrieve agent profile id(s) with the specified parameters

Parameters:
  • agent (tincan.agent.Agent) – Agent object of desired agent profiles
  • since (str | unicode) – Retrieve agent profile id’s since this time
Returns:

LRS Response object with list of retrieved agent profile id’s as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_state(activity, agent, state_id, registration=None)

Retrieve state from LRS with the provided parameters

Parameters:
  • activity (tincan.activity.Activity) – Activity object of desired state
  • agent (tincan.agent.Agent) – Agent object of desired state
  • state_id (str | unicode) – UUID of desired state
  • registration (str | unicode) – registration UUID of desired state
Returns:

LRS Response object with retrieved state document as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_state_ids(activity, agent, registration=None, since=None)

Retrieve state id’s from the LRS with the provided parameters

Parameters:
  • activity (tincan.activity.Activity) – Activity object of desired states
  • agent (tincan.agent.Agent) – Agent object of desired states
  • registration (str | unicode) – Registration UUID of desired states
  • since (str | unicode) – Retrieve state id’s since this time
Returns:

LRS Response object with the retrieved state id’s as content

Return type:

tincan.lrs_response.LRSResponse

retrieve_statement(statement_id)

Retrieve a statement from the server from its id

Parameters:statement_id (str | unicode) – The UUID of the desired statement
Returns:LRS Response object with the retrieved statement as content
Return type:tincan.lrs_response.LRSResponse
retrieve_voided_statement(statement_id)

Retrieve a voided statement from the server from its id

Parameters:statement_id (str | unicode) – The UUID of the desired voided statement
Returns:LRS Response object with the retrieved voided statement as content
Return type:tincan.lrs_response.LRSResponse
save_activity_profile(profile)

Save an activity profile doc to the LRS

Parameters:profile (tincan.documents.activity_profile_document.ActivityProfileDocument) – Activity profile doc to be saved
Returns:LRS Response object with the saved activity profile doc as content
Return type:tincan.lrs_response.LRSResponse
save_agent_profile(profile)

Save an agent profile doc to the LRS

Parameters:profile (tincan.documents.agent_profile_document.AgentProfileDocument) – Agent profile doc to be saved
Returns:LRS Response object with the saved agent profile doc as content
Return type:tincan.lrs_response.LRSResponse
save_state(state)

Save a state doc to the LRS

Parameters:state (tincan.documents.state_document.StateDocument) – State document to be saved
Returns:LRS Response object with saved state as content
Return type:tincan.lrs_response.LRSResponse
save_statement(statement)

Save statement to LRS and update statement id if necessary

Parameters:statement (tincan.statement.Statement) – Statement object to be saved
Returns:LRS Response object with the saved statement as content
Return type:tincan.lrs_response.LRSResponse
save_statements(statements)

Save statements to LRS and update their statement id’s

Parameters:statements (StatementList) – A list of statement objects to be saved
Returns:LRS Response object with the saved list of statements as content
Return type:tincan.lrs_response.LRSResponse
version

Version being used for remote LRS communication

Setter:Tries to convert to unicode. Must be a supported

version. Setting to None defaults to the latest version. :setter type: str | unicode :rtype: unicode

tincan.result module

class tincan.result.Result(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

Stores the state of an activity.

Can be created from a dict, another Result, or from kwargs.

All these attributes are optional and settable to None:

Parameters:
  • score (tincan.Score) – Contains the score and its scaling information
  • success (bool) – Whether successful
  • completion (bool) – Whether completed
  • duration (timedelta) – How long it took
  • response (unicode) – HTTPResponse data
  • extensions (tincan.Extensions) – Custom user data
__init__(*args, **kwargs)
completion

Completion for Result

Setter:Tries to convert to bool. If None is provided,

this signifies the absence of this data. :setter type: bool | None :rtype: bool | None

duration

Duration for Result

Setter:Tries to convert to datetime.timedelta. If

None is provided, this signifies the absence of this data.

Strings will be parsed as ISO 8601 durations.

If a number is provided, it will be interpreted as the number of seconds.

If a dict is provided, does datetime.timedelta(**value).

Setter type:datetime.timedelta | unicode | str | int | float | dict | None
Return type:datetime.timedelta | None
Raises:ValueError if the provided data was a valid type, but could not be converted
Raises:TypeError if unsupported type is provided
extensions

Extensions for Result

Setter:Tries to convert to tincan.Extensions. If None is provided,

this signifies the absence of this data. :setter type: tincan.Extensions | dict | None :rtype: tincan.Extensions | None

response

Response for Result

Setter:Tries to convert to unicode. If None is provided,

this signifies the absence of this data. :setter type: unicode | str | None :rtype: unicode | None

score

Score for Result

Setter:Tries to convert to tincan.Score. If

None is provided, this signifies the absence of this data. :setter type: tincan.Score | dict | None :rtype: tincan.Score | None

success

Success for Result

Setter:Tries to convert to bool. If None is provided,

this signifies the absence of this data. :setter type: bool | None :rtype: bool | None

tincan.score module

class tincan.score.Score(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

Stores the scoring data for an activity.

Can be created from a dict, another Score, or from kwargs.

All these attributes are optional and settable to None:

Parameters:
  • scaled (float) – Scaled score
  • raw (float) – Raw score
  • min (float) – Minimum score possible
  • max (float) – Maximum score possible
__init__(*args, **kwargs)
max

Max for Score

Setter:Tries to convert to float. If None is provided,

this signifies the absence of this data. :setter type: float | int | None :rtype: float | None :raises: TypeError if unsupported type is provided

min

Min for Score

Setter:Tries to convert to float. If None is provided,

this signifies the absence of this data. :setter type: float | int | None :rtype: float | None :raises: TypeError if unsupported type is provided

raw

Raw for Score

Setter:Tries to convert to float. If None is provided,

this signifies the absence of this data. :setter type: float | int | None :rtype: float | None :raises: TypeError if unsupported type is provided

scaled

Scaled for Score

Setter:Tries to convert to float. If None is provided,

this signifies the absence of this data. :setter type: float | int | None :rtype: float | None :raises: TypeError if unsupported type is provided

tincan.serializable_base module

class tincan.serializable_base.SerializableBase(*args, **kwargs)

Bases: tincan.base.Base

__init__(*args, **kwargs)
as_version(version='1.0.1')

Returns a dict that has been modified based on versioning in order to be represented in JSON properly

A class should overload as_version(self, version) implementation in order to tailor a more specific representation

Parameters:version (str | unicode) – the relevant version. This allows for variance between versions
classmethod from_json(json_data)

Tries to convert a JSON representation to an object of the same type as self

A class can provide a _fromJSON implementation in order to do specific type checking or other custom implementation details. This method will throw a ValueError for invalid JSON, a TypeError for improperly constructed, but valid JSON, and any custom errors that can be be propagated from class constructors.

Parameters:json_data (str | unicode) – The JSON string to convert
Raises:TypeError, ValueError, LanguageMapInitError
to_json(version='1.0.1')

Tries to convert an object into a JSON representation and return the resulting string

An Object can define how it is serialized by overriding the as_version() implementation. A caller may further define how the object is serialized by passing in a custom encoder. The default encoder will ignore properties of an object that are None at the time of serialization.

Parameters:version – The version to which the object must be serialized to.

This will default to the latest version supported by the library. :type version: str | unicode

tincan.statement module

class tincan.statement.Statement(*args, **kwargs)

Bases: tincan.statement_base.StatementBase

__init__(*args, **kwargs)
authority

Authority for Statement

Setter:Tries to convert to tincan.Agent
Setter type:tincan.Agent
Return type:tincan.Agent
id

Id for Statement

Setter:Tries to unicode
Setter type:unicode
Return type:unicode
object

Object for Statement

Setter:Sets the object
Setter type:tincan.Agent | tincan.Group | tincan.StatementRef | tincan.SubStatement | tincan.Activity
Return type:tincan.Agent | tincan.Group | tincan.StatementRef | tincan.SubStatement | tincan.Activity
result

Result for Statement

Setter:Tries to convert to tincan.Result
Setter type:tincan.Result
Return type:tincan.Result
stored

Storage time. Tries to convert to datetime.datetime. If no timezone is given, makes a naive datetime.datetime.

Strings will be parsed as ISO 8601 timestamps.

If a number is provided, it will be interpreted as a UNIX timestamp, which by definition is UTC.

If a dict is provided, does datetime.datetime(**value).

If a tuple or a list is provided, does datetime.datetime(*value). Uses the timezone in the tuple or list if provided.

Setter type:datetime.datetime | unicode | str | int | float | dict | tuple | list | None
Return type:datetime.datetime
version

Version for Statement

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.statement_base module

class tincan.statement_base.StatementBase(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
actor

Actor for StatementBase

Setter:Tries to convert to tincan.Agent or tincan.Group
Setter type:tincan.Agent | tincan.Group
Return type:tincan.Agent | tincan.Group
attachments

Attachments for StatementBase

Setter:Tries to convert each element to tincan.Attachment
Setter type:tincan.AttachmentList
Return type:tincan.AttachmentList
context

Context for StatementBase

Setter:Tries to convert to tincan.Context
Setter type:tincan.Context
Return type:tincan.Context
timestamp

Timestamp for StatementBase

Setter:Tries to convert to datetime.datetime. If

no timezone is given, makes a naive datetime.datetime.

Strings will be parsed as ISO 8601 timestamps.

If a number is provided, it will be interpreted as a UNIX timestamp, which by definition is UTC.

If a dict is provided, does datetime.datetime(**value).

If a tuple or a list is provided, does datetime.datetime(*value). Uses the timezone in the tuple or list if provided.

Setter type:datetime.datetime | unicode | str | int | float | dict | tuple | list | None
Return type:datetime.datetime
verb

Verb for StatementBase

Setter:Tries to convert to tincan.Verb
Setter type:tincan.Verb
Return type:tincan.Verb

tincan.statement_list module

class tincan.statement_list.StatementList(*args, **kwargs)

Bases: tincan.typed_list.TypedList

tincan.statement_ref module

class tincan.statement_ref.StatementRef(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
id

Id for Statement Ref

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
object_type

Object type for Statement Ref. Will always be “StatementRef”

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.statement_targetable module

class tincan.statement_targetable.StatementTargetable

Bases: object

__init__()
get_object_type()

Returns the object type of self [Activity | Agent | StatementRef | SubStatement]

tincan.statements_result module

class tincan.statements_result.StatementsResult(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
more

More for StatementsResult

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode
statements

Statements for StatementsResult

Setter:Tries to convert each element to tincan.Statement
Setter type:list of tincan.Statement
Return type:list of tincan.Statement

tincan.substatement module

class tincan.substatement.SubStatement(*args, **kwargs)

Bases: tincan.statement_base.StatementBase

__init__(*args, **kwargs)
object

Object for SubStatement

Setter:Setter for object
Setter type:tincan.Agent | tincan.Group | tincan.Activity
Return type:tincan.Agent | tincan.Group | tincan.Activity
object_type

Object Type for SubStatement. Will always be “SubStatement”

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.typed_list module

class tincan.typed_list.TypedList(*args, **kwargs)

Bases: list, tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
append(value)
extend(value)
insert(ind, value)

tincan.verb module

class tincan.verb.Verb(*args, **kwargs)

Bases: tincan.serializable_base.SerializableBase

__init__(*args, **kwargs)
display

Display for Verb

Setter:Tries to convert to tincan.LanguageMap
Setter type:tincan.LanguageMap
Return type:tincan.LanguageMap
id

Id for Verb

Setter:Tries to convert to unicode
Setter type:unicode
Return type:unicode

tincan.version module

class tincan.version.Version

Bases: object

latest = '1.0.1'
supported = ['1.0.1', '1.0.0']

Module contents

Client library for communicating with an LRS (Learning Record Store) implementing Tin Can API version 1.0.0 or 1.0.1.

Web site: <https://github.com/RusticiSoftware/TinCanPython>

For more info about the Tin Can API, see <http://tincanapi.com/>.