Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #5344: Introduce & modify controllers to support multiple classrooms #5419

Merged
merged 89 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
f6b1f60
Add ClassroomIdList & ClassroomSummary protos
theMr17 May 30, 2024
fdcf183
Add classroom_id & classroom_title fields
theMr17 May 30, 2024
a66a5ac
Add json & textproto test data
theMr17 May 30, 2024
b292594
Update controllers to add classroom references in topics and stories
theMr17 May 30, 2024
d68d1b5
Add and update tests for controller changes
theMr17 May 30, 2024
69352df
Remove ClassroomList model
theMr17 May 30, 2024
700a001
Fix ktlint issues
theMr17 May 30, 2024
9063bcd
Fix textproto syntax issue
theMr17 May 30, 2024
8ce636d
Fix textproto syntax issue
theMr17 May 30, 2024
dbe9842
TopicListController is updated to load all topics irrespective of the…
theMr17 May 31, 2024
238d96c
Fix failing tests of TopicControllerTest
theMr17 May 31, 2024
d5a8bc8
Update test_classroom_id_0.textproto
theMr17 May 31, 2024
db67666
Update test_classroom_id_1.textproto
theMr17 May 31, 2024
405f160
Update test_classroom_id_2.textproto
theMr17 May 31, 2024
ff3444f
Add classroom file names in domain assets list
theMr17 May 31, 2024
4c5f322
Update domain_assets.bzl
theMr17 May 31, 2024
2a26a2b
Remove classroom thumbnail data from test_classroom_id_0
theMr17 May 31, 2024
c22fead
Remove classroom thumbnail data from test_classroom_id_1
theMr17 May 31, 2024
6cb9146
Remove classroom thumbnail data from test_classroom_id_2
theMr17 May 31, 2024
b214206
Fix bazel lint issue
theMr17 May 31, 2024
884a675
Introduce topic_ids field for classrooms
theMr17 May 31, 2024
9fbfda3
Fix textproto formatting issue
theMr17 May 31, 2024
0ee6828
Introduce ClassroomController to surface getClassroomList function
theMr17 Jun 1, 2024
1954d60
Add tests for getClassroomList function
theMr17 Jun 1, 2024
0d39117
Fix ktlint issues
theMr17 Jun 1, 2024
4e0335f
Add kdoc for getClassroomList function
theMr17 Jun 1, 2024
a31850f
Add getTopicList to ClassroomController
theMr17 Jun 1, 2024
ae1b072
Add tests for getTopicList function
theMr17 Jun 1, 2024
ea5e65e
Fix tests
theMr17 Jun 1, 2024
714f57d
Fix ktlint issues
theMr17 Jun 1, 2024
e90f4d2
Fix tests
theMr17 Jun 1, 2024
637b704
Move test classroom id constants to ClassroomController
theMr17 Jun 1, 2024
008a233
Add missing import
theMr17 Jun 1, 2024
e3dbfde
Gate the createTopicList function
theMr17 Jun 1, 2024
9bec9d6
Fix tests
theMr17 Jun 2, 2024
4ceece2
Add kdoc for test classroom id constants
theMr17 Jun 2, 2024
a89b8a7
Update ProfileManagementController to store last selected classroom I…
theMr17 Jun 2, 2024
49ae0a4
Temporarily hard code default classroom ID in ProfileManagementContro…
theMr17 Jun 2, 2024
e957499
Return nullable classroom ID from ProfileManagementController
theMr17 Jun 2, 2024
6584fe7
Update checkProfile test
theMr17 Jun 2, 2024
48921d5
Remove getTopicList function from TopicListController
theMr17 Jun 2, 2024
52c5b13
Remove unused imports from TopicListController
theMr17 Jun 2, 2024
74e4edf
Revert "Remove unused imports from TopicListController"
theMr17 Jun 3, 2024
baea849
Revert "Remove getTopicList function from TopicListController"
theMr17 Jun 3, 2024
cb96baf
Revert "Gate the createTopicList function"
theMr17 Jun 3, 2024
2c894e8
Remove translationLocaleProvider from getClassroomList
theMr17 Jun 3, 2024
e1c9254
Add EphemeralClassroomSummary & ClassroomList objects
theMr17 Jun 5, 2024
1b3b02e
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 5, 2024
a226a72
Replace List<ClassroomSummary> with ClassroomList
theMr17 Jun 5, 2024
c82994e
Remove classroom info from CompletedStory
theMr17 Jun 6, 2024
2649461
Fix error message
theMr17 Jun 6, 2024
857d296
Update comments
theMr17 Jun 6, 2024
693bfe8
Revert "Introduce topic_ids field for classrooms"
theMr17 Jun 6, 2024
a0bf50c
Add test thumbnails
theMr17 Jun 7, 2024
c9ae332
Refactor topicIdsList to use keys of topicPrerequisitesMay
theMr17 Jun 7, 2024
5f1fa81
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 7, 2024
81a89a3
Fix kdoc checks
theMr17 Jun 7, 2024
d438cb5
Pass classroomId to createTopicList directly
theMr17 Jun 8, 2024
4de2222
Update kdoc comments
theMr17 Jun 12, 2024
223f217
Update variable name
theMr17 Jun 12, 2024
e6bd04b
Update kdoc and return default instances
theMr17 Jun 12, 2024
4b3d596
Merge branch 'develop' into multiple-classrooms-model-support
theMr17 Jun 12, 2024
2baca12
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 12, 2024
73fb79e
Remove extra new line
theMr17 Jun 13, 2024
2432150
Move classroom titles to ephemeral objects and pass the class written…
theMr17 Jun 14, 2024
d2a454d
Remove classroom title from topic data files
theMr17 Jun 14, 2024
ac24de1
Fix regex validation checks
theMr17 Jun 14, 2024
6cf8ae4
Handle empty classroom id when the proto asset is overridden for tests
theMr17 Jun 15, 2024
3d91ac2
Remove classroom ID from topic data files
theMr17 Jun 20, 2024
8296e2e
Remove unused import & variable
theMr17 Jun 20, 2024
8c5a77b
Fetch classroom ID from topic ID
theMr17 Jun 20, 2024
37dc6a3
Update left out classroom ID fetching
theMr17 Jun 20, 2024
8d5f678
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 20, 2024
b149154
Update ClassroomController per latest changes in model layer
theMr17 Jun 20, 2024
b694868
Fix ktlint check
theMr17 Jun 20, 2024
9a328e5
Merge branch 'develop' into multiple-classrooms-model-support
theMr17 Jun 20, 2024
0994300
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 20, 2024
8b902eb
Remove empty classroom from the list
theMr17 Jun 23, 2024
74c29af
Merge branch 'develop' into multiple-classrooms-model-support
theMr17 Jun 23, 2024
ff884f1
Merge remote-tracking branch 'upstream/multiple-classrooms-model-supp…
theMr17 Jun 23, 2024
2e3d2f0
Merge branch 'develop' into multiple-classrooms-domain-support
theMr17 Jun 24, 2024
3f02092
Fix classroom filtering logic for textproto
theMr17 Jun 24, 2024
0f4e98b
Simplify isNotNullOrEmpty check
theMr17 Jun 26, 2024
f0134fb
Rename to createClassroomSummaryFromJson function
theMr17 Jun 26, 2024
24eed39
Split createClassroomList function
theMr17 Jun 26, 2024
2dc399b
Add test for updating classroomId twice
theMr17 Jun 26, 2024
273caf2
Remove fetching of TopicSummary from getTopicIdListFromClassroomRecord
theMr17 Jun 26, 2024
afd7251
Revert "Add test for updating classroomId twice"
theMr17 Jun 26, 2024
b4d6bd5
Add test for updating classroomId twice
theMr17 Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ private const val SET_SURVEY_LAST_SHOWN_TIMESTAMP_PROVIDER_ID =
"record_survey_last_shown_timestamp_provider_id"
private const val RETRIEVE_SURVEY_LAST_SHOWN_TIMESTAMP_PROVIDER_ID =
"retrieve_survey_last_shown_timestamp_provider_id"
private const val SET_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID =
"set_last_selected_classroom_id_provider_id"
private const val RETRIEVE_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID =
"retrieve_last_selected_classroom_id_provider_id"

