Commit 33521224 authored by Jakob Moser's avatar Jakob Moser
Browse files

Sloppily remove dependency of state on pooltest

parent 9f6d724b
Loading
Loading
Loading
Loading
+4 −8
Changes for static/js/state.mjs: 4 added lines, 8 removed lines.
Original line number Diff line number Diff line
/** Read and modify the current state of the application. Allows saving to local storage. */

import { pooltest } from "./exercises.mjs"

export const currentState = {

    /**
@@ -46,9 +44,8 @@ export const currentState = {
            throw new Error("index must be a number")
        }

        if (index < 0 || index > pooltest.exercises.length) {
            throw new Error(`Exercise index must be >= 0 and < exercises.length (${pooltest.exercises.length})`)
        }
        // TODO Verify that index is in range, else
        // throw new Error(`Exercise index must be >= 0 and < exercises.length (${pooltest.exercises.length})`)

        localStorage.setItem("exerciseIndex", index)
    },
@@ -77,9 +74,8 @@ export const currentState = {
            throw new Error(`Can't solve the same exercise (${exerciseIndex}) twice`)
        }

        if (exerciseIndex < 0 || exerciseIndex > pooltest.exercises.length) {
            throw new Error(`Exercise index must be >= 0 and < exercises.length (${pooltest.exercises.length})`)
        }
        // TODO Verify that exerciseIndex is in range, else
        // throw new Error(`Exercise index must be >= 0 and < exercises.length (${pooltest.exercises.length})`)

        const newIndices = this.solvedExercises
        newIndices.push(exerciseIndex)