Skip to content

Commit

Permalink
Merge pull request #2419 from oat-sa/feature/AUT-3352-Allow-Authors-t…
Browse files Browse the repository at this point in the history
…o-edit-SCORE-Outcome-declaration

feature: make SCORE outcome editable
  • Loading branch information
viktar-dzmitryieu-tao authored Nov 22, 2023
2 parents 1d7664b + 8dad863 commit b7f268c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
4 changes: 3 additions & 1 deletion views/js/qtiCreator/model/mixin/editableInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ define([
if (!outcome) {
outcome = item.createOutcomeDeclaration({
cardinality: 'single',
baseType: 'float'
baseType: 'float',
normalMinimum: 0.0,
normalMaximum: 0.0
});

buildIdentifier
Expand Down
38 changes: 31 additions & 7 deletions views/js/qtiCreator/plugins/panel/outcomeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ define([
human: 'human',
externalMachine: 'externalMachine'
};
const externalScoredValidOptions = [
externalScoredOptions.human,
externalScoredOptions.externalMachine
];

/**
* Get the identifiers of the variables that are used in the response declaration
Expand All @@ -68,15 +72,14 @@ define([
*/
function getRpUsedVariables(item) {
const rpXml = xmlRenderer.render(item.responseProcessing);
const variables = [ ];
if (rpXml !== '') {
variables.push('SCORE', 'MAXSCORE');
}
const variables = ['MAXSCORE'];
const $rp = $(rpXml);

$rp.find('variable,setOutcomeValue').each(function () {
const id = $(this).attr('identifier');
variables.push(id);
if (id !== 'SCORE') {
variables.push(id);
}
});

return _.uniq(variables);
Expand All @@ -89,10 +92,10 @@ define([
* @param {JQuery} $outcomeEditorPanel
*/
function renderListing(item, $outcomeEditorPanel) {
const rpVariables = getRpUsedVariables(item);
const readOnlyRpVariables = getRpUsedVariables(item);

const outcomesData = _.map(item.outcomes, function (outcome) {
const readonly = rpVariables.indexOf(outcome.id()) >= 0;
const readonly = readOnlyRpVariables.indexOf(outcome.id()) >= 0;

const externalScored = {
none: { label: __('None'), selected: !outcome.attr('externalScored') },
Expand Down Expand Up @@ -197,10 +200,22 @@ define([
const serial = $outcomeContainer.data('serial');
const outcomeElement = Element.getElementBySerial(serial);
const $labelContainer = $outcomeContainer.find('.identifier-label');
const $incrementerContainer = $outcomeContainer.find(".incrementer");
const $identifierLabel = $labelContainer.find('.label');
const $identifierInput = $labelContainer.find('.identifier');
const isScoreOutcome = outcomeElement.attributes.identifier === 'SCORE';
let isScoringTraitValidationEnabled =
outcomeElement.attr('externalScored') === externalScoredOptions.human;
if (
isScoreOutcome &&
!externalScoredValidOptions.includes(
outcomeElement.attr("externalScored")
)
) {
$incrementerContainer.incrementer("disable");
} else {
$incrementerContainer.incrementer("enable");
}

$outcomeContainer.addClass('editing');
$outcomeContainer.removeClass('editable');
Expand Down Expand Up @@ -261,6 +276,15 @@ define([
externalScored(outcome, value) {
//Turn off scoring trait validation if externalScored is not human
isScoringTraitValidationEnabled = value === externalScoredOptions.human;
if (isScoreOutcome && value !== externalScoredOptions.none) {
$incrementerContainer.incrementer("enable");
} else if (isScoreOutcome) {
outcome.attr('normalMaximum', 0);
$outcomeValueContainer.find('[name="normalMaximum"]').val(0);
outcome.attr('normalMinimum', 0);
$outcomeValueContainer.find('[name="normalMinimum"]').val(0);
$incrementerContainer.incrementer("disable");
}

/**
* Attaches scoring trait warning tooltips when `externalScored` is `human`
Expand Down
6 changes: 3 additions & 3 deletions views/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 views/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"dependencies": {
"@oat-sa/tao-item-runner": "^0.8.2",
"@oat-sa/tao-item-runner-qti": "^1.11.2"
"@oat-sa/tao-item-runner-qti": "^2.1.0"
}
}

0 comments on commit b7f268c

Please sign in to comment.