Class RunLearningUnitRequest

    • Field Detail

      • version

        public final int version
      • learningUnitId

        @NonNull
        public final String learningUnitId
        An ID, defined by the learning app, that uniquely identifies the learning unit to run.
      • learningUnitRunId

        @NonNull
        public final String learningUnitRunId
        A unique identifier of each learning unit run, which may be used for reporting purposes.
      • learnerId

        @NonNull
        public final String learnerId
        The obfuscated ID of the learner who is playing the learning unit. May be used for reporting purposes.
      • schoolId

        @NonNull
        public final String schoolId
        The obfuscated ID of the school at which the learning unit is being played. May be used for reporting purposes.
      • stage

        @NonNull
        public final String stage
        Identifies the stage of the EIDU app, e.g. "test", "prod". May be used for reporting purposes.
      • remainingForegroundTimeInMs

        @Nullable
        public final Long remainingForegroundTimeInMs
        Optional. The maximum amount of time that this run may take. The learning app must end the run with RunLearningUnitResult.ResultType.TimeUp after this amount of foreground time has elapsed.
    • Method Detail

      • of

        @NonNull
        public static RunLearningUnitRequest of​(@NonNull
                                                String learningUnitId,
                                                @NonNull
                                                String learningUnitRunId,
                                                @NonNull
                                                String learnerId,
                                                @NonNull
                                                String schoolId,
                                                @NonNull
                                                String stage,
                                                @Nullable
                                                Long remainingForegroundTimeInMs,
                                                @Nullable
                                                Long inactivityTimeoutInMs,
                                                @Nullable
                                                Uri assetsBaseUri)
        Creates a new RunLearningUnitRequest instance.

        Use this to test your learning app against what the EIDU app will send to launch a learning unit.

        Parameters:
        learningUnitId - Required, see learningUnitId.
        learningUnitRunId - Required, see learningUnitRunId.
        learnerId - Required, see learnerId.
        schoolId - Required, see schoolId.
        stage - Required, see stage.
        remainingForegroundTimeInMs - Optional, see remainingForegroundTimeInMs.
        inactivityTimeoutInMs - Optional, see inactivityTimeoutInMs.
        assetsBaseUri - Optional, the base content URI from which to retrieve assets.
        Returns:
        The new instance.
      • fromIntent

        @Nullable
        public static RunLearningUnitRequest fromIntent​(@NonNull
                                                        Intent intent)
                                                 throws IllegalArgumentException
        Creates a new RunLearningUnitRequest instance from the provided intent.

        Use this on the intent sent to your learning app by EIDU to get access to the necessary data.

        Parameters:
        intent - Required, the intent sent from the EIDU app to your learning app.
        Returns:
        The new RunLearningUnitRequest instance, initialized from the provided intent, or null if intent was not a request to run a learning unit
        Throws:
        IllegalArgumentException - If the provided intent does not contain all required data.
      • toIntent

        @NonNull
        public Intent toIntent​(@NonNull
                               String packageName,
                               @NonNull
                               String className)
        Creates an explicit intent usable to launch a learning app.

        You can use this method, along with of(String, String, String, String, String, Long, Long, Uri) to test your app.

        Parameters:
        packageName - The package name of the learning app.
        className - The class name of the activity to launch with this intent
        Returns:
        An intent for the given package and class, containing all the launch information.
      • getAssetAsStream

        @NonNull
        public InputStream getAssetAsStream​(@NonNull
                                            Context context,
                                            @NonNull
                                            String path)
                                     throws FileNotFoundException
        Retrieves the contents of an asset as an InputStream. It is the caller's responsibility to close this stream after use.
        Parameters:
        context - The current context. May be an application context.
        path - The path of the asset to retrieve.
        Returns:
        An InputStream from which the asset's contents can be read.
        Throws:
        FileNotFoundException - In case an asset by that name cannot be found for the learning unit being run, the request does not support asset loading, or EIDU has crashed.
      • getAssetAsUri

        @NonNull
        public Uri getAssetAsUri​(@NonNull
                                 String path)
                          throws FileNotFoundException
        Retrieves a content Uri for an asset, which can be used, for example, with MediaPlayer.

        At this point, it is not guaranteed that the Uri points to a valid asset.

        Parameters:
        path - The path of the asset to retrieve.
        Returns:
        A Uri from which the asset's contents can be read.
        Throws:
        FileNotFoundException - In case the request does not support asset loading.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object