Loading static/js/exercises.api.mjs +10 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,16 @@ export class Exercise { /** * Set the handler that is called every time the exercise's completion * is verified (this verification might fail or be successful) * is in the process of being verified. * @param {Function} handler Function with no parameter */ onVerifiying(handler) { // TODO } /** * Set the handler that is called every time the exercise's completion * is verified (this verification either failed or was successful) * @param {Function} handler Function that takes the result of the verification (true/false) as parameter */ onVerified(handler) { Loading static/js/yalikejazz.mjs +3 −1 Original line number Diff line number Diff line import { State } from "./state.mjs" import * as tests from "./exercises.mjs" import { createExerciseCard, displayAsSolved, displayAsNonCurrent, displayAsCurrent } from "./exercises.cards.mjs" import { createExerciseCard, displayAsSolved, displayAsNonCurrent, displayAsCurrent, displayAsVerifying, displayAsNonVerifying } from "./exercises.cards.mjs" import { Exercise } from "./exercises.api.mjs" import { enableAutoFocus } from "./jslinux.api.mjs" Loading Loading @@ -44,8 +44,10 @@ function startExercise(exercise) { exercise.markAsCurrent(currentState) exercise.onDescribed((/** @type {string} */ description) => cardEl.querySelector(".description").textContent = description) exercise.onVerifiying(()=>displayAsVerifying(cardEl)) exercise.onVerified( (/** @type {boolean} */ success) => { displayAsNonVerifying(cardEl) if (success) { exercise.markAsSolved(currentState) displayAsSolved(cardEl) Loading Loading
static/js/exercises.api.mjs +10 −1 Original line number Diff line number Diff line Loading @@ -73,7 +73,16 @@ export class Exercise { /** * Set the handler that is called every time the exercise's completion * is verified (this verification might fail or be successful) * is in the process of being verified. * @param {Function} handler Function with no parameter */ onVerifiying(handler) { // TODO } /** * Set the handler that is called every time the exercise's completion * is verified (this verification either failed or was successful) * @param {Function} handler Function that takes the result of the verification (true/false) as parameter */ onVerified(handler) { Loading
static/js/yalikejazz.mjs +3 −1 Original line number Diff line number Diff line import { State } from "./state.mjs" import * as tests from "./exercises.mjs" import { createExerciseCard, displayAsSolved, displayAsNonCurrent, displayAsCurrent } from "./exercises.cards.mjs" import { createExerciseCard, displayAsSolved, displayAsNonCurrent, displayAsCurrent, displayAsVerifying, displayAsNonVerifying } from "./exercises.cards.mjs" import { Exercise } from "./exercises.api.mjs" import { enableAutoFocus } from "./jslinux.api.mjs" Loading Loading @@ -44,8 +44,10 @@ function startExercise(exercise) { exercise.markAsCurrent(currentState) exercise.onDescribed((/** @type {string} */ description) => cardEl.querySelector(".description").textContent = description) exercise.onVerifiying(()=>displayAsVerifying(cardEl)) exercise.onVerified( (/** @type {boolean} */ success) => { displayAsNonVerifying(cardEl) if (success) { exercise.markAsSolved(currentState) displayAsSolved(cardEl) Loading