mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 07:04:35 +00:00
Add year-3 civics lessons on the individual and the law.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d453c54e52
commit
0ee2f8e960
26 changed files with 2321 additions and 23 deletions
|
|
@ -136,6 +136,11 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
|
|||
refresh()
|
||||
}
|
||||
|
||||
fun markOn3(id: Int) {
|
||||
progress.markOn3(id)
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun markMluv(n: Int) {
|
||||
progress.markMluv(n)
|
||||
refresh()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ 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.On3QuizScreen
|
||||
import org.maturita.maturita.ui.OnQuizScreen
|
||||
import org.maturita.maturita.ui.OnYearsScreen
|
||||
import org.maturita.maturita.ui.PlotScreen
|
||||
|
|
@ -258,6 +259,20 @@ private fun MaturitaAppBody(vm: AppViewModel) {
|
|||
}
|
||||
}
|
||||
is Route.On2Ex -> On2QuizScreen(vm, r.id)
|
||||
Route.On3Map -> LessonListScreen(
|
||||
vm, vm.tr("on_year3"), vm.tr("on3_sub"),
|
||||
vm.content.on3.map { l ->
|
||||
val id = l.int("id")
|
||||
LessonRow(vm.tr(l.str("titleKey")), vm.progress.on3Done(id), Route.On3Lesson(id))
|
||||
},
|
||||
)
|
||||
is Route.On3Lesson -> {
|
||||
val l = vm.content.on3Lesson(r.id)
|
||||
if (l != null) SlidesScreen(vm, vm.tr(l.str("titleKey")), vm.tr(l.str("subKey")), l.arr("slides")) {
|
||||
vm.replace(Route.On3Ex(r.id))
|
||||
}
|
||||
}
|
||||
is Route.On3Ex -> On3QuizScreen(vm, r.id)
|
||||
Route.CzechMap -> CzechMapScreen(vm)
|
||||
Route.Mluvnice -> LessonListScreen(
|
||||
vm, vm.tr("Mluvnice"), vm.tr("mluv_sub"),
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ sealed class Route(val page: String) {
|
|||
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 On3Map : Route("on3map")
|
||||
data class On3Lesson(val id: Int) : Route("on3unit$id")
|
||||
data class On3Ex(val id: Int) : Route("on3ex$id")
|
||||
data object CzechMap : Route("czechmap")
|
||||
data object Mluvnice : Route("mluvnice")
|
||||
data class MluvEx(val n: Int) : Route("mluve$n")
|
||||
|
|
@ -38,8 +41,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 MluvEx || this is BookQuiz || this is BookPlot ||
|
||||
this is NetLesson || this is HwLesson || this is OnLesson || this is On2Lesson
|
||||
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
|
||||
|
||||
/** Full stack from the practice root to this screen, so back always goes up one level. */
|
||||
fun stack(): List<Route> = when (this) {
|
||||
|
|
@ -65,6 +68,9 @@ sealed class Route(val page: String) {
|
|||
On2Map -> listOf(Subjects, OnYears, On2Map)
|
||||
is On2Lesson -> listOf(Subjects, OnYears, On2Map, this)
|
||||
is On2Ex -> listOf(Subjects, OnYears, On2Map, On2Lesson(id), this)
|
||||
On3Map -> listOf(Subjects, OnYears, On3Map)
|
||||
is On3Lesson -> listOf(Subjects, OnYears, On3Map, this)
|
||||
is On3Ex -> listOf(Subjects, OnYears, On3Map, On3Lesson(id), this)
|
||||
CzechMap -> listOf(Subjects, CzechMap)
|
||||
Mluvnice -> listOf(Subjects, CzechMap, Mluvnice)
|
||||
is MluvEx -> listOf(Subjects, CzechMap, Mluvnice, this)
|
||||
|
|
@ -88,6 +94,7 @@ fun routeFromPage(page: String): Route? = when (page) {
|
|||
"onyears" -> Route.OnYears
|
||||
"onmap" -> Route.OnMap
|
||||
"on2map" -> Route.On2Map
|
||||
"on3map" -> Route.On3Map
|
||||
"czechmap" -> Route.CzechMap
|
||||
"mluvnice" -> Route.Mluvnice
|
||||
"readinglist" -> Route.ReadingList
|
||||
|
|
@ -119,6 +126,12 @@ fun routeFromPage(page: String): Route? = when (page) {
|
|||
Regex("""hwex(\d+)""").matchEntire(page)?.let {
|
||||
return Route.HwEx(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on3unit(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On3Lesson(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on3ex(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On3Ex(it.groupValues[1].toInt())
|
||||
}
|
||||
Regex("""on2unit(\d+)""").matchEntire(page)?.let {
|
||||
return Route.On2Lesson(it.groupValues[1].toInt())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class Content(root: JSONObject) {
|
|||
val hw = raw.arr("hw")
|
||||
val on = raw.arr("on")
|
||||
val on2 = raw.arr("on2")
|
||||
val on3 = raw.arr("on3")
|
||||
val mluvnice = raw.arr("mluvnice")
|
||||
val books = raw.arr("books")
|
||||
val changelog = raw.arr("changelog")
|
||||
|
|
@ -40,6 +41,7 @@ class Content(root: JSONObject) {
|
|||
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 on3Lesson(id: Int) = on3.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 }
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ class ProgressStore(context: Context) {
|
|||
fun on2Done(id: Int) = prefs.getBoolean("on2.$id", false)
|
||||
fun markOn2(id: Int) { prefs.edit().putBoolean("on2.$id", true).apply() }
|
||||
|
||||
fun on3Done(id: Int) = prefs.getBoolean("on3.$id", false)
|
||||
fun markOn3(id: Int) { prefs.edit().putBoolean("on3.$id", true).apply() }
|
||||
|
||||
fun mluvDone(n: Int) = prefs.getBoolean("mluv.$n", false)
|
||||
fun markMluv(n: Int) { prefs.edit().putBoolean("mluv.$n", true).apply() }
|
||||
|
||||
|
|
@ -92,6 +95,14 @@ fun summarize(content: Content, p: ProgressStore): ProgressSum {
|
|||
sum.doneUnits += 1
|
||||
}
|
||||
}
|
||||
content.on3.forEach { l ->
|
||||
sum.totalEx += 1
|
||||
sum.openUnits += 1
|
||||
if (p.on3Done(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")) }
|
||||
|
|
|
|||
|
|
@ -872,6 +872,18 @@ fun On2QuizScreen(vm: AppViewModel, id: Int) {
|
|||
DispatchExercise(vm, spec, vm.tr(lesson.str("exTitleKey"))) { vm.markOn2(id) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun On3QuizScreen(vm: AppViewModel, id: Int) {
|
||||
val lesson = vm.content.on3Lesson(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.markOn3(id) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HwQuizScreen(vm: AppViewModel, id: Int) {
|
||||
val lesson = vm.content.hwLesson(id) ?: return
|
||||
|
|
|
|||
|
|
@ -300,10 +300,11 @@ 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" -> {
|
||||
sum.totalEx = vm.content.on.size + vm.content.on2.size
|
||||
"onyears", "onmap", "on2map", "on3map" -> {
|
||||
sum.totalEx = vm.content.on.size + vm.content.on2.size + vm.content.on3.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.on2.count { vm.progress.on2Done(it.int("id")) } +
|
||||
vm.content.on3.count { vm.progress.on3Done(it.int("id")) }
|
||||
}
|
||||
"czechmap" -> {
|
||||
sum.totalEx = vm.content.mluvnice.size
|
||||
|
|
@ -494,7 +495,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"), "onyears", locked = true, 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")
|
||||
vm.content.on.forEach { l ->
|
||||
add(vm.tr(l.str("titleKey")), vm.tr("search_lesson"), "onunit${l.int("id")}", extra = "obcanka")
|
||||
|
|
@ -504,6 +505,10 @@ private fun buildSearch(vm: AppViewModel): List<Hit> {
|
|||
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")}")
|
||||
}
|
||||
vm.content.on3.forEach { l ->
|
||||
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")}")
|
||||
}
|
||||
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")
|
||||
|
|
@ -609,8 +614,9 @@ fun OnYearsScreen(vm: AppViewModel) {
|
|||
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) }
|
||||
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_year3", "on_year4")) { key ->
|
||||
items(listOf("on_year4")) { key ->
|
||||
NavRow(title = vm.tr(key), subtitle = vm.tr("on_year_locked_sub"), locked = true, onClick = null)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue