Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,20 +56,25 @@ def YtToQuizz(link, difficulty_level):
|
|
56 |
mcqs = re.findall(mcq_pattern, response_text, re.DOTALL)
|
57 |
|
58 |
if len(mcqs) < 10:
|
59 |
-
return
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
for idx, mcq in enumerate(mcqs[:10]):
|
66 |
question, correct_answer, incorrect_answers = mcq
|
67 |
incorrect_answers = incorrect_answers.split(', ')
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
def main(link, difficulty_level):
|
75 |
return YtToQuizz(link, difficulty_level)
|
@@ -90,4 +95,4 @@ iface = gr.Interface(
|
|
90 |
)
|
91 |
|
92 |
if __name__ == '__main__':
|
93 |
-
iface.launch()
|
|
|
56 |
mcqs = re.findall(mcq_pattern, response_text, re.DOTALL)
|
57 |
|
58 |
if len(mcqs) < 10:
|
59 |
+
return "Failed to generate 10 complete MCQs. Please try again.", "", ""
|
60 |
|
61 |
+
questions_str = ""
|
62 |
+
correct_answers_str = ""
|
63 |
+
options_str = ""
|
64 |
|
65 |
for idx, mcq in enumerate(mcqs[:10]):
|
66 |
question, correct_answer, incorrect_answers = mcq
|
67 |
incorrect_answers = incorrect_answers.split(', ')
|
68 |
+
questions_str += f"Q{idx+1}: {question}, "
|
69 |
+
correct_answers_str += f"Q{idx+1}: {correct_answer}, "
|
70 |
+
options_str += f"Q{idx+1}: A) {correct_answer}, B) {incorrect_answers[0]}, C) {incorrect_answers[1]}, D) {incorrect_answers[2]}, "
|
71 |
|
72 |
+
# Removing the trailing comma and space
|
73 |
+
questions_str = questions_str.rstrip(", ")
|
74 |
+
correct_answers_str = correct_answers_str.rstrip(", ")
|
75 |
+
options_str = options_str.rstrip(", ")
|
76 |
+
|
77 |
+
return questions_str, correct_answers_str, options_str
|
78 |
|
79 |
def main(link, difficulty_level):
|
80 |
return YtToQuizz(link, difficulty_level)
|
|
|
95 |
)
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
+
iface.launch()
|