mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Flip value and initial for dynamic challenges to better support ctfcli (#1921)
* Makes the initial value for a dynamic challenge provided by the `initial` argument instead of the `value` argument. This makes it easier to support ctfcli. Refer to https://github.com/CTFd/ctfcli/issues/13. * Closes #1875
This commit is contained in:
@@ -22,7 +22,7 @@ class DynamicChallenge(Challenges):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DynamicChallenge, self).__init__(**kwargs)
|
super(DynamicChallenge, self).__init__(**kwargs)
|
||||||
self.initial = kwargs["value"]
|
self.value = kwargs["initial"]
|
||||||
|
|
||||||
|
|
||||||
class DynamicValueChallenge(BaseChallenge):
|
class DynamicValueChallenge(BaseChallenge):
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
This is how many points the challenge is worth initially.
|
This is how many points the challenge is worth initially.
|
||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
<input type="number" class="form-control" name="value" placeholder="Enter value" required>
|
<input type="number" class="form-control" name="initial" placeholder="Enter value" required>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def test_missing_challenge_type():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "visible",
|
"state": "visible",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def test_can_create_dynamic_challenge():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "hidden",
|
"state": "hidden",
|
||||||
@@ -54,7 +54,7 @@ def test_can_update_dynamic_challenge():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "hidden",
|
"state": "hidden",
|
||||||
@@ -102,7 +102,7 @@ def test_can_add_requirement_dynamic_challenge():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "hidden",
|
"state": "hidden",
|
||||||
@@ -160,7 +160,7 @@ def test_can_delete_dynamic_challenge():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "hidden",
|
"state": "hidden",
|
||||||
@@ -191,7 +191,7 @@ def test_dynamic_challenge_loses_value_properly():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "visible",
|
"state": "visible",
|
||||||
@@ -240,7 +240,7 @@ def test_dynamic_challenge_doesnt_lose_value_on_update():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 10000,
|
"initial": 10000,
|
||||||
"decay": 4,
|
"decay": 4,
|
||||||
"minimum": 10,
|
"minimum": 10,
|
||||||
"state": "visible",
|
"state": "visible",
|
||||||
@@ -273,7 +273,7 @@ def test_dynamic_challenge_value_isnt_affected_by_hidden_users():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "visible",
|
"state": "visible",
|
||||||
@@ -330,7 +330,7 @@ def test_dynamic_challenges_reset():
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"value": 100,
|
"initial": 100,
|
||||||
"decay": 20,
|
"decay": 20,
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"state": "hidden",
|
"state": "hidden",
|
||||||
|
|||||||
Reference in New Issue
Block a user