Advanced Requirements - Gerrit0/CTFd_unique_challenges GitHub Wiki
For Unique Challenges, this plugin makes it possible for administrators to specify more flexible requirements than the builtin requirements which only allow specifying other challenges as prerequisites.
There are 25 building blocks that can be used to specify almost any combination of requirements. The blocks can be combined into four categories.
- Constant
- Logical
- Dynamic
- Arithmetic
Of these, most of the time you will probably only use the first three.
The advanced requirements GUI is a more user friendly wrapper over LispIsh. There is additional documentation and description of the language itself on the LispIsh documentation page.
Constant
There are two constant blocks, String
and Number
. These can be used to specify values for comparison using the logical blocks or as parameters to the dynamic blocks. In the UI, they look like this:
Constant blocks don't do anything special, they are just a way to specify static values.
Logical
There are 9 logical blocks, though four are most commonly used. They are: =, ≠, < ≤, > ≥, AND, OR, and NOT.
A value is "truthy" unless it is false, the number 0, or the empty string.
Operator | Description |
---|---|
= | Checks if all child blocks return equal values, if they do, returns true, otherwise returns false. |
≠ | Checks if all child blocks return distinct values. If they do, returns true, otherwise returns false. |
AND | True if all child blocks return truthy values, otherwise false. |
OR | True if any child block returns a truthy value, otherwise false. |
NOT | Inverts the truthiness of its child block |
< | True if every value is strictly less than the value following it. |
≤ | True if every value is less than or equal to the value following it. |
> | True if every value is strictly greater than the value following it. |
≥ | True if every value is greater than or equal to the value following it. |
Dynamic
Dynamic blocks change their value depending on which user views them and the current settings of the CTF. There are 7 dynamic blocks.
Block | Description |
---|---|
User name | Evaluates to the current user's username. Note that usernames are not necessarily unique and may be changed at any time. |
User ID | Evaluates to the current user's user ID. User IDs are fixed and are displayed as the number in the URL when you view that user's page. |
User email | Evaluates to the current user's email. Note that while emails are unique, they are not static and may be changed at any time. |
User score | Evaluates to the user's total score from completing challenges and from awards. |
Before / After | Checks if the current date is before or after chosen time. |
Completed challenges | Checks if the user has completed all of the listed challenges. If any challenge has not been completed, returns false. Otherwise returns true. |
Cohorts | Checks if the current user is in all of the listed cohorts. If they are not in any of the cohorts, returns false. Otherwise returns true. |
Arithmetic
The arithmetic blocks make it possible to do some limited math operations on the result from the dynamic user score block. Note that the results from logical blocks can also be used as arithmetic values. True is interpreted as 1, and false is interpreted as 0.
Operation | Description |
---|---|
+ | Adds all the child blocks together |
- | Subtracts the value from separate child blocks. If only one child block is provided, returns the unary negation of its value. |
max | Takes the maximum value from all the child blocks. |
min | Takes the minimum value from all the child blocks. |