Skip to content

Commit

Permalink
Merge pull request #438 from oat-sa/hotfix/TR-1473/pause-timer-after-…
Browse files Browse the repository at this point in the history
…connectivity-issue-while-waiting-for-reconnection-2

[Backport] fix/tr 1473/pause timer after connectivity issue while waiting for reconnection
  • Loading branch information
oatymart authored Oct 27, 2021
2 parents 9b07461 + d2952c3 commit dd26caa
Show file tree
Hide file tree
Showing 37 changed files with 2,225 additions and 256 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-test-runner-qti",
"version": "2.23.4",
"version": "2.23.4-1",
"description": "TAO Test Runner QTI implementation",
"files": [
"dist",
Expand Down
6 changes: 3 additions & 3 deletions src/provider/qti.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ var qtiProvider = {
stopwatch.init();
stopwatch.spread(this, 'tick');

const timerClientMode = config.options.timer && config.options.timer.restoreTimerFromClient;
const isTimerClientMode = () => config.options.timer && config.options.timer.restoreTimerFromClient;

/*
* Install behavior on events
Expand Down Expand Up @@ -562,13 +562,13 @@ var qtiProvider = {
this.trigger('enableitem enablenav');
})
.on('disableitem', function() {
if (timerClientMode) {
if (isTimerClientMode()) {
stopwatch.stop();
}
this.trigger('disabletools');
})
.on('enableitem', function() {
if (timerClientMode) {
if (isTimerClientMode()) {
stopwatch.start();
}
this.trigger('enabletools');
Expand Down
62 changes: 62 additions & 0 deletions src/proxy/cache/assetPreloader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 Open Assessment Technologies SA
*/

import preloaders from 'taoQtiTest/runner/proxy/cache/preloaders/assets/preloaders';
import preloaderManagerFactory from 'taoQtiTest/runner/proxy/cache/preloaderManager';

/**
* @callback assetPreloaderManagerAction
* @param {string} type - The type of asset to preload
* @param {string} url - the url of the asset to load/unload
* @param {string} [sourceUrl] - the unresolved URL (used to index)
* @param {string} [itemIdentifier] - the id of the item the asset belongs to
*/

/**
* @callback assetPreloaderAction
* @param {string} url - the url of the asset to load/unload
* @param {string} [sourceUrl] - the unresolved URL (used to index)
* @param {string} [itemIdentifier] - the id of the item the asset belongs to
*/

/**
* @typedef {object} assetPreloaderManager
* @property {string} name - The name of the preloader
* @property {assetPreloaderManagerAction} loaded - Tells whether an asset is loaded or not
* @property {assetPreloaderManagerAction} load - Preload an asset
* @property {assetPreloaderManagerAction} unload - Unload an asset
*/

/**
* @typedef {object} assetPreloader
* @property {string} name - The name of the preloader
* @property {assetPreloaderAction} loaded - Tells whether an asset is loaded or not
* @property {assetPreloaderAction} load - Preload an asset
* @property {assetPreloaderAction} unload - Unload an asset
*/

/**
* Manages the preloading of assets
* @function assetPreloaderFactory
* @param assetManager - A reference to the assetManager
* @return {assetPreloaderManager}
*/
const assetPreloaderFactory = preloaderManagerFactory();
preloaders.forEach(preloader => assetPreloaderFactory.registerProvider(preloader.name, preloader));

export default assetPreloaderFactory;
62 changes: 62 additions & 0 deletions src/proxy/cache/interactionPreloader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2021 Open Assessment Technologies SA
*/

import preloaders from 'taoQtiTest/runner/proxy/cache/preloaders/interactions/preloaders';
import preloaderManagerFactory from 'taoQtiTest/runner/proxy/cache/preloaderManager';

/**
* @callback interactionPreloaderManagerAction
* @param {string} type - The type of asset to preload
* @param {object} interaction - The interaction
* @param {object} itemData - The item data
* @param {string} itemIdentifier - the id of the item the interaction belongs to
*/

/**
* @callback interactionPreloaderAction
* @param {object} interaction - The interaction
* @param {object} itemData - The item data
* @param {string} itemIdentifier - the id of the item the interaction belongs to
*/

/**
* @typedef {object} interactionPreloaderManager
* @property {string} name - The name of the preloader
* @property {interactionPreloaderManagerAction} loaded - Tells whether an interaction is loaded or not
* @property {interactionPreloaderManagerAction} load - Preload an interaction
* @property {interactionPreloaderManagerAction} unload - Unload an interaction
*/

/**
* @typedef {object} interactionPreloader
* @property {string} name - The name of the preloader
* @property {interactionPreloaderAction} loaded - Tells whether an interaction is loaded or not
* @property {interactionPreloaderAction} load - Preload an interaction
* @property {interactionPreloaderAction} unload - Unload an interaction
*/

/**
* Manages the preloading of assets
* @function assetPreloaderFactory
* @param assetManager - A reference to the assetManager
* @return {assetPreloaderManager}
*/
const interactionPreloaderFactory = preloaderManagerFactory();
preloaders.forEach(preloader => interactionPreloaderFactory.registerProvider(preloader.name, preloader));

export default interactionPreloaderFactory;
Loading

0 comments on commit dd26caa

Please sign in to comment.