3v324v23 commited on
Commit
6953a11
·
1 Parent(s): 96e58a0

Refactor scoring tests and add pronunciation rules documentation

Browse files

- Updated test_sign_in_guards_the_practice_endpoints to reflect changes in scoring logic for unmatched recordings.
- Enhanced test_spoken_questions_keep_expected_forms_server_side to assert additional properties of speech phrases.
- Introduced a new markdown file for pronunciation rules tailored for Hebrew speakers learning Palestinian Arabic, detailing articulation, dialect differences, and self-practice guidelines.

README.md CHANGED
@@ -273,7 +273,7 @@ A writing topic can be the class's homework like any topic, and is the one offer
273
 
274
  In the panel the teacher opens a class in five steps, a question each: its name (such as "מתחילים אוקטובר 2026"), its level (the class studies all the level's lessons; one not written yet opens to the class once it is), its students (ticked from the accounts the panel knows, or added by Google email, each with an optional nickname), its homework, and a summary to confirm, which says where all of it is changed later. That is the class's edit dialog ("עריכה", beside the class in the panel's list of classes): the name, the lessons one by one (by level: a level's box ticks all of it), the homework, and the students, a line each with the Google email and an optional nickname (`dana@gmail.com דנה`); the class is deleted there too. A student may be in several classes: after the opening screen the page asks which one they practise in now, and the learning path shows that class's lessons (a teacher, and anyone before the first class, sees every lesson and is not asked). The page shows the class under the app's name, and pressing it lists the class's students, with a button to move to another class; each student appears by their nickname in it or else their Google name (no addresses; `GET /api/classmates`). Once there is a class, only the classes' students and the teachers can sign in; before the first one, any Google account can.
275
 
276
- The panel's parts are chosen at its top (**תוכן** is described under "Content and videos"). **כיתות** lists the classes, each with its lessons, students and homework and its buttons: "עריכה", "מחיקה", and "התקדמות התלמידים", which moves to the other part; "כיתה חדשה" opens the steps above. **תלמידים** starts with one unique list of all students, with an "all students" filter and a filter for each class; every row names the student's classes. The all-students view uses the student's overall progress, and their page offers buttons for switching into each class's context. A class filter counts only what its students practised since the class was opened (its `created_at`), so a new class starts clean even when its students practised the same lessons before, in another class or in none; the students' own path keeps all they did. A recording that did not match the sentence on the screen (`unrelated`) is no try and has no score, but the panel shows it: "לא זוהו" beside the student, on their screen, and beside each topic it happened in. A class filter shows the class's figures, its lessons (each with the sentences the class finds hard: the class average of each student's best score under 70) and its students, with the same columns however many lessons the class has: the homework topic (when one is set), all the class's sentences, and the grade. Before the first class it shows every account that signed in. This replaces the former `ALLOWED_EMAILS`, which is no longer read. The lessons limit what the path shows; the sentences themselves stay public, as before.
277
 
278
  ### Content and videos
279
 
 
273
 
274
  In the panel the teacher opens a class in five steps, a question each: its name (such as "מתחילים אוקטובר 2026"), its level (the class studies all the level's lessons; one not written yet opens to the class once it is), its students (ticked from the accounts the panel knows, or added by Google email, each with an optional nickname), its homework, and a summary to confirm, which says where all of it is changed later. That is the class's edit dialog ("עריכה", beside the class in the panel's list of classes): the name, the lessons one by one (by level: a level's box ticks all of it), the homework, and the students, a line each with the Google email and an optional nickname (`dana@gmail.com דנה`); the class is deleted there too. A student may be in several classes: after the opening screen the page asks which one they practise in now, and the learning path shows that class's lessons (a teacher, and anyone before the first class, sees every lesson and is not asked). The page shows the class under the app's name, and pressing it lists the class's students, with a button to move to another class; each student appears by their nickname in it or else their Google name (no addresses; `GET /api/classmates`). Once there is a class, only the classes' students and the teachers can sign in; before the first one, any Google account can.
275
 
276
+ The panel's parts are chosen at its top (**תוכן** is described under "Content and videos"). **כיתות** lists the classes, each with its lessons, students and homework and its buttons: "עריכה", "מחיקה", and "התקדמות התלמידים", which moves to the other part; "כיתה חדשה" opens the steps above. **תלמידים** starts with one unique list of all students, with an "all students" filter and a filter for each class; every row names the student's classes. The all-students view uses the student's overall progress, and their page offers buttons for switching into each class's context. A class filter counts only what its students practised since the class was opened (its `created_at`), so a new class starts clean even when its students practised the same lessons before, in another class or in none; the students' own path keeps all they did. Every non-empty recording is a try and completes its exercise, including one that did not match the sentence on the screen (`unrelated`); only an empty recording remains incomplete. The panel still shows unmatched recordings diagnostically as "לא זוהו" beside the student and each topic. A class filter shows the class's figures, its lessons (each with the sentences the class finds hard: the class average of each student's best score under 70) and its students, with the same columns however many lessons the class has: the homework topic (when one is set), all the class's sentences, and the grade. Before the first class it shows every account that signed in. This replaces the former `ALLOWED_EMAILS`, which is no longer read. The lessons limit what the path shows; the sentences themselves stay public, as before.
277
 
278
  ### Content and videos
279
 
app/auth.py CHANGED
@@ -146,11 +146,11 @@ class SupabaseAuth:
146
  log.warning("attempt not recorded: %s", e)
147
 
148
  def attempts(self, token: str) -> list[dict]:
149
- """The student's attempts, newest first, without the "different sentence" ones: cat, phrase, score,
150
- created_at. Row-level security limits them to the token's student. What cannot be read is logged."""
151
  rows: list[dict] = []
152
  while len(rows) < MAX_ATTEMPTS:
153
- query = urllib.parse.urlencode({"select": "cat,phrase,score,created_at", "unrelated": "is.false",
154
  "order": "created_at.desc", "limit": PAGE, "offset": len(rows)})
155
  try:
156
  batch = self._get(f"/rest/v1/attempts?{query}", token, self.key)
@@ -514,8 +514,8 @@ class SupabaseAuth:
514
  return users
515
 
516
  def all_attempts(self) -> list[dict]:
517
- """Every student's attempts, as `attempts` gives one student's, each with its user_id, and with the "different
518
- sentence" ones too (unrelated = true): the panel shows them beside the progress they are not part of."""
519
  rows: list[dict] = []
520
  while len(rows) < MAX_CLASS_ATTEMPTS:
521
  query = urllib.parse.urlencode({"select": "user_id,cat,phrase,score,unrelated,created_at",
 
146
  log.warning("attempt not recorded: %s", e)
147
 
148
  def attempts(self, token: str) -> list[dict]:
149
+ """The student's non-empty scored recordings, newest first: cat, phrase, score, unrelated, created_at.
150
+ Row-level security limits them to the token's student. What cannot be read is logged."""
151
  rows: list[dict] = []
152
  while len(rows) < MAX_ATTEMPTS:
153
+ query = urllib.parse.urlencode({"select": "cat,phrase,score,unrelated,created_at",
154
  "order": "created_at.desc", "limit": PAGE, "offset": len(rows)})
155
  try:
156
  batch = self._get(f"/rest/v1/attempts?{query}", token, self.key)
 
514
  return users
515
 
516
  def all_attempts(self) -> list[dict]:
517
+ """Every student's attempts, as `attempts` gives one student's, each with its user_id. "Different sentence"
518
+ rows remain marked as unrelated for diagnostics, but count toward progress like every non-empty recording."""
519
  rows: list[dict] = []
520
  while len(rows) < MAX_CLASS_ATTEMPTS:
521
  query = urllib.parse.urlencode({"select": "user_id,cat,phrase,score,unrelated,created_at",
app/main.py CHANGED
@@ -288,9 +288,9 @@ def utc(stamp: str) -> datetime:
288
 
289
  def summary(rows: list[dict], texts: dict[int, dict] | None = None) -> dict:
290
  """One student's attempts summed up: best score and tries per phrase id, recordings (all, and of the last
291
- 7 days), days practised, time of the last one. A recording that did not match the sentence on the screen
292
- (unrelated) is a recording, on its day, but no try and no score: such ones are counted per phrase id in "missed",
293
- and all together in "unmatched"."""
294
  shown = {c["id"] for c in CATEGORIES + GAMES}
295
  ids = {(p["cat"], p["he"]): i for i, p in enumerate(PHRASES) if p["cat"] in shown}
296
  ids.update({(p["cat"], p["key"]): i for i, p in (texts or {}).items()}) # the lines of the teacher's texts (see `text_bank`)
@@ -310,7 +310,7 @@ def summary(rows: list[dict], texts: dict[int, dict] | None = None) -> dict:
310
  unmatched += 1
311
  if i is not None:
312
  missed[i] = missed.get(i, 0) + 1
313
- elif i is not None: # a sentence the page no longer lists still counts as a recording
314
  best[i] = max(best.get(i, 0), r["score"])
315
  tries[i] = tries.get(i, 0) + 1
316
  return {"best": best, "tries": tries, "missed": missed, "unmatched": unmatched, "recordings": len(rows), "days": len(days), "week": week,
@@ -1139,11 +1139,31 @@ def create_app(scorer: Scorer | None = None, tts: SawtakTTS | None = None,
1139
  "message": "לא נשמע מספיק דיבור. האזינו להקלטה ונסו שוב."}
1140
  result = SpeechEvaluationService(app.state.scorer).evaluate(
1141
  wav, phrase, diagnostics=bool(user and user["teacher"]))
1142
- if result.get("outcome") == "correct":
1143
- app.state.verb_game.sessions.finish(question_id)
1144
  result["level"] = question.mode
1145
  return result
1146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1147
  @app.get("/api/health")
1148
  def health():
1149
  s: Scorer = app.state.scorer
@@ -1244,7 +1264,12 @@ def create_app(scorer: Scorer | None = None, tts: SawtakTTS | None = None,
1244
  result = app.state.scorer.score(wav, phrase, refs)
1245
  if result.get("error"):
1246
  raise HTTPException(400, result["message"])
1247
- mime = (audio.content_type or "application/octet-stream").lower()
 
 
 
 
 
1248
  ext = AUDIO_EXT.get(mime.partition(";")[0].strip().rpartition("/")[2], "bin")
1249
  row = {"email": user["email"].lower(), "cat": phrase["cat"], "phrase": phrase.get("key", phrase["he"]),
1250
  "he": phrase["he"], "ar": result["variant"]["ar"], "ipa": result["variant"]["ipa"],
 
288
 
289
  def summary(rows: list[dict], texts: dict[int, dict] | None = None) -> dict:
290
  """One student's attempts summed up: best score and tries per phrase id, recordings (all, and of the last
291
+ 7 days), days practised, time of the last one. Every non-empty scored recording is a try and completes its
292
+ exercise, including one the recognizer labels unrelated. Those are still counted per phrase id in "missed"
293
+ and all together in "unmatched" as diagnostics."""
294
  shown = {c["id"] for c in CATEGORIES + GAMES}
295
  ids = {(p["cat"], p["he"]): i for i, p in enumerate(PHRASES) if p["cat"] in shown}
296
  ids.update({(p["cat"], p["key"]): i for i, p in (texts or {}).items()}) # the lines of the teacher's texts (see `text_bank`)
 
310
  unmatched += 1
311
  if i is not None:
312
  missed[i] = missed.get(i, 0) + 1
313
+ if i is not None: # a sentence the page no longer lists still counts as a recording
314
  best[i] = max(best.get(i, 0), r["score"])
315
  tries[i] = tries.get(i, 0) + 1
316
  return {"best": best, "tries": tries, "missed": missed, "unmatched": unmatched, "recordings": len(rows), "days": len(days), "week": week,
 
1139
  "message": "לא נשמע מספיק דיבור. האזינו להקלטה ונסו שוב."}
1140
  result = SpeechEvaluationService(app.state.scorer).evaluate(
1141
  wav, phrase, diagnostics=bool(user and user["teacher"]))
 
 
1142
  result["level"] = question.mode
1143
  return result
1144
 
1145
+ @app.post("/api/verb-game/flag")
1146
+ def verb_flag(question_id: str = Form(...), audio: UploadFile = File(...), note: str = Form(""),
1147
+ user: dict | None = Depends(signed_in)):
1148
+ """A tutor reports an incorrect judgement of a dynamic spoken verb answer."""
1149
+ if not user or not user["tutor"]:
1150
+ raise HTTPException(403, "tutors only")
1151
+ try:
1152
+ _question, phrase = app.state.verb_game.speech_phrase(question_id)
1153
+ except LookupError as e:
1154
+ raise HTTPException(410, str(e))
1155
+ data = audio.file.read(MAX_UPLOAD + 1)
1156
+ if len(data) > MAX_UPLOAD:
1157
+ raise HTTPException(413, "recording too long")
1158
+ try:
1159
+ wav = decode_audio(data)
1160
+ except ValueError:
1161
+ raise HTTPException(400, "could not decode audio")
1162
+ result = app.state.scorer.score(wav, phrase, [])
1163
+ if result.get("error"):
1164
+ raise HTTPException(400, result["message"])
1165
+ return save_flag(phrase, result, data, audio.content_type, note, user)
1166
+
1167
  @app.get("/api/health")
1168
  def health():
1169
  s: Scorer = app.state.scorer
 
1264
  result = app.state.scorer.score(wav, phrase, refs)
1265
  if result.get("error"):
1266
  raise HTTPException(400, result["message"])
1267
+ return save_flag(phrase, result, data, audio.content_type, note, user)
1268
+
1269
+ def save_flag(phrase: dict, result: dict, data: bytes, content_type: str | None,
1270
+ note: str, user: dict) -> dict:
1271
+ """Store a reviewed-score candidate from a bank phrase or a dynamic verb-game phrase."""
1272
+ mime = (content_type or "application/octet-stream").lower()
1273
  ext = AUDIO_EXT.get(mime.partition(";")[0].strip().rpartition("/")[2], "bin")
1274
  row = {"email": user["email"].lower(), "cat": phrase["cat"], "phrase": phrase.get("key", phrase["he"]),
1275
  "he": phrase["he"], "ar": result["variant"]["ar"], "ipa": result["variant"]["ipa"],
app/verb_game.py CHANGED
@@ -251,13 +251,14 @@ class VerbExerciseGenerator:
251
  else:
252
  verb, pron = self._target(verbs, mastery, recent)
253
  form = _form(verb, pron)
 
254
  variants = [(form["arabic"], ipa) for ipa in form["ipas"]]
255
  if level == 5:
256
  pron_ar, pron_ipa = PRONOUNS[0][3][0]
257
  variants += [(f"{pron_ar} {form['arabic']}", f"{pron_ipa} | {ipa}") for ipa in form["ipas"]]
258
- phrase = {"variants": variants}
 
259
  qid = self.sessions.put(StoredQuestion(level, verb, {}, time.monotonic(), phrase=phrase))
260
- p = PRONOUNS[pron]
261
  result = {
262
  "question_id": qid, "level": level, "tense": {"id": "past", "name": "עבר"},
263
  "verb": {"id": verb, "name": VERB_META[verb]["name"], "arabic": _form(verb, 3)["arabic"]},
 
251
  else:
252
  verb, pron = self._target(verbs, mastery, recent)
253
  form = _form(verb, pron)
254
+ p = PRONOUNS[pron]
255
  variants = [(form["arabic"], ipa) for ipa in form["ipas"]]
256
  if level == 5:
257
  pron_ar, pron_ipa = PRONOUNS[0][3][0]
258
  variants += [(f"{pron_ar} {form['arabic']}", f"{pron_ipa} | {ipa}") for ipa in form["ipas"]]
259
+ phrase = {"variants": variants, "cat": "verb-game", "key": f"{verb}:past:{p[0]}:spoken",
260
+ "he": f"{p[1]} · {VERB_META[verb]['name']} (עבר)"}
261
  qid = self.sessions.put(StoredQuestion(level, verb, {}, time.monotonic(), phrase=phrase))
 
262
  result = {
263
  "question_id": qid, "level": level, "tense": {"id": "past", "name": "עבר"},
264
  "verb": {"id": verb, "name": VERB_META[verb]["name"], "arabic": _form(verb, 3)["arabic"]},
app/workbook.py CHANGED
@@ -3,7 +3,7 @@
3
  A topic is a list of items, each written once as (Hebrew, Arabic), and is one of three kinds:
4
  "say": Hebrew -> Arabic. The usual flow: Hebrew prompt, the student says it in Arabic.
5
  "read": Arabic -> Hebrew. The page shows the transliteration, the student reads it aloud (and is
6
- scored on it) and checks the translation with "הצג תרגום".
7
  "write": the workbook's homework, sentences of the student's own. It has no items: the page shows its task
8
  (WRITING) and a line for each sentence. What is written is kept for the student (the Supabase table
9
  `writings`) and read by the teacher in the panel. Nothing is said or scored.
 
3
  A topic is a list of items, each written once as (Hebrew, Arabic), and is one of three kinds:
4
  "say": Hebrew -> Arabic. The usual flow: Hebrew prompt, the student says it in Arabic.
5
  "read": Arabic -> Hebrew. The page shows the transliteration, the student reads it aloud (and is
6
+ scored on it) and can reveal the translation one word at a time.
7
  "write": the workbook's homework, sentences of the student's own. It has no items: the page shows its task
8
  (WRITING) and a line for each sentence. What is written is kept for the student (the Supabase table
9
  `writings`) and read by the teacher in the panel. Nothing is said or scored.
static/assets/pronunciation-rules.md ADDED
@@ -0,0 +1,402 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # כללי הגייה לדוברי עברית: ערבית פלסטינית מדוברת
2
+
3
+ גרסה: 2026-10 · מיקום מוצע ב־repo: `docs/pronunciation-rules.md`
4
+
5
+ המסמך משמש שני קהלים:
6
+
7
+ | קהל | חלקים | איך משתמשים |
8
+ |---|---|---|
9
+ | תלמידים | חלקים 1–4 (מסומנים `audience: student`) | מוצגים באפליקציה כמדריך. בלי כתב ערבי, רק תעתיק עברי. |
10
+ | ה־scorer | חלקים 5–8 (מסומנים `audience: scorer`) | הבלוקים ` ```yaml ` נקראים בקוד ומגדירים מימושים מקובלים, שגיאות, חומרה, ספים ומקרים מיוחדים. |
11
+
12
+ עיקרון: **עירוני וכפרי תקינים שניהם.** ה־scorer לא מתקן הגייה שתקינה באחד הניבים, גם אם התלמיד מערבב ניבים באותו משפט.
13
+
14
+ ---
15
+
16
+ <!-- audience: student -->
17
+ ## 1. איך קוראים את התעתיק
18
+
19
+ | בתעתיק | איך הוגים | דוגמה |
20
+ |---|---|---|
21
+ | ח | ח לועית: מכווצים את הגרון ונושפים, בלי גירוד | חַמַּאם (שירותים) |
22
+ | ח' | ח עברית רגילה | ח'ֵיר (טוב) |
23
+ | ע | ע לועית עם קול | סַאעַה (שעה) |
24
+ | ע' | ר עברית רגילה (גרונית) | בַּשְתְע'ִל (אני עובד) |
25
+ | ר | ר מתגלגלת בקצה הלשון | כְּתִיר (הרבה) |
26
+ | צ | ס מודגשת, **לא** ts | צַבַּאח (בוקר) |
27
+ | ט | ת מודגשת | מַחַטַּה (תחנה) |
28
+ | ד' | ד מודגשת | בַּעְד' (אחד את השני) |
29
+ | ט' | ז מודגשת | ט'ֻהְר (צהריים) |
30
+ | ק | לפי הניב: עצירה בגרון (עיר) או כּ (כפר). ראו חלק 2 | אַהְוֶה / כַּהְוֶה (קפה) |
31
+ | ג' | כמו ב'ג'ינס', או ז' | פִנְג'אן (כוס קפה) |
32
+ | צ' | כמו ב'צ'יפס'. רק בניב הכפרי, במקום כּ | צ'ַלְבּ (כלב, בכפר) |
33
+ | ת' | th כמו ב־think. רק בניב הכפרי | ת'לַאת'ֶה (שלוש, בכפר) |
34
+ | ד״ | th כמו ב־this. רק בניב הכפרי | ד״ַהַבּ (זהב, בכפר) |
35
+ | ו | w, אף פעם לא v | וֵין (איפה) |
36
+ | ב | b, אף פעם לא v, גם בסוף מילה | שוֹבּ (חם) |
37
+ | פ | f, אף פעם לא p | פַאהֵם (מבין) |
38
+ | ה | נשיפה רכה, תמיד נשמעת | אַהְוֶה (קפה) |
39
+ | א | עצירה קצרה בגרון | אַהְלַא (שלום) |
40
+ | אַא, ִי, וּ | תנועה ארוכה: מחזיקים בערך כפול | כְּתִיר = ktiir |
41
+ | ּ (דגש) | עיצור כפול: מחזיקים אותו | חַמַּאם = ħam-maam |
42
+
43
+ ---
44
+
45
+ <!-- audience: student -->
46
+ ## 2. שני ניבים, שניהם נכונים
47
+
48
+ בערבית הפלסטינית יש שני ניבים עיקריים: **עירוני** (ירושלים, יפו, חיפה, שכם, רמאללה) ו**כפרי** (פַלַּאחִי, בכפרי הגדה והגליל). ההבדל העיקרי ביניהם הוא בחמש אותיות. האפליקציה מקבלת את שתי ההגיות, והמורה מחליט איזו מהן ללמד.
49
+
50
+ | אות | עירוני | כפרי | דוגמה: עיר / כפר |
51
+ |---|---|---|---|
52
+ | ק | עצירה בגרון (א) | כּ | אַהְוֶה / כַּהְוֶה (קפה) |
53
+ | כּ | כּ | בכפרים רבים צ' | כַּלְבּ / צ'ַלְבּ (כלב) |
54
+ | ת' | ת (ובמילים ספרותיות ס) | ת' (th כמו think) | תְלַאתֶה / ת'לַאת'ֶה (שלוש) |
55
+ | ד״ | ד (ובמילים ספרותיות ז) | ד״ (th כמו this) | דַהַבּ / ד״ַהַבּ (זהב) |
56
+ | ט' | ד' או ט' מודגשת | ט' מודגשת (th מודגשת) | ד'ֻהְר / ט'ֻהְר (צהריים) |
57
+
58
+ **דוגמה שמראה למה זה חשוב:** בכפר, קַלְבּ (לב) נהגה כַּלְבּ, וכַּלְבּ (כלב) נהגה צ'ַלְבּ. בעיר, אותן שתי מילים נהגות אַלְבּ (לב) וכַּלְבּ (כלב). כלומר "כַּלְבּ" פירושו לב בכפר וכלב בעיר. האפליקציה בודקת לפי המשפט שביקשו מכם לומר, ולכן שתי ההגיות יתקבלו במקומן.
59
+
60
+ **המלצה:** בחרו ניב אחד והיצמדו אליו. האפליקציה לא תוריד ציון על ערבוב, אבל דובר ילידי לא מערבב.
61
+
62
+ ---
63
+
64
+ <!-- audience: student -->
65
+ ## 3. כללים שהאפליקציה בודקת
66
+
67
+ הכללים מסודרים לפי כמה הטעות עולה לכם: **משנה משמעות** קודם, אחריו **מבטא עברי חזק**, ובסוף **דיוק**.
68
+
69
+ ### 3.1 ח לועית · משנה משמעות
70
+ - **למה זה קשה:** בעברית המודרנית ח ו־כ נהגות אותו דבר, בחיכוך של גב הלשון בחך הרך. בערבית זה צליל אחר (ח'), ושתי המילים בזוג שלמטה שונות לגמרי.
71
+ - **מה עושים:** גב הלשון לא נוגע בחך. מכווצים את שרירי הלוע, נמוך בגרון, ונושפים. הצליל יבש ונקי, בלי גירוד. אם מרגישים רטט או חיכוך מאחור בפה, יצאה ח' עברית.
72
+ - **זוג מינימלי:** חַאל (מצב) ≠ ח'ַאל (דוד מצד האם)
73
+ - **דוגמאות:** חַמַּאם (שירותים), מְנִיח (טוב), תִחְכִּי (לדבר)
74
+
75
+ ```yaml
76
+ id: pharyngeal_h
77
+ title: ח לועית
78
+ arabic: ح
79
+ checks:
80
+ - {target: ħ, heard: [χ, x], severity: 3, feedback: "נהגתה כמו ח עברית (חיכוך בחך). ח ערבית נוצרת בלוע: כווצו את הגרון ונשפו, בלי גירוד."}
81
+ - {target: ħ, heard: [h, ɦ], severity: 2, feedback: "נהגתה רכה מדי, כמו ה. צריך יותר כיווץ בלוע: לחישה חזקה מגרון צר."}
82
+ - {target: ħ, heard: ["_"], severity: 2, feedback: "לא נשמעה. ח היא עיצור מלא, גם באמצע מילה."}
83
+ ```
84
+
85
+ ### 3.2 ע לועית · משנה משמעות
86
+ - **למה זה קשה:** בעברית הישראלית ע נהגית כמו א, או נבלעת לגמרי.
87
+ - **מה עושים:** אותו כיווץ לוע של ח, אבל עם קול, כלומר מיתרי הקול רוטטים. אומרים 'אַ' כשהגרון מכווץ, בלי לסגור אותו לגמרי כמו ב־א.
88
+ - **זוג מינימלי:** עַלַם (דגל) ≠ אַלַם (כאב)
89
+ - **דוגמאות:** סַאעַה (שעה), בְּתִעְמַל (אתה עושה), אִלְעַרַבִּי (הערבי)
90
+
91
+ ```yaml
92
+ id: ayin
93
+ title: ע לועית
94
+ arabic: ع
95
+ checks:
96
+ - {target: ʕ, heard: [ʔ], severity: 3, feedback: "נהגתה כמו א (סגירה של הגרון). ע לא סוגרת את הגרון, היא מכווצת אותו, עם קול."}
97
+ - {target: ʕ, heard: ["_", a, aː], severity: 3, feedback: "נבלעה. ע נהגית תמיד, גם באמצע מילה."}
98
+ ```
99
+
100
+ ### 3.3 עיצורים מודגשים: צ, ט, ד', ט' · מבטא חזק
101
+ - **למה זה קשה:** בעברית אין עיצורים מודגשים: ט עברית זהה ל־ת. ו־צ עברית היא ts, צליל שלא קיים בערבית בכלל. בתעתיק, צ מסמנת ס מודגשת.
102
+ - **מה עושים:** אומרים ס, ת, ד או ז רגילים, ובאותו רגע מושכים את גב הלשון לאחור ומורידים מעט את הלסת. הסימן שהצלחתם: התנועה שאחרי העיצור נשמעת כהה ועמוקה (אָ במקום אַ).
103
+ - **זוגות מינימליים:** צֵיף (קיץ) ≠ סֵיף (חרב) · טִין (בוץ) ≠ תִין (תאנים)
104
+ - **דוגמאות:** צַבַּאח (בוקר), מַחַטַּה (תחנה), בַּעְד' (אחד את השני)
105
+
106
+ ```yaml
107
+ id: emphatics
108
+ title: עיצורים מודגשים
109
+ arabic: ص ط ض ظ
110
+ checks:
111
+ - {target: sˤ, heard: [s], severity: 2, feedback: "נהגתה כ־ס רגילה. משכו את גב הלשון לאחור: התנועה אחריה צריכה להישמע כהה."}
112
+ - {target: sˤ, heard: [ts, t͡s], severity: 2, feedback: "נהגתה כמו צ עברית (ts). בתעתיק צ היא ס מודגשת, בלי t בהתחלה."}
113
+ - {target: tˤ, heard: [t], severity: 2, feedback: "נהגתה כ־ת רגילה. ט ערבית מודגשת: גב הלשון לאחור, תנועה כהה."}
114
+ - {target: dˤ, heard: [d], severity: 2, feedback: "נהגתה כ־ד רגילה. ד' מודגשת: גב הלשון לאחור, תנועה כהה."}
115
+ - {target: ZH, heard: [z, ð, d], severity: 2, feedback: "נהגתה בלי הדגשה. ט' מודגשת: גב הלשון לאחור, תנועה כהה."}
116
+ ```
117
+
118
+ ### 3.4 ר מתגלגלת · מבטא חזק
119
+ - **למה זה קשה:** ר עברית נהגית בגרון, ובאוזן ערבית היא נשמעת כמו ע', שהיא עיצור אחר.
120
+ - **מה עושים:** ר ערבית נוצרת בקצה הלשון: נקישה אחת או גלגול מאחורי השיניים העליונות.
121
+ - **זוג מינימלי:** רֵים (צבייה) ≠ ע'ֵים (עננים)
122
+ - **דוגמאות:** כְּתִיר (הרבה), בֻּכְּרַה (מחר)
123
+
124
+ ```yaml
125
+ id: r_tap
126
+ title: ר מתגלגלת
127
+ arabic: ر
128
+ checks:
129
+ - {target: r, heard: [ʁ, ɣ, χ, x], severity: 2, feedback: "נהגתה גרונית, כמו ר עברית. ר ערבית מתגלגלת בקצה הלשון מאחורי השיניים."}
130
+ ```
131
+
132
+ ### 3.5 ע' היא ה־ר העברית שלכם · מבטא
133
+ - **למה זה קשה:** זה בעצם העיצור הקל ביותר לדוברי עברית, כי ע' היא כמעט בדיוק ה־ר העברית. הטעות הנפוצה היא לתקן יותר מדי: להגות אותה כ־ר מתגלגלת או כ־ג.
134
+ - **מה עושים:** אומרים ר עברית רגילה, מהגרון.
135
+ - **דוגמאות:** בַּשְתְע'ִל (אני עובד), ע'ַאלִי (יקר)
136
+
137
+ ```yaml
138
+ id: ghain
139
+ title: ע' היא ה־ר העברית שלכם
140
+ arabic: غ
141
+ checks:
142
+ - {target: ɣ, heard: [x, χ], severity: 1, feedback: "נהגתה בלי קול, כמו ח עברית. ע' קולית: אמרו ר עברית."}
143
+ - {target: ɣ, heard: [r, ɾ], severity: 2, feedback: "נהגתה כ־ר מתגלגלת. ע' היא ה־ר הגרונית של העברית."}
144
+ - {target: ɣ, heard: [g, ɡ], severity: 2, feedback: "נהגתה כ־ג. ע' היא חיכוך רציף, כמו ר עברית."}
145
+ ```
146
+
147
+ ### 3.6 ה נהגית תמיד · מבטא
148
+ - **למה זה קשה:** בעברית מדוברת ה נבלעת ברוב המקרים.
149
+ - **מה עושים:** נשיפה רכה וקצרה, גם באמצע מילה ולפני עיצור, ובלי שום חיכוך.
150
+ - **דוגמאות:** אַהְוֶה (קפה), פַאהֵם (מבין)
151
+
152
+ ```yaml
153
+ id: h
154
+ title: ה נהגית תמיד
155
+ arabic: ه
156
+ checks:
157
+ - {target: h, heard: ["_"], severity: 2, feedback: "נבלעה. ה נהגית תמיד, גם לפני עיצור."}
158
+ - {target: h, heard: [ħ, χ, x], severity: 1, feedback: "נהגתה חזקה מדי. ה היא נשיפה רכה בלבד."}
159
+ ```
160
+
161
+ ### 3.7 ו = w, ב = b, פ = f · מבטא
162
+ - **למה זה קשה:** התעתיק העברי עצמו מטעה. ו נקראת v, ב רפה נקראת v, ופ דגושה נקראת p. בערבית אין v ואין p.
163
+ - **מה עושים:**
164
+ - ו: מעגלים את השפתיים, w. וֵין נהגית wein ולא vein.
165
+ - ב: סוגרים את השפתיים, גם בסוף מילה. שוֹבּ ולא שוֹב.
166
+ - פ: תמיד f, גם בתחילת מילה. פִנְג'אן ולא פִּנְג'אן.
167
+ - **דוגמאות:** וֵין (איפה), אִלְחְסַאבּ (החשבון), פִנְג'אן (כוס קפה)
168
+
169
+ ```yaml
170
+ id: w
171
+ title: ו היא w
172
+ arabic: و
173
+ checks:
174
+ - {target: w, heard: [v, ʋ], severity: 2, feedback: "נהגתה v. בערבית אין v: עגלו את השפתיים, w."}
175
+ ---
176
+ id: b
177
+ title: ב היא תמיד b
178
+ arabic: ب
179
+ checks:
180
+ - {target: b, heard: [v, β], severity: 2, feedback: "נהגתה v. בערבית ב היא תמיד b, גם בסוף מילה."}
181
+ ---
182
+ id: f
183
+ title: פ היא תמיד f
184
+ arabic: ف
185
+ checks:
186
+ - {target: f, heard: [p], severity: 2, feedback: "נהגתה p. בערבית אין p: פ היא תמיד f."}
187
+ ```
188
+
189
+ ### 3.8 תנועה ארוכה · דיוק
190
+ - **למה זה קשה:** בעברית אין הבדל בין תנועה קצרה לארוכה. בערבית יש, והוא יכול לשנות משמעות.
191
+ - **מה עושים:** כשבתעתיק מופיעה א, י או ו אחרי התנועה, היא ארוכה ומחזיקים אותה בערך כפול.
192
+ - **זוג מינימלי:** עַלַם (דגל) ≠ עַאלַם (עולם)
193
+ - **דוגמאות:** כְּתִיר = ktiir, שוּף = shuuf (תראה)
194
+
195
+ הכלל משנה משמעות, אבל מקבל חומרה 1 כי מודל ההגאים מבחין באורך תנועה פחות טוב. ראו חלק 7.
196
+
197
+ ```yaml
198
+ id: vowel_length
199
+ title: תנועה קצרה ותנועה ארוכה
200
+ checks:
201
+ - {target: aː, heard: [a], severity: 1, feedback: "התנועה הארוכה נהגתה קצרה. החזיקו אותה בערך כפול."}
202
+ - {target: iː, heard: [i], severity: 1, feedback: "התנועה הארוכה נהגתה קצרה. החזיקו אותה בערך כפול."}
203
+ - {target: uː, heard: [u], severity: 1, feedback: "התנועה הארוכה נהגתה קצרה. החזיקו אותה בערך כפול."}
204
+ - {target: eː, heard: [e, i], severity: 1, feedback: "התנועה הארוכה נהגתה קצרה. החזיקו אותה בערך כפול."}
205
+ - {target: oː, heard: [o, u], severity: 1, feedback: "התנועה הארוכה נהגתה קצרה. החזיקו אותה בערך כפול."}
206
+ ```
207
+
208
+ ### 3.9 ג' ולא g · דיוק
209
+ - **מה עושים:** הוגים ג' כמו ב'ג'ינס', או ז' כמו ב'ז'קט'. שתיהן תקינות. ג רגילה (g) היא מבטא מצרי.
210
+ - **דוגמאות:** פִנְג'אן (כוס קפה), גַ'בַל או זַ'בַל (הר)
211
+
212
+ ```yaml
213
+ id: jim
214
+ title: ג' ולא g
215
+ arabic: ج
216
+ checks:
217
+ - {target: J, heard: [g, ɡ], severity: 1, feedback: "נהגתה g. בערבית פלסטינית ג' היא dʒ או ז'."}
218
+ ```
219
+
220
+ ---
221
+
222
+ <!-- audience: student -->
223
+ ## 4. כללים לתרגול עצמי
224
+
225
+ את הכללים האלה האפליקציה עוד לא בודקת. תרגלו אותם מול ההקלטות של המורה.
226
+
227
+ | כלל | מה עושים | דוגמה |
228
+ |---|---|---|
229
+ | **הטעם לא בסוף המילה** | בעברית הטעם בדרך כלל בסוף המילה. בערבית מטעימים את ההברה הסגורה האחרונה שאינה בסוף המילה. | מֻשְ־כִּ־לֶה = **MUSH**-kile, מַדְ־רַ־סֶה = **MAD**-rase, בְּתִעְ־מַל = b**tiʕ**-mal |
230
+ | **ה סופית היא תנועה** | ה בסוף מילה היא לא אות שקטה. ברוב המילים נהגית e, ואחרי ח, ע, ר ועיצור מודגש נהגית a. בכפר שומעים לפעמים i. | אַהְוֶה, מֻשְכִּלֶה, אבל סַאעַה, מַחַטַּה |
231
+ | **עיצור כפול** | מחזיקים את העיצור לפני שממשיכים. ההבדל משנה משמעות. | חַמַּאם (שירותים) ≠ חַמַאם (יונים) |
232
+ | **שני עיצורים בהתחלה** | לא מוסיפים תנועה בין העיצורים. | כְּתִיר = ktiir (לא katiir), מְנִיח = mniiħ |
233
+ | **אִל־ מתחברת** | לפני ת, ד, ס, צ, ש, ז, ר, נ, ט ו־ד' ה־ל נעלמת והעיצור מוכפל. | אִסְּסַאעַה (השעה), לא אִלְסַאעַה |
234
+
235
+ ---
236
+
237
+ <!-- audience: scorer -->
238
+ ## 5. סימונים: הגאים מופשטים
239
+
240
+ ב־`phrases.py` כל אות שנהגית אחרת בעיר ובכפר נכתבת **כסימן מופשט** ולא כהגה ממומש. ה־scorer פורש כל סימן לכל המימושים התקינים שלו. כך נפתרות הכפילויות בשני הכיוונים:
241
+ - **אות אחת, כמה הגאים:** ق יכולה להיות ʔ, k או q.
242
+ - **הגה אחד, כמה אותיות:** ʔ יכול לבוא מ־ق או מ־ء, k יכול לבוא מ־ك או מ־ق כפרית, t יכול לבוא מ־ت או מ־ث עירונית.
243
+
244
+ ```yaml
245
+ # archiphonemes: symbol in phrases.py -> realisations that are correct Palestinian speech
246
+ archiphonemes:
247
+ Q: {arabic: ق, urban: [ʔ], rural: [k], also_ok: [q], optional: [g]} # q: Druze / MSA. g: Bedouin, off by default
248
+ K: {arabic: ك, urban: [k], rural: [k, tʃ], also_ok: []}
249
+ TH: {arabic: ث, urban: [t, s], rural: [θ], also_ok: []} # s in learned words (ثقافة)
250
+ DH: {arabic: ذ, urban: [d, z], rural: [ð], also_ok: []} # z in learned words
251
+ ZH: {arabic: ظ, urban: [dˤ, zˤ], rural: [ðˤ], also_ok: []}
252
+ J: {arabic: ج, urban: [dʒ, ʒ], rural: [dʒ], also_ok: [ʒ]}
253
+ # plain phonemes are NOT expanded: ʔ written as ʔ (hamza) never accepts k; k written as k (from ك in urban-only words) uses K
254
+ dialects_enabled: [urban, rural]
255
+ optional_realisations_enabled: false # true -> Bedouin g for Q
256
+ ```
257
+
258
+ **דוגמאות לכתיבה ב־`phrases.py`:**
259
+
260
+ | עברית | כתיבה | יתקבל |
261
+ |---|---|---|
262
+ | קפה | `Q a h w e` | ʔahwe, kahwe, qahwe |
263
+ | כמה | `Q a d d eː ʃ` | ʔaddeeʃ, kaddeeʃ |
264
+ | כלב | `K a l b` | kalb, tʃalb |
265
+ | לב | `Q a l b` | ʔalb, kalb, qalb |
266
+ | הרבה | `K t iː r` (במקור ث) | ktiir, tʃtiir |
267
+ | שלוש | `TH l aː TH e` | tlaate, θlaaθe, וגם צירוף מעורב |
268
+ | שלום | `ʔ a h l a` (ء, לא ق) | ʔahla. ההגייה kahla **לא** מתקבלת |
269
+
270
+ **בניית המטרות:** לכל וריאנט במשפט ה־scorer בונה שתי מחרוזות מטרה, עירונית וכפרית. כל סימן מופשט ממומש במימוש הראשון שלו באותו ניב. כל מחרוזת עוברת יישור כפוי (forced alignment), ונבחרת זו שסבירותה גבוהה יותר. ערבוב ניבים בתוך משפט מטופל בשלב ההערכה, לפי סעיף 6.1.
271
+
272
+ ---
273
+
274
+ <!-- audience: scorer -->
275
+ ## 6. היוריסטיקות להערכת הגה
276
+
277
+ ### 6.1 מחלקות שקילות
278
+ לכל הגה מטרה שנבנה מסימן מופשט, ההסתברות היא **סכום ההסתברויות של כל המימושים התקינים** בחלון שלו, ולא רק של המימוש שנבחר ביישור.
279
+
280
+ לדוגמה, ב־`Q`: אם P(ʔ)=0.35 ו־P(k)=0.40, ה־GOP מחושב מול 0.75. התלמיד אמר מימוש תקין, גם אם ביישור נבחרה המחרוזת העירונית. הגה אחר מהמחלקה לא נחשב "מתחרה".
281
+
282
+ ### 6.2 סף לשגיאה
283
+ הגה מסומן כשגוי רק אם מתקיימים שלושה תנאים:
284
+ 1. הציון שלו נמוך מ־`flag_below`.
285
+ 2. המתחרה החזק ביותר בחלון **לא** במחלקת השקילות של המטרה.
286
+ 3. היחס בין המתחרה למטרה עובר את מרווח הביטחון של הזוג (`margin`).
287
+
288
+ לזוגות שהמודל מבלבל גם אצל דוברים ילידיים יש מרווח גדול יותר, כדי לא להעניש תלמיד על חולשה של המודל.
289
+
290
+ ```yaml
291
+ scoring:
292
+ flag_below: 50 # phoneme score 0..100
293
+ unrelated_ratio: 0.65 # normalised edit distance of greedy decode vs target -> "different sentence?"
294
+ accept_alt_min_post: 0.20 # an accepted realisation counts if its peak posterior >= this
295
+ accepted_score_floor: 90 # score given to a phoneme realised as an accepted alternative
296
+ deletion: {target_peak_max: 0.05, competitor_peak_max: 0.20}
297
+ vowel_weight: 0.5
298
+ severity_weight: {1: 1.0, 2: 1.5, 3: 2.0}
299
+ sentence_score: "0.5 * weighted_phoneme_mean + 0.5 * mean(word_min)" # a word scores as its weakest phoneme
300
+ bands: {excellent: 85, almost: 60} # below 60 = try again
301
+ max_tips: 3
302
+ # default margin: flag when log P(competitor) - log P(target) >= log(1.0), i.e. competitor at least as likely
303
+ margin_default: 0.0
304
+ margins: # stricter pairs (natural log ratio): competitor must exceed target by e^margin
305
+ - {target: [sˤ, tˤ, dˤ, zˤ, ðˤ], heard: [s, t, d, z, ð], margin: 0.7} # ~2x: emphasis is weak in the base model
306
+ - {target: [h], heard: ["_"], margin: 0.7} # h is short and quiet, natives reduce it too
307
+ - {target: [aː, iː, uː, eː, oː], heard: [a, i, u, e, o], margin: 1.1} # ~3x: length is unreliable from CTC posteriors
308
+ - {target: [ħ], heard: [h], margin: 0.4}
309
+ ```
310
+
311
+ ### 6.3 מקרים מיוחדים: לא מסמנים שגיאה
312
+
313
+ | # | מקרה | למה | כלל ל־scorer |
314
+ |---|---|---|---|
315
+ | 1 | ʔ (ء) נשמטת בתחילת משפט או אחרי תנועה | גם דוברים ילידיים משמיטים: ʔana → ana | מחיקה של ʔ מ־ء: לא מסמנים |
316
+ | 2 | ʔ מ־`Q` נשמטת בין תנועות | עצירה קצרה מאוד בדיבור מהיר | מחיקה: לא מסמנים. החלפה ב־k: תקינה (כפרי) |
317
+ | 3 | i ב־il־ נשמטת אחרי תנועה | חיבור מילים: fi l-beet | מחיקת i ראשונה במילה שמתחילה ב־il: לא מסמנים |
318
+ | 4 | אִל־ בלי התבוללות (il-saaʕa במקום is-saaʕa) | שגיאה קלה, וה־CTC לא מבחין בה באמינות | לא מסמנים. הכלל מופיע במדריך בלבד |
319
+ | 5 | e מול a ב־ة סופית, וגם i בכפר | שונות לגיטימית | בהגה אחרון במילה שמקורה ב־ة: {a, e, i} שקולים |
320
+ | 6 | o מול u בכינוי נסתר (בֵּיתוֹ/בֵּיתוּ) | הבדל בין ניבים | בהגה אחרון של כינוי: {o, u} שקולים |
321
+ | 7 | שונות בתנועות קצרות (miʃ/muʃ, i/e, u/o) | שונות בין דוברים | תנועות קצרות לא מסומנות לעולם, רק אורך דרך כלל 3.8 |
322
+ | 8 | eː/aj ו־oː/aw (בֵּית/בַּיְת) | הגייה כפרית או ותיקה | {eː, aj} ו־{oː, aw} שקולים |
323
+ | 9 | תנועה כהה ליד עיצור מודגש | זו בדיוק ההגייה הנכונה | אין כלל שמסמן איכות תנועה |
324
+ | 10 | עיצור כפול (חַמַּאם) | ה־CTC מכווץ כפילות לטוקן אחד, ואין מדידת משך אמינה | לא נבדק. הכלל מופיע במדריך בלבד |
325
+ | 11 | מתחרה שהוא ההגה השכן | מעבר בין הגאים (קו־ארטיקולציה) | המתחרה לא נלקח מבין תוויות ההגאים השכנים |
326
+ | 12 | ערבוב ניבים במשפט (אַהְוֶה + צ'ְתִיר) | שני המימושים תקינים | לא מורידים ציון. אפשר להציג למורה כ־`info: mixed_dialect` |
327
+ | 13 | g במקום `Q` | מבטא בדואי ודרומי | מתקבל רק אם `optional_realisations_enabled: true`. אחרת סומן כשגיאה כללית, חומרה 1 |
328
+ | 14 | חזרה, היסוס או התחלה מחדש | הפענוח רחוק מכל וריאנט | `unrelated=true`, ציון עד 30, בלי טיפים |
329
+ | 15 | הקלטה קצרה מדי או שקטה | אין חלון לכל הגה | `error: too_short` |
330
+
331
+ ---
332
+
333
+ <!-- audience: scorer -->
334
+ ## 7. מה ה־scorer יכול לזהות
335
+
336
+ הזיהוי תלוי באוצר ההגאים של המודל. ב־`/api/health` השדה `rules` מחזיר לכל כלל אם הוא ניתן לזיהוי. אם הגה מטרה לא קיים במודל וממופה להגה אחר, הכלל לא יסומן, כי לא תהיה לו שגיאה אפשרית. לדוגמה, אם sˤ ממופה ל־s, כלל ההדגשה לא יופעל.
337
+
338
+ | כלל | אמינות צפויה עם מודל הבסיס | הערה |
339
+ |---|---|---|
340
+ | ħ מול χ | גבוהה | שני ההגאים קיימים באוצר, והם רחוקים אקוסטית |
341
+ | ʕ מול ʔ | בינונית־גבוהה | |
342
+ | r מול ʁ | גבוהה | |
343
+ | w מול v, b מול v, f מול p | גבוהה | |
344
+ | עיצורים מודגשים | נמוכה־בינונית | לכן `margin` גבוה |
345
+ | ה נבלעת | בינונית | |
346
+ | אורך תנועה | נמוכה | חומרה 1 ו־`margin` גבוה |
347
+ | טעם, כפילות, התבוללות | לא ניתן | מופיעים במדריך בלבד |
348
+
349
+ ---
350
+
351
+ <!-- audience: scorer -->
352
+ ## 8. תוויות של הגאים שנשמעו
353
+
354
+ אלה התוויות בעברית שמוצגות לתלמיד במקום IPA. כל סמל שמופיע ב־`heard:` בכללים חייב להופיע כאן.
355
+
356
+ ```yaml
357
+ heard_labels:
358
+ "_": לא נשמע
359
+ χ: ח עברית
360
+ x: ח עברית
361
+ ʁ: ר עברית
362
+ ɣ: ר עברית
363
+ h: ה
364
+ ɦ: ה
365
+ ħ: ח
366
+ ʔ: א
367
+ k: כּ
368
+ q: ק
369
+ g: g
370
+ ɡ: g
371
+ v: v
372
+ ʋ: v
373
+ β: v
374
+ p: p
375
+ s: ס רגילה
376
+ t: ת רגילה
377
+ d: ד רגילה
378
+ z: ז רגילה
379
+ ð: th קולית
380
+ ts: צ עברית (ts)
381
+ t͡s: צ עברית (ts)
382
+ r: ר מתגלגלת
383
+ ɾ: ר מתגלגלת
384
+ a: תנועה קצרה
385
+ aː: תנועה
386
+ i: תנועה קצרה
387
+ u: תנו��ה קצרה
388
+ e: תנועה קצרה
389
+ o: תנועה קצרה
390
+ ```
391
+
392
+ ---
393
+
394
+ ## שינויים לעומת הקוד הנוכחי
395
+
396
+ הסעיפים האלה מתארים מה צריך לשנות ב־`app/rules.py`, ב־`app/scorer.py` וב־`app/phrases.py` כדי שיתאימו למסמך:
397
+
398
+ 1. **כלל ק עירונית (`qaf`) מבוטל כשגיאה.** בגלל ש־kahwe תקינה בכפר, ق הופכת למחלקת שקילות `Q`.
399
+ 2. **סימנים מופשטים חדשים:** `K`, `TH`, `DH`, `ZH` ו־`J` מצטרפים ל־`Q`. הפרופיל הבודד מוחלף ב־`dialects_enabled: [urban, rural]`.
400
+ 3. **ה־GOP מחושב מול סכום ההסתברויות של מחלקת השקילות** (סעיף 6.1), במקום ה"החלפה בדיעבד" הנוכחית, שבה ציון ההגה פשוט מוגבה ל־90.
401
+ 4. **מרווחים לפי זוג** (סעיף 6.2) ו**מקרים מיוחדים 1–8** הם חדשים.
402
+ 5. **תעתיק:** צ' (tʃ), ת' (θ) ו־ד״ (ð) נוספים. ד' נשארת ד מודגשת (ض).
static/index.html CHANGED
@@ -217,6 +217,7 @@ body.home:not(.manage) #toNow{bottom:76px} body.home:not(.manage) #logoutBtn{bot
217
  .verb-match{display:grid;grid-template-columns:1fr 1fr;gap:8px}.verb-match button{min-height:68px;padding:6px 8px 3px;border:2px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink);font:700 22px/1.7 var(--f-tr);letter-spacing:.03em}.verb-match button small{display:block;margin-top:-5px;font:500 17px/1.5 var(--f-tr);letter-spacing:.02em;color:var(--muted)}.verb-match button.selected{border-color:var(--amber);background:var(--amber-bg)}.verb-match button.done{border-color:var(--ok);opacity:.58}.verb-match .ar{display:block;margin-top:-4px;font:16px/1.25 var(--f-ar);letter-spacing:0}
218
  .verb-feedback{min-height:44px;padding:10px;border-radius:12px;text-align:center;font-weight:700}.verb-feedback:empty{padding:0}.verb-feedback.good{background:var(--ok-bg);color:var(--ok)}.verb-feedback.bad{background:var(--sumac-bg);color:var(--sumac)}
219
  .verb-speak{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center}.verb-mic{display:grid;place-items:center;width:86px;height:86px;border:0;border-radius:50%;background:var(--olive);color:var(--on-olive);font-size:34px;box-shadow:0 5px 0 var(--olive-deep);cursor:pointer}.verb-mic.live{background:var(--sumac);box-shadow:0 5px 0 color-mix(in srgb,var(--sumac) 70%,#000)}.verb-mic:disabled{opacity:.5}.verb-record-actions{display:flex;gap:8px}.verb-conversation{padding:14px;border-radius:16px;background:var(--olive-soft)}.verb-conversation .ar{font:700 27px/1.6 var(--f-ar)}.verb-answer{font:700 25px/1.7 var(--f-tr);letter-spacing:.035em}
 
220
  @media (max-width:410px){.verb-choices{grid-template-columns:1fr}.verb-shell{padding:12px}.verb-choice{min-height:62px}}
221
  .card{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:14px 16px;display:flex;flex-direction:column;gap:10px}
222
  .meta{display:flex;justify-content:space-between;color:var(--muted);font-size:13px;letter-spacing:.04em;font-variant-numeric:tabular-nums}
@@ -226,13 +227,30 @@ body.home:not(.manage) #toNow{bottom:76px} body.home:not(.manage) #logoutBtn{bot
226
  .prompt{font:400 clamp(22px,5vw,30px)/1.2 var(--f-display);text-wrap:balance;margin:0}
227
  .prompt .note{display:block;margin-top:4px;font:600 14px/1.3 var(--f-body);color:var(--muted)}
228
  .task{color:var(--muted);font-size:14px;margin:-6px 0 0}
229
- .hint{display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 16px;padding:6px 12px;border-radius:10px;background:var(--olive-soft)}
230
- .hint .tr{font:700 25px/1.75 var(--f-tr);letter-spacing:.035em}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  /* doubling mark: drawn here, because an Arabic shadda on a Hebrew letter has no glyph on Android */
232
  .sh{position:relative}
233
  .sh::before{content:"";position:absolute;top:-.04em;left:50%;transform:translateX(-50%);width:.44em;height:.26em;background:currentColor;-webkit-mask:var(--shadda) center/contain no-repeat;mask:var(--shadda) center/contain no-repeat}
234
  :root{--shadda:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1v2a2 2 0 0 0 4 0v-1M5 3a2 2 0 0 0 4 0v-2' fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E")}
235
- .hint .arline{font:500 16px/1.4 var(--f-ar);color:var(--muted)}
236
  .row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
237
  .btn{font:600 15px var(--f-body);border-radius:10px;padding:6px 12px;cursor:pointer;border:1px solid var(--line);background:transparent;color:var(--ink)}
238
  /* the card's action bar: one line on a phone, the same gap between all its buttons; the icon ones share the width left
@@ -243,7 +261,6 @@ body.home:not(.manage) #toNow{bottom:76px} body.home:not(.manage) #logoutBtn{bot
243
  .bar .btn.primary small{color:inherit}
244
  .bar .btn .ic{margin:2px 0 1px}
245
  .bar .cd{display:flex;align-items:center;gap:4px;line-height:1}
246
- .bar #answerBtn{flex:0 0 auto;padding:6px 12px}
247
  .btn.primary{background:var(--olive);border-color:var(--olive);color:var(--on-olive)}
248
  .btn:disabled{opacity:.45;cursor:default}
249
  :focus-visible{outline:3px solid var(--olive);outline-offset:2px}
@@ -606,10 +623,13 @@ dialog::backdrop{background:rgba(0,0,0,.45)}
606
  /* A coloured letter knows why (what the sound was heard as). The dotted line under it says it can be asked: the mouse
607
  resting on it shows the reason, and so does a tap, in a bubble over the letter. */
608
  .word .w span.bad{background:none;color:var(--sumac)} .word .w span.mid{background:none;color:var(--amber)} .word .w span.good{background:none;color:inherit}
609
- .sline .tr .why,.word .w .why{text-decoration:underline dotted;text-decoration-thickness:2px;text-underline-offset:5px;cursor:help;-webkit-tap-highlight-color:transparent}
610
  #whyTip{position:fixed;z-index:20;max-width:min(300px,calc(100vw - 16px));padding:8px 12px;border-radius:10px;background:var(--ink);color:var(--bg);font:500 14px/1.4 var(--f-body);box-shadow:0 6px 18px rgb(0 0 0/.3);pointer-events:none}
611
  #whyTip b{display:block;font-weight:700}
612
  #whyHint{margin:0}
 
 
 
613
  .card.storymode .prompt,.card.storymode .donehint,.card.storymode .task,.card.storymode .verdict,body.driving .story{display:none}
614
  body.driving .card.storymode .prompt{display:block}
615
  /* a story's quiz, once it ended: the grade is back on the card, over the mistakes made most often */
@@ -805,13 +825,13 @@ body.quiet :is(#mic,#playMine,#driveBtn,.phone-btn),body.driving :is(#quietBtn,#
805
  </div>
806
  <div class="donehint" id="heCheck" hidden></div>
807
 
808
- <div class="hint" id="hint" hidden>
809
- <div class="tr" id="hintTr"></div>
810
- <div class="arline" id="hintAr" lang="ar" hidden></div>
811
  </div>
812
 
813
  <section class="result" id="result" hidden>
814
- <div class="verdict"><span class="score" id="score"></span><span class="pill" id="pill"></span><div class="words" id="words"></div></div>
815
  <p class="sub" id="whyHint" hidden></p>
816
  <ul class="tips" id="tips"></ul>
817
  <div class="flag-box" id="flagBox" hidden>
@@ -828,7 +848,6 @@ body.quiet :is(#mic,#playMine,#driveBtn,.phone-btn),body.driving :is(#quietBtn,#
828
  <div class="row bar">
829
  <button class="btn" id="speakBtn" title="השמעת התשובה" aria-label="השמעת התשובה"><svg class="ic" aria-hidden="true"><use href="#i-sound"/></svg><small>השמע</small></button>
830
  <button class="btn" id="playMine" title="ההקלטה שלי, אחרי שהקלטתם" aria-label="ההקלטה שלי" disabled><svg class="ic" aria-hidden="true"><use href="#i-play"/></svg><small>הקלטה</small></button>
831
- <button class="btn" id="answerBtn">הצג תשובה</button>
832
  <button class="btn" id="prevBtn" title="המשפט הקודם" aria-label="המשפט הקודם"><svg class="ic" aria-hidden="true"><use href="#i-back"/></svg><small>הקודם</small></button>
833
  <button class="btn" id="nextBtn" title="המשפט הבא" aria-label="המשפט הבא"><span class="cd"><b id="nextLeft"></b><svg class="ic" aria-hidden="true"><use href="#i-next"/></svg></span><small>הבא</small></button>
834
  </div>
@@ -1767,15 +1786,21 @@ function recordWhenReady(){
1767
  function litWord(into,w){
1768
  for(const l of w.letters){
1769
  const sp=document.createElement("span"); if(l.score!=null) sp.className=band(l.score); setTr(sp,l.t);
1770
- if(l.why){ sp.classList.add("why"); sp.title=l.why+(l.tip?"\n"+l.tip:""); sp.onclick=e=>{ e.stopPropagation(); showWhy(sp,l); }; } // not the line's own click
 
 
 
 
 
1771
  into.append(sp);
1772
  }
1773
  }
1774
  const hasWhy=r=>r.words.some(w=>(w.letters||[]).some(l=>l.why));
1775
- const WHY_HINT=(matchMedia("(hover:none)").matches?"הקישו על":"עמדו עם העכבר על")+" אות עם קו מנוקד כדי לראות מה נשמע במקומה";
1776
  function showWhy(el,l){ // the bubble over the letter, or under it when there is no room above
1777
  const tip=$("whyTip"); tip.innerHTML=""; tip.append(mark("",l.why,"b")); if(l.tip) tip.append(mark("",l.tip));
1778
  tip.hidden=false;
 
1779
  const r=el.getBoundingClientRect(), w=tip.offsetWidth, h=tip.offsetHeight;
1780
  tip.style.left=Math.max(8,Math.min(innerWidth-w-8,r.left+r.width/2-w/2))+"px";
1781
  tip.style.top=(r.top-h-8>=8?r.top-h-8:r.bottom+8)+"px";
@@ -1787,9 +1812,10 @@ for(const ev of ["pointerdown","keydown"]) addEventListener(ev,()=>{
1787
  cancelAutoNext(); // any click or key keeps the sentence on screen
1788
  if(hePending!=null){ const id=hePending; hePending=null; if(cur&&cur.id===id&&heAudio) heAudio.play().catch(()=>{}); }
1789
  },true);
1790
- // A grade above AUTO_NEXT moves on by itself after the grade has been seen for a moment; show() then reads the next prompt.
 
1791
  // The seconds left are counted down on the "next sentence" button.
1792
- const AUTO_NEXT={above:80, seconds:3};
1793
  let autoNext=null;
1794
  function cancelAutoNext(){ clearInterval(autoNext); autoNext=null; $("nextLeft").textContent=""; }
1795
  function startAutoNext(){
@@ -1914,7 +1940,7 @@ $("quizBtn").onclick=()=>{
1914
  };
1915
  async function quizLine(r){ // a line was graded: its score on the line, and on to the next line that has none
1916
  const q=quiz, id=cur.id;
1917
- if(!r.unrelated) keepScore(id,r.score);
1918
  q.got[id]=storyLast[id]=r; drawStory();
1919
  if(q.over){ quizEnd(); return; } // it was still being graded when the quiz ended
1920
  const run=++storyRun; $("status").textContent=`ציון ${r.score}`;
@@ -1936,7 +1962,7 @@ function quizEnd(){
1936
  }
1937
  const top=Object.values(by).sort((a,b)=>b.n-a.n||a.low-b.low).slice(0,QUIZ.tips);
1938
  $("score").textContent=s; $("pill").className="pill "+(s>=EXCELLENT?"good":s>=60?"mid":"bad"); $("pill").textContent=s>=EXCELLENT?"מצוין":s>=60?"כמעט":"נסו שוב";
1939
- const words=$("words"), tips=$("tips"); words.innerHTML=""; tips.innerHTML="";
1940
  $("whyHint").hidden=true;
1941
  words.append(mark("sub",`ציון הבוחן · נאמרו ${said.length} מתוך ${topic.length} משפטים`));
1942
  top.forEach((g,k)=>{
@@ -1987,7 +2013,6 @@ function show(p,wait){ // wait: do not record until the microphone button is p
1987
  if(c.bubble){ $("prompt").style.animation="none"; void $("prompt").offsetWidth; $("prompt").style.animation=""; }
1988
  heStop(); $("heCheck").hidden=true; micZone.classList.toggle("two",heOk&&!!cur.read&&!story); // a phrase to read can be answered in Hebrew too
1989
  $("task").textContent=cur.read?heOk?HE_TASK:"קראו בקול ותרגמו לעברית":mine&&c.task||"איך אומרים את זה בערבית מדוברת?";
1990
- $("answerBtn").textContent=cur.read?"הצג תרגום":"הצג תשובה";
1991
  $("catName").textContent=c.name; $("lessonName").textContent=lessonName(LESSONS.find(l=>l.id===c.lesson));
1992
  // the number and the bar are the sentence's place in the topic, whatever the round holds
1993
  const b=best[cur.id], at=topic.indexOf(cur.id), hintBox=$("doneHint");
@@ -2000,7 +2025,7 @@ function show(p,wait){ // wait: do not record until the microphone button is p
2000
  const n=document.createElement("b"); n.textContent=b;
2001
  hintBox.className="donehint "+(b>=EXCELLENT?"good":b>=60?"mid":"bad"); hintBox.textContent="✓ כבר תרגלתם את המשפט הזה · הציון הטוב ביותר:"; hintBox.append(n);
2002
  }
2003
- $("hint").hidden=true; $("hintAr").hidden=true; $("result").hidden=true;
2004
  $("status").textContent=wait?IDLE:"ההקלטה מתחילה ונעצרת לבד";
2005
  drawSilent();
2006
  $("playMine").disabled=true; $("nextBtn").classList.remove("primary"); // the microphone is the one thing to press until there is a score
@@ -2042,7 +2067,7 @@ function drawSilent(){
2042
  if(picked.map(i=>bank[i]).join(" ")!==words.join(" ")){ line.classList.add("bad"); $("status").textContent="עוד לא. שנו את הסדר ונסו שוב"; return; }
2043
  done=true; draw();
2044
  silent[p.id]=1; store.set("ihki.silent",silent); if(daily) dailySaid.add(p.id);
2045
- $("status").textContent="נכון ✓"; $("answerBtn").onclick(); $("nextBtn").classList.add("primary");
2046
  };
2047
  draw(); box.append(line,pool,check);
2048
  }
@@ -2109,8 +2134,8 @@ $("heBtn").onclick=async()=>{
2109
  box.textContent="ציון התרגום:"; box.append(mark("",Math.round(share*100),"b")); // the grade: the share of the translation's words that were heard
2110
  box.append(` · ${share>=HE.pass?"✓ תרגום נכון":share>=HE.near?"כמעט":"לא דומה לתרגום"} · זוהו ${n} מתוך ${want.length} מילים · נשמע: ${said}`);
2111
  box.hidden=false;
2112
- if(share>=HE.pass){ $("answerBtn").onclick(); $("nextBtn").classList.add("primary"); status.textContent="נכון ✓ אפשר גם לקרוא את המשפט בערבית, לציון על ההגייה"; }
2113
- else status.textContent="נסו שוב, או לחצו על ״הצג תרגום״: ייתכן שניסחתם אחרת";
2114
  };
2115
  try{ r.start(); }catch{ heRec=null; $("status").textContent="זיהוי הדיבור בעברית לא זמין כרגע. נסו שוב, או קראו את המשפט בערבית"; return; }
2116
  btn.classList.add("live"); $("result").hidden=true; $("heCheck").hidden=true;
@@ -2265,24 +2290,14 @@ function render(r){
2265
  pill.className="pill "+(s>=85?"good":s>=60?"mid":"bad");
2266
  pill.textContent= r.unrelated ? "משפט אחר?" : s>=85?"מצוין": s>=60?"כמעט":"נסו שוב";
2267
 
2268
- const words=$("words"); words.innerHTML="";
2269
- const legend=document.createElement("div"); legend.className="word legend";
2270
- legend.innerHTML='<div class="w">הנכון</div><div class="h">נשמע</div>'; words.appendChild(legend);
2271
- for(const w of r.words){
2272
- const box=document.createElement("div"); box.className="word";
2273
- const ar=document.createElement("div"); // letter by letter, as a story's line; a result without letters colours the whole word
2274
- if(w.letters&&w.letters.length){ ar.className="w"; litWord(ar,w); } else{ ar.className="w "+band(w.score); setTr(ar,w.tr); }
2275
- const hd=document.createElement("div"); hd.className="h"; setTr(hd,w.heard_tr||"–");
2276
- const n=document.createElement("div"); n.className="n"; n.textContent=Math.round(w.score)+" · ";
2277
- const a=document.createElement("span"); a.lang="ar"; a.textContent=w.ar; n.append(a);
2278
- box.append(ar,hd,n); words.appendChild(box);
2279
- }
2280
 
2281
  $("whyHint").hidden=!hasWhy(r); $("whyHint").textContent=WHY_HINT;
2282
  const tips=$("tips"); tips.innerHTML="";
2283
  if(r.unrelated){
2284
  const li=document.createElement("li");
2285
- li.innerHTML='<span class="what">ההקלטה לא דומה למשפט הצפוי</span><span>ייתכן שבחרתם ניסוח אחר. לחצו "הצג תשובה" ונסו את הנוסח המוצע.</span>';
2286
  tips.appendChild(li);
2287
  }
2288
  for(const t of r.tips){
@@ -2306,14 +2321,12 @@ function render(r){
2306
  }
2307
  $("result").hidden=false;
2308
  if($("story").hidden) $("result").scrollIntoView({block:"nearest",behavior:"smooth"}); // a story keeps its lines in view
2309
- if(!r.unrelated){ // a "different sentence" is not practice; the server leaves it out too
2310
- keepScore(cur.id,s); if(daily) dailySaid.add(cur.id);
2311
- }
2312
  const story=!driving&&!$("story").hidden;
2313
  if(story){ storyLast[cur.id]=r; drawStory(); } // the line was said: its grade and its Arabic appear on it
2314
  if(story&&!(!r.unrelated&&s>STORY.pass)) storyRetry();
2315
  if(bubbleCat()){ bubbleOutcome(r); return; }
2316
- if(!driving&&!r.unrelated&&s>AUTO_NEXT.above){ // driving mode moves on by itself, in its own loop
2317
  $("status").textContent=`ציון ${s} ✓ עוברים למשפט הבא`;
2318
  startAutoNext();
2319
  }
@@ -2438,7 +2451,7 @@ async function startRec(auto){ // auto: started by the page for the sentence o
2438
  const res=await api("/api/score",{method:"POST",body:fd});
2439
  if(!res.ok) throw new Error(res.status);
2440
  const r=await res.json();
2441
- if(home&&!r.error&&!r.unrelated) keepScore(id,r.score); // graded after the student went back to the path: it still counts
2442
  if(home||cur.id!==id){ mic.disabled=false; finishRec({kind:"cancel"}); recordWhenReady(); return; } // moved on while it was analysed
2443
  render(r); mic.disabled=false; finishRec(r.error?{kind:"nospeech"}:{kind:"result",r});
2444
  }catch(err){ $("status").textContent="הניתוח נכשל ("+err.message+"). נסו שוב."; mic.disabled=false; finishRec({kind:"fail"}); }
@@ -2447,8 +2460,40 @@ async function startRec(auto){ // auto: started by the page for the sentence o
2447
  }
2448
  $("playMine").onclick=()=>{ if(myAudioUrl) new Audio(myAudioUrl).play(); };
2449
 
2450
- /* ---------- hint, answer, TTS ---------- */
2451
- $("answerBtn").onclick=()=>{ setTr($("hintTr"),cur.read?cur.he:cur.tr); $("hintAr").textContent=cur.ar; $("hint").hidden=false; $("hintAr").hidden=false; };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2452
  $("negBtn").onclick=()=>variation("negate");
2453
  $("conjBtn").onclick=()=>variation("conjugate");
2454
  function roundEnd(){ // a story stops at its end and waits for the microphone button; other topics go straight on
@@ -3570,9 +3615,16 @@ async function scoreVerbSpeech(blob,btn,status,actions){
3570
  const replay=mark("btn","▶ ההקלטה שלי","button");replay.onclick=()=>new Audio(verbRecordingUrl).play();const retry=mark("btn","ניסיון נוסף","button");retry.onclick=()=>{actions.replaceChildren();status.textContent="לחצו והקליטו שוב"};actions.append(replay,retry);
3571
  if(!r||!r.ok){status.textContent="הבדיקה אינה זמינה כרגע. ההקלטה לא נחשבה כטעות.";return}const result=await r.json(), feedback=$("verbFeedback");feedback.className="verb-feedback "+(result.outcome==="correct"?"good":result.outcome==="uncertain"?"":"bad");feedback.textContent=result.message||"נסו שוב";
3572
  const answer=mark("verb-answer",result.variant?.tr||"","div");if(result.variant?.ar){answer.append(mark("ar",result.variant.ar));const hear=mark("btn","🔊 תשובה","button");hear.onclick=()=>{const u=new SpeechSynthesisUtterance(result.variant.ar);u.lang="ar-PS";speechSynthesis.cancel();speechSynthesis.speak(u)};actions.append(hear)}actions.before(answer);
 
3573
  if(!result.counts_as_attempt)return;
3574
  const ok=result.outcome==="correct", elapsed=Math.round(performance.now()-verbStarted), key=q.mastery_key,m=verbMastery[key]||{attempts:0,correct:0,times:[],streak:0};m.attempts++;if(ok)m.correct++;m.streak=ok?(m.streak||0)+1:0;m.times=[...(m.times||[]),elapsed].slice(-20);m.median_ms=[...m.times].sort((a,b)=>a-b)[m.times.length>>1];m.last=new Date().toISOString();verbMastery[key]=m;const s=verbSummary[q.level]||{attempts:0,correct:0};s.attempts++;if(ok)s.correct++;verbSummary[q.level]=s;store.set("ihki.verbMastery",verbMastery);store.set("ihki.verbSummary",verbSummary);drawVerbLevels();
3575
- if(ok){verbQuestion=null;verbStreak++;verbN++;status.textContent="נכון ✓";setTimeout(nextVerb,1100)}
 
 
 
 
 
 
3576
  }
3577
 
3578
  function useLessons(ids){ // the path shows these lessons only (null: every one)
 
217
  .verb-match{display:grid;grid-template-columns:1fr 1fr;gap:8px}.verb-match button{min-height:68px;padding:6px 8px 3px;border:2px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink);font:700 22px/1.7 var(--f-tr);letter-spacing:.03em}.verb-match button small{display:block;margin-top:-5px;font:500 17px/1.5 var(--f-tr);letter-spacing:.02em;color:var(--muted)}.verb-match button.selected{border-color:var(--amber);background:var(--amber-bg)}.verb-match button.done{border-color:var(--ok);opacity:.58}.verb-match .ar{display:block;margin-top:-4px;font:16px/1.25 var(--f-ar);letter-spacing:0}
218
  .verb-feedback{min-height:44px;padding:10px;border-radius:12px;text-align:center;font-weight:700}.verb-feedback:empty{padding:0}.verb-feedback.good{background:var(--ok-bg);color:var(--ok)}.verb-feedback.bad{background:var(--sumac-bg);color:var(--sumac)}
219
  .verb-speak{display:flex;flex:1;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center}.verb-mic{display:grid;place-items:center;width:86px;height:86px;border:0;border-radius:50%;background:var(--olive);color:var(--on-olive);font-size:34px;box-shadow:0 5px 0 var(--olive-deep);cursor:pointer}.verb-mic.live{background:var(--sumac);box-shadow:0 5px 0 color-mix(in srgb,var(--sumac) 70%,#000)}.verb-mic:disabled{opacity:.5}.verb-record-actions{display:flex;gap:8px}.verb-conversation{padding:14px;border-radius:16px;background:var(--olive-soft)}.verb-conversation .ar{font:700 27px/1.6 var(--f-ar)}.verb-answer{font:700 25px/1.7 var(--f-tr);letter-spacing:.035em}
220
+ .verb-record-actions{flex-wrap:wrap;justify-content:center}.verb-report{border-color:var(--sumac);color:var(--sumac)}.verb-report:disabled{opacity:.65}
221
  @media (max-width:410px){.verb-choices{grid-template-columns:1fr}.verb-shell{padding:12px}.verb-choice{min-height:62px}}
222
  .card{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:14px 16px;display:flex;flex-direction:column;gap:10px}
223
  .meta{display:flex;justify-content:space-between;color:var(--muted);font-size:13px;letter-spacing:.04em;font-variant-numeric:tabular-nums}
 
227
  .prompt{font:400 clamp(22px,5vw,30px)/1.2 var(--f-display);text-wrap:balance;margin:0}
228
  .prompt .note{display:block;margin-top:4px;font:600 14px/1.3 var(--f-body);color:var(--muted)}
229
  .task{color:var(--muted);font-size:14px;margin:-6px 0 0}
230
+ .hint{display:flex;flex-direction:column;gap:5px;padding:9px 12px;border-radius:10px;background:var(--olive-soft)}
231
+ .hint-label{color:var(--muted);font-size:13px}
232
+ .word-reveals{display:flex}
233
+ .word-reveal{width:100%;min-height:2.65em;padding:5px 12px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--ink);box-shadow:0 2px 0 var(--line);font:700 23px/1.45 var(--f-tr);letter-spacing:.025em;cursor:pointer;overflow:hidden}
234
+ .word-reveal>*{filter:blur(6px);opacity:.62;transition:filter .16s ease,opacity .16s ease}
235
+ .word-reveal:hover{border-color:var(--olive);background:color-mix(in srgb,var(--surface) 72%,var(--olive-soft))}
236
+ .word-reveal.revealed{border-color:var(--olive);box-shadow:none}
237
+ .word-reveal.scored{cursor:default}
238
+ .word-reveal.revealed>*{filter:none;opacity:1}
239
+ .word-reveal .ar{display:block;margin-top:-4px;font:500 16px/1.25 var(--f-ar);letter-spacing:0;color:var(--muted)}
240
+ .word-reveal .he{display:block;margin-top:2px;font:600 17px/1.35 var(--f-body);letter-spacing:0;color:var(--muted)}
241
+ .word-reveal .analysis-key{display:block;margin-bottom:5px;font:600 12px/1.3 var(--f-body);letter-spacing:0;color:var(--muted)}
242
+ .word-reveal .analyzed{display:flex;flex-wrap:wrap;align-items:flex-start;gap:8px 12px}
243
+ .word-reveal .analysis-word{display:grid;grid-template-rows:auto auto;justify-items:center;min-width:2em}
244
+ .word-reveal .analysis-word .expected{font:700 23px/1.45 var(--f-tr);letter-spacing:.025em}
245
+ .word-reveal .analysis-word .heard-word{width:100%;margin-top:2px;padding-top:3px;border-top:1px solid var(--line);font:600 17px/1.4 var(--f-tr);letter-spacing:.02em;color:var(--muted);text-align:center}
246
+ .word-reveal .analysis-word .heard-word.empty{font-family:var(--f-body);font-weight:500}
247
+ .word-reveal .analyzed .bad{color:var(--sumac)}
248
+ .word-reveal .analyzed .mid{color:var(--amber)}
249
+ .word-reveal .analyzed .good{color:inherit}
250
  /* doubling mark: drawn here, because an Arabic shadda on a Hebrew letter has no glyph on Android */
251
  .sh{position:relative}
252
  .sh::before{content:"";position:absolute;top:-.04em;left:50%;transform:translateX(-50%);width:.44em;height:.26em;background:currentColor;-webkit-mask:var(--shadda) center/contain no-repeat;mask:var(--shadda) center/contain no-repeat}
253
  :root{--shadda:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1v2a2 2 0 0 0 4 0v-1M5 3a2 2 0 0 0 4 0v-2' fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E")}
 
254
  .row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
255
  .btn{font:600 15px var(--f-body);border-radius:10px;padding:6px 12px;cursor:pointer;border:1px solid var(--line);background:transparent;color:var(--ink)}
256
  /* the card's action bar: one line on a phone, the same gap between all its buttons; the icon ones share the width left
 
261
  .bar .btn.primary small{color:inherit}
262
  .bar .btn .ic{margin:2px 0 1px}
263
  .bar .cd{display:flex;align-items:center;gap:4px;line-height:1}
 
264
  .btn.primary{background:var(--olive);border-color:var(--olive);color:var(--on-olive)}
265
  .btn:disabled{opacity:.45;cursor:default}
266
  :focus-visible{outline:3px solid var(--olive);outline-offset:2px}
 
623
  /* A coloured letter knows why (what the sound was heard as). The dotted line under it says it can be asked: the mouse
624
  resting on it shows the reason, and so does a tap, in a bubble over the letter. */
625
  .word .w span.bad{background:none;color:var(--sumac)} .word .w span.mid{background:none;color:var(--amber)} .word .w span.good{background:none;color:inherit}
626
+ .sline .tr .why,.word .w .why,.word-reveal .why{text-decoration:underline dotted;text-decoration-thickness:2px;text-underline-offset:5px;cursor:help;-webkit-tap-highlight-color:transparent}
627
  #whyTip{position:fixed;z-index:20;max-width:min(300px,calc(100vw - 16px));padding:8px 12px;border-radius:10px;background:var(--ink);color:var(--bg);font:500 14px/1.4 var(--f-body);box-shadow:0 6px 18px rgb(0 0 0/.3);pointer-events:none}
628
  #whyTip b{display:block;font-weight:700}
629
  #whyHint{margin:0}
630
+ @media (hover:none),(max-width:520px){
631
+ #whyTip{inset:auto 8px calc(10px + env(safe-area-inset-bottom));max-width:none;text-align:center}
632
+ }
633
  .card.storymode .prompt,.card.storymode .donehint,.card.storymode .task,.card.storymode .verdict,body.driving .story{display:none}
634
  body.driving .card.storymode .prompt{display:block}
635
  /* a story's quiz, once it ended: the grade is back on the card, over the mistakes made most often */
 
825
  </div>
826
  <div class="donehint" id="heCheck" hidden></div>
827
 
828
+ <div class="hint" id="hint">
829
+ <span class="hint-label" id="hintLabel">לחצו על הכרטיסייה כדי לגלות את התשובה</span>
830
+ <div class="word-reveals" id="wordReveals"></div>
831
  </div>
832
 
833
  <section class="result" id="result" hidden>
834
+ <div class="verdict"><span class="score" id="score"></span><span class="pill" id="pill"></span><div class="words" id="words" hidden></div></div>
835
  <p class="sub" id="whyHint" hidden></p>
836
  <ul class="tips" id="tips"></ul>
837
  <div class="flag-box" id="flagBox" hidden>
 
848
  <div class="row bar">
849
  <button class="btn" id="speakBtn" title="השמעת התשובה" aria-label="השמעת התשובה"><svg class="ic" aria-hidden="true"><use href="#i-sound"/></svg><small>השמע</small></button>
850
  <button class="btn" id="playMine" title="ההקלטה שלי, אחרי שהקלטתם" aria-label="ההקלטה שלי" disabled><svg class="ic" aria-hidden="true"><use href="#i-play"/></svg><small>הקלטה</small></button>
 
851
  <button class="btn" id="prevBtn" title="המשפט הקודם" aria-label="המשפט הקודם"><svg class="ic" aria-hidden="true"><use href="#i-back"/></svg><small>הקודם</small></button>
852
  <button class="btn" id="nextBtn" title="המשפט הבא" aria-label="המשפט הבא"><span class="cd"><b id="nextLeft"></b><svg class="ic" aria-hidden="true"><use href="#i-next"/></svg></span><small>הבא</small></button>
853
  </div>
 
1786
  function litWord(into,w){
1787
  for(const l of w.letters){
1788
  const sp=document.createElement("span"); if(l.score!=null) sp.className=band(l.score); setTr(sp,l.t);
1789
+ if(l.why){
1790
+ sp.classList.add("why"); sp.title=l.why+(l.tip?"\n"+l.tip:""); sp.tabIndex=0; sp.setAttribute("role","button");
1791
+ sp.setAttribute("aria-label",l.why+(l.tip?". "+l.tip:""));
1792
+ sp.onclick=e=>{ e.stopPropagation(); showWhy(sp,l); }; // not the line's own click
1793
+ sp.onkeydown=e=>{ if(e.key==="Enter"||e.key===" "){ e.preventDefault(); e.stopPropagation(); showWhy(sp,l); } };
1794
+ }
1795
  into.append(sp);
1796
  }
1797
  }
1798
  const hasWhy=r=>r.words.some(w=>(w.letters||[]).some(l=>l.why));
1799
+ const WHY_HINT=(matchMedia("(hover:none)").matches?"הקישו על":"עמדו עם העכבר על")+" הגה עם קו מנוקד כדי לקבל הסבר";
1800
  function showWhy(el,l){ // the bubble over the letter, or under it when there is no room above
1801
  const tip=$("whyTip"); tip.innerHTML=""; tip.append(mark("",l.why,"b")); if(l.tip) tip.append(mark("",l.tip));
1802
  tip.hidden=false;
1803
+ if(matchMedia("(hover:none), (max-width:520px)").matches){ tip.style.left=tip.style.top=""; return; }
1804
  const r=el.getBoundingClientRect(), w=tip.offsetWidth, h=tip.offsetHeight;
1805
  tip.style.left=Math.max(8,Math.min(innerWidth-w-8,r.left+r.width/2-w/2))+"px";
1806
  tip.style.top=(r.top-h-8>=8?r.top-h-8:r.bottom+8)+"px";
 
1812
  cancelAutoNext(); // any click or key keeps the sentence on screen
1813
  if(hePending!=null){ const id=hePending; hePending=null; if(cur&&cur.id===id&&heAudio) heAudio.play().catch(()=>{}); }
1814
  },true);
1815
+ // A grade at AUTO_NEXT.minimum or above moves on by itself after the grade has been seen for a moment; lower grades
1816
+ // stay on the card until the student presses "next", so there is time to inspect the pronunciation feedback.
1817
  // The seconds left are counted down on the "next sentence" button.
1818
+ const AUTO_NEXT={minimum:85, seconds:3};
1819
  let autoNext=null;
1820
  function cancelAutoNext(){ clearInterval(autoNext); autoNext=null; $("nextLeft").textContent=""; }
1821
  function startAutoNext(){
 
1940
  };
1941
  async function quizLine(r){ // a line was graded: its score on the line, and on to the next line that has none
1942
  const q=quiz, id=cur.id;
1943
+ keepScore(id,r.score); // every recording with speech completes the line; empty recordings never reach this function
1944
  q.got[id]=storyLast[id]=r; drawStory();
1945
  if(q.over){ quizEnd(); return; } // it was still being graded when the quiz ended
1946
  const run=++storyRun; $("status").textContent=`ציון ${r.score}`;
 
1962
  }
1963
  const top=Object.values(by).sort((a,b)=>b.n-a.n||a.low-b.low).slice(0,QUIZ.tips);
1964
  $("score").textContent=s; $("pill").className="pill "+(s>=EXCELLENT?"good":s>=60?"mid":"bad"); $("pill").textContent=s>=EXCELLENT?"מצוין":s>=60?"כמעט":"נסו שוב";
1965
+ const words=$("words"), tips=$("tips"); words.innerHTML=""; words.hidden=false; tips.innerHTML="";
1966
  $("whyHint").hidden=true;
1967
  words.append(mark("sub",`ציון הבוחן · נאמרו ${said.length} מתוך ${topic.length} משפטים`));
1968
  top.forEach((g,k)=>{
 
2013
  if(c.bubble){ $("prompt").style.animation="none"; void $("prompt").offsetWidth; $("prompt").style.animation=""; }
2014
  heStop(); $("heCheck").hidden=true; micZone.classList.toggle("two",heOk&&!!cur.read&&!story); // a phrase to read can be answered in Hebrew too
2015
  $("task").textContent=cur.read?heOk?HE_TASK:"קראו בקול ותרגמו לעברית":mine&&c.task||"איך אומרים את זה בערבית מדוברת?";
 
2016
  $("catName").textContent=c.name; $("lessonName").textContent=lessonName(LESSONS.find(l=>l.id===c.lesson));
2017
  // the number and the bar are the sentence's place in the topic, whatever the round holds
2018
  const b=best[cur.id], at=topic.indexOf(cur.id), hintBox=$("doneHint");
 
2025
  const n=document.createElement("b"); n.textContent=b;
2026
  hintBox.className="donehint "+(b>=EXCELLENT?"good":b>=60?"mid":"bad"); hintBox.textContent="✓ כבר תרגלתם את המשפט הזה · הציון הטוב ביותר:"; hintBox.append(n);
2027
  }
2028
+ drawWordReveals(); $("words").hidden=true; $("result").hidden=true;
2029
  $("status").textContent=wait?IDLE:"ההקלטה מתחילה ונעצרת לבד";
2030
  drawSilent();
2031
  $("playMine").disabled=true; $("nextBtn").classList.remove("primary"); // the microphone is the one thing to press until there is a score
 
2067
  if(picked.map(i=>bank[i]).join(" ")!==words.join(" ")){ line.classList.add("bad"); $("status").textContent="עוד לא. שנו את הסדר ונסו שוב"; return; }
2068
  done=true; draw();
2069
  silent[p.id]=1; store.set("ihki.silent",silent); if(daily) dailySaid.add(p.id);
2070
+ $("status").textContent="נכון ✓"; revealAllWords(); $("nextBtn").classList.add("primary");
2071
  };
2072
  draw(); box.append(line,pool,check);
2073
  }
 
2134
  box.textContent="ציון התרגום:"; box.append(mark("",Math.round(share*100),"b")); // the grade: the share of the translation's words that were heard
2135
  box.append(` · ${share>=HE.pass?"✓ תרגום נכון":share>=HE.near?"כמעט":"לא דומה לתרגום"} · זוהו ${n} מתוך ${want.length} מילים · נשמע: ${said}`);
2136
  box.hidden=false;
2137
+ if(share>=HE.pass){ revealAllWords(); $("nextBtn").classList.add("primary"); status.textContent="נכון ✓ אפשר גם לקרוא את המשפט בערבית, לציון על ההגייה"; }
2138
+ else status.textContent="נסו שוב, או גלו את מילות התרגום: ייתכן שניסחתם אחרת";
2139
  };
2140
  try{ r.start(); }catch{ heRec=null; $("status").textContent="זיהוי הדיבור בעברית לא זמין כרגע. נסו שוב, או קראו את המשפט בערבית"; return; }
2141
  btn.classList.add("live"); $("result").hidden=true; $("heCheck").hidden=true;
 
2290
  pill.className="pill "+(s>=85?"good":s>=60?"mid":"bad");
2291
  pill.textContent= r.unrelated ? "משפט אחר?" : s>=85?"מצוין": s>=60?"כמעט":"נסו שוב";
2292
 
2293
+ $("words").hidden=true;
2294
+ drawAnalyzedAnswer(r);
 
 
 
 
 
 
 
 
 
 
2295
 
2296
  $("whyHint").hidden=!hasWhy(r); $("whyHint").textContent=WHY_HINT;
2297
  const tips=$("tips"); tips.innerHTML="";
2298
  if(r.unrelated){
2299
  const li=document.createElement("li");
2300
+ li.innerHTML='<span class="what">ההקלטה לא דומה למשפט הצפוי</span><span>ייתכן שבחרתם ניסוח אחר. גלו את מילות התשובה ונסו את הנוסח המוצע.</span>';
2301
  tips.appendChild(li);
2302
  }
2303
  for(const t of r.tips){
 
2321
  }
2322
  $("result").hidden=false;
2323
  if($("story").hidden) $("result").scrollIntoView({block:"nearest",behavior:"smooth"}); // a story keeps its lines in view
2324
+ keepScore(cur.id,s); if(daily) dailySaid.add(cur.id); // only an empty recording is not practice
 
 
2325
  const story=!driving&&!$("story").hidden;
2326
  if(story){ storyLast[cur.id]=r; drawStory(); } // the line was said: its grade and its Arabic appear on it
2327
  if(story&&!(!r.unrelated&&s>STORY.pass)) storyRetry();
2328
  if(bubbleCat()){ bubbleOutcome(r); return; }
2329
+ if(!driving&&!r.unrelated&&s>=AUTO_NEXT.minimum){ // driving mode moves on by itself, in its own loop
2330
  $("status").textContent=`ציון ${s} ✓ עוברים למשפט הבא`;
2331
  startAutoNext();
2332
  }
 
2451
  const res=await api("/api/score",{method:"POST",body:fd});
2452
  if(!res.ok) throw new Error(res.status);
2453
  const r=await res.json();
2454
+ if(home&&!r.error) keepScore(id,r.score); // graded after the student went back to the path: it still counts
2455
  if(home||cur.id!==id){ mic.disabled=false; finishRec({kind:"cancel"}); recordWhenReady(); return; } // moved on while it was analysed
2456
  render(r); mic.disabled=false; finishRec(r.error?{kind:"nospeech"}:{kind:"result",r});
2457
  }catch(err){ $("status").textContent="הניתוח נכשל ("+err.message+"). נסו שוב."; mic.disabled=false; finishRec({kind:"fail"}); }
 
2460
  }
2461
  $("playMine").onclick=()=>{ if(myAudioUrl) new Audio(myAudioUrl).play(); };
2462
 
2463
+ /* ---------- word-by-word answer, TTS ---------- */
2464
+ function revealWord(button){
2465
+ if(button.classList.contains("revealed")) return;
2466
+ button.classList.add("revealed"); button.removeAttribute("aria-label");
2467
+ for(const child of button.children) child.removeAttribute("aria-hidden");
2468
+ }
2469
+ function revealAllWords(){ for(const button of $("wordReveals").children) revealWord(button); }
2470
+ function drawAnalyzedAnswer(r){
2471
+ const card=$("wordReveals").firstElementChild; if(!card) return;
2472
+ const main=mark("analyzed","","span");
2473
+ r.words.forEach(word=>{
2474
+ const pair=mark("analysis-word","","span"), expected=mark("expected","","span");
2475
+ if(word.letters&&word.letters.length) litWord(expected,word);
2476
+ else{ expected.classList.add(band(word.score)); setTr(expected,word.tr); }
2477
+ const heard=mark(`heard-word${word.heard_tr?"":" empty"}`,"","span"); setTr(heard,word.heard_tr||"לא זוהה");
2478
+ pair.append(expected,heard); main.append(pair);
2479
+ });
2480
+ card.replaceChildren(mark("analysis-key","למעלה: התשובה · למטה: המערכת שמעה","small"),main);
2481
+ card.append(mark("ar",cur.ar,"small"));
2482
+ if(cur.read) card.append(mark("he",cur.he,"small"));
2483
+ card.classList.add("revealed","scored"); card.removeAttribute("role"); card.removeAttribute("tabindex"); card.removeAttribute("aria-label"); card.onclick=null; card.onkeydown=null;
2484
+ $("hintLabel").textContent=hasWhy(r)?WHY_HINT:"התשובה וניתוח ההגייה";
2485
+ }
2486
+ function drawWordReveals(){
2487
+ const box=$("wordReveals"), answer=(cur.read?cur.he:cur.tr).trim();
2488
+ box.replaceChildren();
2489
+ const button=mark("word-reveal","","div"); button.setAttribute("role","button"); button.tabIndex=0;
2490
+ button.setAttribute("aria-label",cur.read?"גלו את התרגום לעברית":"גלו את התרגום לערבית");
2491
+ const main=mark("",answer); setTr(main,answer); main.setAttribute("aria-hidden","true"); button.append(main);
2492
+ if(!cur.read){ const ar=mark("ar",cur.ar,"small"); ar.setAttribute("aria-hidden","true"); button.append(ar); }
2493
+ button.onclick=()=>revealWord(button); box.append(button);
2494
+ button.onkeydown=e=>{ if(e.key==="Enter"||e.key===" "){ e.preventDefault(); revealWord(button); } };
2495
+ $("hintLabel").textContent=cur.read?"לחצו על הכרטיסייה כדי לגלות את התרגום לעברית":"לחצו על הכרטיסייה כדי לגלות את התרגום לערבית";
2496
+ }
2497
  $("negBtn").onclick=()=>variation("negate");
2498
  $("conjBtn").onclick=()=>variation("conjugate");
2499
  function roundEnd(){ // a story stops at its end and waits for the microphone button; other topics go straight on
 
3615
  const replay=mark("btn","▶ ההקלטה שלי","button");replay.onclick=()=>new Audio(verbRecordingUrl).play();const retry=mark("btn","ניסיון נוסף","button");retry.onclick=()=>{actions.replaceChildren();status.textContent="לחצו והקליטו שוב"};actions.append(replay,retry);
3616
  if(!r||!r.ok){status.textContent="הבדיקה אינה זמינה כרגע. ההקלטה לא נחשבה כטעות.";return}const result=await r.json(), feedback=$("verbFeedback");feedback.className="verb-feedback "+(result.outcome==="correct"?"good":result.outcome==="uncertain"?"":"bad");feedback.textContent=result.message||"נסו שוב";
3617
  const answer=mark("verb-answer",result.variant?.tr||"","div");if(result.variant?.ar){answer.append(mark("ar",result.variant.ar));const hear=mark("btn","🔊 תשובה","button");hear.onclick=()=>{const u=new SpeechSynthesisUtterance(result.variant.ar);u.lang="ar-PS";speechSynthesis.cancel();speechSynthesis.speak(u)};actions.append(hear)}actions.before(answer);
3618
+ if(TUTOR){const report=mark("btn verb-report","🚩 דווחו על טעות בבדיקה","button");report.title="ההקלטה, שתי המילים הצפויות ומה שהמודל שמע יישלחו לניטור";report.onclick=()=>reportVerbScore(q.question_id,blob,report,status);actions.append(report)}
3619
  if(!result.counts_as_attempt)return;
3620
  const ok=result.outcome==="correct", elapsed=Math.round(performance.now()-verbStarted), key=q.mastery_key,m=verbMastery[key]||{attempts:0,correct:0,times:[],streak:0};m.attempts++;if(ok)m.correct++;m.streak=ok?(m.streak||0)+1:0;m.times=[...(m.times||[]),elapsed].slice(-20);m.median_ms=[...m.times].sort((a,b)=>a-b)[m.times.length>>1];m.last=new Date().toISOString();verbMastery[key]=m;const s=verbSummary[q.level]||{attempts:0,correct:0};s.attempts++;if(ok)s.correct++;verbSummary[q.level]=s;store.set("ihki.verbMastery",verbMastery);store.set("ihki.verbSummary",verbSummary);drawVerbLevels();
3621
+ if(ok){verbQuestion=null;verbStreak++;verbN++;status.textContent="נכון ✓";if(TUTOR){const next=mark("btn primary","השאלה הבאה","button");next.onclick=nextVerb;actions.append(next)}else setTimeout(nextVerb,1100)}
3622
+ }
3623
+ async function reportVerbScore(questionId,blob,button,status){
3624
+ button.disabled=true;button.textContent="שולח…";const fd=new FormData();fd.append("question_id",questionId);fd.append("audio",blob,"answer.webm");fd.append("note","דיווח ממשחק פועל יוצא");
3625
+ const r=await api("/api/verb-game/flag",{method:"POST",body:fd}).catch(()=>null);
3626
+ if(r?.ok){button.textContent="✓ הדיווח נשלח";status.textContent="הדיווח נשמר בטאב ניטור. תודה!";return}
3627
+ const detail=r?(await r.json().catch(()=>({}))).detail:"";button.disabled=false;button.textContent="🚩 נסו לשלוח שוב";status.textContent=`הדיווח לא נשמר${detail?`: ${detail}`:"."}`;
3628
  }
3629
 
3630
  function useLessons(ids){ // the path shows these lessons only (null: every one)
tests/test_scoring.py CHANGED
@@ -1320,11 +1320,11 @@ def test_sign_in_guards_the_practice_endpoints():
1320
  "best": {str(PHRASES.index(VERB)): 88}, "tries": {str(PHRASES.index(VERB)): 1}, "missed": {}, "unmatched": 0,
1321
  "recordings": 1, "days": 1,
1322
  "week": student["since"]["October 2026"]["week"], "last": "2026-10-09T10:00:00+00:00"}}
1323
- # a recording that did not match its sentence is counted apart: a recording, but no try and no score
1324
  from app.main import summary
1325
  off = summary([{"cat": VERB["cat"], "phrase": VERB["he"], "score": 12, "unrelated": True, "created_at": "2026-10-09T11:00:00+00:00"},
1326
  {"cat": VERB["cat"], "phrase": VERB["he"], "score": 70, "unrelated": False, "created_at": "2026-10-09T10:00:00+00:00"}])
1327
- assert (off["best"], off["tries"], off["missed"]) == ({PHRASES.index(VERB): 70}, {PHRASES.index(VERB): 1}, {PHRASES.index(VERB): 1})
1328
  assert (off["unmatched"], off["recordings"], off["last"]) == (1, 2, "2026-10-09T11:00:00+00:00")
1329
  c.app.state.auth.cls[0]["created_at"] = "2026-10-10T00:00:00+00:00" # opened after both
1330
  since = c.get("/api/class", headers=good).json()["students"][0]["since"]["October 2026"]
 
1320
  "best": {str(PHRASES.index(VERB)): 88}, "tries": {str(PHRASES.index(VERB)): 1}, "missed": {}, "unmatched": 0,
1321
  "recordings": 1, "days": 1,
1322
  "week": student["since"]["October 2026"]["week"], "last": "2026-10-09T10:00:00+00:00"}}
1323
+ # a recording with speech completes the exercise even when it did not match; it is also counted diagnostically
1324
  from app.main import summary
1325
  off = summary([{"cat": VERB["cat"], "phrase": VERB["he"], "score": 12, "unrelated": True, "created_at": "2026-10-09T11:00:00+00:00"},
1326
  {"cat": VERB["cat"], "phrase": VERB["he"], "score": 70, "unrelated": False, "created_at": "2026-10-09T10:00:00+00:00"}])
1327
+ assert (off["best"], off["tries"], off["missed"]) == ({PHRASES.index(VERB): 70}, {PHRASES.index(VERB): 2}, {PHRASES.index(VERB): 1})
1328
  assert (off["unmatched"], off["recordings"], off["last"]) == (1, 2, "2026-10-09T11:00:00+00:00")
1329
  c.app.state.auth.cls[0]["created_at"] = "2026-10-10T00:00:00+00:00" # opened after both
1330
  since = c.get("/api/class", headers=good).json()["students"][0]["since"]["October 2026"]
tests/test_verb_game.py CHANGED
@@ -86,6 +86,7 @@ def test_spoken_questions_keep_expected_forms_server_side(game, level):
86
  stored, phrase = game.speech_phrase(q["question_id"])
87
  assert stored.mode == level
88
  assert phrase["variants"]
 
89
  assert all(ar and ipa for ar, ipa in phrase["variants"])
90
  if level == 5:
91
  assert q["conversation"]["arabic"]
 
86
  stored, phrase = game.speech_phrase(q["question_id"])
87
  assert stored.mode == level
88
  assert phrase["variants"]
89
+ assert phrase["cat"] == "verb-game" and phrase["key"] == q["mastery_key"] and phrase["he"]
90
  assert all(ar and ipa for ar, ipa in phrase["variants"])
91
  if level == 5:
92
  assert q["conversation"]["arabic"]