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

Add exercise index as property of the exercise

parent 27b83099
Loading
Loading
Loading
Loading
+3 −2
Changes for static/js/exercises.api.mjs: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@ class Exercise {
    #execute = null
    #context = new ExerciseExecutionContext()

    constructor(name, execute) {
    constructor(name, index, execute) {
        this.name = name
        this.index = index
        // Bind the execute function to the ExerciseExecutionContext.
        // This means that the `this` keyword, when used in the function, will
        // point to this ExerciseExecutionContext object.
@@ -231,7 +232,7 @@ export function test(name, exerciseCreationFunction) {
         * Note: This must be a function declared with the function keyword, arrow functions (()=>{...}) do not work.
         */
        exercise(name, execute) {
            const exerciseObj = new Exercise(name, execute)
            const exerciseObj = new Exercise(name, this.exercises.length, execute)
            this.exercises.push(exerciseObj)
        }
    }