Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,6 +120,23 @@ def generate_MCQquestion(text):
|
|
| 120 |
"questions": questions,
|
| 121 |
"answers": answers
|
| 122 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
return json.dumps(final_output, ensure_ascii=False, indent=2)
|
| 125 |
|
|
|
|
| 120 |
"questions": questions,
|
| 121 |
"answers": answers
|
| 122 |
}
|
| 123 |
+
# create readable text output
|
| 124 |
+
readable = "\n\n===== الأسئلة مع الإجابات =====\n\n"
|
| 125 |
+
for q, a in zip(questions, answers):
|
| 126 |
+
correct_index = a["correct_answer_index"] - 1
|
| 127 |
+
readable += f"س{q['id']}: {q['question']}\n"
|
| 128 |
+
for idx, opt in enumerate(q["options"]):
|
| 129 |
+
prefix = "✓" if idx == correct_index else "-"
|
| 130 |
+
readable += f" {prefix} {opt}\n"
|
| 131 |
+
readable += "\n"
|
| 132 |
+
|
| 133 |
+
# combine json + readable text
|
| 134 |
+
combined_output = {
|
| 135 |
+
"json": final_output,
|
| 136 |
+
"preview": readable
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
return json.dumps(combined_output, ensure_ascii=False, indent=2)
|
| 140 |
|
| 141 |
return json.dumps(final_output, ensure_ascii=False, indent=2)
|
| 142 |
|