Commit 5bad3c90 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add markWelcomeAsRead method and isWelcomeRead method

parent ce9460d7
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -268,6 +268,22 @@ class Test {
            return this.exercises[nextUnsolvedExerciseIndex]
        }
    }

    /**
     * Return if the welcome message was already read in the current state
     */
    wasWelcomeRead(currentState) {
        // TODO Properly implement this for each test separately
        return !currentState.firstStart
    }

    /**
     * Marks the welcome message as read, modifying the given current state
     */
    markWelcomeAsRead(currentState) {
        // TODO Properly implement this for each test separately
        currentState.firstStart = false
    }
}

/**
+4 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ function initActionLinks() {
            },
            "begin": function () {
                document.body.classList.remove("overlay-shown")
                currentState.firstStart = false
                currentTest.markWelcomeAsRead(currentState)
            },
            "continue": function () {
                document.body.classList.remove("overlay-shown")
@@ -114,11 +114,13 @@ export function main() {

    if(currentTest.welcomeHtml) {
        document.querySelector("#welcome").innerHTML = currentTest.welcomeHtml

        const exerciseCnt = document.querySelector("#exerciseCnt")
        if (exerciseCnt) {
            exerciseCnt.textContent = currentTest.exercises.length
        }
        if (currentState.firstStart) {

        if (!currentTest.wasWelcomeRead(currentState)) {
            document.body.classList.add("overlay-shown")
        }
    } else {