Repository: CTFd/CTFd

Issue:
Stub issue for ctfcli #13
https://github.com/CTFd/ctfcli/issues/13

This needs to be resolved in CTFd most likely.


Discussion:

Resolving patch:
diff --git a/CTFd/plugins/dynamic_challenges/__init__.py b/CTFd/plugins/dynamic_challenges/__init__.py
--- a/CTFd/plugins/dynamic_challenges/__init__.py
+++ b/CTFd/plugins/dynamic_challenges/__init__.py
@@ -22,7 +22,7 @@ class DynamicChallenge(Challenges):
 
     def __init__(self, *args, **kwargs):
         super(DynamicChallenge, self).__init__(**kwargs)
-        self.initial = kwargs["value"]
+        self.value = kwargs["initial"]
 
 
 class DynamicValueChallenge(BaseChallenge):


Test patch:
diff --git a/tests/challenges/test_challenge_types.py b/tests/challenges/test_challenge_types.py
--- a/tests/challenges/test_challenge_types.py
+++ b/tests/challenges/test_challenge_types.py
@@ -16,7 +16,7 @@ def test_missing_challenge_type():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "visible",
diff --git a/tests/challenges/test_dynamic.py b/tests/challenges/test_dynamic.py
--- a/tests/challenges/test_dynamic.py
+++ b/tests/challenges/test_dynamic.py
@@ -26,7 +26,7 @@ def test_can_create_dynamic_challenge():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "hidden",
@@ -54,7 +54,7 @@ def test_can_update_dynamic_challenge():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "hidden",
@@ -102,7 +102,7 @@ def test_can_add_requirement_dynamic_challenge():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "hidden",
@@ -160,7 +160,7 @@ def test_can_delete_dynamic_challenge():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "hidden",
@@ -191,7 +191,7 @@ def test_dynamic_challenge_loses_value_properly():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "visible",
@@ -240,7 +240,7 @@ def test_dynamic_challenge_doesnt_lose_value_on_update():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 10000,
+            "initial": 10000,
             "decay": 4,
             "minimum": 10,
             "state": "visible",
@@ -273,7 +273,7 @@ def test_dynamic_challenge_value_isnt_affected_by_hidden_users():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "visible",
@@ -330,7 +330,7 @@ def test_dynamic_challenges_reset():
             "name": "name",
             "category": "category",
             "description": "description",
-            "value": 100,
+            "initial": 100,
             "decay": 20,
             "minimum": 1,
             "state": "hidden",