mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 07:04:35 +00:00
Add year-2 civics lessons on the citizen in a democratic state.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
515abdc6ce
commit
d453c54e52
25 changed files with 2323 additions and 23 deletions
|
|
@ -133,6 +133,11 @@ final class AppModel: ObservableObject {
|
|||
refresh()
|
||||
}
|
||||
|
||||
func markOn2(_ id: Int) {
|
||||
progress.markOn2(id)
|
||||
refresh()
|
||||
}
|
||||
|
||||
func markMluv(_ n: Int) {
|
||||
progress.markMluv(n)
|
||||
refresh()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ final class Content {
|
|||
let netAnswers: [[J]]
|
||||
let hw: [J]
|
||||
let on: [J]
|
||||
let on2: [J]
|
||||
let mluvnice: [J]
|
||||
let books: [J]
|
||||
let changelog: [J]
|
||||
|
|
@ -64,6 +65,7 @@ final class Content {
|
|||
}
|
||||
hw = raw.arr("hw")
|
||||
on = raw.arr("on")
|
||||
on2 = raw.arr("on2")
|
||||
mluvnice = raw.arr("mluvnice")
|
||||
books = raw.arr("books")
|
||||
changelog = raw.arr("changelog")
|
||||
|
|
@ -73,6 +75,7 @@ final class Content {
|
|||
func netLesson(_ id: Int) -> J? { netLessons.first { $0.int("id") == id } }
|
||||
func hwLesson(_ id: Int) -> J? { hw.first { $0.int("id") == id } }
|
||||
func onLesson(_ id: Int) -> J? { on.first { $0.int("id") == id } }
|
||||
func on2Lesson(_ id: Int) -> J? { on2.first { $0.int("id") == id } }
|
||||
func mluv(_ n: Int) -> J? { mluvnice.first { $0.int("id") == n } }
|
||||
func book(_ id: String) -> J? { books.first { $0.str("id") == id } }
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ final class ProgressStore {
|
|||
func onDone(_ id: Int) -> Bool { defaults.bool(forKey: "on.\(id)") }
|
||||
func markOn(_ id: Int) { defaults.set(true, forKey: "on.\(id)") }
|
||||
|
||||
func on2Done(_ id: Int) -> Bool { defaults.bool(forKey: "on2.\(id)") }
|
||||
func markOn2(_ id: Int) { defaults.set(true, forKey: "on2.\(id)") }
|
||||
|
||||
func mluvDone(_ n: Int) -> Bool { defaults.bool(forKey: "mluv.\(n)") }
|
||||
func markMluv(_ n: Int) { defaults.set(true, forKey: "mluv.\(n)") }
|
||||
|
||||
|
|
@ -88,6 +91,14 @@ func summarize(_ content: Content, _ p: ProgressStore) -> ProgressSum {
|
|||
sum.doneUnits += 1
|
||||
}
|
||||
}
|
||||
for l in content.on2 {
|
||||
sum.totalEx += 1
|
||||
sum.openUnits += 1
|
||||
if p.on2Done(l.int("id")) {
|
||||
sum.doneEx += 1
|
||||
sum.doneUnits += 1
|
||||
}
|
||||
}
|
||||
sum.totalEx += content.mluvnice.count
|
||||
sum.openUnits += 1
|
||||
let md = content.mluvnice.filter { p.mluvDone($0.int("id")) }.count
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ enum Route: Hashable {
|
|||
case onMap
|
||||
case onLesson(Int)
|
||||
case onEx(Int)
|
||||
case on2Map
|
||||
case on2Lesson(Int)
|
||||
case on2Ex(Int)
|
||||
case czechMap
|
||||
case mluvnice
|
||||
case mluvEx(Int)
|
||||
|
|
@ -56,6 +59,9 @@ enum Route: Hashable {
|
|||
case .onMap: return "onmap"
|
||||
case .onLesson(let id): return "onunit\(id)"
|
||||
case .onEx(let id): return "onex\(id)"
|
||||
case .on2Map: return "on2map"
|
||||
case .on2Lesson(let id): return "on2unit\(id)"
|
||||
case .on2Ex(let id): return "on2ex\(id)"
|
||||
case .czechMap: return "czechmap"
|
||||
case .mluvnice: return "mluvnice"
|
||||
case .mluvEx(let n): return "mluve\(n)"
|
||||
|
|
@ -112,6 +118,12 @@ enum Route: Hashable {
|
|||
return [.onYears, .onMap, .onLesson(id)]
|
||||
case .onEx(let id):
|
||||
return [.onYears, .onMap, .onLesson(id), .onEx(id)]
|
||||
case .on2Map:
|
||||
return [.onYears, .on2Map]
|
||||
case .on2Lesson(let id):
|
||||
return [.onYears, .on2Map, .on2Lesson(id)]
|
||||
case .on2Ex(let id):
|
||||
return [.onYears, .on2Map, .on2Lesson(id), .on2Ex(id)]
|
||||
case .czechMap:
|
||||
return [.czechMap]
|
||||
case .mluvnice:
|
||||
|
|
@ -142,6 +154,7 @@ func routeFromPage(_ page: String) -> Route? {
|
|||
case "hwmap": return .hwMap
|
||||
case "onyears": return .onYears
|
||||
case "onmap": return .onMap
|
||||
case "on2map": return .on2Map
|
||||
case "czechmap": return .czechMap
|
||||
case "mluvnice": return .mluvnice
|
||||
case "readinglist": return .readingList
|
||||
|
|
@ -185,6 +198,12 @@ func routeFromPage(_ page: String) -> Route? {
|
|||
if let m = page.wholeMatch(of: /hwex(\d+)/), let n = Int(m.1) {
|
||||
return .hwEx(n)
|
||||
}
|
||||
if let m = page.wholeMatch(of: /on2unit(\d+)/), let n = Int(m.1) {
|
||||
return .on2Lesson(n)
|
||||
}
|
||||
if let m = page.wholeMatch(of: /on2ex(\d+)/), let n = Int(m.1) {
|
||||
return .on2Ex(n)
|
||||
}
|
||||
if let m = page.wholeMatch(of: /onunit(\d+)/), let n = Int(m.1) {
|
||||
return .onLesson(n)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -644,6 +644,25 @@ struct OnQuizScreen: View {
|
|||
}
|
||||
}
|
||||
|
||||
struct On2QuizScreen: View {
|
||||
@ObservedObject var vm: AppModel
|
||||
let id: Int
|
||||
|
||||
var body: some View {
|
||||
if let lesson = vm.content.on2Lesson(id) {
|
||||
let spec = J([
|
||||
"type": "choice",
|
||||
"title": vm.tr(lesson.str("exTitleKey")),
|
||||
"sub": lesson.str("quizHeadKey"),
|
||||
"questions": lesson.rawArray("quiz"),
|
||||
])
|
||||
DispatchExercise(vm: vm, spec: spec, titleFallback: vm.tr(lesson.str("exTitleKey"))) {
|
||||
vm.markOn2(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HwQuizScreen: View {
|
||||
@ObservedObject var vm: AppModel
|
||||
let id: Int
|
||||
|
|
|
|||
|
|
@ -423,9 +423,10 @@ private func subjectSum(_ vm: AppModel, _ s: J) -> ProgressSum {
|
|||
case "hwyears", "hwmap":
|
||||
sum.totalEx = vm.content.hw.count
|
||||
sum.doneEx = vm.content.hw.filter { vm.progress.hwDone($0.int("id")) }.count
|
||||
case "onyears", "onmap":
|
||||
sum.totalEx = vm.content.on.count
|
||||
case "onyears", "onmap", "on2map":
|
||||
sum.totalEx = vm.content.on.count + vm.content.on2.count
|
||||
sum.doneEx = vm.content.on.filter { vm.progress.onDone($0.int("id")) }.count
|
||||
+ vm.content.on2.filter { vm.progress.on2Done($0.int("id")) }.count
|
||||
case "czechmap":
|
||||
sum.totalEx = vm.content.mluvnice.count
|
||||
sum.doneEx = vm.content.mluvnice.filter { vm.progress.mluvDone($0.int("id")) }.count
|
||||
|
|
@ -565,13 +566,17 @@ private func buildSearch(_ vm: AppModel) -> [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")
|
||||
for l in vm.content.on {
|
||||
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"))")
|
||||
}
|
||||
for l in vm.content.on2 {
|
||||
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")
|
||||
add(vm.tr("Maturitní četba"), vm.tr("search_book"), "readinglist")
|
||||
for b in vm.content.books {
|
||||
|
|
@ -796,7 +801,10 @@ struct OnYearsScreen: View {
|
|||
NavigationLink(value: Route.onMap) {
|
||||
ListRowLabel(title: vm.tr("on_year1"), subtitle: vm.tr("on_sub"))
|
||||
}
|
||||
ForEach(["on_year2", "on_year3", "on_year4"], id: \.self) { key in
|
||||
NavigationLink(value: Route.on2Map) {
|
||||
ListRowLabel(title: vm.tr("on_year2"), subtitle: vm.tr("on2_sub"))
|
||||
}
|
||||
ForEach(["on_year3", "on_year4"], id: \.self) { key in
|
||||
Label {
|
||||
ListRowLabel(title: vm.tr(key), subtitle: vm.tr("on_year_locked_sub"))
|
||||
} icon: {
|
||||
|
|
@ -1402,6 +1410,27 @@ struct RouteDestination: View {
|
|||
}
|
||||
case .onEx(let id):
|
||||
OnQuizScreen(vm: vm, id: id)
|
||||
case .on2Map:
|
||||
LessonListScreen(
|
||||
vm: vm,
|
||||
title: vm.tr("on_year2"),
|
||||
subtitle: vm.tr("on2_sub"),
|
||||
rows: vm.content.on2.map { l in
|
||||
let id = l.int("id")
|
||||
return LessonRow(
|
||||
id: "o2\(id)",
|
||||
title: vm.tr(l.str("titleKey")),
|
||||
done: vm.progress.on2Done(id),
|
||||
destination: .on2Lesson(id)
|
||||
)
|
||||
}
|
||||
)
|
||||
case .on2Lesson(let id):
|
||||
if let l = vm.content.on2Lesson(id) {
|
||||
SlidesScreen(vm: vm, title: vm.tr(l.str("titleKey")), subtitle: vm.tr(l.str("subKey")), slides: l.arr("slides"), next: .on2Ex(id))
|
||||
}
|
||||
case .on2Ex(let id):
|
||||
On2QuizScreen(vm: vm, id: id)
|
||||
case .czechMap:
|
||||
CzechMapScreen(vm: vm)
|
||||
case .mluvnice:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue