Skip to content

Commit dd89468

Browse files
adb014David BatemanColdHeatCopilot
authored
Add bulk editing of solution visibility (#2851)
* Add bulk editing of solution visibility to Challenges page in Admin Panel * Add `solved` solution state --------- Co-authored-by: David Bateman <David.Bateman@edf.fr> Co-authored-by: Kevin Chung <kchung@ctfd.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 9aeed56 commit dd89468

24 files changed

+73
-52
lines changed

assets/js/challenges.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ Alpine.data("Challenge", () => ({
142142
return data.solution_id;
143143
},
144144

145+
getSolutionState() {
146+
let data = Alpine.store("challenge").data;
147+
return data.solution_state;
148+
},
149+
150+
setSolutionId(solutionId) {
151+
Alpine.store("challenge").data.solution_id = solutionId;
152+
},
153+
145154
async showSolution() {
146155
let solution_id = this.getSolutionId();
147156
CTFd._functions.challenge.displaySolution = solution => {
@@ -213,6 +222,20 @@ Alpine.data("Challenge", () => ({
213222
this.submission = "";
214223
}
215224

225+
// Decide whether to check for the solution
226+
if (this.getSolutionId() == null) {
227+
if (
228+
CTFd.pages.challenge.checkSolution(
229+
this.getSolutionState(),
230+
Alpine.store("challenge").data,
231+
this.response.data.status,
232+
)
233+
) {
234+
let data = await CTFd.pages.challenge.getSolution(this.id);
235+
this.setSolutionId(data.id);
236+
}
237+
}
238+
216239
// Increment attempts counter
217240
if (
218241
this.max_attempts > 0 &&

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"verify": "vite build; git diff --quiet --exit-code"
1111
},
1212
"dependencies": {
13-
"@ctfdio/ctfd-js": "^0.0.18",
13+
"@ctfdio/ctfd-js": "^0.0.19",
1414
"@fontsource/lato": "^4.5.3",
1515
"@fontsource/raleway": "^4.5.3",
1616
"@fortawesome/fontawesome-free": "6.5.1",

static/assets/challenges.6ea6caae.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/assets/challenges.f0f38b54.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/assets/page.1b85bc2f.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

static/assets/page.94550e0c.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import{C as o,m as d}from"./index.9b9a8697.js";window.CTFd=o;window.Alpine=d;d.start();
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)