Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -454,13 +454,13 @@ def to_records(items:List[MCQ])->List[dict]:
|
|
| 454 |
|
| 455 |
# ------------------ صفحة الأسئلة (HTML فقط) ------------------
|
| 456 |
def render_quiz_html(records: List[dict]) -> str:
|
| 457 |
-
parts=[]
|
| 458 |
for i, rec in enumerate(records, start=1):
|
| 459 |
-
qid
|
| 460 |
qtxt = rec["question"]
|
| 461 |
-
cor
|
| 462 |
-
opts_html=[]
|
| 463 |
-
for o in rec["options"]
|
| 464 |
lid, txt = o["id"], o["text"]
|
| 465 |
opts_html.append(f"""
|
| 466 |
<label class="opt" data-letter="{lid}">
|
|
@@ -485,6 +485,7 @@ def render_quiz_html(records: List[dict]) -> str:
|
|
| 485 |
""")
|
| 486 |
return f"""<div id="quiz" class="quiz-wrap">{''.join(parts)}</div>"""
|
| 487 |
|
|
|
|
| 488 |
# ------------------ توليد الامتحان وتبديل الصفحات ------------------
|
| 489 |
def build_quiz(text_area, file_path, n, model_id, zoom):
|
| 490 |
text_area = (text_area or "").strip()
|
|
|
|
| 454 |
|
| 455 |
# ------------------ صفحة الأسئلة (HTML فقط) ------------------
|
| 456 |
def render_quiz_html(records: List[dict]) -> str:
|
| 457 |
+
parts = []
|
| 458 |
for i, rec in enumerate(records, start=1):
|
| 459 |
+
qid = rec["id"]
|
| 460 |
qtxt = rec["question"]
|
| 461 |
+
cor = next((o["id"] for o in rec["options"] if o["is_correct"]), "")
|
| 462 |
+
opts_html = []
|
| 463 |
+
for o in rec["options"]:
|
| 464 |
lid, txt = o["id"], o["text"]
|
| 465 |
opts_html.append(f"""
|
| 466 |
<label class="opt" data-letter="{lid}">
|
|
|
|
| 485 |
""")
|
| 486 |
return f"""<div id="quiz" class="quiz-wrap">{''.join(parts)}</div>"""
|
| 487 |
|
| 488 |
+
|
| 489 |
# ------------------ توليد الامتحان وتبديل الصفحات ------------------
|
| 490 |
def build_quiz(text_area, file_path, n, model_id, zoom):
|
| 491 |
text_area = (text_area or "").strip()
|