Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,15 +56,20 @@ def YtToQuizz(link, difficulty_level):
|
|
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 |
-
formatted_mcqs = []
|
62 |
for idx, mcq in enumerate(mcqs[:10]):
|
63 |
question, correct_answer, incorrect_answers = mcq
|
64 |
incorrect_answers = incorrect_answers.split(', ')
|
65 |
-
|
|
|
|
|
66 |
|
67 |
-
return
|
68 |
|
69 |
def main(link, difficulty_level):
|
70 |
return YtToQuizz(link, difficulty_level)
|
@@ -76,7 +81,9 @@ iface = gr.Interface(
|
|
76 |
gr.components.Dropdown(["Easy", "Medium", "Hard"], label="Select difficulty level:")
|
77 |
],
|
78 |
outputs=[
|
79 |
-
gr.components.Textbox(label="MCQs
|
|
|
|
|
80 |
],
|
81 |
title="YouTube Video Subtitle to MCQs Quiz",
|
82 |
description="Generate MCQs from YouTube video subtitles"
|
|
|
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."] * 3
|
60 |
+
|
61 |
+
questions = []
|
62 |
+
correct_answers = []
|
63 |
+
options = []
|
64 |
|
|
|
65 |
for idx, mcq in enumerate(mcqs[:10]):
|
66 |
question, correct_answer, incorrect_answers = mcq
|
67 |
incorrect_answers = incorrect_answers.split(', ')
|
68 |
+
questions.append(f"Q{idx+1}: {question}")
|
69 |
+
correct_answers.append(f"Q{idx+1}: {correct_answer}")
|
70 |
+
options.append(f"Q{idx+1}: A) {correct_answer}, B) {incorrect_answers[0]}, C) {incorrect_answers[1]}, D) {incorrect_answers[2]}")
|
71 |
|
72 |
+
return questions, correct_answers, options
|
73 |
|
74 |
def main(link, difficulty_level):
|
75 |
return YtToQuizz(link, difficulty_level)
|
|
|
81 |
gr.components.Dropdown(["Easy", "Medium", "Hard"], label="Select difficulty level:")
|
82 |
],
|
83 |
outputs=[
|
84 |
+
gr.components.Textbox(label="MCQs Statements", lines=20),
|
85 |
+
gr.components.Textbox(label="Correct Answers", lines=10),
|
86 |
+
gr.components.Textbox(label="Options", lines=30)
|
87 |
],
|
88 |
title="YouTube Video Subtitle to MCQs Quiz",
|
89 |
description="Generate MCQs from YouTube video subtitles"
|