import fetch from '@/utils/fetch'

/**
 * 【查】分页查询分配给本学员的在线考试
 * @param {object} params 分页参数
 * @returns
 */
export const pagingOnlineExamListApi = (params) => fetch({ url: '/assessmentEvaluation/StudentOnlineExam/paging', method: 'get', params })

/**
 * 【查】根据在线考试ID获取本次考试所有信息
 * @param {number} id 考试ID
 * @returns
 */
export const getOnlineExamAllDataApi = (id) => fetch({ url: '/assessmentEvaluation/OnlineExamHistory/questions/' + id, method: 'get' })

/**
 * 【增】根据在线考试ID新增考试历史记录
 * @param {{onlineExamId?: number,isPracticeExam?: number}} id 考试ID
 * @returns
 */
export const createExamHistoryApi = (data) => fetch({ url: '/assessmentEvaluation/OnlineExamHistory', method: 'post', data })
/**
 * 【增】根据在线考试ID新增考试历史记录
 * @param {{onlineExamId?: number,isPracticeExam?: number}} id 考试ID
 * @returns
 */
export const createSimExamHistoryApi = (data) => fetch({ url: '/assessmentEvaluation/OnlineExamHistory/simtest', method: 'post', data })

/**
 * 【增】考试完成，提交试卷
 * @param {number} id 考试ID
 * @param {array} answers 考试答案列表
 * @returns
 */
export const submitExamApi = ({ id, answers }) => fetch({ url: '/assessmentEvaluation/OnlineExamHistory/submitExam/' + id, method: 'post', data: answers })
/**
 * 【查】查询最后一次考试的历史记录
 * @param {number} id 考试ID
 * @returns
 */
export const getLastedHistoryApi = (id) => fetch({ url: '/assessmentEvaluation/StudentOnlineExam/lastExamHistory/' + id, method: 'get' })

/**
 * 【查】根据在线考试ID获取考试答题结果
 * @param {number} id 考试ID
 * @returns
 */
export const getOnlineExamResultApi = (id) => fetch({ url: '/assessmentEvaluation/OnlineExamHistory/examQuestionResult/' + id, method: 'get' })
