Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -r7116e79c883ad42375d9fa3278dec8a84733ea86 -r0e7e800e4c633b22882182c4396a4a094cea6d8d --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 7116e79c883ad42375d9fa3278dec8a84733ea86) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 0e7e800e4c633b22882182c4396a4a094cea6d8d) @@ -1135,13 +1135,19 @@ $('').text(activity.title).appendTo(row); $('').text(activity.gradebookToolOutputDefinitionDescription).appendTo(row); $('').append(weight).appendTo(row); + + if (!activity.gradebookToolOutputWeight) { + activity.gradebookToolOutputWeight = 0; + } + weight.spinner({ 'min' : 0, 'max' : 100, 'change' : function(){ var value = $(this).val(); if (value == "" || isNaN(value)) { - value = null; + value = 0; + $(this).val(value); } activity.gradebookToolOutputWeight = value; layout.weightsDialog.data('sumWeights')(); @@ -1164,32 +1170,30 @@ }, 'sumWeights' : function(firstRun){ - var sum = null; + var sum = 0; $('tbody tr', layout.weightsDialog).each(function(){ + var weight = $('input', this); if (!firstRun && !weight.spinner('isValid')) { - weight.val(null); + weight.val(0); return true; } var value = $(this).data('activity').gradebookToolOutputWeight; if (value) { - if (sum == null) { - sum = 0; - } sum += +value; } }); var sumCell = $('#sumWeightCell', layout.weightsDialog); - if (sum == null) { - sumCell.empty(); - } else { + if (sum) { sumCell.text(sum + '%'); if (sum == 100) { sumCell.removeClass('incorrect'); } else { sumCell.addClass('incorrect'); } + } else { + sumCell.empty(); } } } @@ -2328,7 +2332,7 @@ layoutActivityDefs = [], systemGate = null, error = null, - weightsSum = null; + weightsSum = 0; // validate if groupings and inputs still exist for activities that need them $.each(layout.activities, function(){ @@ -2397,14 +2401,11 @@ if (this.gradebookToolOutputDefinitionWeightable && (this.gradebookToolOutputWeight || this.gradebookToolOutputWeight == 0)) { - if (weightsSum == null) { - weightsSum = 0; - } weightsSum += +this.gradebookToolOutputWeight; } }); - if (weightsSum != null && weightsSum != 100) { + if (weightsSum != 0 && weightsSum != 100) { if (displayErrors) { layout.ldStoreDialog.modal('hide'); layout.infoDialog.data('show')(LABELS.WEIGHTS_SUM_ERROR);