mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 07:04:35 +00:00
Add year-4 civics lessons on the economy, the world and philosophy.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
0ee2f8e960
commit
50a23c334b
27 changed files with 2317 additions and 32 deletions
|
|
@ -141,6 +141,11 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
|
|||
refresh()
|
||||
}
|
||||
|
||||
fun markOn4(id: Int) {
|
||||
progress.markOn4(id)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun markMluv(n: Int) {
|
||||
progress.markMluv(n)
|
||||
refresh()
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.maturita.maturita.ui.NetQuizScreen
|
|||
import org.maturita.maturita.ui.NetYearsScreen
|
||||
import org.maturita.maturita.ui.On2QuizScreen
|
||||
import org.maturita.maturita.ui.On3QuizScreen
|
||||
import org.maturita.maturita.ui.On4QuizScreen
|
||||
import org.maturita.maturita.ui.OnQuizScreen
|
||||
import org.maturita.maturita.ui.OnYearsScreen
|
||||
import org.maturita.maturita.ui.PlotScreen
|
||||
|
|
@ -273,6 +274,20 @@ private fun MaturitaAppBody(vm: AppViewModel) {
|
|||
}
|
||||
}
|
||||
is Route.On3Ex -> On3QuizScreen(vm, r.id)
|
||||
Route.On4Map -> LessonListScreen(
|
||||
vm, vm.tr("on_year4"), vm.tr("on4_sub"),
|
||||
vm.content.on4.map { l ->
|
||||
val id = l.int("id")
|
||||
LessonRow(vm.tr(l.str("titleKey")), vm.progress.on4Done(id), Route.On4Lesson(id))
|
||||
},
|
||||
)
|
||||
is Route.On4Lesson -> {
|
||||
val l = vm.content.on4Lesson(r.id)
|
||||
if (l != null) SlidesScreen(vm, vm.tr(l.str("titleKey")), vm.tr(l.str("subKey")), l.arr("slides")) {
|
||||
vm.replace(Route.On4Ex(r.id))
|
||||
}
|
||||
}
|
||||
is Route.On4Ex -> On4QuizScreen(vm, r.id)
|
||||
Route.CzechMap -> CzechMapScreen(vm)
|
||||
Route.Mluvnice -> LessonListScreen(
|
||||
vm, vm.tr("Mluvnice"), vm.tr("mluv_sub"),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ sealed class Route(val page: String) {
|
|||
data object On3Map : Route("on3map")
|
||||
data class On3Lesson(val id: Int) : Route("on3unit$id")
|
||||
data class On3Ex(val id: Int) : Route("on3ex$id")
|
||||
data object On4Map : Route("on4map")
|
||||
data class On4Lesson(val id: Int) : Route("on4unit$id")
|
||||
data class On4Ex(val id: Int) : Route("on4ex$id")
|
||||
data object CzechMap : Route("czechmap")
|
||||
data object Mluvnice : Route("mluvnice")
|
||||
data class MluvEx(val n: Int) : Route("mluve$n")
|
||||
|
|
@ -41,8 +44,8 @@ sealed class Route(val page: String) {
|
|||
/** Screens with their own bottom action bar; the navigation bar stays hidden there. */
|
||||
val isExercise: Boolean
|
||||
get() = this is GermanEx || this is Vocab || this is NetEx || this is HwEx ||
|
||||
this is OnEx || this is On2Ex || this is On3Ex || this is MluvEx || this is BookQuiz || this is BookPlot ||
|
||||
this is NetLesson || this is HwLesson || this is OnLesson || this is On2Lesson || this is On3Lesson
|
||||
this is OnEx || this is On2Ex || this is On3Ex || this is On4Ex || this is MluvEx || this is BookQuiz || this is BookPlot ||
|
||||
this is NetLesson || this is HwLesson || this is OnLesson || this is On2Lesson || this is On3Lesson || this is On4Lesson
|
||||
|
||||
/** Full stack from the practice root to this screen, so back always goes up one level. */
|
||||
fun stack(): List<Route> = when (this) {
|
||||
|
|
@ -71,6 +74,9 @@ sealed class Route(val page: String) {
|
|||
On3Map -> listOf(Subjects, OnYears, On3Map)
|
||||
is On3Lesson -> listOf(Subjects, OnYears, On3Map, this)
|
||||
is On3Ex -> listOf(Subjects, OnYears, On3Map, On3Lesson(id), this)
|
||||
On4Map -> listOf(Subjects, OnYears, On4Map)
|
||||
is On4Lesson -> listOf(Subjects, OnYears, On4Map, this)
|
||||
is On4Ex -> listOf(Subjects, OnYears, On4Map, On4Lesson(id), this)
|
||||
CzechMap -> listOf(Subjects, CzechMap)
|
||||
Mluvnice -> listOf(Subjects, CzechMap, Mluvnice)
|
||||
is MluvEx -> listOf(Subjects, CzechMap, Mluvnice, this)
|
||||
|
|
@ -95,6 +101,7 @@ fun routeFromPage(page: String): Route? = when (page) {
|
|||
"onmap" -> Route.OnMap
|
||||
"on2map" -> Route.On2Map
|
||||
"on3map" -> Route.On3Map
|
||||
"on4map" -> Route.On4Map
|
||||
"czechmap" -> Route.CzechMap
|
||||
"mluvnice" -> Route.Mluvnice
|
||||
"readinglist" -> Route.ReadingList
|
||||
|
|
@ -126,6 +133,12 @@ fun routeFromPage(page: String): Route? = when (page) {
|
|||
Regex("""hwex(\d+)""").matchEntire(page)?.let {
|
||||
return Route.HwEx(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on4unit(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On4Lesson(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on4ex(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On4Ex(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on3unit(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On3Lesson(it.groupValues[1].toInt())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class Content(root: JSONObject) {
|
|||
val on = raw.arr("on")
|
||||
val on2 = raw.arr("on2")
|
||||
val on3 = raw.arr("on3")
|
||||
val on4 = raw.arr("on4")
|
||||
val mluvnice = raw.arr("mluvnice")
|
||||
val books = raw.arr("books")
|
||||
val changelog = raw.arr("changelog")
|
||||
|
|
@ -42,6 +43,7 @@ class Content(root: JSONObject) {
|
|||
fun onLesson(id: Int) = on.firstOrNull { it.int("id") == id }
|
||||
fun on2Lesson(id: Int) = on2.firstOrNull { it.int("id") == id }
|
||||
fun on3Lesson(id: Int) = on3.firstOrNull { it.int("id") == id }
|
||||
fun on4Lesson(id: Int) = on4.firstOrNull { it.int("id") == id }
|
||||
fun mluv(n: Int) = mluvnice.firstOrNull { it.int("id") == n }
|
||||
fun book(id: String) = books.firstOrNull { it.str("id") == id }
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ class ProgressStore(context: Context) {
|
|||
fun on3Done(id: Int) = prefs.getBoolean("on3.$id", false)
|
||||
fun markOn3(id: Int) { prefs.edit().putBoolean("on3.$id", true).apply() }
|
||||
|
||||
fun on4Done(id: Int) = prefs.getBoolean("on4.$id", false)
|
||||
fun markOn4(id: Int) { prefs.edit().putBoolean("on4.$id", true).apply() }
|
||||
|
||||
fun mluvDone(n: Int) = prefs.getBoolean("mluv.$n", false)
|
||||
fun markMluv(n: Int) { prefs.edit().putBoolean("mluv.$n", true).apply() }
|
||||
|
||||
|
|
@ -103,6 +106,14 @@ fun summarize(content: Content, p: ProgressStore): ProgressSum {
|
|||
sum.doneUnits += 1
|
||||
}
|
||||
}
|
||||
content.on4.forEach { l ->
|
||||
sum.totalEx += 1
|
||||
sum.openUnits += 1
|
||||
if (p.on4Done(l.int("id"))) {
|
||||
sum.doneEx += 1
|
||||
sum.doneUnits += 1
|
||||
}
|
||||
}
|
||||
sum.totalEx += content.mluvnice.size
|
||||
sum.openUnits += 1
|
||||
val md = content.mluvnice.count { p.mluvDone(it.int("id")) }
|
||||
|
|
|
|||
|
|
@ -884,6 +884,18 @@ fun On3QuizScreen(vm: AppViewModel, id: Int) {
|
|||
DispatchExercise(vm, spec, vm.tr(lesson.str("exTitleKey"))) { vm.markOn3(id) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun On4QuizScreen(vm: AppViewModel, id: Int) {
|
||||
val lesson = vm.content.on4Lesson(id) ?: return
|
||||
val spec = J(org.json.JSONObject().apply {
|
||||
put("type", "choice")
|
||||
put("title", vm.tr(lesson.str("exTitleKey")))
|
||||
put("sub", lesson.str("quizHeadKey"))
|
||||
put("questions", lesson.o.optJSONArray("quiz"))
|
||||
})
|
||||
DispatchExercise(vm, spec, vm.tr(lesson.str("exTitleKey"))) { vm.markOn4(id) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HwQuizScreen(vm: AppViewModel, id: Int) {
|
||||
val lesson = vm.content.hwLesson(id) ?: return
|
||||
|
|
|
|||
|
|
@ -300,11 +300,12 @@ private fun subjectSum(vm: AppViewModel, s: J): ProgressSum {
|
|||
sum.totalEx = vm.content.hw.size
|
||||
sum.doneEx = vm.content.hw.count { vm.progress.hwDone(it.int("id")) }
|
||||
}
|
||||
"onyears", "onmap", "on2map", "on3map" -> {
|
||||
sum.totalEx = vm.content.on.size + vm.content.on2.size + vm.content.on3.size
|
||||
"onyears", "onmap", "on2map", "on3map", "on4map" -> {
|
||||
sum.totalEx = vm.content.on.size + vm.content.on2.size + vm.content.on3.size + vm.content.on4.size
|
||||
sum.doneEx = vm.content.on.count { vm.progress.onDone(it.int("id")) } +
|
||||
vm.content.on2.count { vm.progress.on2Done(it.int("id")) } +
|
||||
vm.content.on3.count { vm.progress.on3Done(it.int("id")) }
|
||||
vm.content.on3.count { vm.progress.on3Done(it.int("id")) } +
|
||||
vm.content.on4.count { vm.progress.on4Done(it.int("id")) }
|
||||
}
|
||||
"czechmap" -> {
|
||||
sum.totalEx = vm.content.mluvnice.size
|
||||
|
|
@ -496,7 +497,7 @@ private fun buildSearch(vm: AppViewModel): List<Hit> {
|
|||
add(vm.tr("on_year1"), vm.tr("search_lesson"), "onmap", extra = "rocnik")
|
||||
add(vm.tr("on_year2"), vm.tr("search_lesson"), "on2map", extra = "rocnik")
|
||||
add(vm.tr("on_year3"), vm.tr("search_lesson"), "on3map", extra = "rocnik")
|
||||
add(vm.tr("on_year4"), vm.tr("search_lesson"), "onyears", locked = true, extra = "rocnik")
|
||||
add(vm.tr("on_year4"), vm.tr("search_lesson"), "on4map", extra = "rocnik")
|
||||
vm.content.on.forEach { l ->
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_lesson"), "onunit${l.int("id")}", extra = "obcanka")
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_exercise"), "onex${l.int("id")}")
|
||||
|
|
@ -509,6 +510,10 @@ private fun buildSearch(vm: AppViewModel): List<Hit> {
|
|||
add(vm.tr(l.str("titleKey")), vm.tr("search_lesson"), "on3unit${l.int("id")}", extra = "obcanka")
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_exercise"), "on3ex${l.int("id")}")
|
||||
}
|
||||
vm.content.on4.forEach { l ->
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_lesson"), "on4unit${l.int("id")}", extra = "obcanka")
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_exercise"), "on4ex${l.int("id")}")
|
||||
}
|
||||
add(vm.tr("Mluvnice"), vm.tr("search_lesson"), "mluvnice")
|
||||
vm.content.mluvnice.forEach { m -> add(m.str("name"), vm.tr("Mluvnice"), "mluve${m.int("id")}") }
|
||||
add(vm.tr("Maturitní četba"), vm.tr("search_book"), "readinglist")
|
||||
|
|
@ -615,9 +620,7 @@ fun OnYearsScreen(vm: AppViewModel) {
|
|||
NavRow(title = vm.tr("on_year1"), subtitle = vm.tr("on_sub"), leading = { Text("1.", style = MaterialTheme.typography.titleMedium) }) { vm.go(Route.OnMap) }
|
||||
NavRow(title = vm.tr("on_year2"), subtitle = vm.tr("on2_sub"), leading = { Text("2.", style = MaterialTheme.typography.titleMedium) }) { vm.go(Route.On2Map) }
|
||||
NavRow(title = vm.tr("on_year3"), subtitle = vm.tr("on3_sub"), leading = { Text("3.", style = MaterialTheme.typography.titleMedium) }) { vm.go(Route.On3Map) }
|
||||
}
|
||||
items(listOf("on_year4")) { key ->
|
||||
NavRow(title = vm.tr(key), subtitle = vm.tr("on_year_locked_sub"), locked = true, onClick = null)
|
||||
NavRow(title = vm.tr("on_year4"), subtitle = vm.tr("on4_sub"), leading = { Text("4.", style = MaterialTheme.typography.titleMedium) }) { vm.go(Route.On4Map) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue