Skip to content

Commit

Permalink
Merge pull request #2608 from oat-sa/fix/MS-2872/dissabling-external-…
Browse files Browse the repository at this point in the history
…score

fix: improve external scoring
  • Loading branch information
tikhanovichA authored Nov 6, 2024
2 parents 93f6637 + e355295 commit 9e55f2d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions views/js/qtiCreator/plugins/panel/outcomeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ define([
* @param {Object} item
* @param {JQuery} $outcomeEditorPanel
*/
function renderListing(item, $outcomeEditorPanel) {
function renderListing(item, $outcomeEditorPanel, isNewItem = false) {
const readOnlyRpVariables = getRpUsedVariables(item);
const scoreMaxScoreVisible = features.isVisible('taoQtiItem/creator/interaction/response/outcomeDeclarations/scoreMaxScore');
const scoreExternalScored = _.get(_.find(item.outcomes, function (outcome) {
Expand Down Expand Up @@ -154,7 +154,7 @@ define([
: __('Delete'),
titleEdit: readonly ? __('Cannot edit a variable currently used in response processing') : __('Edit'),
readonly: readonly,
externalScoredDisabled: externalScoredDisabled || 0
externalScoredDisabled: isNewItem ? (externalScoredDisabled || 0) : 0
};
});

Expand Down Expand Up @@ -199,13 +199,6 @@ define([
}
};

function hasAllNotExternalScored(outcomes) {
return _.every(outcomes, function (outcome) {
return outcome.attributes &&
outcome.attributes.externalScored === externalScoredOptions.none
});
}

function setMinumumMaximumValue(outcomeElement, outcomeValueContainer, min, max) {
outcomeElement.attr('normalMaximum', max);
outcomeValueContainer.find('[name="normalMaximum"]').val(max);
Expand Down Expand Up @@ -241,9 +234,10 @@ define([
// Iterate over each element in responsePanel and check if any value != none
responsePanel.find('.outcome-container').each(function () {
const currentSerial = $(this).data('serial');
const id = $(this).find(".identifier").val();

// Skip the element with the same serial, as we're focusing on other elements
if (currentSerial === serial) {
if (currentSerial === serial || id === 'SCORE') {
return;
}

Expand Down Expand Up @@ -341,10 +335,6 @@ define([
showScoringTraitWarningOnInvalidValue();
}

if (hasAllNotExternalScored(item.outcome)) {
$outcomeContainer.find("select[name='externalScored']").attr('disabled', false);
}

//attach form change callbacks
formElement.setChangeCallbacks(
$outcomeContainer,
Expand Down Expand Up @@ -503,7 +493,7 @@ define([
newOutcome.buildIdentifier('OUTCOME');

//refresh the list
renderListing(item, $outcomeEditorPanel);
renderListing(item, $outcomeEditorPanel, true);
});

//attach to response form side panel
Expand Down

0 comments on commit 9e55f2d

Please sign in to comment.