hezarfen_zeka
Clone
https://git.tahinli.com/archive/hezarfen_zeka.git
0 watching·0 forks·Python·1.9 MiB·e01a4fa·Ahmet Kaan Gümüş·2 months ago·25 commits
| 1 | """Hezarfen tohum verisi üreticisi — CLI ve üretim akışı. |
| 2 | |
| 3 | Kullanım: |
| 4 | python main.py --scale full --seed 20260413 --out ../seed |
| 5 | |
| 6 | Akış SENARYO Ek A'daki topolojik sırayı izler; dosyalar |
| 7 | `schema.json -> load_order` sırasına göre numaralanır. |
| 8 | """ |
| 9 | |
| 10 | from __future__ import annotations |
| 11 | |
| 12 | import argparse |
| 13 | import datetime as _dt |
| 14 | import json |
| 15 | import os |
| 16 | import statistics |
| 17 | import sys |
| 18 | import time |
| 19 | |
| 20 | BASE = os.path.dirname(os.path.abspath(__file__)) |
| 21 | if BASE not in sys.path: |
| 22 | sys.path.insert(0, BASE) |
| 23 | |
| 24 | import academics |
| 25 | import assessment |
| 26 | import config as C |
| 27 | import counters |
| 28 | import emit |
| 29 | import engagement |
| 30 | import operations |
| 31 | import people |
| 32 | import timeline as T |
| 33 | import verify_queries |
| 34 | from world import Ctx, SCALES |
| 35 | |
| 36 | DEFAULT_SCHEMA = os.path.normpath(os.path.join(BASE, "..", "spec", "schema.json")) |
| 37 | DEFAULT_OUT = os.path.normpath(os.path.join(BASE, "..", "seed")) |
| 38 | |
| 39 | |
| 40 | def parse_args(argv=None): |
| 41 | ap = argparse.ArgumentParser( |
| 42 | description="Hezarfen 250 öğrencilik tohum verisi üreticisi") |
| 43 | ap.add_argument("--seed", type=int, default=C.SEED_DEFAULT, |
| 44 | help="Rastgelelik tohumu (varsayılan %d)" % C.SEED_DEFAULT) |
| 45 | ap.add_argument("--scale", choices=sorted(SCALES), default="full", |
| 46 | help="Ölçek profili: full (250 öğrenci) veya smoke (20)") |
| 47 | ap.add_argument("--date-shift-days", type=int, default=0, |
| 48 | help="Tüm zaman damgalarına eklenecek gün (152/154 önerilir)") |
| 49 | ap.add_argument("--out", default=DEFAULT_OUT, help="Çıktı dizini") |
| 50 | ap.add_argument("--schema", default=DEFAULT_SCHEMA, help="schema.json yolu") |
| 51 | ap.add_argument("--keep-parts", action="store_true", |
| 52 | help="Geçici parça dosyalarını silme (hata ayıklama)") |
| 53 | return ap.parse_args(argv) |
| 54 | |
| 55 | |
| 56 | def generate(args): |
| 57 | started = time.time() |
| 58 | T.configure(args.date_shift_days) |
| 59 | emit.load_schema(args.schema) |
| 60 | os.makedirs(args.out, exist_ok=True) |
| 61 | emitter = emit.Emitter(args.out) |
| 62 | ctx = Ctx(args.seed, SCALES[args.scale], args.date_shift_days, emitter) |
| 63 | |
| 64 | def step(label, fn): |
| 65 | t0 = time.time() |
| 66 | fn(ctx) |
| 67 | print(" %-28s %6.1f sn" % (label, time.time() - t0), flush=True) |
| 68 | |
| 69 | print("Hezarfen tohum verisi üretiliyor (ölçek=%s, tohum=%d, kaydırma=%d gün)" |
| 70 | % (args.scale, args.seed, args.date_shift_days), flush=True) |
| 71 | |
| 72 | step("kimlik (user/parent_link)", people.build_people) |
| 73 | step("akademik yapı", academics.build_structure) |
| 74 | ctx.all_gap_subjects = {k for s in ctx.students for k in s.gap_subject_keys} |
| 75 | step("ders programı", academics.build_timetable) |
| 76 | step("sınav takvimi", assessment.schedule_exams) |
| 77 | ctx.expected_question_count = sum(e.n_questions for e in ctx.exams) |
| 78 | step("soru bankası", assessment.build_bank_templates) |
| 79 | step("sınav soruları", assessment.build_questions) |
| 80 | step("oturum + yoklama", academics.build_sessions) |
| 81 | step("deneme + cevap + sonuç", assessment.build_attempts) |
| 82 | step("ödev", engagement.build_homework) |
| 83 | step("pomodoro", engagement.build_pomodoro) |
| 84 | step("soru havuzu", engagement.build_pool) |
| 85 | step("randevu", operations.build_appointments) |
| 86 | step("etkinlik", operations.build_events) |
| 87 | step("yemek", operations.build_meals) |
| 88 | step("ödeme", operations.build_payments) |
| 89 | step("mesai", operations.build_work_entries) |
| 90 | step("sohbet", engagement.build_chatbot) |
| 91 | step("not", engagement.build_notes) |
| 92 | step("ders notu", academics.build_course_notes) |
| 93 | step("mesaj", engagement.build_messages) |
| 94 | step("tahta", engagement.build_boards) |
| 95 | step("bozma adımı", assessment.apply_sabotage) |
| 96 | step("sınav satırları", assessment.emit_exam_rows) |
| 97 | step("rozet", engagement.build_badges) |
| 98 | step("yapı sayaçları", counters.emit_structure) |
| 99 | step("referans tabloları", counters.emit_reference_tables) |
| 100 | step("kullanıcı satırları", counters.emit_users) |
| 101 | |
| 102 | emitter.close_all() |
| 103 | files = emitter.assemble(C.FILE_LAYOUT, C.FILE_DESCRIPTIONS) |
| 104 | if not args.keep_parts: |
| 105 | emitter.cleanup() |
| 106 | |
| 107 | control_path = os.path.join(args.out, "00_control.surql") |
| 108 | counters.write_control_file(control_path, T.local_ms(_dt.date(2025, 8, 15), 9 * 60)) |
| 109 | files.insert(0, ("00_control.surql", os.path.getsize(control_path))) |
| 110 | |
| 111 | verify_path = os.path.join(args.out, "99_dogrula.surql") |
| 112 | n_queries = verify_queries.write(verify_path, T.T_NOW) |
| 113 | files.append(("99_dogrula.surql", os.path.getsize(verify_path))) |
| 114 | |
| 115 | elapsed = time.time() - started |
| 116 | manifest = build_manifest(ctx, args, files, elapsed, n_queries) |
| 117 | with open(os.path.join(args.out, "MANIFEST.json"), "w", encoding="utf-8") as fh: |
| 118 | json.dump(manifest, fh, ensure_ascii=False, indent=2) |
| 119 | with open(os.path.join(args.out, "_seed_manifest.json"), "w", encoding="utf-8") as fh: |
| 120 | json.dump(build_seed_manifest(ctx, args), fh, ensure_ascii=False, indent=1) |
| 121 | |
| 122 | total = sum(emitter.counts.values()) |
| 123 | print("\nToplam %d satır / %d tablo / %.1f sn" % (total, len(emitter.counts), elapsed)) |
| 124 | print("Çıktı: %s" % args.out) |
| 125 | return ctx, manifest |
| 126 | |
| 127 | |
| 128 | # --------------------------------------------------------------------------- |
| 129 | # MANIFEST |
| 130 | # --------------------------------------------------------------------------- |
| 131 | |
| 132 | def _pct(part, whole): |
| 133 | return round(100.0 * part / whole, 2) if whole else None |
| 134 | |
| 135 | |
| 136 | def build_manifest(ctx, args, files, elapsed, n_queries): |
| 137 | counts = dict(ctx.emitter.counts) |
| 138 | total_rows = sum(counts.values()) |
| 139 | a = ctx.answer_stats |
| 140 | ratio = ctx.scale.ratio |
| 141 | |
| 142 | def scaled(value): |
| 143 | return round(value * ratio) |
| 144 | |
| 145 | attendance = ctx.attendance_stats |
| 146 | att_total = sum(attendance.values()) |
| 147 | denom = attendance.get("present", 0) + attendance.get("absent", 0) + \ |
| 148 | attendance.get("late", 0) |
| 149 | |
| 150 | arch = ctx.archetype_stats |
| 151 | |
| 152 | def arch_acc(name): |
| 153 | s = arch.get(name) |
| 154 | if not s or not s["answered"]: |
| 155 | return None |
| 156 | return _pct(s["correct"], s["answered"]) |
| 157 | |
| 158 | marks = ctx.mark_values |
| 159 | q_p = [] |
| 160 | distractor_wins = 0 |
| 161 | # Madde istatistiği için asgari gözlem sayısı (smoke ölçeğinde düşer) |
| 162 | min_obs = max(3, round(10 * ratio)) |
| 163 | for key, (asked, answered, correct, distractors) in ctx.question_stats.items(): |
| 164 | if answered >= min_obs: |
| 165 | q_p.append(correct / answered) |
| 166 | if distractors and max(distractors.values()) > correct: |
| 167 | distractor_wins += 1 |
| 168 | |
| 169 | expected = { |
| 170 | "H1_user": scaled(563), "H2_student": scaled(250), "H3_teacher": 24, |
| 171 | "H4_parent": scaled(285), "H5_parent_link": scaled(299), "H7_course": 50, |
| 172 | "H8_subject": 390, "H9_class_group": 11, "H10_class_member": scaled(250), |
| 173 | "H11_class_course": 110, "H12_enrollment": scaled(2790), |
| 174 | "H13_course_session": 4428, "H14_session_attendance": scaled(98400), |
| 175 | "H15_exam": 340, "H16_exam_question": 6640, |
| 176 | "H17_exam_attempt": scaled(14800), "H18_exam_answer": scaled(259000), |
| 177 | "H19_exam_result": scaled(13600), "H20_bank_question": 885, |
| 178 | "H21_homework": 590, "H22_homework_submission": scaled(26200), |
| 179 | "H23_homework_result": scaled(23000), "H24_pomodoro_session": scaled(26000), |
| 180 | "H25_chatbot_thread": scaled(1500), "H26_chatbot_message": scaled(9000), |
| 181 | "H27_pool_question": scaled(640), "H28_solution": scaled(780), |
| 182 | "H29_appointment": 520, "H30_message": scaled(6800), |
| 183 | "H31_board_stroke": round(9000 * (192 + 88 * ratio) / 280), |
| 184 | "H32_meal_booking": scaled(11800), |
| 185 | "H33_payment_ledger": scaled(4400), "H34_tables": 60, |
| 186 | "H35_total_rows": scaled(572000), |
| 187 | } |
| 188 | actual = { |
| 189 | "H1_user": counts.get("user", 0), "H2_student": len(ctx.students), |
| 190 | "H3_teacher": len(ctx.teachers), "H4_parent": len(ctx.parents), |
| 191 | "H5_parent_link": counts.get("parent_link", 0), |
| 192 | "H7_course": counts.get("course", 0), "H8_subject": counts.get("subject", 0), |
| 193 | "H9_class_group": counts.get("class_group", 0), |
| 194 | "H10_class_member": counts.get("class_member", 0), |
| 195 | "H11_class_course": counts.get("class_course", 0), |
| 196 | "H12_enrollment": counts.get("enrollment", 0), |
| 197 | "H13_course_session": counts.get("course_session", 0), |
| 198 | "H14_session_attendance": counts.get("session_attendance", 0), |
| 199 | "H15_exam": counts.get("exam", 0), |
| 200 | "H16_exam_question": counts.get("exam_question", 0), |
| 201 | "H17_exam_attempt": counts.get("exam_attempt", 0), |
| 202 | "H18_exam_answer": counts.get("exam_answer", 0), |
| 203 | "H19_exam_result": counts.get("exam_result", 0), |
| 204 | "H20_bank_question": counts.get("bank_question", 0), |
| 205 | "H21_homework": counts.get("homework", 0), |
| 206 | "H22_homework_submission": counts.get("homework_submission", 0), |
| 207 | "H23_homework_result": counts.get("homework_result", 0), |
| 208 | "H24_pomodoro_session": counts.get("pomodoro_session", 0), |
| 209 | "H25_chatbot_thread": counts.get("chatbot_thread", 0), |
| 210 | "H26_chatbot_message": counts.get("chatbot_message", 0), |
| 211 | "H27_pool_question": counts.get("pool_question", 0), |
| 212 | "H28_solution": counts.get("solution", 0), |
| 213 | "H29_appointment": counts.get("appointment", 0), |
| 214 | "H30_message": counts.get("message", 0), |
| 215 | "H31_board_stroke": counts.get("board_stroke", 0), |
| 216 | "H32_meal_booking": counts.get("meal_booking", 0), |
| 217 | "H33_payment_ledger": counts.get("payment_ledger", 0), |
| 218 | "H34_tables": len(counts), "H35_total_rows": total_rows, |
| 219 | } |
| 220 | |
| 221 | learning = { |
| 222 | "L3_genel_dogruluk_pct": {"beklenen": 58.4, |
| 223 | "gercek": _pct(a["choice_correct"], a["choice_answered"])}, |
| 224 | "L4_bos_birakma_pct": {"beklenen": 12.5, |
| 225 | "gercek": _pct(a["choice_asked"] - a["choice_answered"], |
| 226 | a["choice_asked"])}, |
| 227 | "L5_text_soru_pay_pct": { |
| 228 | "beklenen": 15.0, |
| 229 | "gercek": _pct(sum(1 for q in ctx.questions if q.kind == "text"), |
| 230 | len(ctx.questions))}, |
| 231 | "L6_text_bos_pct": {"beklenen": 18.0, |
| 232 | "gercek": _pct(a["text_asked"] - a["text_answered"], |
| 233 | a["text_asked"])}, |
| 234 | "L7_mark_ortalama": {"beklenen": 62.8, |
| 235 | "gercek": round(statistics.fmean(marks), 2) if marks else None}, |
| 236 | "L8_mark_std": {"beklenen": 17.4, |
| 237 | "gercek": round(statistics.pstdev(marks), 2) if len(marks) > 1 else None}, |
| 238 | "L9_mark_90_ustu_pct": {"beklenen": 7.2, |
| 239 | "gercek": _pct(sum(1 for m in marks if m >= 90), len(marks))}, |
| 240 | "L10_p_ortalama": {"beklenen": 0.585, |
| 241 | "gercek": round(statistics.fmean(q_p), 4) if q_p else None}, |
| 242 | "L11_p_030_alti_madde": {"beklenen": 531, |
| 243 | "gercek": sum(1 for p in q_p if p < 0.30)}, |
| 244 | "L12_p_090_ustu_madde": {"beklenen": 531, |
| 245 | "gercek": sum(1 for p in q_p if p > 0.90)}, |
| 246 | "L13_celdirici_dogrudan_fazla": {"beklenen": 180, "gercek": distractor_wins}, |
| 247 | "L17_ikinci_denemede_duzelen": {"beklenen": scaled(2960), |
| 248 | "gercek": ctx.stats.get("improved_items", 0)}, |
| 249 | "L18_from_bank_pay_pct": { |
| 250 | "beklenen": 45.0, |
| 251 | "gercek": _pct(sum(1 for q in ctx.questions if q.from_bank is not None), |
| 252 | len(ctx.questions))}, |
| 253 | "L19_from_bank_kopuk": {"beklenen": 48, |
| 254 | "gercek": ctx.stats.get("broken_from_bank", 0)}, |
| 255 | "L20_banked_as_pay_pct": { |
| 256 | "beklenen": 6.0, |
| 257 | "gercek": _pct(sum(1 for q in ctx.questions if q.banked_as is not None), |
| 258 | len(ctx.questions))}, |
| 259 | "L21_metin_iraksamasi": {"beklenen": 359, |
| 260 | "gercek": sum(1 for v in ctx.text_diverged.values() if v)}, |
| 261 | "L22_seq2_attempt": {"beklenen": scaled(564), |
| 262 | "gercek": ctx.stats.get("second_attempts", 0)}, |
| 263 | "L23_cevapsiz_attempt": {"beklenen": scaled(9), |
| 264 | "gercek": ctx.stats.get("blank_attempts", 0)}, |
| 265 | "L24_finished_none_attempt": {"beklenen": scaled(31), |
| 266 | "gercek": ctx.stats.get("abandoned_attempts", 0)}, |
| 267 | } |
| 268 | |
| 269 | archetypes = { |
| 270 | "A1_A1_dogruluk_pct": {"beklenen": 78, "gercek": arch_acc("A1")}, |
| 271 | "A2_A7_dogruluk_pct": {"beklenen": 42, "gercek": arch_acc("A7")}, |
| 272 | "A3_A1_eksi_A7": {"beklenen": 36, |
| 273 | "gercek": (round(arch_acc("A1") - arch_acc("A7"), 2) |
| 274 | if arch_acc("A1") and arch_acc("A7") else None)}, |
| 275 | "A4_A3_bosluk_dogruluk_pct": { |
| 276 | "beklenen": 31, |
| 277 | "gercek": _pct(arch.get("A3", {}).get("gap_correct", 0), |
| 278 | arch.get("A3", {}).get("gap_asked", 0))}, |
| 279 | "A5_A3_diger_dogruluk_pct": { |
| 280 | "beklenen": 72, |
| 281 | "gercek": _pct(arch.get("A3", {}).get("other_correct", 0), |
| 282 | arch.get("A3", {}).get("other_asked", 0))}, |
| 283 | "A7_bosluk_sinif_ortalamasi_pct": { |
| 284 | "beklenen": 58, |
| 285 | "gercek": _pct(ctx.gap_class_stats["correct"], ctx.gap_class_stats["asked"])}, |
| 286 | "A8_A5_T1_T2_pct": { |
| 287 | "beklenen": "40 -> 70", |
| 288 | "gercek": [_pct(arch.get("A5", {}).get("t1_correct", 0), |
| 289 | arch.get("A5", {}).get("t1_asked", 0)), |
| 290 | _pct(arch.get("A5", {}).get("t2_correct", 0), |
| 291 | arch.get("A5", {}).get("t2_asked", 0))]}, |
| 292 | "A9_A6_kirilma_oncesi_sonrasi_pct": { |
| 293 | "beklenen": "64 -> 37", |
| 294 | "gercek": [_pct(arch.get("A6", {}).get("pre_correct", 0), |
| 295 | arch.get("A6", {}).get("pre_asked", 0)), |
| 296 | _pct(arch.get("A6", {}).get("post_correct", 0), |
| 297 | arch.get("A6", {}).get("post_asked", 0))]}, |
| 298 | "A10_A4_counted_on_time_pct": { |
| 299 | "beklenen": 48, |
| 300 | "gercek": _pct(ctx.hw_archetype.get("A4", {}).get("on_time", 0), |
| 301 | ctx.hw_archetype.get("A4", {}).get("n", 0))}, |
| 302 | "A11_A1_counted_on_time_pct": { |
| 303 | "beklenen": 97, |
| 304 | "gercek": _pct(ctx.hw_archetype.get("A1", {}).get("on_time", 0), |
| 305 | ctx.hw_archetype.get("A1", {}).get("n", 0))}, |
| 306 | "A16_A8_randevu": {"beklenen": scaled(76), |
| 307 | "gercek": ctx.appointment_by_student.get("A8", 0)}, |
| 308 | "A18_A8_failed_3_in_14": {"beklenen": scaled(11), |
| 309 | "gercek": ctx.stats.get("a8_failed_3_in_14", 0)}, |
| 310 | "A21_A7_pomodorosuz": {"beklenen": scaled(13), |
| 311 | "gercek": sum(1 for s in ctx.students |
| 312 | if s.archetype == "A7" |
| 313 | and ctx.pomodoro_true_counted.get(s.key, 0) == 0)}, |
| 314 | "A22_A7_sohbetsiz": {"beklenen": scaled(15), |
| 315 | "gercek": sum(1 for s in ctx.students |
| 316 | if s.archetype == "A7" |
| 317 | and not s.counters.get("chatbot_thread_count"))}, |
| 318 | } |
| 319 | |
| 320 | behaviour = { |
| 321 | "D1_devam_orani_pct": { |
| 322 | "beklenen": 93.5, |
| 323 | "gercek": _pct(attendance.get("present", 0) + attendance.get("late", 0), denom)}, |
| 324 | "D2_present_pay_pct": {"beklenen": 84.1, |
| 325 | "gercek": _pct(attendance.get("present", 0), att_total)}, |
| 326 | "D3_absent_late_excused_pct": { |
| 327 | "beklenen": [9.0, 4.6, 2.3], |
| 328 | "gercek": [_pct(attendance.get("absent", 0), att_total), |
| 329 | _pct(attendance.get("late", 0), att_total), |
| 330 | _pct(attendance.get("excused", 0), att_total)]}, |
| 331 | "D11_son24saat_teslim_pct": {"beklenen": 44.8, |
| 332 | "gercek": _pct(ctx.hw_stats["last24"], |
| 333 | ctx.hw_stats["total"])}, |
| 334 | "D12_gec_teslim_pct": {"beklenen": 19.6, |
| 335 | "gercek": _pct(ctx.hw_stats["late"], ctx.hw_stats["total"])}, |
| 336 | "D13_counted_on_time_pct": {"beklenen": 74.8, |
| 337 | "gercek": _pct(ctx.hw_stats["on_time"], |
| 338 | ctx.hw_stats["total"])}, |
| 339 | "D14_on_time_ama_updated_gec": {"beklenen": scaled(750), |
| 340 | "gercek": ctx.hw_stats["on_time_but_updated_late"]}, |
| 341 | "D15_counted_pomodoro_pct": {"beklenen": 81.4, |
| 342 | "gercek": _pct(ctx.stats.get("pomodoro_counted", 0), |
| 343 | ctx.stats.get("pomodoro_total", 0))}, |
| 344 | "D16_finished_none_pomodoro_pct": { |
| 345 | "beklenen": 6.0, |
| 346 | "gercek": _pct(ctx.stats.get("pomodoro_unfinished", 0), |
| 347 | ctx.stats.get("pomodoro_total", 0))}, |
| 348 | "D17_gece_pomodoro_pct": {"beklenen": 8.0, |
| 349 | "gercek": _pct(ctx.stats.get("pomodoro_night", 0), |
| 350 | ctx.stats.get("pomodoro_total", 0))}, |
| 351 | "D18_sohbet_kullanan_ogrenci": {"beklenen": scaled(155), |
| 352 | "gercek": ctx.stats.get("students_using_chat", 0)}, |
| 353 | # SENARYO 5.4'te oranlar ASISTAN mesajlari uzerinden verilmistir |
| 354 | "D19_failed_pay_pct": {"beklenen": 4.6, |
| 355 | "gercek": _pct(ctx.stats.get("chatbot_failed", 0), |
| 356 | ctx.stats.get("chatbot_assistant", 0))}, |
| 357 | "D20_pending_mesaj": {"beklenen": scaled(270), |
| 358 | "gercek": ctx.stats.get("chatbot_pending", 0)}, |
| 359 | "D21_eski_pending_randevu": {"beklenen": 45, |
| 360 | "gercek": ctx.stats.get("appointments_old_pending", 0)}, |
| 361 | "D22_cozumsuz_eski_havuz": {"beklenen": scaled(180), |
| 362 | "gercek": ctx.stats.get("pool_unsolved_old", 0)}, |
| 363 | "D23_yoklamasiz_oturum": {"beklenen": 399, |
| 364 | "gercek": ctx.stats.get("sessions_without_attendance", 0)}, |
| 365 | "D24_clear_vurus_pct": {"beklenen": 3.0, |
| 366 | "gercek": _pct(ctx.stats.get("board_clear", 0), |
| 367 | ctx.stats.get("board_strokes", 0))}, |
| 368 | "D25_okunmus_mesaj_pct": {"beklenen": 66.0, |
| 369 | "gercek": _pct(ctx.stats.get("messages_read", 0), |
| 370 | ctx.stats.get("messages", 0))}, |
| 371 | } |
| 372 | |
| 373 | intentional = { |
| 374 | "K1_pomodoro_sayac_sismesi": sum( |
| 375 | 1 for s in ctx.students |
| 376 | if s.counters.get("pomodoro_finished_total", 0) |
| 377 | != ctx.pomodoro_true_counted.get(s.key, 0)), |
| 378 | "K2_lessons_attended_total_NONE": len(ctx.students), |
| 379 | "K3_high_mark_total_NONE": len(ctx.students), |
| 380 | "K4_held_counted_at_NONE": ctx.stats.get("held_counted_none", 0), |
| 381 | "K5_bank_question_subject_NONE": sum( |
| 382 | 1 for t in ctx.bank_templates if t.subject is None and not t.deleted), |
| 383 | "K6_from_bank_kopuk": ctx.stats.get("broken_from_bank", 0), |
| 384 | "K7_grade_tutarsizligi": 1, |
| 385 | "K8_answer_key_edits": len(ctx.answer_key_edits), |
| 386 | "K9_negatif_madde": sum(1 for q in ctx.questions |
| 387 | if q.item.quality_band == "negatif"), |
| 388 | "K10_bozuk_madde": sum(1 for q in ctx.questions |
| 389 | if q.item.quality_band == "bozuk"), |
| 390 | } |
| 391 | |
| 392 | deviations = [] |
| 393 | for key, exp in expected.items(): |
| 394 | act = actual.get(key) |
| 395 | if exp and act is not None and exp > 0: |
| 396 | diff = 100.0 * (act - exp) / exp |
| 397 | if abs(diff) > 5.0: |
| 398 | deviations.append({"olcum": key, "beklenen": exp, "gercek": act, |
| 399 | "sapma_pct": round(diff, 1)}) |
| 400 | |
| 401 | return { |
| 402 | "uretim": { |
| 403 | "tohum": args.seed, |
| 404 | "olcek": ctx.scale.name, |
| 405 | "ogrenci_sayisi": ctx.scale.n_students, |
| 406 | "date_shift_days": args.date_shift_days, |
| 407 | "t_now_ms": T.T_NOW, |
| 408 | "t_now_iso": _iso(T.T_NOW), |
| 409 | "uretim_zamani_utc": _dt.datetime.now(_dt.timezone.utc).isoformat(timespec="seconds"), |
| 410 | "sure_sn": round(elapsed, 1), |
| 411 | "okul_slug": C.SCHOOL_SLUG, |
| 412 | "dogrulama_sorgusu": n_queries, |
| 413 | "ogretim_haftasi": ctx.teaching_week_count, |
| 414 | }, |
| 415 | "dosyalar": [{"ad": name, "bayt": size} for name, size in files], |
| 416 | "tablo_satir_sayilari": dict(sorted(counts.items(), key=lambda kv: -kv[1])), |
| 417 | "toplam_satir": total_rows, |
| 418 | "beklenen_vs_gercek": {"hacim": {k: {"beklenen": expected[k], "gercek": actual[k]} |
| 419 | for k in expected}, |
| 420 | "ogrenme": learning, |
| 421 | "arketip": archetypes, |
| 422 | "davranis": behaviour, |
| 423 | "kasitli_hatalar": intentional}, |
| 424 | "sapmalar": deviations, |
| 425 | "sapma_gerekceleri": DEVIATION_NOTES, |
| 426 | } |
| 427 | |
| 428 | |
| 429 | DEVIATION_NOTES = [ |
| 430 | "H16 (exam_question = 6.640): SENARYO §2.5'teki soru sayilari " |
| 431 | "(10,25,6,30,12,25,5,30) ders basina 143 soru verir; 40 ders x 143 + 20 etut " |
| 432 | "sinavi x 12 = 5.960. §2.3'teki 6.640 rakami sinav basina 20 soru varsayar ve " |
| 433 | "§2.5 ile celisir. Uretici §2.5'teki kesin tabloya uyar.", |
| 434 | "H18 (exam_answer = 259.000): H16'daki farkin dogrudan sonucudur; gecmis " |
| 435 | "sinavlarin ortalama soru sayisi 18 oldugu icin cevap sayisi da orantili " |
| 436 | "bicimde duser (259.000 x 18/20 x 0,93 ~ 217.000).", |
| 437 | "H19 (exam_result = 13.600): §2.3 oturumlarin %92'sinin notlandigini varsayar " |
| 438 | "ama kenar durum #12 son 3 haftadaki 26 sinavin HIC notlanmadigini sart kosar. " |
| 439 | "Iki kural birlikte 11.800 satir verir; #12 korunmustur (Y1 testi icin gerekli).", |
| 440 | "H14 (session_attendance = 98.400): §2.3'teki hesap 4.158 oturumun TAMAMINDA " |
| 441 | "yoklama alindigini varsayar; oysa §2.4 ve D23 oturumlarin %9'unda hic yoklama " |
| 442 | "olmadigini sart kosar. Uretici §2.4'e uyar (D23 = 399 oturum korunur).", |
| 443 | "H22 / H23 (homework_submission / homework_result): §2.3'teki hesap tum " |
| 444 | "ogrencilerin her odeve hedef oldugunu varsayar; §2.6'daki 'assigned %22 " |
| 445 | "orninde kayitlilarin %55'i' kurali paydayi %10 kucultur. Ayrica ayrilan " |
| 446 | "ogrenciler (#2) ve donem ortasi kaydolanlar (#1) pencere disinda kalir.", |
| 447 | "H24 (pomodoro_session = 26.000): §2.3'teki '170 ogrenci x 153 stint' hesabi " |
| 448 | "§3'teki arketip parametreleriyle (gun/hafta x Poisson(lambda)) uyusmuyor; o " |
| 449 | "parametreler yaklasik 3 kat daha fazla stint uretir. Arketip tablolari " |
| 450 | "senaryonun cekirdegi oldugu icin (A19, D9, D10, D15-D17, P7 olcumlerini " |
| 451 | "besliyorlar) onlara sadik kalindi. Toplam satir sayisi yine H35 bandinda.", |
| 452 | "H12 (enrollment = 2.790): §1.4'teki etut/kulup kayit sayilari " |
| 453 | "(32+28+30+30 ve 18+22+16+20+24+18) toplam 238 eder, 290 degil. Uretici acik " |
| 454 | "sayilari kullanir: 2.500 cekirdek + 238 = 2.738.", |
| 455 | "H13 (course_session = 4.428): 14 blok x 11 sube x 27 hafta = 4.158 hesabi 3 " |
| 456 | "resmi tatil gununu saymaz; o gunlerde ders yapilmaz.", |
| 457 | "H33 (payment_ledger = 4.400): 4 planin taksit sayilari (1/9/6/9) ve 250 " |
| 458 | "ogrenci 1.948 charge uretir, 2.250 degil; vadesi T_NOW'i gecmemis taksitler " |
| 459 | "icin tahsilat satiri da yazilmaz.", |
| 460 | "L11 / L12 (p uclari): §4.2'deki bant->p esleme a_i = 1 varsayar. §4.3'teki " |
| 461 | "a_i dagiliminda maddelerin %38'i a < 0,8 oldugu icin kolay/zor bantlardaki " |
| 462 | "maddeler uclara tasinmaz. Iki kural ayni anda saglanamaz; a_i dagilimi " |
| 463 | "(T2'nin test ettigi sey) korunmustur.", |
| 464 | "L17 (ikinci denemede duzelen ~2.960): §4.9'un beklentisi oturum basina ~5 " |
| 465 | "madde duzelmesidir; theta + 0,45 bonusu ve 12 soruluk quiz sinavlariyla " |
| 466 | "gerceklesen oran oturum basina ~1,7'dir.", |
| 467 | "L22 (seq=2 attempt = 564): §4.9 'gecmis 240 sinavin %18'i' der; §2.5 tablosu " |
| 468 | "ise max_attempts = 2 olan tek bir sinav penceresi (5 numarali quiz) tanimlar, " |
| 469 | "yani 40 sinav. Uretici §2.5'e uyar.", |
| 470 | "D19 / D20 (sohbet): §5.4'teki status paylari ASISTAN mesaji basinadir, " |
| 471 | "§7'deki D19/D20 ise tum chatbot_message satirlarini sayar. MANIFEST D19'u " |
| 472 | "asistan mesajlari uzerinden olcer; D20 hedefi (270 satir) icin 'pending' payi " |
| 473 | "%3'ten %6'ya cikarilmistir.", |
| 474 | "A3 arketipi (bosluk dersi): §3.6'daki -1,60 / -0,90 sapmalari, madde-ici " |
| 475 | "gurultu ve bos birakma secilimiyle birlikte §7.3 A6 olcutunu (ogrenci ici " |
| 476 | "fark >= 30 puan) saglamiyordu; sapmalar -2,40 / -1,40'a derinlestirildi.", |
| 477 | "Madde kalibrasyonu: b_i bantlarina +0,62 sabit kayma, bos birakma olasiligina " |
| 478 | "0,33 carpani ve nota dogrusal donusum (0,89 x puan + 22,5) uygulanir. Bu uc " |
| 479 | "katsayi §7'deki L3 / L4 / L7 / L8 hedeflerini tutturmak icindir ve " |
| 480 | "config.py'de ITEM_B_OFFSET / OMISSION_SCALE / MARK_SLOPE olarak durur.", |
| 481 | "smoke olceginde ogrenciye bagli tum beklenen degerler 20/250 oraniyla " |
| 482 | "olceklenir; yapisal buyuklukler (11 sube, 50 ders, 390 konu, 340 sinav, 900 " |
| 483 | "banka sablonu, 24 ogretmen, okul takvimi) kucultulmez.", |
| 484 | ] |
| 485 | |
| 486 | |
| 487 | def _iso(ms): |
| 488 | return _dt.datetime.fromtimestamp(ms / 1000, _dt.timezone.utc).isoformat() |
| 489 | |
| 490 | |
| 491 | def build_seed_manifest(ctx, args): |
| 492 | """SENARYO §7.8 — DB'ye yazılmayan 'gizli gerçek'.""" |
| 493 | students = [] |
| 494 | for s in ctx.students: |
| 495 | students.append({ |
| 496 | "user": "user:" + s.key, |
| 497 | "archetype": s.archetype, |
| 498 | "class": s.branch, |
| 499 | "theta_base": round(s.theta_base, 4), |
| 500 | "theta_trend": s.arch.get("trend", 0.0), |
| 501 | "t_break_ms": s.break_ms, |
| 502 | "gap_course": ("course:" + s.gap_course_key) if s.gap_course_key else None, |
| 503 | "gap_subjects": ["subject:" + k for k in s.gap_subject_keys], |
| 504 | "omission_omega": s.omega, |
| 505 | "dim_delta": s.dim_delta, |
| 506 | "edge_flags": s.edge, |
| 507 | "true_counted_pomodoro": ctx.pomodoro_true_counted.get(s.key, 0), |
| 508 | }) |
| 509 | items = [] |
| 510 | for q in ctx.questions: |
| 511 | it = q.item |
| 512 | items.append({ |
| 513 | "question": "exam_question:" + q.key, |
| 514 | "a": round(it.a, 4), "b": round(it.b, 4), "c": round(it.c, 4), |
| 515 | "k": it.k, |
| 516 | "misconception_choice": q.misc_choice, |
| 517 | "dims": it.dims, |
| 518 | "trap_choice": (q.misc_choice |
| 519 | if (it.dims or {}).get("dikkat_tuzagi") == "var" |
| 520 | else None), |
| 521 | "w_m": it.w_m, |
| 522 | "difficulty_band": it.difficulty_band, |
| 523 | "quality_band": it.quality_band, |
| 524 | "from_bank_true": ("bank_question:" + q.from_bank.key) if q.from_bank else None, |
| 525 | "text_diverged": bool(ctx.text_diverged.get(q.key, False)), |
| 526 | }) |
| 527 | return { |
| 528 | "seed": args.seed, |
| 529 | "t_now_ms": T.T_NOW, |
| 530 | "date_shift_days": args.date_shift_days, |
| 531 | "school_slug": C.SCHOOL_SLUG, |
| 532 | "scale": ctx.scale.name, |
| 533 | "calendar": { |
| 534 | "t1": [C.T1_START.isoformat(), C.T1_END.isoformat()], |
| 535 | "t2": [C.T2_START.isoformat(), C.T2_END.isoformat()], |
| 536 | "breaks": [[a.isoformat(), b.isoformat()] for a, b in C.BREAKS], |
| 537 | "holidays": [d.isoformat() for d in C.HOLIDAYS], |
| 538 | "flu_week": [C.FLU_WEEK[0].isoformat(), C.FLU_WEEK[1].isoformat()], |
| 539 | "teaching_weeks_elapsed": ctx.teaching_week_count, |
| 540 | "school_days_elapsed": len(T.past_school_days()), |
| 541 | }, |
| 542 | "students": students, |
| 543 | "items": items, |
| 544 | "pool_questions": ctx.pool_true_subject, |
| 545 | "answer_key_edits": ctx.answer_key_edits, |
| 546 | "deleted_bank_templates": ["bank_question:" + k |
| 547 | for k in ctx.deleted_bank_templates], |
| 548 | "broken_from_bank_questions": ["exam_question:" + k for k in ctx.broken_origin], |
| 549 | "ungraded_exams": ["exam:" + k for k in ctx.ungraded_exams], |
| 550 | } |
| 551 | |
| 552 | |
| 553 | def main(argv=None): |
| 554 | args = parse_args(argv) |
| 555 | generate(args) |
| 556 | return 0 |
| 557 | |
| 558 | |
| 559 | if __name__ == "__main__": |
| 560 | raise SystemExit(main()) |