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

Use cooler way to get currentTest

parent 89f4f34e
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
import { State } from "./state.mjs"
import { pooltest, practice } from "./exercises.mjs"
import * as exercises from "./exercises.mjs"
import { createExerciseCard, displayAsSolved, displayAsNonCurrent, displayAsCurrent } from "./exercises.cards.mjs"
import { Exercise } from "./exercises.api.mjs"

@@ -100,10 +100,7 @@ function redirectToPractice() {
}

export function main() {
    currentTest = {
        "pooltest": pooltest,
        "practice": practice
    }[new URLSearchParams(location.search).get("id")]
    currentTest = exercises[new URLSearchParams(location.search).get("id")]

    if(currentTest === undefined) {
        // When no test can be loaded, redirect to a URL which leads to a known existing test