Add year-2 civics lessons on the citizen in a democratic state.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pepaskopec-blip 2026-10-02 22:38:06 +02:00
commit d453c54e52
25 changed files with 2323 additions and 23 deletions

View file

@ -131,6 +131,11 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
refresh()
}
fun markOn2(id: Int) {
progress.markOn2(id)
refresh()
}
fun markMluv(n: Int) {
progress.markMluv(n)
refresh()

View file

@ -37,6 +37,7 @@ import org.maturita.maturita.ui.LitQuizScreen
import org.maturita.maturita.ui.MluvExercise
import org.maturita.maturita.ui.NetQuizScreen
import org.maturita.maturita.ui.NetYearsScreen
import org.maturita.maturita.ui.On2QuizScreen
import org.maturita.maturita.ui.OnQuizScreen
import org.maturita.maturita.ui.OnYearsScreen
import org.maturita.maturita.ui.PlotScreen
@ -243,6 +244,20 @@ private fun MaturitaAppBody(vm: AppViewModel) {
}
}
is Route.OnEx -> OnQuizScreen(vm, r.id)
Route.On2Map -> LessonListScreen(
vm, vm.tr("on_year2"), vm.tr("on2_sub"),
vm.content.on2.map { l ->
val id = l.int("id")
LessonRow(vm.tr(l.str("titleKey")), vm.progress.on2Done(id), Route.On2Lesson(id))
},
)
is Route.On2Lesson -> {
val l = vm.content.on2Lesson(r.id)
if (l != null) SlidesScreen(vm, vm.tr(l.str("titleKey")), vm.tr(l.str("subKey")), l.arr("slides")) {
vm.replace(Route.On2Ex(r.id))
}
}
is Route.On2Ex -> On2QuizScreen(vm, r.id)
Route.CzechMap -> CzechMapScreen(vm)
Route.Mluvnice -> LessonListScreen(
vm, vm.tr("Mluvnice"), vm.tr("mluv_sub"),

View file

@ -21,6 +21,9 @@ sealed class Route(val page: String) {
data object OnMap : Route("onmap")
data class OnLesson(val id: Int) : Route("onunit$id")
data class OnEx(val id: Int) : Route("onex$id")
data object On2Map : Route("on2map")
data class On2Lesson(val id: Int) : Route("on2unit$id")
data class On2Ex(val id: Int) : Route("on2ex$id")
data object CzechMap : Route("czechmap")
data object Mluvnice : Route("mluvnice")
data class MluvEx(val n: Int) : Route("mluve$n")
@ -35,8 +38,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 MluvEx || this is BookQuiz || this is BookPlot ||
this is NetLesson || this is HwLesson || this is OnLesson
this is OnEx || this is On2Ex || this is MluvEx || this is BookQuiz || this is BookPlot ||
this is NetLesson || this is HwLesson || this is OnLesson || this is On2Lesson
/** Full stack from the practice root to this screen, so back always goes up one level. */
fun stack(): List<Route> = when (this) {
@ -59,6 +62,9 @@ sealed class Route(val page: String) {
OnMap -> listOf(Subjects, OnYears, OnMap)
is OnLesson -> listOf(Subjects, OnYears, OnMap, this)
is OnEx -> listOf(Subjects, OnYears, OnMap, OnLesson(id), this)
On2Map -> listOf(Subjects, OnYears, On2Map)
is On2Lesson -> listOf(Subjects, OnYears, On2Map, this)
is On2Ex -> listOf(Subjects, OnYears, On2Map, On2Lesson(id), this)
CzechMap -> listOf(Subjects, CzechMap)
Mluvnice -> listOf(Subjects, CzechMap, Mluvnice)
is MluvEx -> listOf(Subjects, CzechMap, Mluvnice, this)
@ -81,6 +87,7 @@ fun routeFromPage(page: String): Route? = when (page) {
"hwmap" -> Route.HwMap
"onyears" -> Route.OnYears
"onmap" -> Route.OnMap
"on2map" -> Route.On2Map
"czechmap" -> Route.CzechMap
"mluvnice" -> Route.Mluvnice
"readinglist" -> Route.ReadingList
@ -112,6 +119,12 @@ fun routeFromPage(page: String): Route? = when (page) {
Regex("""hwex(\d+)""").matchEntire(page)?.let {
return Route.HwEx(it.groupValues[1].toInt())
}
Regex("""on2unit(\d+)""").matchEntire(page)?.let {
return Route.On2Lesson(it.groupValues[1].toInt())
}
Regex("""on2ex(\d+)""").matchEntire(page)?.let {
return Route.On2Ex(it.groupValues[1].toInt())
}
Regex("""onunit(\d+)""").matchEntire(page)?.let {
return Route.OnLesson(it.groupValues[1].toInt())
}

View file

@ -30,6 +30,7 @@ class Content(root: JSONObject) {
}
val hw = raw.arr("hw")
val on = raw.arr("on")
val on2 = raw.arr("on2")
val mluvnice = raw.arr("mluvnice")
val books = raw.arr("books")
val changelog = raw.arr("changelog")
@ -38,6 +39,7 @@ class Content(root: JSONObject) {
fun netLesson(id: Int) = netLessons.firstOrNull { it.int("id") == id }
fun hwLesson(id: Int) = hw.firstOrNull { it.int("id") == id }
fun onLesson(id: Int) = on.firstOrNull { it.int("id") == id }
fun on2Lesson(id: Int) = on2.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 }

View file

@ -35,6 +35,9 @@ class ProgressStore(context: Context) {
fun onDone(id: Int) = prefs.getBoolean("on.$id", false)
fun markOn(id: Int) { prefs.edit().putBoolean("on.$id", true).apply() }
fun on2Done(id: Int) = prefs.getBoolean("on2.$id", false)
fun markOn2(id: Int) { prefs.edit().putBoolean("on2.$id", true).apply() }
fun mluvDone(n: Int) = prefs.getBoolean("mluv.$n", false)
fun markMluv(n: Int) { prefs.edit().putBoolean("mluv.$n", true).apply() }
@ -81,6 +84,14 @@ fun summarize(content: Content, p: ProgressStore): ProgressSum {
sum.doneUnits += 1
}
}
content.on2.forEach { l ->
sum.totalEx += 1
sum.openUnits += 1
if (p.on2Done(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")) }

View file

@ -860,6 +860,18 @@ fun OnQuizScreen(vm: AppViewModel, id: Int) {
DispatchExercise(vm, spec, vm.tr(lesson.str("exTitleKey"))) { vm.markOn(id) }
}
@Composable
fun On2QuizScreen(vm: AppViewModel, id: Int) {
val lesson = vm.content.on2Lesson(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.markOn2(id) }
}
@Composable
fun HwQuizScreen(vm: AppViewModel, id: Int) {
val lesson = vm.content.hwLesson(id) ?: return

View file

@ -300,9 +300,10 @@ 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" -> {
sum.totalEx = vm.content.on.size
sum.doneEx = vm.content.on.count { vm.progress.onDone(it.int("id")) }
"onyears", "onmap", "on2map" -> {
sum.totalEx = vm.content.on.size + vm.content.on2.size
sum.doneEx = vm.content.on.count { vm.progress.onDone(it.int("id")) } +
vm.content.on2.count { vm.progress.on2Done(it.int("id")) }
}
"czechmap" -> {
sum.totalEx = vm.content.mluvnice.size
@ -492,13 +493,17 @@ private fun buildSearch(vm: AppViewModel): List<Hit> {
add(vm.tr(l.str("titleKey")), vm.tr("search_exercise"), "hwex${l.int("id")}")
}
add(vm.tr("on_year1"), vm.tr("search_lesson"), "onmap", extra = "rocnik")
add(vm.tr("on_year2"), vm.tr("search_lesson"), "onyears", locked = true, extra = "rocnik")
add(vm.tr("on_year2"), vm.tr("search_lesson"), "on2map", extra = "rocnik")
add(vm.tr("on_year3"), vm.tr("search_lesson"), "onyears", locked = true, extra = "rocnik")
add(vm.tr("on_year4"), vm.tr("search_lesson"), "onyears", locked = true, 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")}")
}
vm.content.on2.forEach { l ->
add(vm.tr(l.str("titleKey")), vm.tr("search_lesson"), "on2unit${l.int("id")}", extra = "obcanka")
add(vm.tr(l.str("titleKey")), vm.tr("search_exercise"), "on2ex${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")
@ -603,8 +608,9 @@ fun OnYearsScreen(vm: AppViewModel) {
LazyColumn(contentPadding = PaddingValues(top = inner.calculateTopPadding(), bottom = inner.calculateBottomPadding() + 16.dp)) {
item {
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) }
}
items(listOf("on_year2", "on_year3", "on_year4")) { key ->
items(listOf("on_year3", "on_year4")) { key ->
NavRow(title = vm.tr(key), subtitle = vm.tr("on_year_locked_sub"), locked = true, onClick = null)
}
}