Jay7442 commited on
Commit
dda55ee
·
verified ·
1 Parent(s): 71a46a3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ story = "https://raw.githubusercontent.com/jmyoon7442/jmyoon7442/main/The%20Cave%20of%20Whisper.txt"
4
+
5
+ # Define the comprehension questions
6
+ questions = [
7
+ {"question": "1. What did they bring on their adventure?", "options": ["1) water, snacks, and a tent", "2) maps, books, and a compass", "3) flashlights, a compass, and a camera"], "answer": "3) flashlights, a compass, and a camera"},
8
+ {"question": "2. Who did read the message?", "options": ["1) Emma", "2) Liam", "3) Jake", "4) Mia"], "answer": "1) Emma"},
9
+ {"question": "3. What did the friends find inside the Cave of Whispers?", "options": ["1) A map to another treasure", "2) An old parchment", "3) A magical stone"], "answer": "2) An old parchment"},
10
+ {"question": "4 What did the message on the ancient parchment say?", "options" : ["1) Finders keepers, losers weepers.", "2) Gold is the measure of true wealth.", "3) True treasure lies in gold and gems only.", "4) True treasure lies not in gold but in the journey and the friendships forged along the way."], "answer": "4) True treasure lies not in gold but in the journey and the friendships forged along the way."},
11
+ {"question": "5. The four friends found an old map in a newly published book", "options": ["True", "False"], "answer": "False"},
12
+ {"question": "6. The four friends set the adventure in the morning.", "options": ["True", "False"], "answer": "False"},
13
+ {"question": "7. The four friends found a wooden chest in the Cave of Whispers, which contained golden coins and jewels.", "options": ["True", "False"], "answer": "True"},
14
+ {"question": "8. The four friends decided to sell the treasure and split the money.", "options": ["True", "False"], "answer": "True"},
15
+ {"question": "9. The friends used a GPS device and a smartphone to document their journey", "options": ["True", "False"], "answer": "False"}
16
+ ]
17
+
18
+
19
+ # Function to display the story and ask questions
20
+ def quiz(*answers):
21
+ score = 0
22
+ incorrect = []
23
+ for i, question in enumerate(questions):
24
+ if answers[i] == question["answer"]:
25
+ score += 1
26
+ else:
27
+ incorrect.append(f"Question {i+1}: Correct answer is {question['answer']}")
28
+ results = "\n".join(incorrect)
29
+ return score, results
30
+
31
+ story_display = gr.Markdown(story)
32
+ inputs = [gr.Radio(label=q["question"], choices=q["options"]) for q in questions]
33
+ outputs = [gr.Textbox(label="Score"), gr.Textbox(label="Incorrect Answers")]
34
+
35
+ iface = gr.Interface(fn=quiz, inputs=inputs, outputs=outputs, description="Comprehension Quiz for 'The Cave of Whispers'")
36
+ iface.launch(share=True)