Skip to content

Commit

Permalink
Merge branch 'release-0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
krampstudio committed May 18, 2021
2 parents 112d5b8 + f34ff34 commit 6ea42ce
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 12 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-item-runner",
"version": "0.7.2",
"version": "0.8.0",
"displayName": "TAO Item Runner",
"description": "TAO Item Runner modules",
"files": [
Expand Down
24 changes: 23 additions & 1 deletion src/runner/api/itemRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* 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) 2014-2020 (original work) Open Assessment Technlogies SA (under the project TAO-PRODUCT);
* Copyright (c) 2014-2021 (original work) Open Assessment Technlogies SA (under the project TAO-PRODUCT);
*
*/

Expand Down Expand Up @@ -405,6 +405,28 @@ const itemRunnerFactory = function itemRunnerFactory(providerName, data = {}, op
return Promise.resolve();
},

/**
* Get the item runner options.
*
* @returns {Object} the item rendering options
*/
getOptions() {
return this.options;
},

/**
* Replaces item runner's options.
* @param {Object} newOptions - the options to set
* @returns {Promise}
*/
setOptions(newOptions = {}) {
this.options = newOptions;
if (typeof provider.setOptions === 'function') {
return provider.setOptions.call(this, this.options);
}
return Promise.resolve();
},

/**
* Get the responses of the running item.
*
Expand Down
92 changes: 83 additions & 9 deletions test/runner/api/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ define(['jquery', 'taoItems/runner/api/itemRunner', 'test/taoItems/runner/provid
.init();
});




QUnit.module('ItemRunner render', {
afterEach() {
//reset the providers
Expand Down Expand Up @@ -683,15 +686,17 @@ define(['jquery', 'taoItems/runner/api/itemRunner', 'test/taoItems/runner/provid
value: 0
})
.on('render', function () {
this.renderFeedbacks({ f1: 'feedback1', f2: 'feedback2', f3: 'feedback3' }, ['f2'], function (
renderingQueue
) {
assert.ok(renderingQueue instanceof Array, 'renderingQueue is an array');
assert.equal(renderingQueue.length, 1, 'renderingQueue contains one entry');
assert.equal(renderingQueue[0], 'feedback2', 'renderingQueue contains selected entry');
this.renderFeedbacks(
{ f1: 'feedback1', f2: 'feedback2', f3: 'feedback3' },
['f2'],
function (renderingQueue) {
assert.ok(renderingQueue instanceof Array, 'renderingQueue is an array');
assert.equal(renderingQueue.length, 1, 'renderingQueue contains one entry');
assert.equal(renderingQueue[0], 'feedback2', 'renderingQueue contains selected entry');

ready();
});
ready();
}
);
})
.init()
.render($container);
Expand Down Expand Up @@ -872,7 +877,6 @@ define(['jquery', 'taoItems/runner/api/itemRunner', 'test/taoItems/runner/provid
.render($container);
});


QUnit.test('Close has no effect before rendering', assert => {
const ready = assert.async();
assert.expect(2);
Expand Down Expand Up @@ -983,4 +987,74 @@ define(['jquery', 'taoItems/runner/api/itemRunner', 'test/taoItems/runner/provid
.init()
.render($container);
});

QUnit.test('get item runner options', assert => {
const ready = assert.async();
const options = {
settings: {
muted: true,
baseVolume: 75
}
};

assert.expect(1);

itemRunner.register('dummyProvider', dummyProvider);

itemRunner('dummyProvider', {}, options)
.on('init', function () {
assert.deepEqual(this.getOptions(), options, 'the options are correct');
ready();
})
.init();
});

QUnit.module('ItemRunner options', {
afterEach() {
//reset the provides
itemRunner.providers = noop;
}
});

QUnit.test('update item runner options', assert => {
const ready = assert.async();
const initialOptions = {
settings: {
muted: true,
baseVolume: 75
}
};
const newOptions = {
settings: {
muted: false,
baseVolume: 50
}
};

assert.expect(3);

itemRunner.register(
'dummyProvider',
Object.assign(
{
setOptions(receivedOptions) {
assert.deepEqual(receivedOptions, newOptions, 'the provider receives the updated options');
return Promise.resolve();
}
},
dummyProvider
)
);

itemRunner('dummyProvider', {}, initialOptions)
.on('init', function () {
assert.deepEqual(this.getOptions(), initialOptions, 'initial options are correct');

this.setOptions(newOptions).then(() => {
assert.deepEqual(this.getOptions(), newOptions, 'updated options are correct');
ready();
});
})
.init();
});
});

0 comments on commit 6ea42ce

Please sign in to comment.