2025-06-18 11:49:42 +00:00
|
|
|
import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
|
|
|
|
|
|
|
|
export default class extends Controller {
|
2025-06-19 12:14:46 +00:00
|
|
|
static targets = ["radio", "answerDetails"];
|
2025-06-18 11:49:42 +00:00
|
|
|
|
|
|
|
static values = {
|
|
|
|
answer: String
|
|
|
|
};
|
|
|
|
|
|
|
|
connect() {
|
|
|
|
}
|
|
|
|
|
|
|
|
submitAnswer(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
|
2025-06-19 02:51:37 +00:00
|
|
|
this.element.classList.add("reveal");
|
|
|
|
|
|
|
|
window.setTimeout(() => {
|
|
|
|
this.radioTargets.forEach(e => {
|
|
|
|
e.disabled = true;
|
|
|
|
if (e.value === this.answerValue) {
|
|
|
|
e.classList.add("answer");
|
|
|
|
} else {
|
|
|
|
e.classList.add("wrong");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 1);
|
2025-06-19 12:14:46 +00:00
|
|
|
|
|
|
|
this.answerDetailsTarget.classList.remove("hidden");
|
2025-06-18 11:49:42 +00:00
|
|
|
}
|
|
|
|
};
|