Skip to content

Commit

Permalink
Initial changes to support classrooms.
Browse files Browse the repository at this point in the history
This doesn't actually finish the new data definitions or properly
integrate them, nor is it updating any local development assets.
  • Loading branch information
BenHenning committed May 17, 2024
1 parent 98257db commit fe68597
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 34 deletions.
4 changes: 2 additions & 2 deletions domain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ DOMAIN_ASSETS = generate_assets_list_from_text_protos(
"GJ2rLXRKD5hw",
"omzF4oqgeTXd",
],
topic_list_file_names = [
"topics",
classroom_list_file_names = [
"classrooms",
],
)

Expand Down
10 changes: 5 additions & 5 deletions domain/domain_assets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("//model:text_proto_assets.bzl", "generate_proto_binary_assets")

def generate_assets_list_from_text_protos(
name,
topic_list_file_names,
classroom_list_file_names,
topic_file_names,
subtopic_file_names,
story_file_names,
Expand All @@ -17,7 +17,7 @@ def generate_assets_list_from_text_protos(
Args:
name: str. The name of this generation instance. This will be a prefix for derived targets.
topic_list_file_names: list of str. The list of topic list file names.
classroom_list_file_names: list of str. The classroom list file names.
topic_file_names: list of str. The list of topic file names.
subtopic_file_names: list of str. The list of subtopic file names.
story_file_names: list of str. The list of story file names.
Expand All @@ -29,10 +29,10 @@ def generate_assets_list_from_text_protos(
"""
return generate_proto_binary_assets(
name = name,
names = topic_list_file_names,
names = classroom_list_file_names,
proto_dep_name = "topic",
proto_type_name = "TopicIdList",
name_prefix = "topic_id_list",
proto_type_name = "ClassroomList",
name_prefix = "classroom_list",
asset_dir = "src/main/assets",
proto_dep_bazel_target_prefix = "//model/src/main/proto",
proto_package = "model",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.json.JSONObject
import org.oppia.android.app.model.ChapterPlayState
import org.oppia.android.app.model.ChapterProgress
import org.oppia.android.app.model.ChapterSummary
import org.oppia.android.app.model.ClassroomList
import org.oppia.android.app.model.ComingSoonTopicList
import org.oppia.android.app.model.EphemeralTopicSummary
import org.oppia.android.app.model.LessonThumbnail
Expand All @@ -18,7 +19,6 @@ import org.oppia.android.app.model.StoryRecord
import org.oppia.android.app.model.StorySummary
import org.oppia.android.app.model.SubtitledHtml
import org.oppia.android.app.model.Topic
import org.oppia.android.app.model.TopicIdList
import org.oppia.android.app.model.TopicList
import org.oppia.android.app.model.TopicPlayAvailability
import org.oppia.android.app.model.TopicPlayAvailability.AvailabilityCase.AVAILABLE_TO_PLAY_IN_FUTURE
Expand All @@ -44,8 +44,6 @@ import javax.inject.Singleton
private const val ONE_WEEK_IN_DAYS = 7

private const val TOPIC_BG_COLOR = "#C6DCDA"
private const val BAKER_BG_COLOR = "#0F63A3"
private const val DUCK_BG_COLOR = "#05538F"

private const val CHAPTER_BG_COLOR_1 = "#F8BF74"
private const val CHAPTER_BG_COLOR_2 = "#D68F78"
Expand Down Expand Up @@ -135,16 +133,16 @@ class TopicListController @Inject constructor(

private fun createTopicList(contentLocale: OppiaLocale.ContentLocale): TopicList {
return if (loadLessonProtosFromAssets) {
val topicIdList =
val classroomList =
assetRepository.loadProtoFromLocalAssets(
assetName = "topics",
baseMessage = TopicIdList.getDefaultInstance()
assetName = "classrooms",
baseMessage = ClassroomList.getDefaultInstance()
)
return TopicList.newBuilder().apply {
// Only include topics currently playable in the topic list.
addAllTopicSummary(
topicIdList.topicIdsList.map {
createEphemeralTopicSummary(it, contentLocale)
classroomList.classroomsList.flatMap { classroom ->
classroom.topicIdsList.map { createEphemeralTopicSummary(it, contentLocale) }
}.filter {
it.topicSummary.topicPlayAvailability.availabilityCase == AVAILABLE_TO_PLAY_NOW
}
Expand Down Expand Up @@ -577,14 +575,12 @@ class TopicListController @Inject constructor(
contentLocale: OppiaLocale.ContentLocale
): List<PromotedStory> {
return if (loadLessonProtosFromAssets) {
val topicIdList =
val topicIdsList =
assetRepository.loadProtoFromLocalAssets(
assetName = "topics",
baseMessage = TopicIdList.getDefaultInstance()
)
return computeSuggestedStoriesForTopicIds(
topicProgressList, topicIdList.topicIdsList, contentLocale
)
assetName = "classrooms",
baseMessage = ClassroomList.getDefaultInstance()
).flatMap { it.topicIdsList }
return computeSuggestedStoriesForTopicIds(topicProgressList, topicIdsList, contentLocale)
} else computeSuggestedStoriesFromJson(topicProgressList, contentLocale)
}

Expand Down Expand Up @@ -877,7 +873,7 @@ internal fun createTopicThumbnail0(): LessonThumbnail {
internal fun createTopicThumbnail1(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.DUCK_AND_CHICKEN)
.setBackgroundColorRgb(Color.parseColor(DUCK_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(TOPIC_BG_COLOR))
.build()
}

Expand All @@ -891,7 +887,7 @@ internal fun createTopicThumbnail2(): LessonThumbnail {
internal fun createTopicThumbnail3(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.BAKER)
.setBackgroundColorRgb(Color.parseColor(BAKER_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(TOPIC_BG_COLOR))
.build()
}

Expand All @@ -905,7 +901,7 @@ internal fun createDefaultStoryThumbnail(): LessonThumbnail {
internal fun createStoryThumbnail0(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.DUCK_AND_CHICKEN)
.setBackgroundColorRgb(0x0F63A3)
.setBackgroundColorRgb(0xa5d3ec)
.build()
}

Expand All @@ -926,7 +922,7 @@ internal fun createStoryThumbnail2(): LessonThumbnail {
internal fun createStoryThumbnail3(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.BAKER)
.setBackgroundColorRgb(0x0F63A3)
.setBackgroundColorRgb(0xa5a2d3)
.build()
}

Expand All @@ -947,7 +943,7 @@ internal fun createChapterThumbnail0(): LessonThumbnail {
internal fun createChapterThumbnail1(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.DUCK_AND_CHICKEN)
.setBackgroundColorRgb(Color.parseColor(DUCK_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(CHAPTER_BG_COLOR_2))
.build()
}

Expand All @@ -968,21 +964,21 @@ internal fun createChapterThumbnail3(): LessonThumbnail {
internal fun createChapterThumbnail4(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.BAKER)
.setBackgroundColorRgb(Color.parseColor(BAKER_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(CHAPTER_BG_COLOR_1))
.build()
}

internal fun createChapterThumbnail5(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.DUCK_AND_CHICKEN)
.setBackgroundColorRgb(Color.parseColor(DUCK_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(CHAPTER_BG_COLOR_2))
.build()
}

internal fun createChapterThumbnail8(): LessonThumbnail {
return LessonThumbnail.newBuilder()
.setThumbnailGraphic(LessonThumbnailGraphic.DUCK_AND_CHICKEN)
.setBackgroundColorRgb(Color.parseColor(DUCK_BG_COLOR))
.setBackgroundColorRgb(Color.parseColor(CHAPTER_BG_COLOR_1))
.build()
}

Expand Down
36 changes: 32 additions & 4 deletions model/src/main/proto/topic.proto
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,38 @@ message EphemeralRevisionCard {
WrittenTranslationContext written_translation_context = 2;
}

// Corresponds to a local file cataloging all topics available to load.
message TopicIdList {
// The list of IDs corresponding to topics available on the local filesystem.
repeated string topic_ids = 1;
// Corresponds to a local file cataloging all available classrooms in the app.
message ClassroomList {
// The list of classrooms available to the app.
repeated ClassroomRecord classrooms = 1;
}

// Corresponds to a loadable classroom.
message ClassroomRecord {
// The classroom's ID.
string id = 1;

// Mapping from content_id to a TranslationMapping for each SubtitledHtml in this classroom that
// has a corresponding translation.
map<string, TranslationMapping> written_translations = 2;

// The title of the classroom.
SubtitledHtml translatable_title = 3;

// The thumbnail corresponding to this classroom.
LessonThumbnail classroom_thumbnail = 4;

// A map from topic ID to a TopicIdList indicating the prerequisite topics to suggest to the user
// before they play the topic given by the key. Note that the keys of this map indicate the
// complete list of topics contained within this classroom. The prerequisite list of topics may
// include topics outside of this classroom.
map<string, TopicIdList> topic_prerequisites = 5;

// Represents a list of topic IDs (to be used in the context of topic deps in a classroom).
message TopicIdList {
// A list of topics IDs.
repeated string topic_ids = 1;
}
}

// Corresponds to a local file cataloging all concept cards available to load.
Expand Down

0 comments on commit fe68597

Please sign in to comment.