Skip to content

Commit

Permalink
Don't clear assessment penalty fields on initial load (#2006)
Browse files Browse the repository at this point in the history
* Don't clear on initial load

* Remove extraneous spaces
  • Loading branch information
damianhxy authored Nov 15, 2023
1 parent 5a0c3fc commit 2417815
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/assets/javascripts/edit_assessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@
});

// Penalties tab
let initial_load = true; // determines if the page is loading for the first time, if so, don't clear the fields

function unlimited_submissions_callback() {
const checked = $(this).prop('checked');
const $max_submissions = $('#assessment_max_submissions');
$max_submissions.prop('disabled', checked);
if (checked) {
$max_submissions.val('Unlimited submissions');
} else {
} else if (!initial_load) {
$max_submissions.val('');
}
}
Expand All @@ -73,7 +75,7 @@
$max_grace_days.prop('disabled', checked);
if (checked) {
$max_grace_days.val('Unlimited grace days');
} else {
} else if (!initial_load) {
$max_grace_days.val('');
}
}
Expand All @@ -87,7 +89,7 @@
$latePenaltyField.find('select').prop('disabled', checked);
if (checked) {
$latePenaltyValue.val('Course default');
} else {
} else if (!initial_load) {
$latePenaltyValue.val('');
}
}
Expand All @@ -99,7 +101,7 @@
$version_threshold.prop('disabled', checked);
if (checked) {
$version_threshold.val('Course default');
} else {
} else if (!initial_load) {
$version_threshold.val('');
}
}
Expand All @@ -113,7 +115,7 @@
$versionPenaltyField.find('select').prop('disabled', checked);
if (checked) {
$versionPenaltyValue.val('Course default');
} else {
} else if (!initial_load) {
$versionPenaltyValue.val('');
}
}
Expand All @@ -125,6 +127,7 @@
use_default_late_penalty_callback.call($('#use_default_late_penalty'));
use_default_version_threshold_callback.call($('#use_default_version_threshold'));
use_default_version_penalty_callback.call($('#use_default_version_penalty'));
initial_load = false;
});

})();
Expand Down

0 comments on commit 2417815

Please sign in to comment.