diff --git a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt index d7948f01945..b95fba334c5 100755 --- a/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedFragmentPresenter.kt @@ -26,6 +26,7 @@ import org.oppia.android.domain.exploration.lightweightcheckpointing.Exploration import org.oppia.android.domain.oppialogger.OppiaLogger import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** The presenter for [RecentlyPlayedFragment]. */ @@ -97,7 +98,7 @@ class RecentlyPlayedFragmentPresenter @Inject constructor( if (promotedStory.chapterPlayState == ChapterPlayState.IN_PROGRESS_SAVED) { val explorationCheckpointLiveData = explorationCheckpointController.retrieveExplorationCheckpoint( - profileId, promotedStory.explorationId + profileId.toProfileIdPreservingZero(), promotedStory.explorationId ).toLiveData() explorationCheckpointLiveData.observe( @@ -178,13 +179,13 @@ class RecentlyPlayedFragmentPresenter @Inject constructor( // cases, lessons played from this fragment are known to be in progress, and that progress // can't be resumed here (hence the restart). explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } else { // The only lessons that can't have their progress saved are those that were already // completed. explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } startPlayingProvider.toLiveData().observe(fragment) { result -> diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt index 913b711b27e..f503ababa02 100755 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt @@ -30,6 +30,8 @@ import org.oppia.android.app.topic.conceptcard.ConceptCardListener import org.oppia.android.util.extensions.getProtoExtra import org.oppia.android.util.extensions.putProtoExtra import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName +import org.oppia.android.util.profile.toLegacyProfileId +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject const val TAG_HINTS_AND_SOLUTION_DIALOG = "HINTS_AND_SOLUTION_DIALOG" @@ -65,7 +67,7 @@ class ExplorationActivity : val params = intent.extractParams() explorationActivityPresenter.handleOnCreate( this, - params.profileId, + params.profileId.toLegacyProfileId(), params.classroomId, params.topicId, params.storyId, @@ -102,7 +104,7 @@ class ExplorationActivity : isCheckpointingEnabled: Boolean ): Intent { val params = ExplorationActivityParams.newBuilder().apply { - this.profileId = profileId + this.profileId = profileId.toProfileIdPreservingZero() this.classroomId = classroomId this.topicId = topicId this.storyId = storyId diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt index 2f11fa4580b..4364b9db4cf 100644 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt @@ -42,6 +42,7 @@ import org.oppia.android.domain.translation.TranslationController import org.oppia.android.util.accessibility.AccessibilityService import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject private const val TAG_UNSAVED_EXPLORATION_DIALOG = "UNSAVED_EXPLORATION_DIALOG" @@ -276,7 +277,9 @@ class ExplorationActivityPresenter @Inject constructor( /** Deletes the saved progress for the current exploration and then stops the exploration. */ fun deleteCurrentProgressAndStopExploration(isCompletion: Boolean) { - explorationDataController.deleteExplorationProgressById(profileId, explorationId) + explorationDataController.deleteExplorationProgressById( + profileId.toProfileIdPreservingZero(), explorationId + ) stopExploration(isCompletion) } @@ -287,7 +290,7 @@ class ExplorationActivityPresenter @Inject constructor( // without deleting any checkpoints. if (::oldestCheckpointExplorationId.isInitialized) { explorationDataController.deleteExplorationProgressById( - profileId, + profileId.toProfileIdPreservingZero(), oldestCheckpointExplorationId ) } @@ -351,7 +354,9 @@ class ExplorationActivityPresenter @Inject constructor( private fun updateToolbarTitle(explorationId: String) { subscribeToExploration( - explorationDataController.getExplorationById(profileId, explorationId).toLiveData() + explorationDataController.getExplorationById( + profileId.toProfileIdPreservingZero(), explorationId + ).toLiveData() ) } @@ -504,7 +509,7 @@ class ExplorationActivityPresenter @Inject constructor( */ private fun subscribeToOldestSavedExplorationDetails() { explorationDataController.getOldestExplorationDetailsDataProvider( - profileId + profileId.toProfileIdPreservingZero() ).toLiveData().observe(activity) { when (it) { is AsyncResult.Success -> { diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragment.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragment.kt index 1b0a43c5b59..d8223f517fa 100755 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragment.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragment.kt @@ -11,6 +11,7 @@ import org.oppia.android.app.model.ExplorationFragmentArguments import org.oppia.android.app.model.LegacyProfileId import org.oppia.android.app.model.ReadingTextSize import org.oppia.android.util.extensions.putProto +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** Fragment that contains displays single exploration. */ @@ -29,7 +30,7 @@ class ExplorationFragment : InjectableFragment() { readingTextSize: ReadingTextSize ): ExplorationFragment { val args = ExplorationFragmentArguments.newBuilder().apply { - this.profileId = profileId + this.profileId = profileId.toProfileIdPreservingZero() this.classroomId = classroomId this.topicId = topicId this.storyId = storyId diff --git a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt index fe1880a8249..7ff9a76d605 100755 --- a/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt @@ -28,7 +28,6 @@ import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto -import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** The presenter for [ExplorationFragment]. */ @@ -72,7 +71,7 @@ class ExplorationFragmentPresenter @Inject constructor( /** Handles the [Fragment.onViewCreated] portion of [ExplorationFragment]'s lifecycle. */ fun handleViewCreated() { val profileDataProvider = profileManagementController.getProfile( - retrieveArguments().profileId.toProfileIdPreservingZero() + retrieveArguments().profileId ) profileDataProvider.toLiveData().observe( fragment diff --git a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt index 1b6374b1efd..175f4e39399 100755 --- a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt @@ -55,6 +55,7 @@ import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders.Companion.toLiveData import org.oppia.android.util.gcsresource.DefaultResourceBucketName import org.oppia.android.util.parser.html.ExplorationHtmlParserEntityType +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.oppia.android.util.system.OppiaClock import javax.inject.Inject @@ -493,7 +494,7 @@ class StateFragmentPresenter @Inject constructor( private fun markExplorationCompleted() { val markStoryCompletedLivedata = storyProgressController.recordCompletedChapter( - profileId, + profileId.toProfileIdPreservingZero(), topicId, storyId, explorationId, diff --git a/app/src/main/java/org/oppia/android/app/player/state/StateViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/StateViewModel.kt index 164e95dd8e4..5ce93f4e102 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/StateViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StateViewModel.kt @@ -131,7 +131,7 @@ class StateViewModel @Inject constructor( }.build() val updateResultProvider = explorationProgressController.updateWrittenTranslationContentLanguageMidLesson( - profileId, languageSelection + profileId.toProfileIdPreservingZero(), languageSelection ) val updateResultLiveData = updateResultProvider.toLiveData() updateResultLiveData.observe( diff --git a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt index 78475d56e48..dd0cc4b54a9 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt @@ -5,7 +5,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.databinding.DataBindingUtil import org.oppia.android.app.activity.ActivityScope import org.oppia.android.app.databinding.databinding.StateFragmentTestActivityBinding -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.StateFragmentTestActivityParams import org.oppia.android.app.player.exploration.HintsAndSolutionExplorationManagerFragment import org.oppia.android.app.player.exploration.TAG_HINTS_AND_SOLUTION_EXPLORATION_MANAGER @@ -35,6 +35,7 @@ class StateFragmentTestActivityPresenter @Inject constructor( ) { private var profileId: Int = 1 + private val profileIdProto get() = ProfileId.newBuilder().setInternalId(profileId).build() private lateinit var classroomId: String private lateinit var topicId: String private lateinit var storyId: String @@ -87,7 +88,7 @@ class StateFragmentTestActivityPresenter @Inject constructor( fun deleteCurrentProgressAndStopExploration(isCompletion: Boolean) { explorationDataController.deleteExplorationProgressById( - LegacyProfileId.newBuilder().setInternalId(profileId).build(), + profileIdProto, explorationId ) stopExploration(isCompletion) @@ -106,11 +107,13 @@ class StateFragmentTestActivityPresenter @Inject constructor( explorationDataController.stopPlayingExploration(isCompletion = false) val startPlayingProvider = if (shouldSavePartialProgress) { explorationDataController.startPlayingNewExploration( - profileId, classroomId, topicId, storyId, explorationId + profileIdProto, + classroomId, topicId, storyId, explorationId ) } else { explorationDataController.replayExploration( - profileId, classroomId, topicId, storyId, explorationId + profileIdProto, + classroomId, topicId, storyId, explorationId ) } startPlayingProvider.toLiveData().observe( diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt index ea7d949f0c1..5e87adc8daa 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonActivity.kt @@ -18,6 +18,8 @@ import org.oppia.android.app.player.exploration.ExplorationActivity import org.oppia.android.util.extensions.getProtoExtra import org.oppia.android.util.extensions.putProtoExtra import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName +import org.oppia.android.util.profile.toLegacyProfileId +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** Activity that allows the user to resume a saved exploration. */ @@ -34,7 +36,7 @@ class ResumeLessonActivity : val params = intent.getProtoExtra(PARAMS_KEY, ResumeLessonActivityParams.getDefaultInstance()) resumeLessonActivityPresenter.handleOnCreate( - params.profileId, + params.profileId.toLegacyProfileId(), params.classroomId, params.topicId, params.storyId, @@ -72,7 +74,7 @@ class ResumeLessonActivity : checkpoint: ExplorationCheckpoint ): Intent { val params = ResumeLessonActivityParams.newBuilder().apply { - this.profileId = profileId + this.profileId = profileId.toProfileIdPreservingZero() this.classroomId = classroomId this.topicId = topicId this.storyId = storyId diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragment.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragment.kt index aff1d40fe44..054170811c3 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragment.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragment.kt @@ -14,6 +14,8 @@ import org.oppia.android.app.model.ReadingTextSize import org.oppia.android.app.model.ResumeLessonFragmentArguments import org.oppia.android.util.extensions.getProto import org.oppia.android.util.extensions.putProto +import org.oppia.android.util.profile.toLegacyProfileId +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** Fragment that allows the user to resume a saved exploration. */ @@ -35,7 +37,7 @@ class ResumeLessonFragment : InjectableFragment() { readingTextSize: ReadingTextSize ): ResumeLessonFragment { val args = ResumeLessonFragmentArguments.newBuilder().apply { - this.profileId = profileId + this.profileId = profileId.toProfileIdPreservingZero() this.classroomId = classroomId this.topicId = topicId this.storyId = storyId @@ -75,7 +77,7 @@ class ResumeLessonFragment : InjectableFragment() { return resumeLessonFragmentPresenter.handleOnCreate( inflater, container, - args.profileId, + args.profileId.toLegacyProfileId(), args.classroomId, args.topicId, args.storyId, diff --git a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt index 8818bd725e2..4f9fc2d079d 100644 --- a/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentPresenter.kt @@ -26,6 +26,7 @@ import org.oppia.android.util.data.DataProviders.Companion.toLiveData import org.oppia.android.util.extensions.getProto import org.oppia.android.util.gcsresource.DefaultResourceBucketName import org.oppia.android.util.parser.html.HtmlParser +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** The presenter for [ResumeLessonFragment]. */ @@ -198,11 +199,16 @@ class ResumeLessonFragmentPresenter @Inject constructor( ) { val startPlayingProvider = if (checkpoint == ExplorationCheckpoint.getDefaultInstance()) { explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } else { explorationDataController.resumeExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId, checkpoint + profileId.toProfileIdPreservingZero(), + classroomId, + topicId, + storyId, + explorationId, + checkpoint ) } startPlayingProvider.toLiveData().observe(fragment) { result -> diff --git a/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt index 6e37c11cd27..6b30c2990ad 100644 --- a/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/story/StoryFragmentPresenter.kt @@ -41,6 +41,7 @@ import org.oppia.android.util.data.DataProviders.Companion.toLiveData import org.oppia.android.util.gcsresource.DefaultResourceBucketName import org.oppia.android.util.parser.html.HtmlParser import org.oppia.android.util.parser.html.TopicHtmlParserEntityType +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** The presenter for [StoryFragment]. */ @@ -272,7 +273,7 @@ class StoryFragmentPresenter @Inject constructor( // one. val startPlayingProvider = if (canHavePartialProgressSaved) { explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, @@ -280,7 +281,7 @@ class StoryFragmentPresenter @Inject constructor( ) } else { explorationDataController.replayExploration( - profileId.internalId, + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, diff --git a/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt b/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt index 73482451f97..4b0e9d3ef52 100644 --- a/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/story/storyitemviewmodel/StoryChapterSummaryViewModel.kt @@ -15,6 +15,7 @@ import org.oppia.android.domain.exploration.lightweightcheckpointing.Exploration import org.oppia.android.domain.translation.TranslationController import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.profile.toProfileIdPreservingZero /** Chapter summary view model for the recycler view in [StoryFragment]. */ class StoryChapterSummaryViewModel( @@ -63,9 +64,7 @@ class StoryChapterSummaryViewModel( if (chapterPlayState == ChapterPlayState.IN_PROGRESS_SAVED) { val explorationCheckpointLiveData = explorationCheckpointController.retrieveExplorationCheckpoint( - LegacyProfileId.newBuilder().apply { - internalId = internalProfileId - }.build(), + profileId.toProfileIdPreservingZero(), explorationId ).toLiveData() diff --git a/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt b/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt index e3536e10d37..295ce8a3296 100644 --- a/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/testing/ExplorationTestActivityPresenter.kt @@ -10,6 +10,7 @@ import org.oppia.android.app.fragment.InjectableFragment import org.oppia.android.app.home.RouteToExplorationListener import org.oppia.android.app.model.ExplorationActivityParams import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.ui.R import org.oppia.android.app.utility.SplitScreenManager import org.oppia.android.domain.classroom.TEST_CLASSROOM_ID_0 @@ -53,7 +54,7 @@ class ExplorationTestActivityPresenter @Inject constructor( private fun playExplorationButton() { explorationDataController.stopPlayingExploration(isCompletion = false) explorationDataController.replayExploration( - INTERNAL_PROFILE_ID, + ProfileId.newBuilder().setInternalId(INTERNAL_PROFILE_ID).build(), CLASSROOM_ID, TOPIC_ID, STORY_ID, diff --git a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt index a60c9394d95..d7fdaeb9c59 100644 --- a/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentPresenter.kt @@ -31,6 +31,7 @@ import org.oppia.android.util.accessibility.AccessibilityService import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProviders.Companion.toLiveData import org.oppia.android.util.enumfilter.filterByEnumCondition +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject /** The presenter for [TopicLessonsFragment]. */ @@ -298,7 +299,7 @@ class TopicLessonsFragmentPresenter @Inject constructor( ChapterPlayState.IN_PROGRESS_SAVED -> { val explorationCheckpointLiveData = explorationCheckpointController.retrieveExplorationCheckpoint( - profileId, explorationId + profileId.toProfileIdPreservingZero(), explorationId ).toLiveData() explorationCheckpointLiveData.observe( fragment, @@ -369,21 +370,21 @@ class TopicLessonsFragmentPresenter @Inject constructor( !canHavePartialProgressSaved -> { // Only explorations that have been completed can't be saved, so replay the lesson. explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } hadProgress -> { // If there was progress, either the checkpoint was never saved, failed to save, or failed // to be retrieved. In all cases, this is a restart. explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } else -> { // If there's no progress and it was never completed, then it's a new play through (or the // user is very low on device memory). explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId.toProfileIdPreservingZero(), classroomId, topicId, storyId, explorationId ) } } diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentTest.kt index e0a6e533cdd..c46af6f2357 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/markchapterscompleted/MarkChaptersCompletedFragmentTest.kt @@ -108,6 +108,7 @@ import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.html.HtmlParserEntityTypeModule import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -1054,7 +1055,7 @@ class MarkChaptersCompletedFragmentTest { ): ChapterPlayState { val playStateProvider = storyProgressController.retrieveChapterPlayStateByExplorationId( - profileId, topicId, storyId, expId + profileId.toProfileIdPreservingZero(), topicId, storyId, expId ) return monitorFactory.waitForNextSuccessfulResult(playStateProvider) } diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityTest.kt index 6262e00b6a1..fb432a7acce 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedActivityTest.kt @@ -43,6 +43,7 @@ import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule import org.oppia.android.app.model.ExplorationActivityParams import org.oppia.android.app.model.ExplorationCheckpoint import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.RecentlyPlayedActivityParams import org.oppia.android.app.model.RecentlyPlayedActivityTitle import org.oppia.android.app.model.RecentlyPlayedActivityTitle.RECENTLY_PLAYED_STORIES @@ -314,7 +315,7 @@ class RecentlyPlayedActivityTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED checkpoint = ExplorationCheckpoint.newBuilder().apply { explorationTitle = "What is a Fraction?" @@ -367,7 +368,7 @@ class RecentlyPlayedActivityTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -402,7 +403,7 @@ class RecentlyPlayedActivityTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() @@ -442,7 +443,7 @@ class RecentlyPlayedActivityTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED }.build() diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index 3a960058171..3af239f5630 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt @@ -71,6 +71,7 @@ import org.oppia.android.app.model.HelpActivityParams import org.oppia.android.app.model.LegacyProfileId import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.OptionsActivityParams +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.ScreenName import org.oppia.android.app.model.Spotlight import org.oppia.android.app.model.WrittenTranslationLanguageSelection @@ -1539,7 +1540,7 @@ class ExplorationActivityTest { shouldSavePartialProgress = false ) { explorationDataController.replayExploration( - internalProfileId, + ProfileId.newBuilder().setInternalId(internalProfileId).build(), TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID, FRACTIONS_STORY_ID_0, @@ -1569,7 +1570,7 @@ class ExplorationActivityTest { shouldSavePartialProgress = false ) { explorationDataController.replayExploration( - internalProfileId, + ProfileId.newBuilder().setInternalId(internalProfileId).build(), TEST_CLASSROOM_ID_1, FRACTIONS_TOPIC_ID, FRACTIONS_STORY_ID_0, @@ -2308,7 +2309,8 @@ class ExplorationActivityTest { classroomId, topicId, storyId, explorationId, shouldSavePartialProgress ) { explorationDataController.startPlayingNewExploration( - internalProfileId, classroomId, topicId, storyId, explorationId + ProfileId.newBuilder().setInternalId(internalProfileId).build(), + classroomId, topicId, storyId, explorationId ) testCoroutineDispatchers.runCurrent() testBlock() diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt index 891fb17758b..fe5d9863dcd 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt @@ -38,6 +38,7 @@ import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule import org.oppia.android.app.model.ExplorationActivityParams import org.oppia.android.app.model.ExplorationCheckpoint import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.ReadingTextSize import org.oppia.android.app.model.ResumeLessonFragmentArguments import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule @@ -283,7 +284,7 @@ class ResumeLessonFragmentTest { val receivedCheckpoint = args.checkpoint assertThat(receivedProfileId) - .isEqualTo(LegacyProfileId.newBuilder().apply { internalId = 1 }.build()) + .isEqualTo(ProfileId.newBuilder().setInternalId(1).build()) assertThat(receivedClassroomId).isEqualTo(TEST_CLASSROOM_ID_1) assertThat(receivedTopicId).isEqualTo(FRACTIONS_TOPIC_ID) assertThat(receivedStoryId).isEqualTo(FRACTIONS_STORY_ID_0) diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt index 1c45c416bf9..c1d99a7c487 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt @@ -36,7 +36,7 @@ import org.oppia.android.app.application.testing.TestingBuildFlavorModule import org.oppia.android.app.devoptions.DeveloperOptionsModule import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule import org.oppia.android.app.model.ExplorationActivityParams -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.ScreenName import org.oppia.android.app.player.exploration.ExplorationActivity import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule @@ -196,7 +196,7 @@ class StoryActivityTest { storyId = TEST_STORY_ID_0 topicId = TEST_TOPIC_ID_0 classroomId = TEST_CLASSROOM_ID_0 - profileId = LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build() + profileId = ProfileId.newBuilder().apply { internalId = internalProfileId }.build() parentScreen = ExplorationActivityParams.ParentScreen.STORY_SCREEN isCheckpointingEnabled = true }.build() diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt index 61ab7fb2d1a..2e70cad10f5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt @@ -143,6 +143,7 @@ import org.oppia.android.util.platformparameter.EnableTopicInfoTab import org.oppia.android.util.platformparameter.EnableTopicPracticeTab import org.oppia.android.util.platformparameter.PlatformParameterValue import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -741,7 +742,7 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = profileId + profileId = this@TopicLessonsFragmentTest.profileId.toProfileIdPreservingZero() parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB checkpoint = ExplorationCheckpoint.newBuilder().apply { explorationTitle = "What is a Fraction?" @@ -797,7 +798,7 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = profileId + profileId = this@TopicLessonsFragmentTest.profileId.toProfileIdPreservingZero() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -835,7 +836,7 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = profileId + profileId = this@TopicLessonsFragmentTest.profileId.toProfileIdPreservingZero() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -878,7 +879,7 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = profileId + profileId = this@TopicLessonsFragmentTest.profileId.toProfileIdPreservingZero() isCheckpointingEnabled = true parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() @@ -920,7 +921,7 @@ class TopicLessonsFragmentTest { storyId = FRACTIONS_STORY_ID_0 topicId = FRACTIONS_TOPIC_ID classroomId = TEST_CLASSROOM_ID_1 - profileId = profileId + profileId = this@TopicLessonsFragmentTest.profileId.toProfileIdPreservingZero() isCheckpointingEnabled = false parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB }.build() diff --git a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt index 1064bff397b..20dfd02dcce 100644 --- a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt @@ -40,6 +40,7 @@ import org.oppia.android.app.model.EventLog import org.oppia.android.app.model.EventLog.Context.ActivityContextCase.OPEN_EXPLORATION_ACTIVITY import org.oppia.android.app.model.ExplorationActivityParams import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.Spotlight import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule import org.oppia.android.app.shim.IntentFactoryShimModule @@ -143,6 +144,9 @@ class ExplorationActivityLocalTest { private lateinit var networkConnectionUtil: NetworkConnectionUtil private lateinit var explorationDataController: ExplorationDataController private val internalProfileId: Int = 0 + private val profileId by lazy { + ProfileId.newBuilder().setInternalId(internalProfileId).build() + } private val afternoonUtcTimestampMillis = 1556101812000 @Before @@ -161,7 +165,6 @@ class ExplorationActivityLocalTest { fun testExploration_onLaunch_logsEvent() { setUpTestApplicationComponent() getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -194,7 +197,6 @@ class ExplorationActivityLocalTest { fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -212,7 +214,7 @@ class ExplorationActivityLocalTest { ) ).use { explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -244,7 +246,6 @@ class ExplorationActivityLocalTest { fun testExplorationActivity_closeExploration_surveyGatingCriteriaNotMet_noSurveyPopup() { setUpTestWithNpsEnabled() getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -266,7 +267,7 @@ class ExplorationActivityLocalTest { ) ).use { explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -293,7 +294,6 @@ class ExplorationActivityLocalTest { fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -311,7 +311,7 @@ class ExplorationActivityLocalTest { ) ).use { explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -359,7 +359,6 @@ class ExplorationActivityLocalTest { fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -377,7 +376,7 @@ class ExplorationActivityLocalTest { ) ).use { scenario -> explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -418,7 +417,6 @@ class ExplorationActivityLocalTest { fakeOppiaClock.setCurrentTimeMs(afternoonUtcTimestampMillis) getApplicationDependencies( - internalProfileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -436,7 +434,7 @@ class ExplorationActivityLocalTest { ) ).use { explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -478,13 +476,12 @@ class ExplorationActivityLocalTest { } private fun markSpotlightSeen(feature: Spotlight.FeatureCase) { - val profileId = LegacyProfileId.newBuilder().setInternalId(internalProfileId).build() - spotlightStateController.markSpotlightViewed(profileId, feature) + val legacyProfileId = LegacyProfileId.newBuilder().setInternalId(internalProfileId).build() + spotlightStateController.markSpotlightViewed(legacyProfileId, feature) testCoroutineDispatchers.runCurrent() } private fun getApplicationDependencies( - internalProfileId: Int, classroomId: String, topicId: String, storyId: String, @@ -495,7 +492,7 @@ class ExplorationActivityLocalTest { networkConnectionUtil = activity.networkConnectionUtil explorationDataController = activity.explorationDataController explorationDataController.startPlayingNewExploration( - internalProfileId, + profileId, classroomId, topicId, storyId, diff --git a/domain/src/main/java/org/oppia/android/domain/devoptions/ModifyLessonProgressController.kt b/domain/src/main/java/org/oppia/android/domain/devoptions/ModifyLessonProgressController.kt index a8b751457c0..bcbf06bc416 100644 --- a/domain/src/main/java/org/oppia/android/domain/devoptions/ModifyLessonProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/devoptions/ModifyLessonProgressController.kt @@ -11,6 +11,7 @@ import org.oppia.android.domain.topic.TopicListController import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.data.DataProviders.Companion.transformAsync +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.oppia.android.util.system.OppiaClock import javax.inject.Inject import javax.inject.Singleton @@ -102,7 +103,7 @@ class ModifyLessonProgressController @Inject constructor( topic.storyList.forEach { storySummary -> storySummary.chapterList.forEach { chapterSummary -> storyProgressController.recordCompletedChapter( - profileId = profileId, + profileId = profileId.toProfileIdPreservingZero(), topicId = topic.topicId, storyId = storySummary.storyId, explorationId = chapterSummary.explorationId, @@ -125,7 +126,7 @@ class ModifyLessonProgressController @Inject constructor( val storySummary = topicController.retrieveStory(topicId = it.value, storyId = it.key) storySummary.chapterList.forEach { chapterSummary -> storyProgressController.recordCompletedChapter( - profileId = profileId, + profileId = profileId.toProfileIdPreservingZero(), topicId = it.value, storyId = storySummary.storyId, explorationId = chapterSummary.explorationId, @@ -148,7 +149,7 @@ class ModifyLessonProgressController @Inject constructor( ) { chapterMap.forEach { storyProgressController.recordCompletedChapter( - profileId = profileId, + profileId = profileId.toProfileIdPreservingZero(), topicId = it.value.second, storyId = it.value.first, explorationId = it.key, diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt index 404dd3b2696..7eff326a874 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.actor import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.TopicLearningTime import org.oppia.android.app.model.TopicLearningTimeDatabase import org.oppia.android.data.persistence.PersistentCacheStore @@ -22,6 +22,7 @@ import org.oppia.android.util.data.DataProviders import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.platformparameter.EnableNpsSurvey import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.oppia.android.util.profile.toLegacyProfileId import org.oppia.android.util.system.OppiaClock import org.oppia.android.util.threading.BackgroundDispatcher import java.util.UUID @@ -82,9 +83,9 @@ class ExplorationActiveTimeController @Inject constructor( } private val cacheStoreMap = - mutableMapOf>() + mutableMapOf>() - override fun onExplorationStarted(profileId: LegacyProfileId, topicId: String) { + override fun onExplorationStarted(profileId: ProfileId, topicId: String) { this.explorationStarted = true if (enableNpsSurvey.value) { startSessionTimer( @@ -133,7 +134,7 @@ class ExplorationActiveTimeController @Inject constructor( private fun startSessionTimer( isAppInForeground: Boolean, explorationStarted: Boolean, - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String ): DataProvider { val sessionId = UUID.randomUUID().toString().also { @@ -286,7 +287,7 @@ class ExplorationActiveTimeController @Inject constructor( beginTimerResultFlow: MutableStateFlow>, isAppInForeground: Boolean, isExplorationStarted: Boolean, - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, ) { tryOperation(beginTimerResultFlow) { @@ -394,7 +395,7 @@ class ExplorationActiveTimeController @Inject constructor( data class InitializeController( val isAppInForeground: Boolean, val isExplorationStarted: Boolean, - val profileId: LegacyProfileId, + val profileId: ProfileId, val topicId: String, override val sessionId: String, override val callbackFlow: MutableStateFlow> @@ -473,7 +474,7 @@ class ExplorationActiveTimeController @Inject constructor( * @return a [DataProvider] that indicates the success/failure of this record operation */ private fun recordAggregateTopicLearningTime( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, sessionDuration: Long ): DataProvider { @@ -510,7 +511,7 @@ class ExplorationActiveTimeController @Inject constructor( /** Returns the [TopicLearningTime] [DataProvider] for a specific topicId, per-profile basis. */ fun retrieveAggregateTopicLearningTimeDataProvider( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String ): DataProvider { return retrieveCacheStore(profileId) @@ -529,13 +530,13 @@ class ExplorationActiveTimeController @Inject constructor( } private fun retrieveCacheStore( - profileId: LegacyProfileId + profileId: ProfileId ): PersistentCacheStore { return cacheStoreMap.getOrPut(profileId) { cacheStoreFactory.createPerProfile( CACHE_NAME, TopicLearningTimeDatabase.getDefaultInstance(), - profileId + profileId.toLegacyProfileId() ).also { cacheStore -> cacheStore.primeInMemoryAndDiskCacheAsync( updateMode = PersistentCacheStore.UpdateMode.UPDATE_IF_NEW_CACHE, diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt index f4321e1b636..a5396d144df 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationDataController.kt @@ -3,7 +3,7 @@ package org.oppia.android.domain.exploration import org.oppia.android.app.model.EphemeralExploration import org.oppia.android.app.model.Exploration import org.oppia.android.app.model.ExplorationCheckpoint -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationCheckpointController import org.oppia.android.domain.oppialogger.exceptions.ExceptionsController import org.oppia.android.domain.translation.TranslationController @@ -12,7 +12,6 @@ import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders import org.oppia.android.util.data.DataProviders.Companion.combineWith import org.oppia.android.util.locale.OppiaLocale -import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject private const val GET_EXPLORATION_BY_ID_PROVIDER_ID = "get_exploration_by_id_provider_id" @@ -37,13 +36,11 @@ class ExplorationDataController @Inject constructor( ) { /** Returns an [EphemeralExploration] given an ID. */ fun getExplorationById( - profileId: LegacyProfileId, + profileId: ProfileId, id: String ): DataProvider { val translationLocaleProvider = - translationController.getWrittenTranslationContentLocale( - profileId.toProfileIdPreservingZero() - ) + translationController.getWrittenTranslationContentLocale(profileId) val explorationProvider = dataProviders.createInMemoryDataProviderAsync( GET_EXPLORATION_BY_ID_PROVIDER_ID ) { retrieveExplorationById(id) } @@ -70,22 +67,21 @@ class ExplorationDataController @Inject constructor( * and it will save the user's progress. See [resumeExploration], [restartExploration], and * [replayExploration] for other situations. * - * @param internalProfileId the ID corresponding to the profile for which exploration is to be - * played + * @param profileId the ID corresponding to the profile for which exploration is to be played * @param topicId the ID corresponding to the topic for which exploration has to be played * @param storyId the ID corresponding to the story for which exploration has to be played * @param explorationId the ID of the exploration which has to be played * @return a [DataProvider] to observe whether initiating the play request succeeded */ fun startPlayingNewExploration( - internalProfileId: Int, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, explorationId: String ): DataProvider { return startPlayingExploration( - internalProfileId, + profileId, classroomId, topicId, storyId, @@ -99,7 +95,7 @@ class ExplorationDataController @Inject constructor( /** * Resumes the specified exploration indicated by [topicId], [storyId], and [explorationId] for - * the user corresponding to [internalProfileId] by restoring the provided + * the user corresponding to [profileId] by restoring the provided * [explorationCheckpoint], and returns a [DataProvider] tracking whether the start succeeded. * * This method behaves the same as [startPlayingNewExploration] except it resumes a previous @@ -110,7 +106,7 @@ class ExplorationDataController @Inject constructor( * used). */ fun resumeExploration( - internalProfileId: Int, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, @@ -118,7 +114,7 @@ class ExplorationDataController @Inject constructor( explorationCheckpoint: ExplorationCheckpoint ): DataProvider { return startPlayingExploration( - internalProfileId, + profileId, classroomId, topicId, storyId, @@ -132,7 +128,7 @@ class ExplorationDataController @Inject constructor( /** * Restarts the specified exploration indicated by [topicId], [storyId], and [explorationId] for - * the user corresponding to [internalProfileId], and returns a [DataProvider] tracking whether + * the user corresponding to [profileId], and returns a [DataProvider] tracking whether * the start succeeded. * * This method behaves the same as [resumeExploration] except any prior progress the user might @@ -142,14 +138,14 @@ class ExplorationDataController @Inject constructor( * lesson (otherwise [resumeExploration] should be used to resume the lesson). */ fun restartExploration( - internalProfileId: Int, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, explorationId: String ): DataProvider { return startPlayingExploration( - internalProfileId, + profileId, classroomId, topicId, storyId, @@ -163,7 +159,7 @@ class ExplorationDataController @Inject constructor( /** * Replays the specified exploration indicated by [topicId], [storyId], and [explorationId] for - * the user corresponding to [internalProfileId], and returns a [DataProvider] tracking whether + * the user corresponding to [profileId], and returns a [DataProvider] tracking whether * the start succeeded. * * This method behaves the same as [startPlayingNewExploration] except no progress is tracked @@ -176,14 +172,14 @@ class ExplorationDataController @Inject constructor( * instead, depending on the specific situation. */ fun replayExploration( - internalProfileId: Int, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, explorationId: String ): DataProvider { return startPlayingExploration( - internalProfileId, + profileId, classroomId, topicId, storyId, @@ -208,7 +204,7 @@ class ExplorationDataController @Inject constructor( * [stopPlayingExploration] may be optionally called to clean up the session--see the * documentation for that method for details. * - * @param internalProfileId the ID corresponding to the profile for which exploration has to be + * @param profileId the ID corresponding to the profile for which exploration has to be * played * @param topicId the ID corresponding to the topic for which exploration has to be played * @param storyId the ID corresponding to the story for which exploration has to be played @@ -224,7 +220,7 @@ class ExplorationDataController @Inject constructor( * requests, succeeded */ private fun startPlayingExploration( - internalProfileId: Int, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, @@ -235,7 +231,7 @@ class ExplorationDataController @Inject constructor( isReplay: Boolean ): DataProvider { return explorationProgressController.beginExplorationAsync( - LegacyProfileId.newBuilder().apply { internalId = internalProfileId }.build(), + profileId, classroomId, topicId, storyId, @@ -270,7 +266,7 @@ class ExplorationDataController @Inject constructor( * has to be retrieved * @return a [DataProvider] that indicates the success or failure of the retrieve operation */ - fun getOldestExplorationDetailsDataProvider(profileId: LegacyProfileId) = + fun getOldestExplorationDetailsDataProvider(profileId: ProfileId) = explorationCheckpointController.retrieveOldestSavedExplorationCheckpointDetails(profileId) /** @@ -281,7 +277,7 @@ class ExplorationDataController @Inject constructor( * has to be retrieved * @param explorationId the ID of the exploration whose checkpoint has to be deleted */ - fun deleteExplorationProgressById(profileId: LegacyProfileId, explorationId: String) { + fun deleteExplorationProgressById(profileId: ProfileId, explorationId: String) { explorationCheckpointController.deleteSavedExplorationCheckpoint( profileId, explorationId diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgress.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgress.kt index 69075203851..e0a18f86bf7 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgress.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgress.kt @@ -4,7 +4,7 @@ import org.oppia.android.app.model.CheckpointState import org.oppia.android.app.model.EphemeralState import org.oppia.android.app.model.Exploration import org.oppia.android.app.model.ExplorationCheckpoint -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.State import org.oppia.android.domain.oppialogger.OppiaLogger import org.oppia.android.domain.state.StateDeck @@ -19,7 +19,7 @@ private const val TERMINAL_INTERACTION_ID = "EndExploration" * instances, but calling code is responsible for ensuring it is properly reset. */ internal class ExplorationProgress(private val oppiaLogger: OppiaLogger) { - internal lateinit var currentProfileId: LegacyProfileId + internal lateinit var currentProfileId: ProfileId internal lateinit var currentClassroomId: String internal lateinit var currentTopicId: String internal lateinit var currentStoryId: String diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt index 4604273a8fd..1c4e3c06575 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt @@ -24,7 +24,7 @@ import org.oppia.android.app.model.HelpIndex.IndexTypeCase.INDEXTYPE_NOT_SET import org.oppia.android.app.model.HelpIndex.IndexTypeCase.LATEST_REVEALED_HINT_INDEX import org.oppia.android.app.model.HelpIndex.IndexTypeCase.NEXT_AVAILABLE_HINT_INDEX import org.oppia.android.app.model.HelpIndex.IndexTypeCase.SHOW_SOLUTION -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.UserAnswer import org.oppia.android.app.model.WrittenTranslationLanguageSelection import org.oppia.android.domain.classify.AnswerClassificationController @@ -50,7 +50,7 @@ import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.platformparameter.EnableFlashbackSupport import org.oppia.android.util.platformparameter.EnableLessonProgressVisualization import org.oppia.android.util.platformparameter.PlatformParameterValue -import org.oppia.android.util.profile.toProfileIdPreservingZero +import org.oppia.android.util.profile.toLegacyProfileId import org.oppia.android.util.system.OppiaClock import org.oppia.android.util.threading.BackgroundDispatcher import java.util.UUID @@ -139,7 +139,7 @@ class ExplorationProgressController @Inject constructor( // TODO(#606): Replace this with a profile scope to avoid this hacky workaround (which is needed // for getCurrentState). - private lateinit var profileId: LegacyProfileId + private lateinit var profileId: ProfileId private var mostRecentSessionId = MutableStateFlow(null) private val activeSessionId: String @@ -163,7 +163,7 @@ class ExplorationProgressController @Inject constructor( * [submitAnswer]. */ internal fun beginExplorationAsync( - profileId: LegacyProfileId, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, @@ -443,9 +443,7 @@ class ExplorationProgressController @Inject constructor( */ fun getCurrentState(): DataProvider { val writtenTranslationContentLocale = - translationController.getWrittenTranslationContentLocale( - profileId.toProfileIdPreservingZero() - ) + translationController.getWrittenTranslationContentLocale(profileId) val ephemeralStateDataProvider = mostRecentEphemeralStateFlow.convertToSessionProvider(CURRENT_STATE_PROVIDER_ID) return writtenTranslationContentLocale.combineWith( @@ -475,11 +473,11 @@ class ExplorationProgressController @Inject constructor( * language */ fun updateWrittenTranslationContentLanguageMidLesson( - profileId: LegacyProfileId, + profileId: ProfileId, selection: WrittenTranslationLanguageSelection ): DataProvider { return translationController.updateWrittenTranslationContentLanguage( - profileId.toProfileIdPreservingZero(), selection + profileId, selection ).transform(UPDATE_WRITTEN_TRANSLATION_CONTENT_PROVIDER_ID) { previousSelection -> val explorationLogger = learnerAnalyticsLogger.explorationAnalyticsLogger.value val stateLogger = explorationLogger?.stateAnalyticsLogger?.value @@ -507,12 +505,12 @@ class ExplorationProgressController @Inject constructor( is ControllerMessage.InitializeController -> { // Synchronously fetch the learner & installation IDs (these may result in file I/O). val learnerId = profileManagementController.fetchLearnerId( - message.profileId.toProfileIdPreservingZero() + message.profileId ) val installationId = loggingIdentifierController.fetchInstallationId() val isContinueButtonAnimationSeen = profileManagementController.fetchContinueAnimationSeenStatus( - message.profileId.toProfileIdPreservingZero() + message.profileId ) ?: false // Ensure the state is completely recreated for each session to avoid leaking state @@ -635,7 +633,7 @@ class ExplorationProgressController @Inject constructor( private suspend fun ControllerState.beginExplorationImpl( beginExplorationResultFlow: MutableStateFlow>, - profileId: LegacyProfileId, + profileId: ProfileId, classroomId: String, topicId: String, storyId: String, @@ -880,9 +878,7 @@ class ExplorationProgressController @Inject constructor( } if (!isContinueButtonAnimationSeen) { - profileManagementController.markContinueButtonAnimationSeen( - profileId.toProfileIdPreservingZero() - ) + profileManagementController.markContinueButtonAnimationSeen(profileId) } isContinueButtonAnimationSeen = true } @@ -1201,7 +1197,7 @@ class ExplorationProgressController @Inject constructor( // Do not save checkpoints if shouldSavePartialProgress is false. This is expected to happen // when the current exploration has been already completed previously. if (!explorationProgress.shouldSavePartialProgress) return - val profileId: LegacyProfileId = explorationProgress.currentProfileId + val profileId: ProfileId = explorationProgress.currentProfileId val topicId: String = explorationProgress.currentTopicId val storyId: String = explorationProgress.currentStoryId val explorationId: String = explorationProgress.currentExplorationId @@ -1267,7 +1263,7 @@ class ExplorationProgressController @Inject constructor( * unsuccessfully */ private suspend fun ControllerState.processSaveCheckpointResult( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -1328,7 +1324,7 @@ class ExplorationProgressController @Inject constructor( interactionId == "Continue" private fun markExplorationAsInProgressSaved( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -1344,7 +1340,7 @@ class ExplorationProgressController @Inject constructor( } private fun markExplorationAsInProgressNotSaved( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -1389,7 +1385,7 @@ class ExplorationProgressController @Inject constructor( val ephemeralStateFlow: MutableStateFlow>, val commandQueue: SendChannel>, private val installationId: String?, - private val profileId: LegacyProfileId, + private val profileId: ProfileId, private val learnerId: String?, private val learnerAnalyticsLogger: LearnerAnalyticsLogger, val startSessionTimeMs: Long, @@ -1428,7 +1424,7 @@ class ExplorationProgressController @Inject constructor( fun initializeEventLogger(exploration: Exploration) { explorationAnalyticsLogger = learnerAnalyticsLogger.beginExploration( installationId, - profileId, + profileId.toLegacyProfileId(), learnerId, exploration, explorationProgress.currentClassroomId, @@ -1541,7 +1537,7 @@ class ExplorationProgressController @Inject constructor( /** [ControllerMessage] for initializing a new play session. */ data class InitializeController( - val profileId: LegacyProfileId, + val profileId: ProfileId, val classroomId: String, val topicId: String, val storyId: String, @@ -1667,7 +1663,7 @@ class ExplorationProgressController @Inject constructor( * the app (e.g. that an exploration is considered 'in-progress' in such circumstances). */ data class ProcessSavedCheckpointResult( - val profileId: LegacyProfileId, + val profileId: ProfileId, val topicId: String, val storyId: String, val explorationId: String, diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressListener.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressListener.kt index 53fc95d6205..43e039b1755 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressListener.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressListener.kt @@ -1,6 +1,6 @@ package org.oppia.android.domain.exploration -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId /** * Listener for when an exploration has started or ended. @@ -12,7 +12,7 @@ import org.oppia.android.app.model.LegacyProfileId */ interface ExplorationProgressListener { /** Called when an exploration has started. */ - fun onExplorationStarted(profileId: LegacyProfileId, topicId: String) + fun onExplorationStarted(profileId: ProfileId, topicId: String) /** Called when an exploration has ended. */ fun onExplorationEnded() diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/TimerSessionState.kt b/domain/src/main/java/org/oppia/android/domain/exploration/TimerSessionState.kt index 60dd02599c3..adeec4fd4b5 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/TimerSessionState.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/TimerSessionState.kt @@ -1,6 +1,6 @@ package org.oppia.android.domain.exploration -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId /** * Private class that encapsulates the mutable state of an [ExplorationActiveTimeController]. @@ -12,7 +12,7 @@ internal class TimerSessionState { internal var sessionStartTime: Long = 0L /** The profileId of the profile currently logged in. */ - internal lateinit var currentProfileId: LegacyProfileId + internal lateinit var currentProfileId: ProfileId /** The id of the topic that the current exploration belongs to. */ internal lateinit var currentTopicId: String diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt index c99f27c5c47..0821b29eec4 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointController.kt @@ -9,7 +9,7 @@ import org.oppia.android.app.model.Exploration import org.oppia.android.app.model.ExplorationCheckpoint import org.oppia.android.app.model.ExplorationCheckpointDatabase import org.oppia.android.app.model.ExplorationCheckpointDetails -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.State import org.oppia.android.data.persistence.PersistentCacheStore import org.oppia.android.data.persistence.PersistentCacheStore.PublishMode @@ -22,6 +22,7 @@ import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.data.DataProviders.Companion.transformAsync +import org.oppia.android.util.profile.toLegacyProfileId import javax.inject.Inject import javax.inject.Singleton @@ -68,7 +69,7 @@ class ExplorationCheckpointController @Inject constructor( } private val cacheStoreMap = - mutableMapOf>() + mutableMapOf>() /** * Records an exploration checkpoint for the specified profile. @@ -82,7 +83,7 @@ class ExplorationCheckpointController @Inject constructor( * completion of deferred. */ internal fun recordExplorationCheckpointAsync( - profileId: LegacyProfileId, + profileId: ProfileId, explorationId: String, explorationCheckpoint: ExplorationCheckpoint ): Deferred { @@ -129,7 +130,7 @@ class ExplorationCheckpointController @Inject constructor( * Returns a [DataProvider] for the [Deferred] returned from [recordExplorationCheckpointAsync]. */ fun recordExplorationCheckpoint( - profileId: LegacyProfileId, + profileId: ProfileId, explorationId: String, explorationCheckpoint: ExplorationCheckpoint ): DataProvider { @@ -147,7 +148,7 @@ class ExplorationCheckpointController @Inject constructor( /** Returns the saved checkpoint for a specified explorationId and profileId. */ fun retrieveExplorationCheckpoint( - profileId: LegacyProfileId, + profileId: ProfileId, explorationId: String ): DataProvider { return retrieveCacheStore(profileId) @@ -193,7 +194,7 @@ class ExplorationCheckpointController @Inject constructor( * and explorationVersion of the oldest saved checkpoint for the specified profile. */ fun retrieveOldestSavedExplorationCheckpointDetails( - profileId: LegacyProfileId + profileId: ProfileId ): DataProvider { return retrieveCacheStore(profileId) .transform( @@ -214,7 +215,7 @@ class ExplorationCheckpointController @Inject constructor( /** Deletes the saved checkpoint for a specified explorationId and profileId. */ fun deleteSavedExplorationCheckpoint( - profileId: LegacyProfileId, + profileId: ProfileId, explorationId: String ): DataProvider { val deferred = retrieveCacheStore(profileId).storeDataWithCustomChannelAsync( @@ -252,7 +253,7 @@ class ExplorationCheckpointController @Inject constructor( private suspend fun getDeferredResult( deferred: Deferred, explorationId: String?, - profileId: LegacyProfileId?, + profileId: ProfileId?, ): AsyncResult { return when (deferred.await()) { ExplorationCheckpointActionStatus.CHECKPOINT_NOT_FOUND -> @@ -267,7 +268,7 @@ class ExplorationCheckpointController @Inject constructor( } private fun retrieveCacheStore( - profileId: LegacyProfileId + profileId: ProfileId ): PersistentCacheStore { val cacheStore = if (profileId in cacheStoreMap) { cacheStoreMap[profileId]!! @@ -276,7 +277,7 @@ class ExplorationCheckpointController @Inject constructor( cacheStoreFactory.createPerProfile( CACHE_NAME, ExplorationCheckpointDatabase.getDefaultInstance(), - profileId + profileId.toLegacyProfileId() ) cacheStoreMap[profileId] = cacheStore cacheStore diff --git a/domain/src/main/java/org/oppia/android/domain/survey/SurveyGatingController.kt b/domain/src/main/java/org/oppia/android/domain/survey/SurveyGatingController.kt index 63c40cd6528..7f68b26b7e7 100644 --- a/domain/src/main/java/org/oppia/android/domain/survey/SurveyGatingController.kt +++ b/domain/src/main/java/org/oppia/android/domain/survey/SurveyGatingController.kt @@ -84,7 +84,7 @@ class SurveyGatingController @Inject constructor( topicId: String ): DataProvider { return activeTimeController.retrieveAggregateTopicLearningTimeDataProvider( - profileId, topicId + profileId.toProfileIdPreservingZero(), topicId ).transform( GET_TOPIC_LEARNING_TIME_PROVIDER_ID, TopicLearningTime::getTopicLearningTimeMs diff --git a/domain/src/main/java/org/oppia/android/domain/topic/StoryProgressController.kt b/domain/src/main/java/org/oppia/android/domain/topic/StoryProgressController.kt index b424deafecb..d9527c2ccb7 100644 --- a/domain/src/main/java/org/oppia/android/domain/topic/StoryProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/topic/StoryProgressController.kt @@ -3,7 +3,7 @@ package org.oppia.android.domain.topic import kotlinx.coroutines.Deferred import org.oppia.android.app.model.ChapterPlayState import org.oppia.android.app.model.ChapterProgress -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.StoryProgress import org.oppia.android.app.model.TopicProgress import org.oppia.android.app.model.TopicProgressDatabase @@ -16,6 +16,7 @@ import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders import org.oppia.android.util.data.DataProviders.Companion.transform import org.oppia.android.util.data.DataProviders.Companion.transformAsync +import org.oppia.android.util.profile.toLegacyProfileId import javax.inject.Inject import javax.inject.Singleton @@ -70,7 +71,7 @@ class StoryProgressController @Inject constructor( } private val cacheStoreMap = - mutableMapOf>() + mutableMapOf>() /** * Records the specified chapter completed within the context of the specified exploration, story, @@ -85,7 +86,7 @@ class StoryProgressController @Inject constructor( * @return a [DataProvider] that indicates the success/failure of this record progress operation */ fun recordCompletedChapter( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -148,7 +149,7 @@ class StoryProgressController @Inject constructor( * @return a [DataProvider] that indicates the success/failure of this record progress operation */ fun recordChapterAsInProgressSaved( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -231,7 +232,7 @@ class StoryProgressController @Inject constructor( * @return a [DataProvider] that indicates the success/failure of this record progress operation */ fun recordChapterAsInProgressNotSaved( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String, @@ -302,7 +303,7 @@ class StoryProgressController @Inject constructor( /** Returns the [ChapterPlayState] [DataProvider] for a particular explorationId and profile. */ fun retrieveChapterPlayStateByExplorationId( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String @@ -320,7 +321,7 @@ class StoryProgressController @Inject constructor( /** Returns list of [TopicProgress] [DataProvider] for a particular profile. */ internal fun retrieveTopicProgressListDataProvider( - profileId: LegacyProfileId + profileId: ProfileId ): DataProvider> { return retrieveCacheStore(profileId) .transformAsync(RETRIEVE_TOPIC_PROGRESS_LIST_DATA_PROVIDER_ID) { topicProgressDatabase -> @@ -332,7 +333,7 @@ class StoryProgressController @Inject constructor( /** Returns a [TopicProgress] [DataProvider] for a specific topicId, per-profile basis. */ private fun retrieveTopicProgressDataProvider( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String ): DataProvider { return retrieveTopicsProgressDataProvider(profileId, listOf(topicId)) @@ -346,7 +347,7 @@ class StoryProgressController @Inject constructor( * The provider defaults the progress for any IDs that don't have progress corresponding to them. */ internal fun retrieveTopicsProgressDataProvider( - profileId: LegacyProfileId, + profileId: ProfileId, topicIds: List ): DataProvider> { return retrieveCacheStore(profileId) @@ -359,7 +360,7 @@ class StoryProgressController @Inject constructor( /** Returns a [StoryProgress] [DataProvider] for a specific storyId, per-profile basis. */ internal fun retrieveStoryProgressDataProvider( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String ): DataProvider { @@ -378,7 +379,7 @@ class StoryProgressController @Inject constructor( } private fun retrieveCacheStore( - profileId: LegacyProfileId + profileId: ProfileId ): PersistentCacheStore { val cacheStore = if (profileId in cacheStoreMap) { cacheStoreMap[profileId]!! @@ -387,7 +388,7 @@ class StoryProgressController @Inject constructor( cacheStoreFactory.createPerProfile( CACHE_NAME, TopicProgressDatabase.getDefaultInstance(), - profileId + profileId.toLegacyProfileId() ) cacheStoreMap[profileId] = cacheStore cacheStore diff --git a/domain/src/main/java/org/oppia/android/domain/topic/TopicController.kt b/domain/src/main/java/org/oppia/android/domain/topic/TopicController.kt index e6ad34f1764..5caef4c1fd1 100755 --- a/domain/src/main/java/org/oppia/android/domain/topic/TopicController.kt +++ b/domain/src/main/java/org/oppia/android/domain/topic/TopicController.kt @@ -157,7 +157,9 @@ class TopicController @Inject constructor( AsyncResult.Success(topics) } val topicsProgressDataProvider = - storyProgressController.retrieveTopicsProgressDataProvider(profileId, topicIds) + storyProgressController.retrieveTopicsProgressDataProvider( + profileId.toProfileIdPreservingZero(), topicIds + ) val topicsCombinedProvider = topicsDataProvider.combineWith( topicsProgressDataProvider, @@ -193,7 +195,9 @@ class TopicController @Inject constructor( return@createInMemoryDataProviderAsync AsyncResult.Success(retrieveStory(topicId, storyId)) } val storyProgressDataProvider = - storyProgressController.retrieveStoryProgressDataProvider(profileId, topicId, storyId) + storyProgressController.retrieveStoryProgressDataProvider( + profileId.toProfileIdPreservingZero(), topicId, storyId + ) val storyCombinedProvider = storyDataProvider.combineWith( storyProgressDataProvider, @@ -320,7 +324,9 @@ class TopicController @Inject constructor( */ fun getCompletedStoryList(profileId: LegacyProfileId): DataProvider { val retrieveTopicProgressListProvider = - storyProgressController.retrieveTopicProgressListDataProvider(profileId) + storyProgressController.retrieveTopicProgressListDataProvider( + profileId.toProfileIdPreservingZero() + ) val translationLocaleProvider = translationController.getWrittenTranslationContentLocale( profileId.toProfileIdPreservingZero() @@ -347,7 +353,9 @@ class TopicController @Inject constructor( */ fun getOngoingTopicList(profileId: LegacyProfileId): DataProvider { val retrieveTopicProgressListProvider = - storyProgressController.retrieveTopicProgressListDataProvider(profileId) + storyProgressController.retrieveTopicProgressListDataProvider( + profileId.toProfileIdPreservingZero() + ) val translationLocaleProvider = translationController.getWrittenTranslationContentLocale( profileId.toProfileIdPreservingZero() diff --git a/domain/src/main/java/org/oppia/android/domain/topic/TopicListController.kt b/domain/src/main/java/org/oppia/android/domain/topic/TopicListController.kt index 47f25e287e8..4b1c1a71bb4 100644 --- a/domain/src/main/java/org/oppia/android/domain/topic/TopicListController.kt +++ b/domain/src/main/java/org/oppia/android/domain/topic/TopicListController.kt @@ -129,7 +129,9 @@ class TopicListController @Inject constructor( */ fun getPromotedActivityList(profileId: LegacyProfileId): DataProvider { val retrieveTopicProgressListProvider = - storyProgressController.retrieveTopicProgressListDataProvider(profileId) + storyProgressController.retrieveTopicProgressListDataProvider( + profileId.toProfileIdPreservingZero() + ) val translationLocaleProvider = translationController.getWrittenTranslationContentLocale( profileId.toProfileIdPreservingZero() diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index 0cd16adde34..a243cae12ed 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -949,7 +949,11 @@ class AudioPlayerControllerTest { ) { val playingProvider = explorationDataController.startPlayingNewExploration( - internalProfileId = 0, classroomId, topicId, storyId, explorationId + profileId = profileId.toProfileIdPreservingZero(), + classroomId, + topicId, + storyId, + explorationId ) monitorFactory.waitForNextSuccessfulResult(playingProvider) monitorFactory.waitForNextSuccessfulResult(explorationProgressController.getCurrentState()) @@ -957,7 +961,9 @@ class AudioPlayerControllerTest { private fun loadExploration(explorationId: String): Exploration { return monitorFactory.waitForNextSuccessfulResult( - explorationDataController.getExplorationById(profileId, explorationId) + explorationDataController.getExplorationById( + profileId.toProfileIdPreservingZero(), explorationId + ) ).exploration } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt index 8eea2ba5444..f8acf313745 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt @@ -13,7 +13,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.classify.InteractionsModule import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule @@ -94,8 +94,8 @@ class ExplorationActiveTimeControllerTest { @Inject lateinit var explorationDataController: ExplorationDataController - private val firstTestProfile = LegacyProfileId.newBuilder().setInternalId(0).build() - private val secondTestProfile = LegacyProfileId.newBuilder().setInternalId(1).build() + private val firstTestProfile = ProfileId.newBuilder().setInternalId(0).build() + private val secondTestProfile = ProfileId.newBuilder().setInternalId(1).build() @Before fun setUp() { @@ -493,11 +493,11 @@ class ExplorationActiveTimeControllerTest { topicId: String, storyId: String, explorationId: String, - profileId: LegacyProfileId + profileId: ProfileId ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt index d5b9612395f..075a503425e 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt @@ -14,7 +14,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ExplorationCheckpoint -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.classify.InteractionsModule import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule @@ -91,7 +91,7 @@ class ExplorationDataControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var explorationCheckpointController: ExplorationCheckpointController - private val profileId = LegacyProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setInternalId(0).build() @Before fun setUp() { @@ -196,7 +196,7 @@ class ExplorationDataControllerTest { fun testStartPlayingNewExploration_returnsSuccess() { val startProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -272,7 +272,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, TEST_EXPLORATION_ID_2 @@ -294,7 +294,7 @@ class ExplorationDataControllerTest { val checkpoint = retrieveExplorationCheckpoint(TEST_EXPLORATION_ID_2) val secondStartProvider = explorationDataController.resumeExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -309,7 +309,7 @@ class ExplorationDataControllerTest { fun testRestartExploration_returnsSuccess() { val startProvider = explorationDataController.restartExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -331,7 +331,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.restartExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -345,7 +345,7 @@ class ExplorationDataControllerTest { fun testReplayExploration_returnsSuccess() { val startProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -367,7 +367,7 @@ class ExplorationDataControllerTest { val secondStartProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -388,7 +388,7 @@ class ExplorationDataControllerTest { val dataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_1, TEST_STORY_ID_2, @@ -448,7 +448,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -461,7 +461,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -474,7 +474,7 @@ class ExplorationDataControllerTest { ) { val startPlayingProvider = explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -501,7 +501,7 @@ class ExplorationDataControllerTest { val checkpoint = retrieveExplorationCheckpoint(explorationId) val resumeProvider = explorationDataController.resumeExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId, checkpoint + profileId, classroomId, topicId, storyId, explorationId, checkpoint ) monitorFactory.waitForNextSuccessfulResult(resumeProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerLessonProgressTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerLessonProgressTest.kt index e7d3e332c64..332cf37db0e 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerLessonProgressTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerLessonProgressTest.kt @@ -18,8 +18,8 @@ import org.oppia.android.app.model.EphemeralState import org.oppia.android.app.model.Fraction import org.oppia.android.app.model.InteractionObject import org.oppia.android.app.model.ItemSelectionAnswerState -import org.oppia.android.app.model.LegacyProfileId import org.oppia.android.app.model.ListOfSetsOfTranslatableHtmlContentIds +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.RatioExpression import org.oppia.android.app.model.SetOfTranslatableHtmlContentIds import org.oppia.android.app.model.TranslatableHtmlContentId @@ -104,7 +104,7 @@ class ExplorationProgressControllerLessonProgressTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers - private val profileId = LegacyProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setInternalId(0).build() @Before fun setUp() { @@ -245,7 +245,7 @@ class ExplorationProgressControllerLessonProgressTest { storyId: String = TEST_STORY_ID_0 ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, TEST_CLASSROOM_ID_0, topicId, storyId, explorationId + profileId, TEST_CLASSROOM_ID_0, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index cc0bf280aee..66300d88459 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -41,10 +41,10 @@ import org.oppia.android.app.model.HelpIndex.IndexTypeCase.NEXT_AVAILABLE_HINT_I import org.oppia.android.app.model.HelpIndex.IndexTypeCase.SHOW_SOLUTION import org.oppia.android.app.model.InteractionObject import org.oppia.android.app.model.ItemSelectionAnswerState -import org.oppia.android.app.model.LegacyProfileId import org.oppia.android.app.model.ListOfSetsOfTranslatableHtmlContentIds import org.oppia.android.app.model.OppiaLanguage import org.oppia.android.app.model.Point2d +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.RatioExpression import org.oppia.android.app.model.SetOfTranslatableHtmlContentIds import org.oppia.android.app.model.TranslatableHtmlContentId @@ -115,7 +115,6 @@ import org.oppia.android.util.logging.GlobalLogLevel import org.oppia.android.util.logging.LogLevel import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule -import org.oppia.android.util.profile.toProfileIdPreservingZero import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import java.util.Locale @@ -162,7 +161,7 @@ class ExplorationProgressControllerTest { @Inject lateinit var profileManagementController: ProfileManagementController @Inject lateinit var explorationActiveTimeController: ExplorationActiveTimeController - private val profileId = LegacyProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setInternalId(0).build() @Before fun setUp() { @@ -192,7 +191,7 @@ class ExplorationProgressControllerTest { fun testPlayExploration_invalid_returnsSuccess() { val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, INVALID_CLASSROOM_ID, INVALID_TOPIC_ID, INVALID_STORY_ID, @@ -219,7 +218,7 @@ class ExplorationProgressControllerTest { fun testPlayExploration_valid_returnsSuccess() { val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -268,7 +267,7 @@ class ExplorationProgressControllerTest { @Test fun testEphemeralState_profile1ClicksContinue_switchToProfile2_shouldIndicateButtonAnimation() { oppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) - val profileId2 = LegacyProfileId.newBuilder().setInternalId(1).build() + val profileId2 = ProfileId.newBuilder().setInternalId(1).build() startPlayingNewExploration( TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, TEST_EXPLORATION_ID_2 ) @@ -358,7 +357,7 @@ class ExplorationProgressControllerTest { // Try playing another exploration without finishing the previous one. val resultDataProvider = explorationDataController.replayExploration( - profileId.internalId, + profileId, TEST_CLASSROOM_ID_0, TEST_TOPIC_ID_0, TEST_STORY_ID_0, @@ -2192,7 +2191,7 @@ class ExplorationProgressControllerTest { @Test fun testGetCurrentState_englishLangProfile_includesTranslationContextForEnglish() { - val englishProfileId = LegacyProfileId.newBuilder().apply { internalId = 1 }.build() + val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startPlayingNewExploration( TEST_CLASSROOM_ID_0, @@ -2213,7 +2212,7 @@ class ExplorationProgressControllerTest { @Test fun testGetCurrentState_englishLangProfile_switchToArabic_includesTranslationContextForArabic() { - val englishProfileId = LegacyProfileId.newBuilder().apply { internalId = 1 }.build() + val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) startPlayingNewExploration( TEST_CLASSROOM_ID_0, @@ -2236,8 +2235,8 @@ class ExplorationProgressControllerTest { @Test fun testGetCurrentState_arabicLangProfile_includesTranslationContextForArabic() { - val englishProfileId = LegacyProfileId.newBuilder().apply { internalId = 1 }.build() - val arabicProfileId = LegacyProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + val arabicProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) updateContentLanguage(arabicProfileId, OppiaLanguage.ARABIC) startPlayingNewExploration( @@ -3169,7 +3168,7 @@ class ExplorationProgressControllerTest { // Verify that the learner's profile-wide content language has changed. val contentLangProvider = translationController.getWrittenTranslationContentLanguage( - profileId.toProfileIdPreservingZero() + profileId ) val contentLanguage = monitorFactory.waitForNextSuccessfulResult(contentLangProvider) assertThat(contentLanguage).isEqualTo(OppiaLanguage.SWAHILI) @@ -3203,8 +3202,8 @@ class ExplorationProgressControllerTest { @Test fun testUpdateLanguageMidLesson_englishToSwahili_diffProfile_doesNotChangeOtherProfilesLang() { - val englishProfileId = LegacyProfileId.newBuilder().apply { internalId = 1 }.build() - val arabicProfileId = LegacyProfileId.newBuilder().apply { internalId = 2 }.build() + val englishProfileId = ProfileId.newBuilder().apply { internalId = 1 }.build() + val arabicProfileId = ProfileId.newBuilder().apply { internalId = 2 }.build() updateContentLanguage(englishProfileId, OppiaLanguage.ENGLISH) updateContentLanguage(arabicProfileId, OppiaLanguage.ARABIC) startPlayingNewExploration( @@ -3227,7 +3226,7 @@ class ExplorationProgressControllerTest { // Verify that the other learner's profile-wide content language hasn't changed. val contentLangProvider = translationController.getWrittenTranslationContentLanguage( - arabicProfileId.toProfileIdPreservingZero() + arabicProfileId ) val contentLanguage = monitorFactory.waitForNextSuccessfulResult(contentLangProvider) assertThat(contentLanguage).isEqualTo(OppiaLanguage.ARABIC) @@ -3253,7 +3252,7 @@ class ExplorationProgressControllerTest { // Verify that the learner's profile-wide content language has changed. val contentLangProvider = translationController.getWrittenTranslationContentLanguage( - profileId.toProfileIdPreservingZero() + profileId ) val contentLanguage = monitorFactory.waitForNextSuccessfulResult(contentLangProvider) assertThat(contentLanguage).isEqualTo(OppiaLanguage.ENGLISH) @@ -3709,11 +3708,11 @@ class ExplorationProgressControllerTest { topicId: String, storyId: String, explorationId: String, - profileId: LegacyProfileId = this.profileId + profileId: ProfileId = this.profileId ) { val startPlayingProvider = explorationDataController.startPlayingNewExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3724,11 +3723,11 @@ class ExplorationProgressControllerTest { storyId: String, explorationId: String, explorationCheckpoint: ExplorationCheckpoint, - profileId: LegacyProfileId = this.profileId + profileId: ProfileId = this.profileId ) { val startPlayingProvider = explorationDataController.resumeExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId, explorationCheckpoint + profileId, classroomId, topicId, storyId, explorationId, explorationCheckpoint ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3738,11 +3737,11 @@ class ExplorationProgressControllerTest { topicId: String, storyId: String, explorationId: String, - profileId: LegacyProfileId = this.profileId + profileId: ProfileId = this.profileId ) { val startPlayingProvider = explorationDataController.restartExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } @@ -3752,18 +3751,18 @@ class ExplorationProgressControllerTest { topicId: String, storyId: String, explorationId: String, - profileId: LegacyProfileId = this.profileId + profileId: ProfileId = this.profileId ) { val startPlayingProvider = explorationDataController.replayExploration( - profileId.internalId, classroomId, topicId, storyId, explorationId + profileId, classroomId, topicId, storyId, explorationId ) monitorFactory.waitForNextSuccessfulResult(startPlayingProvider) } private fun retrieveExplorationCheckpoint( explorationId: String, - profileId: LegacyProfileId = this.profileId + profileId: ProfileId = this.profileId ): ExplorationCheckpoint { return monitorFactory.waitForNextSuccessfulResult( explorationCheckpointController.retrieveExplorationCheckpoint(profileId, explorationId) @@ -4164,9 +4163,9 @@ class ExplorationProgressControllerTest { Locale.setDefault(locale) } - private fun updateContentLanguage(profileId: LegacyProfileId, language: OppiaLanguage) { + private fun updateContentLanguage(profileId: ProfileId, language: OppiaLanguage) { val updateProvider = translationController.updateWrittenTranslationContentLanguage( - profileId.toProfileIdPreservingZero(), + profileId, WrittenTranslationLanguageSelection.newBuilder().apply { selectedLanguage = language }.build() @@ -4226,7 +4225,7 @@ class ExplorationProgressControllerTest { } private fun logIntoAnalyticsReadyAdminProfile() { - val rootProfileId = LegacyProfileId.getDefaultInstance() + val rootProfileId = ProfileId.newBuilder().setInternalId(0).build() val addProfileProvider = profileManagementController.addProfile( name = "Admin", pin = "", @@ -4237,7 +4236,7 @@ class ExplorationProgressControllerTest { ) monitorFactory.waitForNextSuccessfulResult(addProfileProvider) monitorFactory.waitForNextSuccessfulResult( - profileManagementController.loginToProfile(rootProfileId.toProfileIdPreservingZero()) + profileManagementController.loginToProfile(rootProfileId) ) } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt index 4cf55fe3a29..bad0f54ffc3 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt @@ -18,7 +18,7 @@ import org.oppia.android.app.model.CheckpointState import org.oppia.android.app.model.ExplorationCheckpoint import org.oppia.android.app.model.HelpIndex.IndexTypeCase.NEXT_AVAILABLE_HINT_INDEX import org.oppia.android.app.model.InteractionObject -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.app.model.UserAnswer import org.oppia.android.domain.classify.InteractionsModule import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule @@ -117,8 +117,8 @@ class ExplorationCheckpointControllerTest { @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject lateinit var fakeExplorationRetriever: FakeExplorationRetriever - private val firstTestProfile = LegacyProfileId.newBuilder().setInternalId(0).build() - private val secondTestProfile = LegacyProfileId.newBuilder().setInternalId(1).build() + private val firstTestProfile = ProfileId.newBuilder().setInternalId(0).build() + private val secondTestProfile = ProfileId.newBuilder().setInternalId(1).build() @Before fun setUp() { @@ -832,7 +832,7 @@ class ExplorationCheckpointControllerTest { } } - private fun saveCheckpoint(profileId: LegacyProfileId, index: Int): Any? { + private fun saveCheckpoint(profileId: ProfileId, index: Int): Any? { val recordProvider = explorationCheckpointController.recordExplorationCheckpoint( profileId = profileId, explorationId = createExplorationIdForIndex(index), @@ -841,7 +841,7 @@ class ExplorationCheckpointControllerTest { return monitorFactory.waitForNextSuccessfulResult(recordProvider) } - private fun saveMultipleCheckpoints(profileId: LegacyProfileId, numberOfCheckpoints: Int) { + private fun saveMultipleCheckpoints(profileId: ProfileId, numberOfCheckpoints: Int) { for (index in 0 until numberOfCheckpoints) { saveCheckpoint(profileId, index) } @@ -885,7 +885,7 @@ class ExplorationCheckpointControllerTest { .build() private fun retrieveExplorationCheckpointWithOverride( - profileId: LegacyProfileId, + profileId: ProfileId, expIdToLoadInstead: String ): DataProvider { fakeExplorationRetriever.setExplorationProxy( @@ -898,7 +898,7 @@ class ExplorationCheckpointControllerTest { } private fun createCheckpointForTestExploration( - profileId: LegacyProfileId, + profileId: ProfileId, playRoutine: () -> Unit ) { fakeExplorationRetriever.setExplorationProxy( @@ -906,7 +906,7 @@ class ExplorationCheckpointControllerTest { expIdToLoadInstead = "test_checkpointing_base_exploration" ) explorationDataController.startPlayingNewExploration( - internalProfileId = profileId.internalId, + profileId = profileId, classroomId = "", topicId = "", storyId = "", diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index c8af7b398ff..4f67676e314 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -66,6 +66,7 @@ import org.oppia.android.util.data.DataProvidersInjectorProvider import org.oppia.android.util.locale.LocaleProdModule import org.oppia.android.util.logging.LoggerModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import org.robolectric.shadows.ShadowLog @@ -2311,7 +2312,7 @@ class LearnerAnalyticsLoggerTest { private fun loadExploration(expId: String): Exploration { return monitorFactory.waitForNextSuccessfulResult( - explorationDataController.getExplorationById(profileId, expId) + explorationDataController.getExplorationById(profileId.toProfileIdPreservingZero(), expId) ).exploration } diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt index 91d63634dc8..872db8038ac 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyGatingControllerTest.kt @@ -639,7 +639,9 @@ class SurveyGatingControllerTest { topicId: String ) { explorationActiveTimeController.onAppInForeground() - explorationActiveTimeController.onExplorationStarted(profileId, topicId) + explorationActiveTimeController.onExplorationStarted( + profileId.toProfileIdPreservingZero(), topicId + ) testCoroutineDispatchers.advanceTimeBy(sessionLengthMs) explorationActiveTimeController.onExplorationEnded() } diff --git a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt index 5c74619fc02..0e6ac16b36e 100644 --- a/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/StoryProgressControllerTest.kt @@ -13,7 +13,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ChapterPlayState -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.LoggingIdentifierModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule @@ -55,11 +55,11 @@ class StoryProgressControllerTest { @Inject lateinit var fakeOppiaClock: FakeOppiaClock @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private lateinit var profileId: LegacyProfileId + private lateinit var profileId: ProfileId @Before fun setUp() { - profileId = LegacyProfileId.newBuilder().setInternalId(0).build() + profileId = ProfileId.newBuilder().setInternalId(0).build() setUpTestApplicationComponent() } @@ -281,7 +281,7 @@ class StoryProgressControllerTest { } private fun retrieveChapterPlayState( - profileId: LegacyProfileId, + profileId: ProfileId, topicId: String, storyId: String, explorationId: String diff --git a/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt index 3e81586e7d8..110413a2873 100755 --- a/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt @@ -1280,7 +1280,7 @@ class TopicControllerTest { */ private fun markInProgressSavedFractionsStory0Exp1WithoutCompletingPreviousChapters() { val resultProvider = storyProgressController.recordChapterAsInProgressSaved( - profileId1, + profileId1.toProfileIdPreservingZero(), FRACTIONS_TOPIC_ID, FRACTIONS_STORY_ID_0, FRACTIONS_EXPLORATION_ID_1, diff --git a/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt index 0939342f851..1beb60a0aec 100644 --- a/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/topic/TopicListControllerTest.kt @@ -49,6 +49,7 @@ import org.oppia.android.util.logging.SyncStatusModule import org.oppia.android.util.networking.NetworkConnectionUtilDebugModule import org.oppia.android.util.parser.image.DefaultGcsPrefix import org.oppia.android.util.parser.image.ImageDownloadUrlTemplate +import org.oppia.android.util.profile.toProfileIdPreservingZero import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -694,7 +695,7 @@ class TopicListControllerTest { val previousTopicId = "previous_topic_id" val recordProgressDataProvider = storyProgressController.recordChapterAsInProgressSaved( - profileId0, + profileId0.toProfileIdPreservingZero(), topicId = previousTopicId, storyId = "previous_story_id", explorationId = "previous_exploration_id", diff --git a/model/src/main/proto/arguments.proto b/model/src/main/proto/arguments.proto index 16e95009a85..19e1682aac1 100644 --- a/model/src/main/proto/arguments.proto +++ b/model/src/main/proto/arguments.proto @@ -122,7 +122,7 @@ enum RecentlyPlayedActivityTitle { // Params required when creating a new ExplorationActivity. message ExplorationActivityParams { // The ID of the profile that wants to start an exploration play session. - LegacyProfileId profile_id = 1; + ProfileId profile_id = 1; // The ID of the classroom to which the opening exploration belongs. string classroom_id = 7; @@ -158,7 +158,7 @@ message ExplorationActivityParams { // Arguments that must be passed to a new ExplorationFragment. message ExplorationFragmentArguments { // The ID of the profile that wants to start an exploration play session. - LegacyProfileId profile_id = 1; + ProfileId profile_id = 1; // The ID of the classroom to which the opening exploration belongs. string classroom_id = 6; @@ -179,7 +179,7 @@ message ExplorationFragmentArguments { // Params required when creating a new ResumeLessonActivity. message ResumeLessonActivityParams { // The ID of the profile that wants to start an exploration play session. - LegacyProfileId profile_id = 1; + ProfileId profile_id = 1; // The ID of the classroom to which the opening exploration belongs. string classroom_id = 7; @@ -203,7 +203,7 @@ message ResumeLessonActivityParams { // Arguments that must be passed to a new ResumeLessonFragment. message ResumeLessonFragmentArguments { // The ID of the profile that wants to start an exploration play session. - LegacyProfileId profile_id = 1; + ProfileId profile_id = 1; // The ID of the classroom to which the opening exploration belongs. string classroom_id = 7; diff --git a/testing/src/main/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelper.kt b/testing/src/main/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelper.kt index a2ad2a6567b..4b730da87f7 100644 --- a/testing/src/main/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelper.kt +++ b/testing/src/main/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelper.kt @@ -12,6 +12,7 @@ import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations import org.oppia.android.app.model.ExplorationCheckpoint import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationCheckpointController import org.oppia.android.domain.exploration.lightweightcheckpointing.ExplorationCheckpointController.ExplorationCheckpointNotFoundException import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 @@ -23,6 +24,7 @@ import org.oppia.android.testing.time.FakeOppiaClock import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.profile.toProfileIdPreservingZero import javax.inject.Inject import javax.inject.Singleton @@ -96,7 +98,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the checkpoint has to be saved * @param version the version of the exploration for which the checkpoint has to be created */ - fun saveCheckpointForFractionsStory0Exploration0(profileId: LegacyProfileId, version: Int) { + fun saveCheckpointForFractionsStory0Exploration0(profileId: ProfileId, version: Int) { val checkpoint = createExplorationCheckpoint( explorationTitle = FRACTIONS_EXPLORATION_0_TITLE, pendingStateName = FRACTIONS_STORY_0_EXPLORATION_0_FIRST_STATE_NAME, @@ -110,13 +112,24 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Saves a checkpoint for topic Fractions, story 0, exploration 0. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun saveCheckpointForFractionsStory0Exploration0(profileId: LegacyProfileId, version: Int) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + saveCheckpointForFractionsStory0Exploration0(profileId.toProfileIdPreservingZero(), version) + } + /** * Saves a checkpoint for topic Fractions, story 0, exploration 1. * * @param profileId the profile ID for which the checkpoint has to be saved * @param version the version of the exploration for which the checkpoint has to be created */ - fun saveCheckpointForFractionsStory0Exploration1(profileId: LegacyProfileId, version: Int) { + fun saveCheckpointForFractionsStory0Exploration1(profileId: ProfileId, version: Int) { val checkpoint = createExplorationCheckpoint( explorationTitle = FRACTIONS_EXPLORATION_1_TITLE, pendingStateName = FRACTIONS_STORY_0_EXPLORATION_1_FIRST_STATE_NAME, @@ -130,6 +143,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Saves a checkpoint for topic Fractions, story 0, exploration 1. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun saveCheckpointForFractionsStory0Exploration1(profileId: LegacyProfileId, version: Int) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + saveCheckpointForFractionsStory0Exploration1(profileId.toProfileIdPreservingZero(), version) + } + /** * Updates the saved checkpoint for Fractions, story 0, exploration 0. For this function to work * correctly it should be called after [saveCheckpointForFractionsStory0Exploration0]. @@ -137,7 +161,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the checkpoint has to be saved * @param version the version of the exploration for which the checkpoint has to be created */ - fun updateCheckpointForFractionsStory0Exploration0(profileId: LegacyProfileId, version: Int) { + fun updateCheckpointForFractionsStory0Exploration0(profileId: ProfileId, version: Int) { val checkpoint = createUpdatedExplorationCheckpoint( explorationTitle = FRACTIONS_EXPLORATION_0_TITLE, pendingStateName = FRACTIONS_STORY_0_EXPLORATION_0_SECOND_STATE_NAME, @@ -151,6 +175,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Updates the saved checkpoint for Fractions, story 0, exploration 0. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun updateCheckpointForFractionsStory0Exploration0(profileId: LegacyProfileId, version: Int) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + updateCheckpointForFractionsStory0Exploration0(profileId.toProfileIdPreservingZero(), version) + } + /** * Updates the saved checkpoint for Fractions, story 0, exploration 1. For this function to work * correctly it should be called after [saveCheckpointForFractionsStory0Exploration1]. @@ -158,7 +193,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the checkpoint has to be saved * @param version the version of the exploration for which the checkpoint has to be created */ - fun updateCheckpointForFractionsStory0Exploration1(profileId: LegacyProfileId, version: Int) { + fun updateCheckpointForFractionsStory0Exploration1(profileId: ProfileId, version: Int) { val checkpoint = createUpdatedExplorationCheckpoint( explorationTitle = FRACTIONS_EXPLORATION_1_TITLE, pendingStateName = FRACTIONS_STORY_0_EXPLORATION_1_SECOND_STATE_NAME, @@ -172,6 +207,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Updates the saved checkpoint for Fractions, story 0, exploration 1. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun updateCheckpointForFractionsStory0Exploration1(profileId: LegacyProfileId, version: Int) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + updateCheckpointForFractionsStory0Exploration1(profileId.toProfileIdPreservingZero(), version) + } + /** * Saves a checkpoint for topic Ratios, story 0, exploration 0. * @@ -179,7 +225,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param version the version of the exploration for which the checkpoint has to be created */ fun saveCheckpointForRatiosStory0Exploration0( - profileId: LegacyProfileId, + profileId: ProfileId, version: Int, ) { val checkpoint = createExplorationCheckpoint( @@ -195,6 +241,20 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Saves a checkpoint for topic Ratios, story 0, exploration 0. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun saveCheckpointForRatiosStory0Exploration0( + profileId: LegacyProfileId, + version: Int, + ) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + saveCheckpointForRatiosStory0Exploration0(profileId.toProfileIdPreservingZero(), version) + } + /** * Updates the saved checkpoint for Fractions, story 0, exploration 0. For this function to work * correctly it should be called after [saveCheckpointForFractionsStory0Exploration0]. @@ -202,7 +262,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the checkpoint has to be saved * @param version the version of the exploration for which the checkpoint has to be created */ - fun updateCheckpointForRatiosStory0Exploration0(profileId: LegacyProfileId, version: Int) { + fun updateCheckpointForRatiosStory0Exploration0(profileId: ProfileId, version: Int) { val checkpoint = createUpdatedExplorationCheckpoint( explorationTitle = RATIOS_EXPLORATION_0_TITLE, pendingStateName = RATIOS_STORY_0_EXPLORATION_0_SECOND_STATE_NAME, @@ -216,6 +276,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( verifyProviderFinishesWithSuccess(saveCheckpointDataProvider) } + /** + * Updates the saved checkpoint for Ratios, story 0, exploration 0. + * + * @param profileId the legacy profile ID for which the checkpoint has to be saved + * @param version the version of the exploration for which the checkpoint has to be created + */ + fun updateCheckpointForRatiosStory0Exploration0(profileId: LegacyProfileId, version: Int) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + updateCheckpointForRatiosStory0Exploration0(profileId.toProfileIdPreservingZero(), version) + } + /** * Function to verify progress for the exploration specified by the explorationId exists in the * checkpoint database of the specified profileId. @@ -223,7 +294,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the save operation has to be verified * @param explorationId the ID of the exploration for which checkpoint was saved */ - fun verifyExplorationProgressIsSaved(profileId: LegacyProfileId, explorationId: String) { + fun verifyExplorationProgressIsSaved(profileId: ProfileId, explorationId: String) { val retrieveCheckpointDataProvider = explorationCheckpointController.retrieveExplorationCheckpoint( @@ -247,6 +318,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( } } + /** + * Verifies that progress for the given [explorationId] exists for the specified [profileId]. + * + * @param profileId the legacy profile ID for which the save operation has to be verified + * @param explorationId the ID of the exploration for which checkpoint was saved + */ + fun verifyExplorationProgressIsSaved(profileId: LegacyProfileId, explorationId: String) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + verifyExplorationProgressIsSaved(profileId.toProfileIdPreservingZero(), explorationId) + } + /** * Function to verify no progress for the exploration specified by the explorationId exists in the * checkpoint database of the specified profileId. @@ -254,7 +336,7 @@ class ExplorationCheckpointTestHelper @Inject constructor( * @param profileId the profile ID for which the delete operation has to be verified * @param explorationId the ID of the exploration for which checkpoint should be deleted */ - fun verifyExplorationProgressIsDeleted(profileId: LegacyProfileId, explorationId: String) { + fun verifyExplorationProgressIsDeleted(profileId: ProfileId, explorationId: String) { val retrieveCheckpointDataProvider = explorationCheckpointController.retrieveExplorationCheckpoint( profileId, @@ -279,6 +361,17 @@ class ExplorationCheckpointTestHelper @Inject constructor( } } + /** + * Verifies that no progress for the given [explorationId] exists for the specified [profileId]. + * + * @param profileId the legacy profile ID for which the delete operation has to be verified + * @param explorationId the ID of the exploration for which checkpoint should be deleted + */ + fun verifyExplorationProgressIsDeleted(profileId: LegacyProfileId, explorationId: String) { + // TODO(#6203): Remove once app-layer tests are migrated to ProfileId. + verifyExplorationProgressIsDeleted(profileId.toProfileIdPreservingZero(), explorationId) + } + private fun createExplorationCheckpoint( explorationTitle: String, pendingStateName: String, diff --git a/testing/src/main/java/org/oppia/android/testing/story/StoryProgressTestHelper.kt b/testing/src/main/java/org/oppia/android/testing/story/StoryProgressTestHelper.kt index 98ef108d16f..12421ef949d 100644 --- a/testing/src/main/java/org/oppia/android/testing/story/StoryProgressTestHelper.kt +++ b/testing/src/main/java/org/oppia/android/testing/story/StoryProgressTestHelper.kt @@ -36,6 +36,7 @@ import org.oppia.android.testing.time.FakeOppiaClock import org.oppia.android.util.data.AsyncResult import org.oppia.android.util.data.DataProvider import org.oppia.android.util.data.DataProviders.Companion.toLiveData +import org.oppia.android.util.profile.toProfileIdPreservingZero import java.util.concurrent.TimeUnit import javax.inject.Inject import javax.inject.Singleton @@ -1001,7 +1002,7 @@ class StoryProgressTestHelper @Inject constructor( ) { primeClockForRecordingProgress() val resultProvider = storyProgressController.recordCompletedChapter( - profileId, + profileId.toProfileIdPreservingZero(), topicId, storyId, explorationId, @@ -1019,7 +1020,7 @@ class StoryProgressTestHelper @Inject constructor( ) { primeClockForRecordingProgress() val resultProvider = storyProgressController.recordChapterAsInProgressNotSaved( - profileId, + profileId.toProfileIdPreservingZero(), topicId, storyId, explorationId, @@ -1037,7 +1038,7 @@ class StoryProgressTestHelper @Inject constructor( ) { primeClockForRecordingProgress() val resultProvider = storyProgressController.recordChapterAsInProgressSaved( - profileId, + profileId.toProfileIdPreservingZero(), topicId, storyId, explorationId, diff --git a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt index 589b1a01d99..cacf7bf5abf 100644 --- a/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/lightweightcheckpointing/ExplorationCheckpointTestHelperTest.kt @@ -14,7 +14,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.ExplorationCheckpoint -import org.oppia.android.app.model.LegacyProfileId +import org.oppia.android.app.model.ProfileId import org.oppia.android.domain.classify.InteractionsModule import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule @@ -75,7 +75,7 @@ class ExplorationCheckpointTestHelperTest { @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var monitorFactory: DataProviderTestMonitor.Factory - private val profileId = LegacyProfileId.newBuilder().setInternalId(0).build() + private val profileId = ProfileId.newBuilder().setInternalId(0).build() @Before fun setUp() { @@ -211,7 +211,7 @@ class ExplorationCheckpointTestHelperTest { } private fun retrieveCheckpoint( - profileId: LegacyProfileId, + profileId: ProfileId, explorationId: String ): ExplorationCheckpoint { val retrieveCheckpointProvider =