Skip to content

Conversation

@ColdHeat
Copy link
Member

  • Add CTFd.pages.challenge.getSolution
  • Add CTFd.pages.challenge.checkSolution

@ColdHeat ColdHeat requested a review from Copilot October 20, 2025 07:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds two new exported functions to the challenge pages API: getSolution and checkSolution. These functions enable fetching challenge solutions via API and determining whether the UI should check for a solution based on solution state and submission status.

Key Changes:

  • Added getSolution function to fetch challenge solutions from the API
  • Added checkSolution function to determine if the UI should retrieve a solution based on state
  • Exposed both functions through the main API surface in main.js

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pages/challenge.js Implements getSolution and checkSolution functions with API fetching and conditional logic
main.js Exports new functions and adds checkSolution hook to _functions.challenge

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +154 to +156
if (solutionState == "hidden" || solutionState == "visible") {
return false;
} else if (solutionState == "solved" && submissionStatus === "correct") {
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent equality operators: use strict equality (===) for solutionState comparisons on line 154, matching the strict equality used for submissionStatus on line 156.

Suggested change
if (solutionState == "hidden" || solutionState == "visible") {
return false;
} else if (solutionState == "solved" && submissionStatus === "correct") {
if (solutionState === "hidden" || solutionState === "visible") {
return false;
} else if (solutionState === "solved" && submissionStatus === "correct") {

Copilot uses AI. Check for mistakes.
@ColdHeat ColdHeat merged commit 48400b5 into main Oct 20, 2025
1 check passed
@ColdHeat ColdHeat deleted the add-solution-visibility-functions branch October 20, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants