import streamlit as st from utils.levels import complete_level, render_page, initialize_level from utils.login import initialize_login import random import json LEVEL = 5 initialize_login() initialize_level() if "questions" not in st.session_state: with open("assets/quiz.json") as f: questions = json.load(f) for i in range(len(questions)): random.shuffle(questions[i]["options"]) random.shuffle(questions) st.session_state["questions"] = questions def step_page(): st.header("Quiz") st.markdown( """Now that you've learned about how Face Recognition work, let's test your knowledge with a quiz!""" ) for i in range(len(st.session_state["questions"])): st.subheader(f"Question {i + 1}") question = st.session_state["questions"][i] st.markdown(question["question"]) answer = st.radio("Select an answer:", question["options"], key=f"radio{i}") if st.session_state.get("EVALUATE", False): if answer == question["answer"]: st.success("Correct!") else: st.error("Incorrect! Try Again") if st.button("Evaluate"): st.session_state["EVALUATE"] = True st.experimental_rerun() st.info("Click on the button below to complete the tutorial!") if st.button("Complete"): complete_level(LEVEL) render_page(step_page, LEVEL)