diff options
Diffstat (limited to 'internal/handlers')
| -rw-r--r-- | internal/handlers/main.go | 25 | 
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/handlers/main.go b/internal/handlers/main.go index c04fd4e..b6ce093 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -113,6 +113,31 @@ func getCorrectOption(q *models.Question) string {  	}  } +func (h *Handlers) HandleMixedUbung(w http.ResponseWriter, r *http.Request) { +	mixedID := r.URL.Query().Get("id") +	if mixedID == "" { +		h.log.Error("missing mixed ID parameter") +		abortWithError(w, "Missing exercise ID") +		return +	} + +	questions, err := h.repo.DBGetQuestionsByMixedID(mixedID) +	if err != nil { +		h.log.Error("failed to get questions for mixed exercise", "error", err, "mixed_id", mixedID) +		abortWithError(w, "Failed to load exercise") +		return +	} + +	if len(questions) == 0 { +		h.log.Error("no questions found for mixed exercise", "mixed_id", mixedID) +		abortWithError(w, "Exercise contains no questions") +		return +	} + +	// Render first question in the sequence +	h.renderQuestion(w, &questions[0]) +} +  func (h *Handlers) HandleNextQuestion(w http.ResponseWriter, r *http.Request) {  	currentID := r.URL.Query().Get("current_id")  	currID, err := strconv.Atoi(currentID)  | 
