mirror of
https://github.com/saymrwulf/QuantumLearning.git
synced 2026-05-14 20:58:00 +00:00
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
from qiskit import QuantumCircuit
|
|
|
|
from quantum_learning.interactive import (
|
|
editable_circuit_lab,
|
|
multiple_choice_quiz,
|
|
quiz_block,
|
|
reflection_box,
|
|
step_reference_table,
|
|
)
|
|
|
|
|
|
def test_multiple_choice_quiz_returns_widget():
|
|
widget = multiple_choice_quiz(
|
|
prompt="What does H do in the simplest story?",
|
|
options=["Prepare superposition", "Measure the qubit", "Delete the wire"],
|
|
correct_index=0,
|
|
explanation="H is used here as a preparation step.",
|
|
)
|
|
assert widget.children
|
|
|
|
|
|
def test_quiz_block_returns_widget_group():
|
|
widget = quiz_block(
|
|
[
|
|
{
|
|
"prompt": "Is this a quiz?",
|
|
"options": ["Yes", "No"],
|
|
"correct_index": 0,
|
|
"explanation": "Yes.",
|
|
}
|
|
],
|
|
heading="Check",
|
|
)
|
|
assert widget.children
|
|
|
|
|
|
def test_step_reference_table_returns_html_widget():
|
|
widget = step_reference_table(
|
|
[
|
|
{
|
|
"marker": "[1]",
|
|
"code_focus": "Apply H",
|
|
"diagram_effect": "Create branching",
|
|
"why_it_matters": "Preparation matters",
|
|
}
|
|
]
|
|
)
|
|
assert "[1]" in widget.value
|
|
|
|
|
|
def test_reflection_box_returns_widget():
|
|
widget = reflection_box("What changed in your mental model?")
|
|
assert widget.children
|
|
|
|
|
|
def test_editable_circuit_lab_builds_widget():
|
|
widget = editable_circuit_lab(
|
|
initial_code="""
|
|
circuit = QuantumCircuit(1, 1, name="demo")
|
|
circuit.h(0)
|
|
circuit.measure(0, 0)
|
|
""",
|
|
context={"QuantumCircuit": QuantumCircuit},
|
|
title="Demo Lab",
|
|
)
|
|
assert widget.children
|
|
|