Update app.py
Browse files
app.py
CHANGED
@@ -284,3 +284,168 @@ elif options == "CoTracker3 Demo 🕵️♂️":
|
|
284 |
|
285 |
# Footer with self-deprecating humor
|
286 |
st.write("If you find any bugs, remember they're just features in disguise! 🐞")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
# Footer with self-deprecating humor
|
286 |
st.write("If you find any bugs, remember they're just features in disguise! 🐞")
|
287 |
+
|
288 |
+
|
289 |
+
|
290 |
+
import random
|
291 |
+
import requests
|
292 |
+
import streamlit as st
|
293 |
+
from streamlit_lottie import st_lottie
|
294 |
+
|
295 |
+
class QuoteQuizGame:
|
296 |
+
def __init__(self):
|
297 |
+
self.questions = [
|
298 |
+
{
|
299 |
+
"question": "Who said: 'The unexamined life is not worth living'?",
|
300 |
+
"choices": ["Plato", "Socrates", "Aristotle"],
|
301 |
+
"correct_answer": "Socrates"
|
302 |
+
},
|
303 |
+
{
|
304 |
+
"question": "Which philosopher wrote: 'God is dead. God remains dead. And we have killed him.'?",
|
305 |
+
"choices": ["Jean-Paul Sartre", "Friedrich Nietzsche", "Albert Camus"],
|
306 |
+
"correct_answer": "Friedrich Nietzsche"
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"question": "Who is credited with the quote: 'I think, therefore I am' (originally in Latin: 'Cogito, ergo sum')?",
|
310 |
+
"choices": ["René Descartes", "Immanuel Kant", "John Locke"],
|
311 |
+
"correct_answer": "René Descartes"
|
312 |
+
},
|
313 |
+
{
|
314 |
+
"question": "Which ancient Chinese philosopher said: 'The journey of a thousand miles begins with a single step'?",
|
315 |
+
"choices": ["Confucius", "Sun Tzu", "Lao Tzu"],
|
316 |
+
"correct_answer": "Lao Tzu"
|
317 |
+
},
|
318 |
+
{
|
319 |
+
"question": "Who wrote: 'He who has a why to live can bear almost any how'?",
|
320 |
+
"choices": ["Viktor Frankl", "Friedrich Nietzsche", "Carl Jung"],
|
321 |
+
"correct_answer": "Friedrich Nietzsche"
|
322 |
+
},
|
323 |
+
{
|
324 |
+
"question": "Which existentialist philosopher said: 'Man is condemned to be free'?",
|
325 |
+
"choices": ["Albert Camus", "Simone de Beauvoir", "Jean-Paul Sartre"],
|
326 |
+
"correct_answer": "Jean-Paul Sartre"
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"question": "Who is known for the quote: 'The owl of Minerva spreads its wings only with the falling of the dusk'?",
|
330 |
+
"choices": ["Georg Wilhelm Friedrich Hegel", "Arthur Schopenhauer", "Søren Kierkegaard"],
|
331 |
+
"correct_answer": "Georg Wilhelm Friedrich Hegel"
|
332 |
+
},
|
333 |
+
{
|
334 |
+
"question": "Which philosopher wrote: 'The life of man [is] solitary, poor, nasty, brutish, and short'?",
|
335 |
+
"choices": ["John Locke", "Thomas Hobbes", "Jean-Jacques Rousseau"],
|
336 |
+
"correct_answer": "Thomas Hobbes"
|
337 |
+
},
|
338 |
+
{
|
339 |
+
"question": "Who said: 'He who fights with monsters should look to it that he himself does not become a monster'?",
|
340 |
+
"choices": ["Carl Jung", "Friedrich Nietzsche", "Fyodor Dostoevsky"],
|
341 |
+
"correct_answer": "Friedrich Nietzsche"
|
342 |
+
},
|
343 |
+
{
|
344 |
+
"question": "Which philosopher wrote: 'The function of prayer is not to influence God, but rather to change the nature of the one who prays'?",
|
345 |
+
"choices": ["Søren Kierkegaard", "Blaise Pascal", "Martin Buber"],
|
346 |
+
"correct_answer": "Søren Kierkegaard"
|
347 |
+
}
|
348 |
+
]
|
349 |
+
random.shuffle(self.questions)
|
350 |
+
self.score = 0
|
351 |
+
self.current_question = 0
|
352 |
+
|
353 |
+
def get_current_question(self):
|
354 |
+
return self.questions[self.current_question]
|
355 |
+
|
356 |
+
def check_answer(self, answer):
|
357 |
+
question = self.questions[self.current_question]
|
358 |
+
if question["choices"][answer - 1] == question["correct_answer"]:
|
359 |
+
self.score += 1
|
360 |
+
return True
|
361 |
+
return False
|
362 |
+
|
363 |
+
def next_question(self):
|
364 |
+
self.current_question += 1
|
365 |
+
return self.current_question < len(self.questions)
|
366 |
+
|
367 |
+
def load_lottie_url(url: str):
|
368 |
+
r = requests.get(url)
|
369 |
+
if r.status_code != 200:
|
370 |
+
return None
|
371 |
+
return r.json()
|
372 |
+
|
373 |
+
def show_animation(name, url):
|
374 |
+
anim = load_lottie_url(url)
|
375 |
+
st_lottie(anim, key=name)
|
376 |
+
|
377 |
+
def main():
|
378 |
+
st.set_page_config(page_title="Quote Quiz Game with Animations", layout="wide")
|
379 |
+
|
380 |
+
st.title("Quote Quiz Game with Animations")
|
381 |
+
|
382 |
+
if 'quiz_game' not in st.session_state:
|
383 |
+
st.session_state.quiz_game = QuoteQuizGame()
|
384 |
+
st.session_state.game_over = False
|
385 |
+
|
386 |
+
quiz = st.session_state.quiz_game
|
387 |
+
|
388 |
+
# Quiz Game Section
|
389 |
+
st.header("PhD-level Quote Quiz Game")
|
390 |
+
if not st.session_state.game_over:
|
391 |
+
question = quiz.get_current_question()
|
392 |
+
st.write(f"Question {quiz.current_question + 1}:")
|
393 |
+
st.write(question["question"])
|
394 |
+
|
395 |
+
answer = st.radio("Choose your answer:", question["choices"], key=f"question_{quiz.current_question}")
|
396 |
+
|
397 |
+
if st.button("Submit Answer"):
|
398 |
+
correct = quiz.check_answer(question["choices"].index(answer) + 1)
|
399 |
+
if correct:
|
400 |
+
st.success("Correct!")
|
401 |
+
else:
|
402 |
+
st.error(f"Incorrect. The correct answer was: {question['correct_answer']}")
|
403 |
+
|
404 |
+
if not quiz.next_question():
|
405 |
+
st.session_state.game_over = True
|
406 |
+
|
407 |
+
if st.session_state.game_over:
|
408 |
+
st.write(f"Game over! Your final score is: {quiz.score} out of {len(quiz.questions)}.")
|
409 |
+
if quiz.score == len(quiz.questions):
|
410 |
+
st.write("Perfect score! You're a true philosophy expert!")
|
411 |
+
elif quiz.score >= len(quiz.questions) * 0.8:
|
412 |
+
st.write("Excellent job! You have a deep understanding of philosophical quotes.")
|
413 |
+
elif quiz.score >= len(quiz.questions) * 0.6:
|
414 |
+
st.write("Good effort! You have a solid grasp of famous quotes.")
|
415 |
+
elif quiz.score >= len(quiz.questions) * 0.4:
|
416 |
+
st.write("Not bad! There's room for improvement in your philosophical knowledge.")
|
417 |
+
else:
|
418 |
+
st.write("Keep studying! The world of philosophy has much to offer.")
|
419 |
+
|
420 |
+
if st.button("Play Again"):
|
421 |
+
st.session_state.quiz_game = QuoteQuizGame()
|
422 |
+
st.session_state.game_over = False
|
423 |
+
st.experimental_rerun()
|
424 |
+
|
425 |
+
# Animation Section
|
426 |
+
st.header("Animations")
|
427 |
+
st.markdown('# Animations: https://lottiefiles.com/recent')
|
428 |
+
st.markdown("# Animate with JSON, SVG, Adobe XD, Figma, and deploy to web, mobile as tiny animation files ")
|
429 |
+
|
430 |
+
col1, col2, col3 = st.columns(3)
|
431 |
+
|
432 |
+
with col1:
|
433 |
+
show_animation("Badge1", "https://assets5.lottiefiles.com/packages/lf20_wtohqzml.json")
|
434 |
+
show_animation("Badge2", "https://assets5.lottiefiles.com/packages/lf20_i4zw2ddg.json")
|
435 |
+
show_animation("Badge3", "https://assets5.lottiefiles.com/private_files/lf30_jfhmdmk5.json")
|
436 |
+
show_animation("Graph", "https://assets6.lottiefiles.com/packages/lf20_4gqhiayj.json")
|
437 |
+
|
438 |
+
with col2:
|
439 |
+
show_animation("PhoneBot", "https://assets9.lottiefiles.com/packages/lf20_zrqthn6o.json")
|
440 |
+
show_animation("SupportBot", "https://assets5.lottiefiles.com/private_files/lf30_cmd8kh2q.json")
|
441 |
+
show_animation("ChatBot", "https://assets8.lottiefiles.com/packages/lf20_j1oeaifz.json")
|
442 |
+
show_animation("IntelligentMachine", "https://assets8.lottiefiles.com/packages/lf20_edouagsj.json")
|
443 |
+
|
444 |
+
with col3:
|
445 |
+
show_animation("GearAI", "https://assets10.lottiefiles.com/packages/lf20_3jkp7dqt.json")
|
446 |
+
show_animation("ContextGraph", "https://assets10.lottiefiles.com/private_files/lf30_vwC61X.json")
|
447 |
+
show_animation("Yggdrasil", "https://assets4.lottiefiles.com/packages/lf20_8q1bhU.json")
|
448 |
+
show_animation("Studying", "https://assets9.lottiefiles.com/packages/lf20_6ft9bypa.json")
|
449 |
+
|
450 |
+
if __name__ == "__main__":
|
451 |
+
main()
|