{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coderpad/json-schema/coderpad-question-details-result-schema.json",
  "title": "QuestionDetailsResult",
  "description": "Details of a question",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coderpad-questions-api-openapi.yml#/components/schemas/QuestionDetailsResult",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "the question id",
      "format": "uuid"
    },
    "version": {
      "type": "integer",
      "description": "the question version",
      "format": "int32"
    },
    "type": {
      "type": "string",
      "description": "the question type",
      "enum": [
        "MCQ",
        "CODE",
        "TEXT",
        "MULTI",
        "GAME",
        "CLASH",
        "COURSE",
        "FILE_UPLOAD",
        "PROJECT",
        "VIDEO"
      ]
    },
    "domain": {
      "type": "string",
      "description": "the question domain name"
    },
    "difficulty": {
      "type": "string",
      "description": "difficulty level",
      "enum": [
        "EASY",
        "MEDIUM",
        "HARD"
      ]
    },
    "points": {
      "type": "integer",
      "description": "maximum score weight for the question",
      "format": "int32"
    },
    "title": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "description": "question title, by locale"
      },
      "description": "question title, by locale"
    },
    "statement": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "description": "HTML statement, by locale"
      },
      "description": "HTML statement, by locale"
    },
    "locales": {
      "type": "array",
      "description": "locales available for this question",
      "items": {
        "type": "string",
        "description": "locales available for this question"
      }
    },
    "skill": {
      "type": "string",
      "description": "the question skill"
    },
    "resources": {
      "type": "array",
      "description": "external attachments; empty if none",
      "items": {
        "$ref": "#/$defs/QuestionResourceDetails"
      }
    },
    "comment": {
      "type": "string",
      "description": "internal comment on the question"
    },
    "evaluation": {
      "$ref": "#/$defs/EvaluationDetails"
    },
    "duration_seconds": {
      "type": "integer",
      "description": "the question duration in seconds",
      "format": "int32"
    },
    "creation_time": {
      "type": "string",
      "description": "creation time of the first version of the question, in UTC"
    },
    "modification_time": {
      "type": "string",
      "description": "modification time in UTC"
    },
    "from_coderpad_question_bank": {
      "type": "boolean",
      "description": "true if the question comes from the CoderPad question bank"
    },
    "team_id": {
      "type": "string",
      "description": "the id of the team owning the question; see GET /me for the teams of the token owner",
      "format": "uuid"
    },
    "automatically_selectable": {
      "type": "boolean",
      "description": "whether the question can be automatically selected in campaigns"
    },
    "mcq_details": {
      "$ref": "#/$defs/McqDetails"
    },
    "code_details": {
      "$ref": "#/$defs/CodeDetails"
    },
    "game_details": {
      "$ref": "#/$defs/GameDetails"
    },
    "text_details": {
      "$ref": "#/$defs/TextDetails"
    },
    "file_upload_details": {
      "$ref": "#/$defs/FileUploadDetails"
    },
    "video_details": {
      "$ref": "#/$defs/VideoDetails"
    },
    "project_details": {
      "$ref": "#/$defs/ProjectDetails"
    }
  },
  "$defs": {
    "ChoiceSelectionDetails": {
      "type": "object",
      "properties": {
        "correct_choice_indexes": {
          "type": "array",
          "description": "0-based indexes of the correct choices in mcq_details.choices",
          "items": {
            "type": "integer",
            "description": "0-based indexes of the correct choices in mcq_details.choices",
            "format": "int32"
          }
        }
      },
      "description": "Choices the candidate has to select"
    },
    "CodeDetails": {
      "type": "object",
      "properties": {
        "environment": {
          "$ref": "#/$defs/EnvironmentDetails"
        },
        "mode": {
          "type": "string",
          "description": "SINGLE_LANGUAGE when the question is bound to programming_language, MULTI_LANGUAGE when the candidate picks one of available_programming_language_ids",
          "enum": [
            "SINGLE_LANGUAGE",
            "MULTI_LANGUAGE"
          ]
        },
        "programming_language_id": {
          "type": "string",
          "description": "the programming language id; only set when mode is SINGLE_LANGUAGE"
        },
        "candidate_test_code": {
          "type": "string",
          "description": "code the candidate can run against their answer; language-specific questions only"
        },
        "validator_code": {
          "type": "string",
          "description": "code defining the tests referenced by evaluation.validation_code.test_cases; language-specific questions only"
        },
        "timeout_ms": {
          "type": "integer",
          "description": "execution timeout in milliseconds when it overrides the default of the language",
          "format": "int32"
        },
        "database_engine": {
          "$ref": "#/$defs/DatabaseEngineDetails"
        },
        "database_setup_script": {
          "type": "string",
          "description": "script creating and filling the tables the query runs against; SQL questions only, mandatory for them"
        },
        "starter_code": {
          "type": "string",
          "description": "starter code; only set when mode is SINGLE_LANGUAGE"
        },
        "function_signature": {
          "$ref": "#/$defs/FunctionSignatureDetails"
        },
        "possible_solution": {
          "$ref": "#/$defs/PossibleSolutionDetails"
        },
        "show_function_signature_in_statement": {
          "type": "boolean",
          "description": "whether the function signature is shown to the candidate in the statement"
        },
        "available_programming_language_ids": {
          "type": "array",
          "description": "ids of the programming languages the candidate can choose from; only set when mode is MULTI_LANGUAGE",
          "items": {
            "type": "string",
            "description": "ids of the programming languages the candidate can choose from; only set when mode is MULTI_LANGUAGE"
          }
        }
      },
      "description": "CODE-specific question details"
    },
    "DatabaseEngineDetails": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string",
          "description": "the database engine version, absent for h2 which has a single version"
        },
        "engine_id": {
          "type": "string",
          "description": "the database engine id, or \"h2\" for the default engine"
        }
      },
      "description": "The single database engine a SQL question runs on, H2 when the question declares none. Saving a question without this block means H2 on an update too, so an update meant to keep another engine has to name it"
    },
    "EnvironmentDetails": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string",
          "description": "the environment version"
        },
        "environment_id": {
          "type": "string",
          "description": "the environment id"
        }
      },
      "description": "Execution environment version a question runs on"
    },
    "EvaluationAcceptedAnswerDetails": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "description": "the accepted answer, as an exact value or a regular expression"
        },
        "match_type": {
          "type": "string",
          "description": "how the candidate answer is compared to the value",
          "enum": [
            "EXACT",
            "REGEX"
          ]
        }
      },
      "description": "One answer accepted as correct"
    },
    "EvaluationDetails": {
      "type": "object",
      "properties": {
        "rubric": {
          "$ref": "#/$defs/RubricDetails"
        },
        "test_report": {
          "$ref": "#/$defs/TestReportDetails"
        },
        "validation_code": {
          "$ref": "#/$defs/ValidationCodeDetails"
        },
        "input_output": {
          "$ref": "#/$defs/InputOutputDetails"
        },
        "sql_query_result_comparison": {
          "$ref": "#/$defs/SqlQueryResultComparisonDetails"
        },
        "text_answer_matching": {
          "$ref": "#/$defs/TextAnswerMatchingDetails"
        },
        "choice_selection": {
          "$ref": "#/$defs/ChoiceSelectionDetails"
        }
      },
      "description": "How the candidate answer is evaluated"
    },
    "FileUploadDetails": {
      "type": "object",
      "properties": {
        "download_url": {
          "type": "string",
          "description": "signed download URL of the statement file"
        }
      },
      "description": "FILE_UPLOAD-specific question details"
    },
    "FunctionSignatureDetails": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "the function name"
        },
        "parameters": {
          "type": "array",
          "description": "the parameters, in order, each a JSON Schema draft-6 object whose 'title' is the parameter name",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "return_type": {
          "type": "object",
          "additionalProperties": true,
          "description": "the return type, as a JSON Schema draft-6 object"
        }
      },
      "description": "Signature of the function the candidate has to implement"
    },
    "GameDetails": {
      "type": "object",
      "properties": {
        "available_programming_language_ids": {
          "type": "array",
          "description": "ids of the programming languages the candidate can choose from",
          "items": {
            "type": "string",
            "description": "ids of the programming languages the candidate can choose from"
          }
        }
      },
      "description": "GAME-specific question details"
    },
    "InputOutputDetails": {
      "type": "object",
      "properties": {
        "test_cases": {
          "type": "array",
          "description": "test cases in the order the editor shows them",
          "items": {
            "$ref": "#/$defs/InputOutputTestCaseDetails"
          }
        }
      },
      "description": "Input and output pairs the candidate code is run on"
    },
    "InputOutputTestCaseDetails": {
      "type": "object",
      "properties": {
        "label": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "description": "test case label, by locale; a missing question locale is filled from a provided one"
          },
          "description": "test case label, by locale; a missing question locale is filled from a provided one"
        },
        "input": {
          "type": "string",
          "description": "input given to the candidate code"
        },
        "output": {
          "type": "string",
          "description": "output expected from the candidate code"
        },
        "skill": {
          "type": "string",
          "description": "skill assessed by this test case"
        },
        "points": {
          "type": "integer",
          "description": "points awarded by this test case; set on every graded test case or on none, when omitted they are derived from the weights to add up to the question points",
          "format": "int32"
        },
        "weight": {
          "type": "integer",
          "description": "relative weight of this test case; defaults to 1",
          "format": "int32"
        },
        "difficulty": {
          "type": "integer",
          "description": "difficulty of this test case",
          "format": "int32"
        },
        "contributes_to_score": {
          "type": "boolean",
          "description": "whether the test case takes part in the score; defaults to true"
        },
        "visible_to_candidate": {
          "type": "boolean",
          "description": "whether the candidate sees the test case; defaults to true"
        },
        "timeout_ms_by_programming_language_id": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "description": "execution timeout in milliseconds, by programming language id, when it overrides the default of that language",
            "format": "int32"
          },
          "description": "execution timeout in milliseconds, by programming language id, when it overrides the default of that language"
        }
      },
      "description": "Test case feeding an input to the candidate code and comparing its output"
    },
    "McqDetails": {
      "type": "object",
      "properties": {
        "choices": {
          "type": "array",
          "description": "MCQ choices",
          "items": {
            "$ref": "#/$defs/QuestionChoiceDetailsResult"
          }
        },
        "selection_mode": {
          "type": "string",
          "description": "whether the candidate can select one or multiple choices: SINGLE or MULTIPLE",
          "enum": [
            "SINGLE",
            "MULTIPLE"
          ]
        },
        "randomize_choices": {
          "type": "boolean",
          "description": "whether MCQ choices are randomized"
        }
      },
      "description": "MCQ-specific question details"
    },
    "PossibleSolutionDetails": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "the solution source code"
        },
        "programming_language_id": {
          "type": "string",
          "description": "the programming language the solution is written in"
        }
      },
      "description": "A working solution of the question, kept for the author"
    },
    "ProjectDetails": {
      "type": "object",
      "properties": {
        "environment": {
          "$ref": "#/$defs/EnvironmentDetails"
        },
        "resources": {
          "type": "array",
          "description": "additional resources the project runs with; empty if none",
          "items": {
            "$ref": "#/$defs/ProjectResourceDetails"
          }
        },
        "ai_assist_additional_instructions": {
          "type": "string",
          "description": "instructions given to the AI assist during the test"
        },
        "ai_assist_allowed": {
          "type": "boolean",
          "description": "whether AI assist is allowed"
        },
        "download_url": {
          "type": "string",
          "description": "signed tar.gz download URL"
        }
      },
      "description": "PROJECT-specific question details"
    },
    "ProjectResourceDetails": {
      "type": "object",
      "properties": {
        "version": {
          "type": "string",
          "description": "the resource version"
        },
        "resource_id": {
          "type": "string",
          "description": "the resource id"
        }
      },
      "description": "Additional resource a PROJECT runs with, such as a database"
    },
    "QueryComparisonRulesDetails": {
      "type": "object",
      "properties": {
        "row_order_matters": {
          "type": "boolean",
          "description": "whether rows must come in the expected order"
        },
        "column_order_matters": {
          "type": "boolean",
          "description": "whether columns must come in the expected order"
        },
        "compare_all_tables": {
          "type": "boolean",
          "description": "whether every table of the database is compared, not only the query result"
        }
      },
      "description": "Rules applied when comparing the candidate query result to the expected one"
    },
    "QuestionChoiceDetailsResult": {
      "type": "object",
      "properties": {
        "label": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "description": "choice label, by locale"
          },
          "description": "choice label, by locale"
        }
      },
      "description": "MCQ choice offered to the candidate"
    },
    "QuestionResourceDetails": {
      "type": "object",
      "properties": {
        "filename": {
          "type": "string",
          "description": "resource filename"
        },
        "mime_type": {
          "type": "string",
          "description": "resource MIME type"
        },
        "download_url": {
          "type": "string",
          "description": "signed download URL"
        }
      },
      "description": "External attachment on a question"
    },
    "RubricCriterionDetails": {
      "type": "object",
      "properties": {
        "label": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "description": "criterion label, by locale"
          },
          "description": "criterion label, by locale"
        },
        "skill": {
          "type": "string",
          "description": "skill assessed by this criterion"
        },
        "points": {
          "type": "integer",
          "description": "points awarded by this criterion",
          "format": "int32"
        },
        "weight": {
          "type": "integer",
          "description": "relative weight of this criterion",
          "format": "int32"
        },
        "review_mode": {
          "type": "string",
          "description": "how this criterion is reviewed",
          "enum": [
            "HUMAN_ONLY",
            "AI_SUGGESTIONS",
            "AI_GRADING"
          ]
        },
        "description": {
          "type": "string",
          "description": "reviewer-facing description of the criterion"
        }
      },
      "description": "One criterion the candidate answer is reviewed against"
    },
    "RubricDetails": {
      "type": "object",
      "properties": {
        "criteria": {
          "type": "array",
          "description": "criteria of the rubric, in the order the editor shows them",
          "items": {
            "$ref": "#/$defs/RubricCriterionDetails"
          }
        }
      },
      "description": "Rubric the candidate answer is reviewed against"
    },
    "SqlQueryResultComparisonDetails": {
      "type": "object",
      "properties": {
        "reference_query": {
          "type": "string",
          "description": "query producing the expected result"
        },
        "comparison": {
          "$ref": "#/$defs/QueryComparisonRulesDetails"
        }
      },
      "description": "Reference query the candidate query result is compared to"
    },
    "TestReportDetails": {
      "type": "object",
      "properties": {
        "test_cases": {
          "type": "array",
          "description": "tests of the report, in the order the editor shows them",
          "items": {
            "$ref": "#/$defs/TestReportTestCaseDetails"
          }
        }
      },
      "description": "Test suite report the candidate project is scored on"
    },
    "TestReportTestCaseDetails": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "stable identifier of the test case"
        },
        "test_identifier": {
          "type": "string",
          "description": "identifier of the test in the report"
        },
        "label": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "description": "test label, by locale"
          },
          "description": "test label, by locale"
        },
        "skill": {
          "type": "string",
          "description": "skill assessed by this test"
        },
        "points": {
          "type": "integer",
          "description": "points awarded by this test",
          "format": "int32"
        },
        "weight": {
          "type": "integer",
          "description": "relative weight of this test",
          "format": "int32"
        }
      },
      "description": "Test of the project test suite the answer is scored on"
    },
    "TextAnswerMatchingDetails": {
      "type": "object",
      "properties": {
        "accepted_answers": {
          "type": "array",
          "description": "answers accepted as correct; matching any of them is enough",
          "items": {
            "$ref": "#/$defs/EvaluationAcceptedAnswerDetails"
          }
        }
      },
      "description": "Answers the candidate text is matched against"
    },
    "TextDetails": {
      "type": "object",
      "properties": {
        "evaluation_mode": {
          "type": "string",
          "description": "how the question is graded: AUTOMATIC uses a text_answer_matching evaluation, MANUAL a rubric one",
          "enum": [
            "MANUAL",
            "AUTOMATIC"
          ]
        }
      },
      "description": "TEXT-specific question details"
    },
    "ValidationCodeDetails": {
      "type": "object",
      "properties": {
        "test_cases": {
          "type": "array",
          "description": "test cases in the order the editor shows them",
          "items": {
            "$ref": "#/$defs/ValidationCodeTestCaseDetails"
          }
        }
      },
      "description": "Validation methods the candidate code is run against"
    },
    "ValidationCodeTestCaseDetails": {
      "type": "object",
      "properties": {
        "label": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "description": "test case label, by locale; a missing question locale is filled from a provided one"
          },
          "description": "test case label, by locale; a missing question locale is filled from a provided one"
        },
        "test_identifier": {
          "type": "string",
          "description": "validation method running the test"
        },
        "skill": {
          "type": "string",
          "description": "skill assessed by this test case"
        },
        "points": {
          "type": "integer",
          "description": "points awarded by this test case; set on every test case or on none, when omitted they are derived from the weights to add up to the question points",
          "format": "int32"
        },
        "weight": {
          "type": "integer",
          "description": "relative weight of this test case; defaults to 1",
          "format": "int32"
        },
        "difficulty": {
          "type": "integer",
          "description": "difficulty of this test case",
          "format": "int32"
        },
        "contributes_to_score": {
          "type": "boolean",
          "description": "whether the test case takes part in the score"
        },
        "visible_to_candidate": {
          "type": "boolean",
          "description": "whether the candidate sees the test case"
        }
      },
      "description": "Test case running a validation method against the candidate code"
    },
    "VideoDetails": {
      "type": "object",
      "properties": {
        "recording_media": {
          "type": "string",
          "description": "the recording media",
          "enum": [
            "VIDEO",
            "AUDIO"
          ]
        }
      },
      "description": "VIDEO-specific question details"
    }
  }
}