Loading static/js/exercises.api.mjs +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,14 @@ export class Exercise { this.#context._confirmExerciseCompletion() } /** * Returns true if the user should be able to click a button * to manually confirm they completed this exercise */ get awaitsManualConfirmation() { return this.#context._confirmExerciseCompletion !== null } /** * Set the handler that is called every time the exercise executor * sets the description of the exercise. Loading static/js/exercises.cards.mjs +15 −7 Original line number Diff line number Diff line Loading @@ -36,21 +36,27 @@ export function displayAsNonCurrent(cardEl) { } /** * Create a confirm and a reset button that can be appended to the actions section of * Create an (optional) confirm and a reset button that can be appended to the actions section of * an exercise card. * @param {Function} manuallyConfirm Function to call to manually confirm this exercise * @param {Function} manuallyConfirm Function to call to manually confirm this exercise. If falsy, no confirm button is created. * @returns List of buttons */ function createExerciseCardActionButtons(manuallyConfirm) { const ret = [] if(manuallyConfirm) { const confirmButton = createElementWithClass("button", "primary") confirmButton.textContent = "Ich denke, ich bin fertig." confirmButton.onclick = () => manuallyConfirm() ret.push(confirmButton) } const resetButton = document.createElement("button") resetButton.textContent = "Aufgabe neu beginnen" resetButton.onclick = () => location.reload() ret.push(resetButton) return [confirmButton, resetButton] return ret } /** Loading @@ -71,7 +77,9 @@ export function createExerciseCard(exercise, onTitleClick) { const descriptionEl = createElementWithClass("p", "description") const actionsEl = createElementWithClass("div", "actions") actionsEl.append(...createExerciseCardActionButtons( exercise.manuallyConfirm.bind(exercise) exercise.awaitsManualConfirmation ? exercise.manuallyConfirm.bind(exercise) : null )) cardEl.querySelector(".content").append(descriptionEl, actionsEl) Loading Loading
static/js/exercises.api.mjs +8 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,14 @@ export class Exercise { this.#context._confirmExerciseCompletion() } /** * Returns true if the user should be able to click a button * to manually confirm they completed this exercise */ get awaitsManualConfirmation() { return this.#context._confirmExerciseCompletion !== null } /** * Set the handler that is called every time the exercise executor * sets the description of the exercise. Loading
static/js/exercises.cards.mjs +15 −7 Original line number Diff line number Diff line Loading @@ -36,21 +36,27 @@ export function displayAsNonCurrent(cardEl) { } /** * Create a confirm and a reset button that can be appended to the actions section of * Create an (optional) confirm and a reset button that can be appended to the actions section of * an exercise card. * @param {Function} manuallyConfirm Function to call to manually confirm this exercise * @param {Function} manuallyConfirm Function to call to manually confirm this exercise. If falsy, no confirm button is created. * @returns List of buttons */ function createExerciseCardActionButtons(manuallyConfirm) { const ret = [] if(manuallyConfirm) { const confirmButton = createElementWithClass("button", "primary") confirmButton.textContent = "Ich denke, ich bin fertig." confirmButton.onclick = () => manuallyConfirm() ret.push(confirmButton) } const resetButton = document.createElement("button") resetButton.textContent = "Aufgabe neu beginnen" resetButton.onclick = () => location.reload() ret.push(resetButton) return [confirmButton, resetButton] return ret } /** Loading @@ -71,7 +77,9 @@ export function createExerciseCard(exercise, onTitleClick) { const descriptionEl = createElementWithClass("p", "description") const actionsEl = createElementWithClass("div", "actions") actionsEl.append(...createExerciseCardActionButtons( exercise.manuallyConfirm.bind(exercise) exercise.awaitsManualConfirmation ? exercise.manuallyConfirm.bind(exercise) : null )) cardEl.querySelector(".content").append(descriptionEl, actionsEl) Loading