import axiosInstance from "@/apis/axios.config";
//提交的后端路径
const ENGAGE_PREFIX = "/api/assignment/engage"

const engagementApis = {
    engageAssignment(assignmentId:number){
        return axiosInstance.post(ENGAGE_PREFIX, {}, {
            params: {
                assignmentId
            }
        })
    },
    getEngagement: (studentId: number, assignmentId: number) => {
        return axiosInstance.get(ENGAGE_PREFIX, {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    getDetailEngagement: (studentId: number, assignmentId: number) => {
        return axiosInstance.get(ENGAGE_PREFIX+"/detail", {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    // 提交作业
    engagementSubmit: (studentId: number, assignmentId: number,supplementarySubmission:boolean) => {
        return axiosInstance.put(ENGAGE_PREFIX+"/submit", {}, {
            params: {
                studentId,
                assignmentId,
                supplementarySubmission
            }
        })
    },
    // 暂存作业
    engagementStage: (studentId: number, assignmentId: number, quillContent: string, textContent: string, htmlContent: string) => {
        return axiosInstance.put(ENGAGE_PREFIX+"/stage", {
            studentId,
            assignmentId,
            quillContent,
            textContent,
            htmlContent
        })
    },
    //提交批改
    engagementCorrect: (studentId: number, assignmentId: number, correctDTO: {score: number, remark: string}) => {
        return axiosInstance.put(`${ENGAGE_PREFIX}/correct`, correctDTO, {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    getEngagementByAssignmentId(assignmentId:number, page: number=0, size: number=10){
        return axiosInstance.post(`${ENGAGE_PREFIX}/query`, {

        }, {
            params: {
                page,
                size,
                assignmentId
            }
        })
    },
    // 获取下一个学生作业ID
    getNextStudentAssignment: (assignmentId: number, studentId: number) => {
        return axiosInstance.get(`${ENGAGE_PREFIX}/next`, {
            params: {
                assignmentId,
                studentId
            }
        })
    },
    // 获取当前作业参与及批改情况
    getAssignmentCorrectionStats: (assignmentId: number) => {
        return axiosInstance.get(`${ENGAGE_PREFIX}/number`, {
            params: {
                assignmentId
            }
        })
    }
}

export default engagementApis
