Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
loadUnlock,
displayUnlock,
displayHint,
loadSolution,
displaySolution,
} from "./pages/challenge";
import { getScoreboard, getScoreboardDetail, getBrackets } from "./pages/scoreboard";
import { updateSettings, generateToken, deleteToken } from "./pages/settings";
Expand Down Expand Up @@ -127,6 +129,8 @@ const pages = {
loadUnlock,
displayUnlock,
displayHint,
loadSolution,
displaySolution,
},
challenges: {
getChallenges,
Expand Down
16 changes: 16 additions & 0 deletions pages/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,19 @@ export async function displaySolves(challengeId) {
CTFd._functions.challenge.displaySolves(solves);
}
}

export async function loadSolution(solutionId) {
const response = await CTFd.fetch(`/api/v1/solutions/${solutionId}`, {
method: "GET",
});

const body = await response.json();
return body["data"];
}

export async function displaySolution(solutionId) {
let solution = await loadSolution(solutionId);
if (CTFd._functions.challenge.displaySolution) {
CTFd._functions.challenge.displaySolution(solution);
}
}