Published unlisted
Edited
Sep 20, 2022
Insert cell
Insert cell
Qs = [["Mars has one moon, just like Earth." , false],
["Scurvy is caused by a deficit of vitamin C.", true],
["Brass is made from iron and copper.", false]]
Insert cell
function question(txt, answerKey) {
const chk = Inputs.checkbox([txt], {unique:true, label: 'Check if true', valueof: x=>!!x});
return Inputs.form([
chk,
Inputs.bind(Inputs.text({label: "Result", placeholder: "placeholder"}), chk),
htl.html`<br>` // clicking Evaluate should label answers as correct or incorrect here
]);
}
Insert cell
viewof quiz = Inputs.form(Qs.map((args) => question(...args)))
Insert cell
viewof submitted = Inputs.button('Evaluate')
Insert cell
function set(input, value) {
input.value = value;
input.dispatchEvent(new Event("input", {bubbles: true}));
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more