β¨ Feature Description
Allow admins to create a new coding quest via a POST /api/quests endpoint. All required fields must be validated before persisting the new Quest record to the coding_quests table.
π§© Problem Statement
There is currently no endpoint to create quests programmatically. Admins need a validated API to add new quests to the platform without touching the database directly.
π‘ Proposed Solution
Add a POST /api/quests endpoint protected by admin-only auth. The route handler delegates to QuestService.create_quest(payload), which validates the payload and persists the new record. The id, created_at, updated_at, and solved_times fields are auto-generated and must not be accepted from the request body.
Required Fields (nullable=False)
language = db.Column(db.String(50), nullable=False)
difficulty = db.Column(db.String(50), nullable=False)
quest_name = db.Column(db.String(255), nullable=False)
quest_author = db.Column(db.String(255), nullable=False)
condition = db.Column(db.Text, nullable=False)
function_template = db.Column(db.Text, nullable=False)
input_0 = db.Column(db.Text, nullable=False) # null/edge-case test
output_0 = db.Column(db.Text, nullable=False) # null/edge-case test
Optional Fields (nullable=True)
input_1 β¦ input_9 = db.Column(db.Text, nullable=True)
output_1 β¦ output_9 = db.Column(db.Text, nullable=True)
example_solution = db.Column(db.Text, nullable=True)
Auto-generated Fields (never accepted from request)
id # uuid4 generated automatically
solved_times # defaults to 0
created_at # set by the database on insert
updated_at # set by the database on insert
Error Responses
| Status |
Scenario |
400 |
Validation failure β missing or invalid required field |
403 |
Requester is not an admin |
π Alternatives Considered
Accepting quest_author from the auth token β rather than requiring it in the payload, the author could be derived from the logged-in admin's identity. Kept as an explicit field for now to allow admins to assign authorship freely.
π Acceptance Criteria
π Related Issues / Links
π Additional Context
input_0 / output_0 being nullable=False differs from input_1β9 / output_1β9 β validation must reflect this distinction explicitly.
β¨ Feature Description
Allow admins to create a new coding quest via a
POST /api/questsendpoint. All required fields must be validated before persisting the newQuestrecord to thecoding_queststable.π§© Problem Statement
There is currently no endpoint to create quests programmatically. Admins need a validated API to add new quests to the platform without touching the database directly.
π‘ Proposed Solution
Add a
POST /api/questsendpoint protected by admin-only auth. The route handler delegates toQuestService.create_quest(payload), which validates the payload and persists the new record. Theid,created_at,updated_at, andsolved_timesfields are auto-generated and must not be accepted from the request body.Required Fields (nullable=False)
Optional Fields (nullable=True)
Auto-generated Fields (never accepted from request)
Error Responses
400403π Alternatives Considered
Accepting
quest_authorfrom the auth token β rather than requiring it in the payload, the author could be derived from the logged-in admin's identity. Kept as an explicit field for now to allow admins to assign authorship freely.π Acceptance Criteria
POST /api/questsendpoint exists and is accessible only to adminsnullable=Falsefields are required β missing any returns400 Bad Requestwith descriptive errorsinput_0andoutput_0are required (null/edge-case test)input_1β9,output_1β9, andexample_solutionare optionalid,solved_times,created_at, andupdated_atare auto-generated and ignored if sent in the request body201 Createdwith the serialized quest object403 Forbiddencreate_quest(payload)encapsulates the business logicπ Related Issues / Links
π Additional Context
input_0/output_0beingnullable=Falsediffers frominput_1β9/output_1β9β validation must reflect this distinction explicitly.