From fa3a781a9a3c8f7b1ae47638a9d0b1cf37bd6cc7 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Tue, 22 Aug 2023 13:08:54 -0500 Subject: [PATCH] feat: add tracking log for completion events --- completion/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/completion/models.py b/completion/models.py index 777d4691..d09ea815 100644 --- a/completion/models.py +++ b/completion/models.py @@ -14,12 +14,17 @@ from model_utils.models import TimeStampedModel +from eventtracking import tracker + from . import waffle log = logging.getLogger(__name__) User = auth.get_user_model() +BLOCK_COMPLETION_CHANGED_EVENT_TYPE = 'edx.completion.block_completion.changed' + + def validate_percent(value): """ Verify that the passed value is between 0.0 and 1.0. @@ -126,6 +131,20 @@ def submit_completion(self, user, block_key, completion): "BlockCompletion.objects.submit_completion should not be \ called when the feature is disabled." ) + + tracker.emit( + str(BLOCK_COMPLETION_CHANGED_EVENT_TYPE), + { + 'user_id': user.id, + 'course_id': str(block_key.course_key), + 'context_key': str(context_key), + 'block_key': str(block_key), + 'block_type': block_type, + 'completion': completion, + 'is_new': is_new, + } + ) + return obj, is_new @transaction.atomic()