You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code against the interfaces for now. The actual Postgres implementations can come once the migrations are in (someone else is handling that). If you want to test in the meantime, throw together an in-memory implementation.
3. Implement service layer
Where:internal/core/services/
AssessmentService that orchestrates repo calls and handles business logic:
Validate that code questions have a language set
Validate that MCQ questions have options populated
Validate score > 0
Handle cascading fetches (get assessment + its questions in one call)
Nothing fancy — just the glue between handlers and repos.
4. Fill in the handler stubs with real logic
Where:internal/handlers/assessments.go
The routes are already wired, these just need actual implementations:
CreateAssessment — parse request body, call service, return created template
Route stubs are wired up already (
internal/handlers/), but they all just return placeholder JSON. Time to make them actually do things.What needs to happen
1. Define domain structs
Where:
internal/core/models/AssessmentTemplate— id, title, description, duration_minutes, timestampsQuestion— id, assessment_template_id, type (mcq_single/mcq_multi/short_answer/code), prompt, options (JSONB), correct_answer (JSONB), score, language (nullable)TestCase— id, question_id, input, expected_output, is_hidden, scoreThese should have JSON tags for API responses and db tags for scanning rows. Keep them clean — no methods on these yet.
2. Write repository interfaces
Where:
internal/core/repositories/AssessmentRepositoryinterface — Create, GetByID, List, Update, DeleteQuestionRepositoryinterface — Create, GetByAssessmentID, Update, DeleteTestCaseRepositoryinterface — Create, GetByQuestionID, DeleteCode against the interfaces for now. The actual Postgres implementations can come once the migrations are in (someone else is handling that). If you want to test in the meantime, throw together an in-memory implementation.
3. Implement service layer
Where:
internal/core/services/AssessmentServicethat orchestrates repo calls and handles business logic:languagesetoptionspopulatedNothing fancy — just the glue between handlers and repos.
4. Fill in the handler stubs with real logic
Where:
internal/handlers/assessments.goThe routes are already wired, these just need actual implementations:
CreateAssessment— parse request body, call service, return created templateListAssessments— call service, return listGetAssessment— parse id param, call service, return template + questionsAddQuestion— parse body + assessment id, validate question type, call serviceAddTestCases— parse body + question id, call serviceEach handler should: bind JSON -> validate -> call service -> return response or error.
5. Add request validation
go-playground/validatoror manual checksmcq_single,mcq_multi,short_answer,code){ "error": "..." }responses on bad inputNotes
migrations/main.gois already done — no need to add new routes