mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-02-20 13:44:22 +01:00
Fix issue where dynamic challenges break if the decay is 0 (#2255)
* Fix issue where dynamic challenges break if the decay is 0 * Prevent users from adding a decay limit of 0 to dynamic value challenges
This commit is contained in:
@@ -69,6 +69,11 @@ class DynamicValueChallenge(BaseChallenge):
|
||||
# We subtract -1 to allow the first solver to get max point value
|
||||
solve_count -= 1
|
||||
|
||||
# Handle situations where admins have entered a 0 decay
|
||||
# This is invalid as it can cause a division by zero
|
||||
if challenge.decay == 0:
|
||||
challenge.decay = 1
|
||||
|
||||
# It is important that this calculation takes into account floats.
|
||||
# Hence this file uses from __future__ import division
|
||||
value = (
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
The amount of solves before the challenge reaches its minimum value
|
||||
</small>
|
||||
</label>
|
||||
<input type="number" class="form-control" name="decay" placeholder="Enter decay limit" required>
|
||||
<input type="number" class="form-control" name="decay" min="1" placeholder="Enter decay limit" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
The amount of solves before the challenge reaches its minimum value
|
||||
</small>
|
||||
</label>
|
||||
<input type="number" class="form-control chal-decay" name="decay" value="{{ challenge.decay }}" required>
|
||||
<input type="number" class="form-control chal-decay" min="1" name="decay" value="{{ challenge.decay }}" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user