Jay7442 commited on
Commit
888770c
Β·
verified Β·
1 Parent(s): 1f66584

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The story "The Cave of Whispers" with blanks for cloze questions
2
+ story = "https://raw.githubusercontent.com/MK316/Spring2024/main/DLEE/Project/story05.txt"
3
+
4
+ # Cloze questions
5
+ cloze_questions = [
6
+ {"question": "1. 역사에 κΉŠμ€ 관심을 κ°€μ§€κ³  있던 λ―Έμ•„λŠ” λ‚˜μ€‘μ— 연ꡬ해 보렀고 μ—¬λŸ¬ μž₯의 사진을 μ°μ—ˆμŠ΅λ‹ˆλ‹€. ------------------------------------------------------------------------------------------------------------------------- [Mia,] [a keen interest in history,] [had] [took several photos,] [who] [hoping to research them later.]", "answer": "Mia, who had a keen interest in history, took several photos, hoping to research them later."},
7
+ {"question": "2. κ°‘μžκΈ° μ•žμž₯μ„œλ˜ μ œμ΄ν¬κ°€ λ©ˆμ·„μŠ΅λ‹ˆλ‹€. -------------------------------------------------------------------- [Suddenly, Jake,] [halted.] [who] [was leading,]", "answer": "Suddenly, Jake, who was leading, halted."},
8
+ {"question": "3. λͺ¨ν—˜μ„ μΆ”κ΅¬ν•˜λŠ” μ‚¬λžŒλ“€μ—κ²Œ, μ§„μ •ν•œ 보물은 금이 μ•„λ‹Œ μ—¬μ •κ³Ό κ·Έ κ³Όμ •μ—μ„œ λ§Ίμ–΄μ§„ μš°μ •μ— μžˆμŠ΅λ‹ˆλ‹€. ---------------------------------------------------------------------------------------------------------------- [those] [To] [seek adventure,] [who] [true treasure lies not in gold but in the journey and the friendships forged along the way.]", "answer": "To those who seek adventure, true treasure lies not in gold but in the journey and the friendships forged along the way."}
9
+ ]
10
+
11
+ # Function to handle the cloze quiz
12
+ def cloze_quiz(name, *answers):
13
+ score = 0
14
+ incorrect_questions = []
15
+ for i, question in enumerate(cloze_questions):
16
+ if answers[i].strip().lower() == question["answer"].lower():
17
+ score += 1
18
+ else:
19
+ incorrect_questions.append(f"Question {i+1}")
20
+ incorrect_questions_text = ", ".join(incorrect_questions)
21
+ result_text = f"* Name: {name}\n* Score: {score} out of {len(cloze_questions)}\n"
22
+ if incorrect_questions:
23
+ result_text += f"Incorrect questions: {incorrect_questions_text}"
24
+ else:
25
+ result_text += "All answers are correct!"
26
+
27
+ return result_text
28
+
29
+ # Add the input for the name
30
+ inputs = [gr.Textbox(label="Enter your name")] + [gr.Textbox(label=q["question"], lines=4) for q in cloze_questions]
31
+ outputs = [gr.Textbox(label="Results")]
32
+
33
+ # Adding the instruction in the description with larger and bolder text
34
+ instruction = """
35
+ <b><span style='font-size: 20px;'>[Assignment (Due by 6/12)]</span></b><br>
36
+ <b><span style='font-size: 16px;'>Step 1. Enter your name.</span></b><br>
37
+ <b><span style='font-size: 16px;'>Step 2. Arrange the following word and phrase fragments in the correct order.</span></b><br>
38
+ <b><span style='font-size: 16px;'>Step 3. Type a complete sentence.</span></b><br>
39
+ <b><span style='font-size: 16px;'>Step 4. Click the submit button and check your score. (If your answers are incorrect, try again.)</span></b><br>
40
+ <b><span style='font-size: 16px;'>Step 5. Capture the screen showing the result and upload it to Padlet.</span></b>
41
+ """
42
+
43
+ iface = gr.Interface(fn=cloze_quiz, inputs=inputs, outputs=outputs, description=instruction)
44
+ iface.launch(share=True)