Sha256: bfc278c67e6585f70cbd3cdbebf64907008297963dbe001628fde46357de2bb5

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

/**
 * @typedef {"input_right" | "input_bottom" | "input_primary" | "input_kindergarten"} Layout
 * @typedef {{id: number, layout: Layout, settings: any}} Exercise
 */

mumuki.exercise = {

  /**
   * The current exercise's id
   *
   * @type {Exercise?}
   * */
  _current: null,

  /**
   * The current exercise's id
   *
   * @type {number?}
   * */
  get id() {
    return this._current ? this._current.id : null;
  },

  /**
   * The current exercise's layout
   *
   * @type {Layout?}
   * */
  get layout() {
    return this._current ? this._current.layout : null;
  },

  /**
   * The current exercise's settings
   *
   * @type {any?}
   * */
  get settings() {
    return this._current ? this._current.settings : null;
  },

  /**
   * @type {Exercise?}
   */
  get current() {
    return this._current;
  },

  /**
   * Set global current exercise information
   */
  load() {
    const $muExerciseId = $('#mu-exercise-id');
    if ($muExerciseId.length) {
      this._current = {
        id: Number($muExerciseId.val()),
        // @ts-ignore
        layout: $('#mu-exercise-layout').val(),
        // @ts-ignore
        settings: JSON.parse($('#mu-exercise-settings').val())
      };
    } else {
      this._current = null;
    }
  }
}

mumuki.load(() => mumuki.exercise.load())

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mumuki-laboratory-8.1.1 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-8.1.0 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.12.3 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-8.0.0 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.12.1 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.12.0 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.11.1 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.11.0 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.5 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.4 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.3 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.2 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.1 app/assets/javascripts/mumuki_laboratory/application/exercise.js
mumuki-laboratory-7.10.0 app/assets/javascripts/mumuki_laboratory/application/exercise.js