import gradio as gr # Quiz data quizzes = { "Easy": [ ("What does AR stand for?", ["Automated Reality", "Augmented Reality", "Artificial Reality", "Altered Reality"], "Augmented Reality"), ("What does VR stand for?", ["Virtual Reality", "Visible Reality", "Verified Reality", "Variable Reality"], "Virtual Reality"), ("Is Pokémon Go an AR or VR game?", ["AR", "VR", "Neither", "Both"], "AR"), ("Which device is commonly used for VR?", ["Smartphone", "Oculus Rift", "Tablet", "Laptop"], "Oculus Rift"), ("Does AR add elements to the real world?", ["Yes", "No", "Sometimes", "Never"], "Yes"), ("Is Google Glass an AR device?", ["Yes", "No", "Not sure", "None"], "Yes"), ("Can AR be used in education?", ["Yes", "No", "Only in gaming", "Maybe"], "Yes"), ("Which senses does VR mainly simulate?", ["Touch", "Sight and sound", "Taste", "Smell"], "Sight and sound"), ("What is the main difference between AR and VR?", ["AR overlays virtual elements on real world, VR is fully virtual", "AR is fully virtual, VR overlays virtual elements on real world", "They are the same", "None of the above"], "AR overlays virtual elements on real world, VR is fully virtual"), ("Name an AR game for smartphones.", ["Minecraft", "Pokémon Go", "Among Us", "Tetris"], "Pokémon Go"), ], "Moderate": [ ("Name an industry where AR is used for training.", ["Healthcare", "Fashion", "Retail", "Agriculture"], "Healthcare"), ("Can VR help people overcome phobias?", ["Yes", "No", "Maybe", "Not yet"], "Yes"), ("Which hardware component is essential for immersive AR?", ["GPS", "Camera", "Ultrasonic Sensor", "Thermometer"], "Camera"), ("What technology powers real-time 3D mapping in AR?", ["SLAM", "HTTP", "Bluetooth", "NFC"], "SLAM"), ("Which programming language is commonly used for VR development?", ["Python", "C#", "Ruby", "JavaScript"], "C#"), ("Which platform supports VR apps mainly?", ["SteamVR", "Netflix", "Spotify", "Instagram"], "SteamVR"), ("What's the stereo display technology for VR called?", ["HoloLens", "VR headset", "Head-Mounted Display", "3D Glasses"], "Head-Mounted Display"), ("Name a common VR input device.", ["Joystick", "Keyboard", "VR Controller", "Mouse"], "VR Controller"), ("Which of these defines the Field of View in VR?", ["Display size", "Viewing angle", "Battery life", "Weight"], "Viewing angle"), ("What kind of feedback is tactile response in VR?", ["Audio Feedback", "Visual Feedback", "Haptic Feedback", "Olfactory Feedback"], "Haptic Feedback"), ("Which of these companies produces VR hardware?", ["Oculus", "Adobe", "Spotify", "Slack"], "Oculus"), ("Which is NOT a VR platform?", ["HTC Vive", "PlayStation VR", "Nintendo Switch", "Valve Index"], "Nintendo Switch"), ("In AR, what does the term 'marker' refer to?", ["A tracking point", "A VR headset", "An app", "A sensor"], "A tracking point"), ("What is the main use of gesture recognition in AR/VR?", ["Input method", "Display method", "Sound method", "Battery saving"], "Input method"), ("Which sensor is widely used for positional tracking in VR?", ["Gyroscope", "LIDAR", "Heart rate monitor", "Microphone"], "Gyroscope"), ], "Hard": [ ("Define SLAM in AR context.", ["Simultaneous Localization and Mapping", "Simple Linear AR Modeling", "Spatial Light and Mapping", "Software Layered AR Mechanics"], "Simultaneous Localization and Mapping"), ("Explain the concept of haptic feedback in VR.", ["Touch feedback via devices", "Visual effects", "Audio feedback", "VR headset weight"], "Touch feedback via devices"), ("What does the acronym FOV stand for in VR?", ["Field of Vision", "Field of View", "Focus of Vision", "Form of View"], "Field of View"), ("Which rendering technique improves VR performance?", ["Deferred Rendering", "Ray Tracing", "Voxelization", "Rasterization"], "Deferred Rendering"), ("What is the role of 'positional tracking' in VR?", ["Tracks body movement", "Tracks battery", "Tracks screen", "Tracks sound"], "Tracks body movement"), ("Precision of AR depends largely on which factor?", ["Camera resolution", "Battery life", "Network speed", "App size"], "Camera resolution"), ("What is '6DoF' in AR/VR?", ["Six Degrees of Freedom", "Six Dimensions of Functionality", "Six Devices of Feedback", "Six Directions of Flow"], "Six Degrees of Freedom"), ("What is the typical refresh rate for smooth VR experience?", ["30Hz", "60Hz", "90Hz", "120Hz"], "90Hz"), ("Which algorithm helps reduce latency in VR?", ["Asynchronous Timewarp", "Ray Casting", "Pathfinding", "Parallel Processing"], "Asynchronous Timewarp"), ("Which sensor data fusion combines in AR devices?", ["Camera and GPS", "Accelerometer and Gyroscope", "Microphone and Speaker", "Screen and Battery"], "Accelerometer and Gyroscope"), ("What is the main challenge of AR in mobile devices?", ["Battery drain", "Storage", "Bandwidth", "Processor speed"], "Battery drain"), ("Which device uses optical see-through for AR?", ["Magic Leap", "Oculus Quest", "HTC Vive", "Valve Index"], "Magic Leap"), ("What is the purpose of stereoscopic rendering in VR?", ["3D depth perception", "Faster rendering", "Less heat generation", "Lower latency"], "3D depth perception"), ("What does 'pass-through AR' mean?", ["Using camera feed to display real environment", "Pure VR", "No rendering", "Audio only"], "Using camera feed to display real environment"), ("Which open-source platform is popular for VR development?", ["Godot", "Unity", "Unreal Engine", "Blender"], "Godot"), ("Which component is critical for low latency in AR/VR?", ["Fast GPU", "Big Screen", "Heavy Battery", "Wireless Controller"], "Fast GPU"), ] } # Quiz grading function def grade_quiz(*args): answers = args[:-1] section = args[-1] correct = 0 total = len(quizzes[section]) for i, ans in enumerate(answers): if ans == quizzes[section][i][2]: correct += 1 return f"Your score: {correct} out of {total}" # CSS css_code = """ body { margin: 0; padding: 0; min-height: 100vh; background-image: url('https://tse2.mm.bing.net/th/id/OIP.3Freg4wHurs0tHpssuPywwHaEK?pid=Api&P=0&h=220'); background-size: cover; background-position: center; background-attachment: fixed; font-family: 'Segoe UI', sans-serif; } .gradio-container { background: rgba(0,0,0,0.6); padding: 20px; margin: auto; border-radius: 20px; max-width: 1000px; } .animation-box { background: linear-gradient(135deg, #1a1a1a, #333333); border-radius: 15px; padding: 15px; margin: 15px 0; box-shadow: 0 0 15px rgba(255, 215, 0, 0.8); animation: glowing 3s ease-in-out infinite alternate; } @keyframes glowing { from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.8); } to { box-shadow: 0 0 25px rgba(255, 239, 180, 1); } } h1, h2, h3 { color: #FFD700; text-shadow: 0 0 10px #ffd700; text-align: center; } .gr-button { background-color: #FFD700 !important; color: black !important; font-weight: bold !important; border-radius: 12px !important; padding: 12px 30px !important; box-shadow: 0 0 15px #FFD700 !important; transition: transform 0.3s ease; } .gr-button:hover { transform: scale(1.05); box-shadow: 0 0 30px #fff; } """ # Build Gradio UI with gr.Blocks(css=css_code) as demo: with gr.Column(elem_classes="animation-box"): gr.Markdown("# 👑 AR/VR Tech Quiz 👑") with gr.Tabs(): for section in ["Easy", "Moderate", "Hard"]: with gr.TabItem(section): with gr.Column(elem_classes="animation-box"): gr.Markdown(f"## {section} Section") radio_list = [] for idx, (question, options, _) in enumerate(quizzes[section]): with gr.Column(elem_classes="animation-box"): radio = gr.Radio(label=f"{idx+1}. {question}", choices=options, interactive=True) radio_list.append(radio) with gr.Column(elem_classes="animation-box"): submit_btn = gr.Button("Submit") with gr.Column(elem_classes="animation-box"): output = gr.Textbox(label="Result", interactive=False) submit_btn.click( fn=grade_quiz, inputs=radio_list + [gr.State(section)], outputs=output, ) if __name__ == "__main__": demo.launch()