/** Controller for retrieving, adding, updating, and deleting profiles. */
@Singleton
Expand Down Expand Up @@ -851,6 +855,47 @@ class ProfileManagementController @Inject constructor(
}
}

/**
* Sets the last selected [classroomId] for the specified [profileId]. Returns a [DataProvider]
* indicating whether the save was a success.
*/
fun updateLastSelectedClassroomId(
profileId: ProfileId,
classroomId: String
): DataProvider<Any?> {
val deferred = profileDataStore.storeDataWithCustomChannelAsync(
updateInMemoryCache = true
) { profileDatabase ->
val profile = profileDatabase.profilesMap[profileId.internalId]
val updatedProfile = profile?.toBuilder()?.setLastSelectedClassroomId(
classroomId
)?.build()
val profileDatabaseBuilder = profileDatabase.toBuilder().putProfiles(
profileId.internalId,
updatedProfile
)
Pair(profileDatabaseBuilder.build(), ProfileActionStatus.SUCCESS)
}
return dataProviders.createInMemoryDataProviderAsync(
SET_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID
) {
return@createInMemoryDataProviderAsync getDeferredResult(profileId, null, deferred)
}
}

/**
* Returns a [DataProvider] containing a nullable last selected classroom ID for the specified
* [profileId].
*/
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
fun retrieveLastSelectedClassroomId(
profileId: ProfileId
): DataProvider<String?> {
return profileDataStore.transformAsync(RETRIEVE_LAST_SELECTED_CLASSROOM_ID_PROVIDER_ID) {
val lastSelectedClassroomId = it.profilesMap[profileId.internalId]?.lastSelectedClassroomId
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
AsyncResult.Success(lastSelectedClassroomId)
}
}

private suspend fun getDeferredResult(
profileId: ProfileId?,
name: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.oppia.android.app.model.TopicProgress
import org.oppia.android.app.model.TopicRecord
import org.oppia.android.app.model.TopicSummary
import org.oppia.android.app.model.UpcomingTopic
import org.oppia.android.domain.classroom.TEST_CLASSROOM_ID_0
import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.domain.util.JsonAssetRetriever
import org.oppia.android.domain.util.getStringFromObject
Expand Down Expand Up @@ -60,11 +61,6 @@ const val SUBTOPIC_TOPIC_ID = 1
const val SUBTOPIC_TOPIC_ID_2 = 2
const val RATIOS_TOPIC_ID = "omzF4oqgeTXd"

// TODO(#5344): Move these classroom ids to [ClassroomController].
const val TEST_CLASSROOM_ID_0 = "test_classroom_id_0"
const val TEST_CLASSROOM_ID_1 = "test_classroom_id_1"
const val TEST_CLASSROOM_ID_2 = "test_classroom_id_2"

val TOPIC_THUMBNAILS = mapOf(
FRACTIONS_TOPIC_ID to createTopicThumbnail0(),
RATIOS_TOPIC_ID to createTopicThumbnail1(),
Expand Down
Loading
Loading