Skip to content

Commit

Permalink
Merge branch 'release-4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
oat-github-bot committed Oct 19, 2023
2 parents c3d57ea + 4dbd562 commit 398f4db
Show file tree
Hide file tree
Showing 17 changed files with 5,753 additions and 3,161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: npm run coverage:clover
- name: Report coverage
if: always()
uses: slavcodev/coverage-monitor-action@1.1.0
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
clover_file: coverage/clover.xml
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release NPM package

on:
pull_request:
branches:
- develop
types: [closed]

jobs:
auto-release:
if: github.event.pull_request.merged == true
name: Automated package release
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: actions/checkout@v3
with:
fetch-depth: 0 #avoid unrelated history error
token: ${{ secrets.SEMVER_GH_TOKEN }} #bypass branch protection rule

- name: Configure git user
#configuring git for runner
run: |
git config --global user.name "oat-github-bot"
git config --global user.email "[email protected]"
- name: Install and apply the release tool
env:
GITHUB_TOKEN: ${{ secrets.SEMVER_GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_RELEASE_TOKEN }}
run: |
# setup the place
npm config set //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
npm i -g @oat-sa/tao-extension-release
# install the package
npm ci
#create tag and release a new version
taoRelease npmRelease --release-branch master --no-interactive
8,512 changes: 5,533 additions & 2,979 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-test-runner-qti",
"version": "3.0.0",
"version": "4.0.0",
"description": "TAO Test Runner QTI implementation",
"files": [
"dist",
Expand Down Expand Up @@ -57,13 +57,13 @@
"@oat-sa/eslint-config-tao": "^2.0.0",
"@oat-sa/prettier-config": "^0.1.1",
"@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
"@oat-sa/tao-core-libs": "^0.5.3",
"@oat-sa/tao-core-sdk": "^2.0.1",
"@oat-sa/tao-core-ui": "^2.0.0",
"@oat-sa/tao-item-runner": "^0.8.2",
"@oat-sa/tao-item-runner-qti": "^1.11.1",
"@oat-sa/tao-core-libs": "^1.0.0",
"@oat-sa/tao-core-sdk": "^3.0.0",
"@oat-sa/tao-core-ui": "^3.0.1",
"@oat-sa/tao-item-runner": "^1.0.0",
"@oat-sa/tao-item-runner-qti": "^2.0.1",
"@oat-sa/tao-qunit-testrunner": "^2.0.0",
"@oat-sa/tao-test-runner": "^0.9.1",
"@oat-sa/tao-test-runner": "^1.0.0",
"async": "0.2.10",
"autoprefixer": "^10.4.14",
"dompurify": "^2.4.0",
Expand All @@ -76,7 +76,7 @@
"jquery": "1.9.1",
"jquery-mockjax": "^2.5.0",
"jquery-simulate": "^1.0.2",
"lodash": "2.4.1",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"nyc": "^15.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/branchRule/types/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/**
* @author Péter Halász <[email protected]>
*/
import _ from 'lodash';

/**
* MATCH branching rule
Expand Down Expand Up @@ -48,8 +47,8 @@ export default function matchBranchRuleFactory(
return Promise.all([
responseStore.getCorrectResponse(correctIdentifier),
responseStore.getResponse(variableIdentifier)
]).then(function(result) {
return _.contains(result[0], result[1]);
]).then(function (result) {
return result[0].includes(result[1]);
});
}
};
Expand Down
27 changes: 11 additions & 16 deletions src/helpers/currentItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var currentItemHelper = {
*/
getResponseDeclaration: function getResponseDeclaration(runner, identifier) {
var found = null;
_.forEach(currentItemHelper.getDeclarations(runner), function(declaration) {
_.forEach(currentItemHelper.getDeclarations(runner), function (declaration) {
var attributes = declaration.attributes || {};
if (attributes.identifier === identifier) {
found = declaration;
Expand Down Expand Up @@ -100,9 +100,9 @@ var currentItemHelper = {
if (baseType === 'boolean') {
transform = v => v === true || v === 'true';
} else if (baseType === 'integer') {
transform = v => typeof v === 'number' ? v : parseInt(v);
transform = v => (typeof v === 'number' ? v : parseInt(v));
} else if (baseType === 'float') {
transform = v => typeof v === 'number' ? v : parseFloat(v);
transform = v => (typeof v === 'number' ? v : parseFloat(v));
} else if (baseType === 'directedPair' || baseType === 'pair') {
transform = v => {
if (_.isString(v)) {
Expand Down Expand Up @@ -155,11 +155,7 @@ var currentItemHelper = {

const stringyValue = 'string' === baseType || 'integer' === baseType || 'float' === baseType;

return (
null === value ||
(stringyValue && value === '') ||
(cardinality !== 'single' && _.isEmpty(value))
);
return null === value || (stringyValue && value === '') || (cardinality !== 'single' && _.isEmpty(value));
},

/**
Expand Down Expand Up @@ -200,7 +196,7 @@ var currentItemHelper = {

var constraintValues = {};

_.forEach(interactions, function(interaction) {
_.forEach(interactions, function (interaction) {
var attributes = interaction.attributes || {};
var qtiClass = interaction.__proto__.qtiClass;
var constraintProperty;
Expand Down Expand Up @@ -233,7 +229,7 @@ var currentItemHelper = {
declarations = currentItemHelper.getDeclarations(runner);
constraintValues = currentItemHelper.guessInteractionConstraintValues(runner);

_.forEach(declarations, function(declaration) {
_.forEach(declarations, function (declaration) {
var attributes = declaration.attributes || {};
var response = responses[attributes.identifier];
var baseType = attributes.baseType;
Expand Down Expand Up @@ -272,12 +268,11 @@ var currentItemHelper = {

return _(interactions)
.values()
.filter(function(element) {
.filter(function (element) {
return element.qtiClass === 'include';
})
.pluck('attributes')
.pluck('href')
.value();
.value()
.map(val => (val.attributes ? val.attributes.href : null));
},

/**
Expand All @@ -291,9 +286,9 @@ var currentItemHelper = {
var textStimuli;
if (stimuli.length > 0) {
// Filter the ones containing text:
textStimuli = stimuli.filter(function(stimulusHref) {
textStimuli = stimuli.filter(function (stimulusHref) {
var domNode = document.querySelector(`.qti-include[data-href="${stimulusHref}"]`);
return _(domNode.childNodes).some(function(child) {
return _(domNode.childNodes).some(function (child) {
return child.nodeType === child.TEXT_NODE;
});
});
Expand Down
14 changes: 3 additions & 11 deletions src/navigator/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import testContextBuilder from 'taoQtiTest/runner/helpers/testContextBuilder';
* @throws {TypeError} if the given parameters aren't objects
*/
var navigatorFactory = function navigatorFactory(testContext, testMap) {
if (!_.all([testContext, testMap], _.isPlainObject)) {
if (![testContext, testMap].every(_.isPlainObject)) {
throw new TypeError('The navigator must be built with a testData, a testContext and a testMap');
}

Expand All @@ -64,23 +64,15 @@ var navigatorFactory = function navigatorFactory(testContext, testMap) {
* @returns {Object} the new test context
*/
nextItem: function nextItem() {
return testContextBuilder.buildTestContextFromPosition(
testContext,
testMap,
testContext.itemPosition + 1
);
return testContextBuilder.buildTestContextFromPosition(testContext, testMap, testContext.itemPosition + 1);
},

/**
* Navigate to the next item
* @returns {Object} the new test context
*/
previousItem: function previsousItem() {
return testContextBuilder.buildTestContextFromPosition(
testContext,
testMap,
testContext.itemPosition - 1
);
return testContextBuilder.buildTestContextFromPosition(testContext, testMap, testContext.itemPosition - 1);
},

/**
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/controls/timer/strategy/strategyHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ export default function getStrategyHandler(testRunner, strategies) {
*/
var applyToStrategies = function applyToStrategies(timerId, action) {
var api = _.keys(strategyHandler);
if (_.isEmpty(timerId) || _.isEmpty(action) || !_.contains(api, action)) {
if (_.isEmpty(timerId) || _.isEmpty(action) || !api.includes(action)) {
throw new TypeError('Invalid timer id or unauthorized action');
}

if (!_.isArray(actives[timerId])) {
return Promise.resolve();
}
return Promise.all(
_.map(actives[timerId], function(strategy) {
_.map(actives[timerId], function (strategy) {
if (_.isFunction(strategy[action])) {
return strategy[action]();
}
Expand All @@ -96,7 +96,7 @@ export default function getStrategyHandler(testRunner, strategies) {
* @returns {Promise} resolves once the set up is done
*/
setUp: function setUp(timer) {
_.forEach(availableStrategies, function(availableStrategy) {
_.forEach(availableStrategies, function (availableStrategy) {
var strategy = availableStrategy(testRunner, timer);
if (strategy !== false) {
actives[timer.id] = actives[timer.id] || [];
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function getStrategyHandler(testRunner, strategies) {
* @returns {Promise}
*/
tearDown: function tearDown(timer) {
return applyToStrategies(timer.id, 'tearDown').then(function() {
return applyToStrategies(timer.id, 'tearDown').then(function () {
actives = _.omit(actives, timer.id);
});
}
Expand Down
25 changes: 9 additions & 16 deletions src/plugins/controls/timer/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var getScope = function getScope(value) {
if (scopeMapping[value]) {
return scopeMapping[value];
}
if (_.contains(scopes, value)) {
if (scopes.includes(value)) {
return value;
}
return null;
Expand Down Expand Up @@ -101,9 +101,9 @@ export default function getTimers(timeConstraints, isLinear, config) {
*/
var constraintsWarnings = _.reduce(
config.warnings,
function(acc, warnings, qtiScope) {
function (acc, warnings, qtiScope) {
var scope = getScope(qtiScope);
acc[scope] = _.map(warnings, function(value, key) {
acc[scope] = _.map(warnings, function (value, key) {
return {
threshold: parseInt(key, 10) * precision,
message: function applyMessage(remainingTime) {
Expand All @@ -120,7 +120,6 @@ export default function getTimers(timeConstraints, isLinear, config) {
{}
);


/**
* The warnings comes in a weird format (ie. {scope:[threshold, ...]}) , so we reformat them
*/
Expand All @@ -129,18 +128,12 @@ export default function getTimers(timeConstraints, isLinear, config) {
(acc, warnings, qtiScope) => {
const scope = getScope(qtiScope);

acc[scope] = _.map(warnings, (value) => ({
acc[scope] = _.map(warnings, value => ({
threshold: parseInt(value, 10) * precision,
message: function applyMessage(remainingTime, unansweredQuestions) {
const displayRemaining = moment
.duration(remainingTime / precision, 'seconds')
.humanize();

return format(
warningMessagesForScreenraeder[scope],
displayRemaining,
unansweredQuestions
);
const displayRemaining = moment.duration(remainingTime / precision, 'seconds').humanize();

return format(warningMessagesForScreenraeder[scope], displayRemaining, unansweredQuestions);
},
scope,
shown: false
Expand Down Expand Up @@ -178,7 +171,7 @@ export default function getTimers(timeConstraints, isLinear, config) {
timer.allowLateSubmission = constraintData.allowLateSubmission;

if (type === 'min') {
timer.id = `${type }-${ constraintData.scope }-${ constraintData.source}`;
timer.id = `${type}-${constraintData.scope}-${constraintData.source}`;
timer.originalTime = constraintData.minTime * precision;
timer.remainingTime = constraintData.minTimeRemaining * precision;
} else {
Expand Down Expand Up @@ -211,7 +204,7 @@ export default function getTimers(timeConstraints, isLinear, config) {
return timer;
};

_.forEach(timeConstraints, function(timeConstraint) {
_.forEach(timeConstraints, function (timeConstraint) {
var constraintData = _.clone(timeConstraint);
var newTimer;

Expand Down
Loading

0 comments on commit 398f4db

Please sign in to comment.