Skip to content

Commit

Permalink
Merge branch 'release-2.3.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
oat-github-bot committed Jul 22, 2024
2 parents 2ecc18d + 37ead4a commit 34e7e66
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 17 deletions.
4 changes: 2 additions & 2 deletions 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-qti",
"version": "2.3.3",
"version": "2.3.4",
"displayName": "TAO Item Runner QTI",
"description": "TAO QTI Item Runner modules",
"files": [
Expand Down
15 changes: 14 additions & 1 deletion src/qtiItem/helper/maxScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,26 @@ export default {
const outcomesWithExternalScored = customOutcomes.filter(outcome => {
return externalScoredValues.includes(outcome.attr('externalScored'));
});
const isResponsesEmpty = _.isEmpty(item.responses);
// remove MAXSCORE and SCORE outcome variables when all interactions are configured with none response processing rule,
// and the externalScored property of the SCORE variable is set to None
// and there are no other outcome variables with externalScored property set to human or externalMachine
if (!scoreOutcome.attr('externalScored') && isAllResponseProcessingRulesNone && outcomesWithExternalScored.size() === 0) {
// or in case all interactions are without responses
if (
(!scoreOutcome.attr('externalScored') &&
isAllResponseProcessingRulesNone &&
outcomesWithExternalScored.size() === 0) ||
isResponsesEmpty
) {
item.removeOutcome('MAXSCORE');
item.removeOutcome('SCORE');
}
// remove custom outcomes if all interactions are without responses
if (isResponsesEmpty) {
customOutcomes.forEach(outcome => {
item.removeOutcome(outcome.id());
});
}
}
},

Expand Down
97 changes: 97 additions & 0 deletions test/qtiItem/maxScore/data/no-responses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"identifier": "i669517204e97420240715143336d37c",
"serial": "item_6695325e7f312981018589",
"qtiClass": "assessmentItem",
"attributes": {
"identifier": "i669517204e97420240715143336d37c",
"title": "Item 12",
"label": "Item 12",
"xml:lang": "en-US",
"adaptive": false,
"timeDependent": false,
"toolName": "TAO",
"toolVersion": "2024.08 LTS",
"class": ""
},
"body": {
"serial": "container_containeritembody_6695325e7f30a634634763",
"body": "\n <div class=\"grid-row\">\n <div class=\"col-12\">\n <p>Lorem ipsum dolor sit amet, consectetur adipisicing ...<\/p>\n <\/div>\n <\/div>\n ",
"elements": {},
"attributes": [],
"debug": {
"relatedItem": "item_6695325e7f312981018589"
}
},
"debug": {
"relatedItem": "item_6695325e7f312981018589"
},
"namespaces": {
"": "http:\/\/www.imsglobal.org\/xsd\/imsqti_v2p2",
"m": "http:\/\/www.w3.org\/1998\/Math\/MathML",
"xsi": "http:\/\/www.w3.org\/2001\/XMLSchema-instance"
},
"schemaLocations": {
"http:\/\/www.imsglobal.org\/xsd\/imsqti_v2p2": "http:\/\/www.imsglobal.org\/xsd\/qti\/qtiv2p2\/imsqti_v2p2.xsd"
},
"stylesheets": {},
"outcomes": {
"outcomedeclaration_654ce58fdf6c6514417636": {
"identifier": "OUTCOME_1456",
"serial": "outcomedeclaration_654ce58fdf6c6514417636",
"qtiClass": "outcomeDeclaration",
"attributes": {
"identifier": "OUTCOME_145",
"cardinality": "single",
"baseType": "float",
"longInterpretation": "",
"normalMaximum": 10,
"normalMinimum": 0
},
"debug": {
"relatedItem": "item_6695325e7f312981018589"
},
"defaultValue": null
},
"outcomedeclaration_58fdf5897e8ad024055546": {
"identifier": "SCORE",
"serial": "outcomedeclaration_58fdf5897e8ad024055546",
"qtiClass": "outcomeDeclaration",
"attributes": {
"identifier": "SCORE",
"cardinality": "single",
"baseType": "float"
},
"debug": {
"relatedItem": "item_6695325e7f312981018589"
},
"defaultValue": null
},
"outcomedeclaration_666ad8e04f8de522536800": {
"identifier": "MAXSCORE",
"serial": "outcomedeclaration_666ad8e04f8de522536800",
"qtiClass": "outcomeDeclaration",
"attributes": {
"identifier": "MAXSCORE",
"cardinality": "single",
"baseType": "float"
},
"debug": {
"relatedItem": "item_6695325e7f312981018589"
},
"defaultValue": "1"
}
},
"responses": {},
"feedbacks": {},
"responseProcessing": {
"serial": "response_templatesdriven_6695325e7f4f3719481730",
"qtiClass": "responseProcessing",
"attributes": {},
"debug": {
"relatedItem": "item_6695325e7f312981018589"
},
"processingType": "templateDriven",
"responseRules": []
},
"apipAccessibility": ""
}
37 changes: 24 additions & 13 deletions test/qtiItem/maxScore/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ define([
'json!taoQtiItem/test/qtiItem/maxScore/data/response-none.json',
'json!taoQtiItem/test/qtiItem/maxScore/data/external-scored.json',
'json!taoQtiItem/test/qtiItem/maxScore/data/external-scored-none.json',
'json!taoQtiItem/test/qtiItem/maxScore/data/external-scored-outcome.json'
'json!taoQtiItem/test/qtiItem/maxScore/data/external-scored-outcome.json',
'json!taoQtiItem/test/qtiItem/maxScore/data/no-responses.json'
], function(
_,
Element,
Expand Down Expand Up @@ -118,11 +119,20 @@ define([
dataResponseNone,
dataResponseExternalScored,
dataResponseExternalScoredNone,
dataResponseExternalScoredOutcome
dataResponseExternalScoredOutcome,
dataResponseNoResponses
) {
'use strict';

const externalScoredValues = ['human', 'externalMachine'];
const DEFAULT_EXPECT_COUNT = 3;

function getCustomOutcomes(item) {
const customOutcomes = _(item.getOutcomes()).filter(function (outcome) {
return outcome.id() !== 'SCORE' && outcome.id() !== 'MAXSCORE';
});
return customOutcomes;
}

var cases = [
{ title: 'single choice correct', data: dataChoiceCorrectMultiple, expectedMaximum: 1, maxScore: 1 },
Expand Down Expand Up @@ -415,11 +425,17 @@ define([
},
{ title: 'response - none', data: dataResponseNone, expectedMaximum: 5, maxScore: 5 },
{ title: 'external scored', data: dataResponseExternalScored, expectedMaximum: 6, maxScore: 6 },
{ title: 'removed MAXSCORE and SCORE', data: dataResponseExternalScoredNone, expectedMaximum: undefined, maxScore: undefined },
{ title: 'removed MAXSCORE and SCORE', data: dataResponseExternalScoredNone, expectedMaximum: void 0, maxScore: void 0 },
{ title: 'MAXSCORE and SCORE are NOT removed when outcome has external scored', data: dataResponseExternalScoredOutcome, expectedMaximum: 0, maxScore: 1 },
{ title: 'Outcome variables are removed when there are no responses in the item', data: dataResponseNoResponses, expectedMaximum: void 0, maxScore: void 0, outcomes: 0 },
];

QUnit.cases.init(cases).test('setNormalMaximum', function(settings, assert) {
const expectCount = [
settings.maxScore,
settings.expectedMaximum,
settings.outcomes
].filter(value => !_.isUndefined(value)).length + DEFAULT_EXPECT_COUNT;
var ready = assert.async();

var loader = new Loader();
Expand All @@ -436,10 +452,7 @@ define([
assert.ok(Element.isA(item, 'assessmentItem'), 'item loaded');

outcomeScore = item.getOutcomeDeclaration('SCORE');
const customOutcomes = _(item.getOutcomes()).filter(function (outcome) {
return outcome.id() !== 'SCORE' && outcome.id() !== 'MAXSCORE';
});
const outcomesWithExternalScored = customOutcomes.filter(outcome => {
const outcomesWithExternalScored = getCustomOutcomes(item).filter(outcome => {
return externalScoredValues.includes(outcome.attr('externalScored'));
});

Expand Down Expand Up @@ -467,18 +480,16 @@ define([

maxScore.setMaxScore(item);
if (!_.isUndefined(settings.maxScore)) {
assert.expect(5);
outcomeMaxScore = item.getOutcomeDeclaration('MAXSCORE');
assert.ok(Element.isA(outcomeMaxScore, 'outcomeDeclaration'), 'MAXSCORE outcome exists');
assert.equal(outcomeMaxScore.getDefaultValue(), settings.maxScore);
} else {
if (!_.isUndefined(settings.expectedMaximum)) {
assert.expect(4);
} else {
assert.expect(3);
}
assert.ok(_.isUndefined(item.getOutcomeDeclaration('MAXSCORE')), 'MAXSCORE undefined');
}
if (!_.isUndefined(settings.outcomes)) {
assert.equal(_(item.getOutcomes()).size(), settings.outcomes, 'outcomes count');
}
assert.expect(expectCount);
});
});
});

0 comments on commit 34e7e66

Please sign in to comment.