-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use result to store completion status
- Loading branch information
Showing
3 changed files
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 21 additions & 6 deletions
27
event_routing_backends/processors/xapi/event_transformers/completion_events.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,51 @@ | ||
""" | ||
Transformers for forum related events. | ||
""" | ||
from tincan import Activity, ActivityDefinition, Extensions, LanguageMap, Verb | ||
from tincan import Activity, ActivityDefinition, Extensions, LanguageMap, Result, Verb | ||
|
||
from event_routing_backends.processors.xapi import constants | ||
from event_routing_backends.processors.xapi.registry import XApiTransformersRegistry | ||
from event_routing_backends.processors.xapi.transformer import XApiTransformer | ||
|
||
|
||
@XApiTransformersRegistry.register('edx.completion.block_completion.changed') | ||
@XApiTransformersRegistry.register("edx.completion.block_completion.changed") | ||
class CompletionCreatedTransformer(XApiTransformer): | ||
""" | ||
Transformers for event generated when an student completion is created or updated. | ||
""" | ||
|
||
verb = Verb( | ||
id=constants.XAPI_VERB_PROGRESSED, | ||
display=LanguageMap({constants.EN: constants.PROGRESSED}), | ||
) | ||
|
||
additional_fields = ('result', ) | ||
|
||
def get_object(self): | ||
""" | ||
Get object for xAPI transformed event related to a thread. | ||
Returns: | ||
`Activity` | ||
""" | ||
print(f'\n\n\n BLOCK ID: {self.get_object_iri("xblock", self.get_data("data.block_id"))}\n\n\n') | ||
return Activity( | ||
id=self.get_object_iri('xblock', self.get_data('data.block_key')), | ||
id=self.get_object_iri("xblock", self.get_data("data.block_id")), | ||
definition=ActivityDefinition( | ||
type=constants.XAPI_ACTIVITY_RESOURCE, | ||
extensions=Extensions({ | ||
constants.XAPI_ACTIVITY_PROGRESS: self.get_data('data.completion')*100 | ||
}) | ||
), | ||
) | ||
|
||
def get_result(self): | ||
""" | ||
Get result for xAPI transformed event related to a thread. | ||
Returns: | ||
`Result` | ||
""" | ||
return Result( | ||
completion=self.get_data("data.completion") == 1.0, | ||
extensions=Extensions( | ||
{constants.XAPI_ACTIVITY_PROGRESS: self.get_data("data.completion")*100} | ||
), | ||
) |
17 changes: 13 additions & 4 deletions
17
...ends/processors/xapi/tests/fixtures/expected/edx.completion.block_completion.changed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters