Skip to content

Commit d7ea743

Browse files
authored
Merge pull request #376 from elimu-ai/375-add-numberassessmentevent
feat(utils): add number assessment event
2 parents 72a6c16 + 21cfc99 commit d7ea743

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

utils/src/main/java/ai/elimu/analytics/utils/AssessmentEventUtil.kt

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ai.elimu.analytics.utils
22

33
import ai.elimu.model.v2.gson.content.LetterGson
44
import ai.elimu.model.v2.gson.content.LetterSoundGson
5+
import ai.elimu.model.v2.gson.content.NumberGson
56
import ai.elimu.model.v2.gson.content.SoundGson
67
import ai.elimu.model.v2.gson.content.WordGson
78
import android.content.Context
@@ -23,7 +24,7 @@ object AssessmentEventUtil {
2324
* @param masteryScore A value in the range [0.0, 1.0].
2425
* @param timeSpentMs The number of milliseconds passed between the student opening the assessment task and submitting a response. E.g. `15000`.
2526
* @param additionalData Any additional data related to the learning event, e.g. `{'is_letter_pressed':true}`
26-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
27+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
2728
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
2829
*/
2930
fun reportLetterSoundAssessmentEvent(
@@ -59,16 +60,16 @@ object AssessmentEventUtil {
5960
* @param masteryScore A value in the range [0.0, 1.0].
6061
* @param timeSpentMs The number of milliseconds passed between the student opening the assessment task and submitting a response. E.g. `15000`.
6162
* @param additionalData Any additional data related to the learning event, e.g. `{'is_word_pressed':true}`
62-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
63+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
6364
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
6465
*/
6566
fun reportWordAssessmentEvent(
6667
wordGson: WordGson,
67-
masteryScore: Float?,
68-
timeSpentMs: Long?,
68+
masteryScore: Float,
69+
timeSpentMs: Long,
6970
additionalData: JSONObject? = null,
7071
context: Context,
71-
analyticsApplicationId: String?
72+
analyticsApplicationId: String
7273
) {
7374
Log.i(TAG, "reportWordAssessmentEvent")
7475

@@ -86,4 +87,37 @@ object AssessmentEventUtil {
8687
broadcastIntent.setPackage(analyticsApplicationId)
8788
context.sendBroadcast(broadcastIntent)
8889
}
90+
91+
/**
92+
* @param numberGson The number that the student is being assessed for.
93+
* @param masteryScore A value in the range [0.0, 1.0].
94+
* @param timeSpentMs The number of milliseconds passed between the student opening the assessment task and submitting a response. E.g. `15000`.
95+
* @param additionalData Any additional data related to the learning event, e.g. `{'is_number_pressed':true}`
96+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
97+
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
98+
*/
99+
fun reportNumberAssessmentEvent(
100+
numberGson: NumberGson,
101+
masteryScore: Float,
102+
timeSpentMs: Long,
103+
additionalData: JSONObject? = null,
104+
context: Context,
105+
analyticsApplicationId: String
106+
) {
107+
Log.i(TAG, "reportNumberAssessmentEvent")
108+
109+
val broadcastIntent = Intent()
110+
broadcastIntent.setPackage(analyticsApplicationId)
111+
broadcastIntent.setAction("ai.elimu.intent.action.NUMBER_ASSESSMENT_EVENT")
112+
broadcastIntent.putExtra(BundleKeys.KEY_PACKAGE_NAME, context.packageName)
113+
broadcastIntent.putExtra(BundleKeys.KEY_MASTERY_SCORE, masteryScore)
114+
broadcastIntent.putExtra(BundleKeys.KEY_TIME_SPENT_MS, timeSpentMs)
115+
additionalData?.let {
116+
broadcastIntent.putExtra(BundleKeys.KEY_ADDITIONAL_DATA, additionalData.toString())
117+
}
118+
broadcastIntent.putExtra(BundleKeys.KEY_NUMBER_VALUE, numberGson.value)
119+
broadcastIntent.putExtra(BundleKeys.KEY_NUMBER_ID, numberGson.id)
120+
121+
context.sendBroadcast(broadcastIntent)
122+
}
89123
}

utils/src/main/java/ai/elimu/analytics/utils/IntentAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ enum class IntentAction(val action: String) {
77
WORD_ASSESSMENT("ai.elimu.intent.action.WORD_ASSESSMENT_EVENT"),
88
WORD_LEARNING("ai.elimu.intent.action.WORD_LEARNING_EVENT"),
99

10-
NUMBER_LEARNING("ai.elimu.intent.action.NUMBER_LEARNING_EVENT"),
1110
// TODO: number assessment
11+
NUMBER_LEARNING("ai.elimu.intent.action.NUMBER_LEARNING_EVENT"),
1212

1313
STORYBOOK_LEARNING("ai.elimu.intent.action.STORYBOOK_LEARNING_EVENT"),
1414

utils/src/main/java/ai/elimu/analytics/utils/LearningEventUtil.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object LearningEventUtil {
2424
/**
2525
* @param letterSoundGson The letter-sound correspondence that the student is learning.
2626
* @param additionalData Any additional data related to the learning event, e.g. `{'is_letter_pressed':true}`
27-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
27+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
2828
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
2929
*/
3030
fun reportLetterSoundLearningEvent(
@@ -64,7 +64,7 @@ object LearningEventUtil {
6464
/**
6565
* @param wordGson The word that the student is learning.
6666
* @param additionalData Any additional data related to the learning event, e.g. `{'is_word_pressed':true}`
67-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
67+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
6868
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
6969
*/
7070
fun reportWordLearningEvent(
@@ -91,7 +91,7 @@ object LearningEventUtil {
9191
/**
9292
* @param storyBookGson The storybook that the student is learning from.
9393
* @param additionalData Any additional data related to the learning event, e.g. `{'time_spent_per_chapter_ms':[7500,12900,34422,5023]}`
94-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
94+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
9595
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
9696
*/
9797
fun reportStoryBookLearningEvent(
@@ -118,7 +118,7 @@ object LearningEventUtil {
118118
/**
119119
* @param videoGson The video that the student is learning from.
120120
* @param additionalData Any additional data related to the learning event, e.g. `{'is_video_paused':true}`
121-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
121+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
122122
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
123123
*/
124124
fun reportVideoLearningEvent(
@@ -145,7 +145,7 @@ object LearningEventUtil {
145145
/**
146146
* @param numberGson The number that the student is learning.
147147
* @param additionalData Any additional data related to the learning event, e.g. `{'is_number_pressed':true}`
148-
* @param context Needed to fetch the `packageName` of the application where the learning event occurred.
148+
* @param context Needed to fetch the `packageName` of the application where the event occurred.
149149
* @param analyticsApplicationId The package name of the analytics application that will receive the Intent and store the event.
150150
*/
151151
fun reportNumberLearningEvent(

0 commit comments

Comments
 (0)