Skip to content

Commit

Permalink
fix 0degrees draw bug + better random thermometer exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
glendc committed Feb 10, 2024
1 parent 75956f0 commit 61ed3a9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions site/1/thermometer.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ <h3 id="exercise-feedback">&nbsp;</h3>
countUntil: 0,
numExercises: 0,
exerciseCount: 0,
seenValues: [],
exercise: {},
wrongExercises: [],
premadeExercises: [],
Expand Down Expand Up @@ -352,6 +353,7 @@ <h3 id="exercise-feedback">&nbsp;</h3>
window.thermomterState.numExercises = window.thermomterState.wrongExercises.length;
window.thermomterState.exerciseCount = 0;
window.thermomterState.wrongExerciseCount = 0;
window.thermomterState.seenValues = [];
window.thermomterState.premadeExercises = window.thermomterState.wrongExercises;
window.thermomterState.wrongExercises = [];

Expand Down Expand Up @@ -441,11 +443,18 @@ <h3 id="exercise-feedback">&nbsp;</h3>
const i = Math.floor(Math.random() * window.thermomterState.premadeExercises.length);
window.thermomterState.exercise = window.thermomterState.premadeExercises.splice(i, 1)[0];
} else {
const exercises = ["teken", "schrijf"];
const exercises = ["teken", "teken", "schrijf", "schrijf"];
window.thermomterState.exercise = {
value: Math.floor(Math.random() * (window.thermomterState.countUntil)),
value: Math.floor(Math.random() * window.thermomterState.countUntil),
exercise: exercises[Math.floor(Math.random() * exercises.length)],
};
while (window.thermomterState.seenValues.includes(window.thermomterState.exercise.value)) {
window.thermomterState.exercise.value = Math.floor(Math.random() * window.thermomterState.countUntil);
}
window.thermomterState.seenValues.push(window.thermomterState.exercise.value);
if (window.thermomterState.seenValues.length >= window.thermomterState.countUntil) {
window.thermomterState.seenValues = [];
}
}

console.log("exercise", window.thermomterState.exerciseCount, window.thermomterState.exercise);
Expand Down Expand Up @@ -525,7 +534,7 @@ <h3 id="exercise-feedback">&nbsp;</h3>
break;

case "teken":
answer = -1;
answer = 0;
document.querySelectorAll('#thermometer.interactive tr:not(:last-child)>td.liquid').forEach((el) => {
const value = Number(el.getAttribute('value'));
if (value > answer) {
Expand Down Expand Up @@ -573,6 +582,7 @@ <h3 id="exercise-feedback">&nbsp;</h3>

window.thermomterState.exercise = {};
window.thermomterState.wrongExercises = [];
window.thermomterState.seenValues = [];
window.thermomterState.premadeExercises = [];

console.log("status data",
Expand Down

0 comments on commit 61ed3a9

Please sign in to comment.