Spaces:
Runtime error
Runtime error
Download app.py from Jay7442/assignment: direct link, hf CLI and curl.
- Browser
- Download file 3.17 kB
-
https://huggingface.co/spaces/Jay7442/assignment/resolve/main/app.py
- Command line
-
hf download hf://spaces/Jay7442/assignment/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Jay7442/assignment/resolve/main/app.py
3.17 kB
| import gradio as gr | |
| # The story "The Cave of Whispers" with blanks for cloze questions | |
| story = "https://raw.githubusercontent.com/MK316/Spring2024/main/DLEE/Project/story05.txt" | |
| # Cloze questions | |
| cloze_questions = [ | |
| {"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."}, | |
| {"question": "2. κ°μκΈ° μμ₯μλ μ μ΄ν¬κ° λ©μ·μ΅λλ€. -------------------------------------------------------------------- [Suddenly, Jake,] [halted.] [who] [was leading,]", "answer": "Suddenly, Jake, who was leading, halted."}, | |
| {"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."} | |
| ] | |
| # Function to handle the cloze quiz | |
| def cloze_quiz(name, *answers): | |
| score = 0 | |
| incorrect_questions = [] | |
| for i, question in enumerate(cloze_questions): | |
| if answers[i].strip().lower() == question["answer"].lower(): | |
| score += 1 | |
| else: | |
| incorrect_questions.append(f"Question {i+1}") | |
| incorrect_questions_text = ", ".join(incorrect_questions) | |
| result_text = f"* Name: {name}\n* Score: {score} out of {len(cloze_questions)}\n" | |
| if incorrect_questions: | |
| result_text += f"Incorrect questions: {incorrect_questions_text}" | |
| else: | |
| result_text += "All answers are correct!" | |
| return result_text | |
| # Add the input for the name | |
| inputs = [gr.Textbox(label="Enter your name")] + [gr.Textbox(label=q["question"], lines=4) for q in cloze_questions] | |
| outputs = [gr.Textbox(label="Results")] | |
| # Adding the instruction in the description with larger and bolder text | |
| instruction = """ | |
| <b><span style='font-size: 20px;'>[Assignment (Due by 6/12)]</span></b><br> | |
| <b><span style='font-size: 16px;'>Step 1. Enter your name.</span></b><br> | |
| <b><span style='font-size: 16px;'>Step 2. Arrange the following word and phrase fragments in the correct order.</span></b><br> | |
| <b><span style='font-size: 16px;'>Step 3. Type a complete sentence.</span></b><br> | |
| <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> | |
| <b><span style='font-size: 16px;'>Step 5. Capture the screen showing the result and upload it to Padlet.</span></b> | |
| """ | |
| iface = gr.Interface(fn=cloze_quiz, inputs=inputs, outputs=outputs, description=instruction) | |
| iface.launch(share=True) |