From 7de82ef0273e8c7b6adef9abfc1c95c7540314d2 Mon Sep 17 00:00:00 2001 From: Shivam Singh Date: Thu, 9 Jul 2026 18:14:37 +0530 Subject: [PATCH 1/2] Fix negative seconds in submission countdown timer Decrement remaining_time on the source object instead of the formatted display string, and guard with <= 0 instead of === 0 to prevent the timer from showing negative values at zero. Fixes #4594 --- frontend/src/js/controllers/challengeCtrl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/js/controllers/challengeCtrl.js b/frontend/src/js/controllers/challengeCtrl.js index b485cec378..5a209c727a 100644 --- a/frontend/src/js/controllers/challengeCtrl.js +++ b/frontend/src/js/controllers/challengeCtrl.js @@ -339,10 +339,10 @@ "minutes": vm.minutes, "seconds": vm.remainingSeconds }; - if (vm.remainingTime === 0) { + if (vm.remainingTime <= 0) { vm.phaseRemainingSubmissionsFlags[details[i].id] = "showSubmissionNumbers"; } else { - vm.remainingSeconds--; + vm.eachPhase.limits.remaining_time--; } }; setInterval(function () { @@ -2081,10 +2081,10 @@ if (vm.remainingSeconds < 10) { vm.remainingSeconds = "0" + vm.remainingSeconds; } - if (vm.remainingTime === 0) { + if (vm.remainingTime <= 0) { vm.showSubmissionNumbers = true; } else { - vm.remainingSeconds--; + vm.message.remaining_time--; } }; setInterval(function() { From a05c06fd83071e28f02fc1719c2cedf444917e52 Mon Sep 17 00:00:00 2001 From: Shivam Singh Date: Thu, 9 Jul 2026 19:03:29 +0530 Subject: [PATCH 2/2] Fix test assertions to match countdown timer fix behavior After the countdown timer fix, vm.remainingTime holds the value copied from source before the decrement, so assertions must compare against constants rather than the mutated source property. --- frontend/tests/controllers-test/challengeCtrl.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/tests/controllers-test/challengeCtrl.test.js b/frontend/tests/controllers-test/challengeCtrl.test.js index b1d6dcfa84..4dedc1ffa2 100644 --- a/frontend/tests/controllers-test/challengeCtrl.test.js +++ b/frontend/tests/controllers-test/challengeCtrl.test.js @@ -706,7 +706,7 @@ describe('Unit tests for challenge controller', function () { expect(vm.phaseRemainingSubmissionsFlags[details[i].id]).toEqual('showClock'); // Unit tests for `countDownTimer` function - expect(vm.remainingTime).toEqual(vm.eachPhase.limits.remaining_time); + expect(vm.remainingTime).toEqual(12 / 12 / 12); expect(vm.days).toEqual(Math.floor(vm.remainingTime / 24 / 60 / 60)); expect(vm.hoursLeft).toEqual(Math.floor((vm.remainingTime) - (vm.days * 86400))); expect(vm.hours).toEqual(Math.floor(vm.hoursLeft / 3600)); @@ -1893,7 +1893,7 @@ describe('Unit tests for challenge controller', function () { expect(vm.message).toEqual(successResponse.phases.first_object.limits); expect(vm.showClock).toEqual(true); - expect(vm.remainingTime).toEqual(successResponse.phases.first_object.limits.remaining_time); + expect(vm.remainingTime).toEqual(36000); expect(vm.days).toEqual(Math.floor(vm.remainingTime / 24 / 60 / 60)); expect(vm.hoursLeft).toEqual(Math.floor((vm.remainingTime) - (vm.days * 86400))); expect(vm.hours).toEqual(Math.floor(vm.hoursLeft / 3600));