Class RunLearningUnitResult
- java.lang.Object
-
- com.eidu.integration.RunLearningUnitResult
-
public class RunLearningUnitResult extends Object
This class represents the result of a learning unit run and should be used to deliver the result to the EIDU app.Depending on how the run ended, this class can be instantiated with one of the methods
ofSuccess(java.lang.Float, long, java.lang.String, java.util.List<com.eidu.integration.ResultItem>)
,ofAbort(java.lang.Float, long, java.lang.String, java.util.List<com.eidu.integration.ResultItem>)
,ofTimeoutInactivity(java.lang.Float, long, java.lang.String, java.util.List<com.eidu.integration.ResultItem>)
,ofTimeUp(java.lang.Float, long, java.lang.String, java.util.List<com.eidu.integration.ResultItem>)
,ofError(java.lang.Float, long, java.lang.String, java.lang.String, java.util.List<com.eidu.integration.ResultItem>)
.Then,
toIntent()
should be used to instantiate anIntent
to be passed toActivity.setResult(int, Intent)
before finishing the activity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RunLearningUnitResult.ResultType
An enum describing the reason why a learning unit run has ended.
-
Field Summary
Fields Modifier and Type Field Description String
additionalData
Optional. An arbitrary string that the learning app would like to associate with the usage data that the EIDU app reports.String
errorDetails
Optional. IfresultType
isRunLearningUnitResult.ResultType.Error
, this should contain any available diagnostic information, e.g.long
foregroundDurationInMs
The amount of time that the user spent with the learning unit at the end of the run.List<ResultItem>
items
Optional. A list of items describing the user interactions during a learning unit run in detail.RunLearningUnitResult.ResultType
resultType
The reason why this run ended.Float
score
Optional. A score between 0.0f and 1.0f that describes how the learner did up to the point in time when the unit ended.int
version
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
static RunLearningUnitResult
fromIntent(Intent intent)
Parses anIntent
into a new RunLearningUnitResult instance.int
hashCode()
static RunLearningUnitResult
ofAbort(Float score, long foregroundDurationInMs, String additionalData, List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Abort
.static RunLearningUnitResult
ofError(Float score, long foregroundDurationInMs, String errorDetails, String additionalData, List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Error
.static RunLearningUnitResult
ofSuccess(Float score, long foregroundDurationInMs, String additionalData, List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Success
.static RunLearningUnitResult
ofTimeoutInactivity(Float score, long foregroundDurationInMs, String additionalData, List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.TimeoutInactivity
.static RunLearningUnitResult
ofTimeUp(Float score, long foregroundDurationInMs, String additionalData, List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.TimeUp
.Intent
toIntent()
Converts this instance of RunLearningUnitResult to anIntent
which may then be passed toActivity.setResult(int, Intent)
in order to inform the EIDU app of the result of a learning unit run.
-
-
-
Field Detail
-
version
public final int version
-
resultType
@NonNull public final RunLearningUnitResult.ResultType resultType
The reason why this run ended.
-
score
@Nullable public final Float score
Optional. A score between 0.0f and 1.0f that describes how the learner did up to the point in time when the unit ended. value of 0.0f should indicate that the learner gave only incorrect answers, whereas a value of 1.0f should indicate the the learner gave only correct answers.In case the nature of the learning unit was such that there was no possibility to give an incorrect answer, the score must be 1.0f.
Only in case it's impossible to compute a meaningful score may this value be null. Learning app developers are strongly encouraged to try hard to compute meaningful scores in as many cases as possible, in order to provide the maximum amount of information for personalisation and analytics.
-
foregroundDurationInMs
public final long foregroundDurationInMs
The amount of time that the user spent with the learning unit at the end of the run. This must exclude any amount of time that the learning app was in the background (because the user navigated away from it, for example using the Android home button or because a different app forced itself into the foreground), and it should exclude time spent for loading and any transition animations.
-
additionalData
@Nullable public final String additionalData
Optional. An arbitrary string that the learning app would like to associate with the usage data that the EIDU app reports. It will be made available to the learning app manufacturer for data analysis purposes. It must not contain any sensitive data (e.g. device identifiers).This is useful because learning apps should not rely on (and should not attempt to take advantage of) Internet connectivity.
-
errorDetails
@Nullable public final String errorDetails
Optional. IfresultType
isRunLearningUnitResult.ResultType.Error
, this should contain any available diagnostic information, e.g. an exception with a stack trace.This information will be reported to EIDU for diagnostic purposes. It must not contain any sensitive data (e.g. device identifiers).
-
items
@Nullable public final List<ResultItem> items
Optional. A list of items describing the user interactions during a learning unit run in detail. See the documentation ofResultItem
for details.Note that a
null
value signifies that no sensible representation of interactions is available, whereas an empty list signifies that no interactions occurred.
-
-
Method Detail
-
ofSuccess
@NonNull public static RunLearningUnitResult ofSuccess(@Nullable Float score, long foregroundDurationInMs, @Nullable String additionalData, @Nullable List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Success
. This should be used when the learner completes the learning unit, independently of their performance.- Parameters:
score
- Strongly encouraged, seescore
.foregroundDurationInMs
- Required, seeforegroundDurationInMs
.additionalData
- Optional, seeadditionalData
.items
- Optional, seeitems
.- Returns:
- The new instance.
-
ofAbort
@NonNull public static RunLearningUnitResult ofAbort(@Nullable Float score, long foregroundDurationInMs, @Nullable String additionalData, @Nullable List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Abort
. This should be used when the learner took an action meant to abort the run, e.g. tapping an abort button.- Parameters:
score
- Strongly encouraged, seescore
.foregroundDurationInMs
- Required, seeforegroundDurationInMs
.additionalData
- Optional, seeadditionalData
.items
- Optional, seeitems
.- Returns:
- The new instance.
-
ofTimeoutInactivity
@NonNull public static RunLearningUnitResult ofTimeoutInactivity(@Nullable Float score, long foregroundDurationInMs, @Nullable String additionalData, @Nullable List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.TimeoutInactivity
. This should be used after the learner hasn't interacted with the app forRunLearningUnitRequest.inactivityTimeoutInMs
milliseconds of foreground time.- Parameters:
score
- Strongly encouraged, seescore
.foregroundDurationInMs
- Required, seeforegroundDurationInMs
.additionalData
- Optional, seeadditionalData
.items
- Optional, seeitems
.- Returns:
- The new instance.
-
ofTimeUp
@NonNull public static RunLearningUnitResult ofTimeUp(@Nullable Float score, long foregroundDurationInMs, @Nullable String additionalData, @Nullable List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.TimeUp
. This should be used afterRunLearningUnitRequest.remainingForegroundTimeInMs
milliseconds of foreground time passed since the start of the run.- Parameters:
score
- Strongly encouraged, seescore
.foregroundDurationInMs
- Required, seeforegroundDurationInMs
.additionalData
- Optional, seeadditionalData
.items
- Optional, seeitems
.- Returns:
- The new instance.
-
ofError
@NonNull public static RunLearningUnitResult ofError(@Nullable Float score, long foregroundDurationInMs, @NonNull String errorDetails, @Nullable String additionalData, @Nullable List<ResultItem> items)
Creates an instance withRunLearningUnitResult.ResultType.Error
. This should be used to indicate that a technical error occurred that prevented the learner from beginning or from completing the run.- Parameters:
score
- Strongly encouraged, seescore
.foregroundDurationInMs
- Required, seeforegroundDurationInMs
.errorDetails
- Required, seeerrorDetails
.additionalData
- Optional, seeadditionalData
.items
- Optional, seeitems
.- Returns:
- The new instance.
-
fromIntent
@NonNull public static RunLearningUnitResult fromIntent(@NonNull Intent intent)
Parses anIntent
into a new RunLearningUnitResult instance.- Parameters:
intent
- The intent to parse.- Returns:
- The new instance.
- Throws:
IllegalArgumentException
- If the intent contains incomplete or invalid data.
-
toIntent
@NonNull public Intent toIntent()
Converts this instance of RunLearningUnitResult to anIntent
which may then be passed toActivity.setResult(int, Intent)
in order to inform the EIDU app of the result of a learning unit run.- Returns:
- An intent that contains all information of this instance of RunLearningUnitResult.
-
-