From f64029bd027f5bf8a98b879ff74643a7217d1fc0 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:09:36 +0700 Subject: [PATCH] feat: add video learning event - learning event util Refs #155 --- .../analytics/utils/LearningEventUtil.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java b/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java index 6e363e4..56c157f 100644 --- a/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java +++ b/utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.java @@ -11,6 +11,7 @@ import ai.elimu.model.v2.gson.content.LetterSoundGson; import ai.elimu.model.v2.gson.content.SoundGson; import ai.elimu.model.v2.gson.content.StoryBookGson; +import ai.elimu.model.v2.gson.content.VideoGson; import ai.elimu.model.v2.gson.content.WordGson; /** @@ -92,4 +93,23 @@ public static void reportStoryBookLearningEvent(StoryBookGson storyBookGson, Lea broadcastIntent.setPackage(analyticsApplicationId); context.sendBroadcast(broadcastIntent); } + + /** + * @param videoGson The video that the student is learning from. + * @param learningEventType The type of learning (i.e. the learning format) that is presented to the student in the application ({@code packageName}). + * @param context Needed to fetch the {@code packageName} of the application where the learning event occurred. + * @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event. + */ + public static void reportVideoLearningEvent(VideoGson videoGson, LearningEventType learningEventType, Context context, String analyticsApplicationId) { + Log.i(LearningEventUtil.class.getName(),"reportVideoLearningEvent"); + + Intent broadcastIntent = new Intent(); + broadcastIntent.setAction("ai.elimu.intent.action.VIDEO_LEARNING_EVENT"); + broadcastIntent.putExtra("packageName", context.getPackageName()); + broadcastIntent.putExtra("videoId", videoGson.getId()); + broadcastIntent.putExtra("videoTitle", videoGson.getTitle()); + broadcastIntent.putExtra("learningEventType", learningEventType.toString()); + broadcastIntent.setPackage(analyticsApplicationId); + context.sendBroadcast(broadcastIntent); + } }