import express from "express";
import { getStdExercises, getStdExerciseById, stdAnswerExercise, getStudentAnswersByStdLearningId } from "../../controllers/learningControllers/stdExercise.js";
import { verifyLoginUser } from "../../middlewares/User/authUser.js";
import { updateStdLearningById } from "../../controllers/learningControllers/stdLearning.js";
import { checkCorrectAnswers, calculateScore, checkFirstFiveCorrect, nextLearning } from "../../middlewares/autoGrading.js";

const router = express.Router();

router.get("/stdExercise", verifyLoginUser, getStdExercises);

router.get("/stdExercise/:id", verifyLoginUser, getStdExerciseById);

router.get("/studentAnswers/:id", verifyLoginUser, getStudentAnswersByStdLearningId);

router.post("/stdExercise", verifyLoginUser, stdAnswerExercise, checkCorrectAnswers, calculateScore, checkFirstFiveCorrect, nextLearning, updateStdLearningById);

export default router