|
|
|
|
@ -0,0 +1,64 @@
|
|
|
|
|
// 从 '@/utils/request' 模块导入 post 方法,用于发送 POST 请求
|
|
|
|
|
import { post } from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开始训练
|
|
|
|
|
* @param {string} mode - 训练模式
|
|
|
|
|
* @param {string|number} repoId - 题库的唯一标识
|
|
|
|
|
* @param {string|number} userId - 用户的唯一标识
|
|
|
|
|
* @param {boolean} clear - 是否清除之前的训练数据
|
|
|
|
|
* @returns {Promise} - 返回一个 Promise 对象,用于处理请求结果
|
|
|
|
|
*/
|
|
|
|
|
export function startTrain(mode, repoId, userId, clear) {
|
|
|
|
|
// 发送 POST 请求到开始训练的接口,携带训练模式、题库 ID、用户 ID 和是否清除数据的参数
|
|
|
|
|
return post('/exam/api/user/repo/start', { mode: mode, repoId: repoId, userId: userId, clear: clear })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 填充训练结果
|
|
|
|
|
* @param {string|number} id - 题目的唯一标识
|
|
|
|
|
* @param {Array|string} answers - 用户给出的答案
|
|
|
|
|
* @param {boolean} isRight - 答案是否正确
|
|
|
|
|
* @returns {Promise} - 返回一个 Promise 对象,用于处理请求结果
|
|
|
|
|
*/
|
|
|
|
|
export function fillResult(id, answers, isRight) {
|
|
|
|
|
// 发送 POST 请求到填充结果的接口,携带题目 ID、用户答案和答案是否正确的参数
|
|
|
|
|
return post('/exam/api/user/repo/fill', { id: id, answers: answers, isRight: isRight })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查是否存在进行中的训练
|
|
|
|
|
* @param {string} mode - 训练模式
|
|
|
|
|
* @param {string|number} repoId - 题库的唯一标识
|
|
|
|
|
* @param {string|number} userId - 用户的唯一标识
|
|
|
|
|
* @returns {Promise} - 返回一个 Promise 对象,用于处理请求结果
|
|
|
|
|
*/
|
|
|
|
|
export function hasTrain(mode, repoId, userId) {
|
|
|
|
|
// 发送 POST 请求到检查训练状态的接口,携带训练模式、题库 ID 和用户 ID 参数
|
|
|
|
|
return post('/exam/api/user/repo/check', { mode: mode, repoId: repoId, userId: userId })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取答题卡列表
|
|
|
|
|
* @param {string} mode - 训练模式
|
|
|
|
|
* @param {string|number} repoId - 题库的唯一标识
|
|
|
|
|
* @param {string|number} userId - 用户的唯一标识
|
|
|
|
|
* @returns {Promise} - 返回一个 Promise 对象,用于处理请求结果
|
|
|
|
|
*/
|
|
|
|
|
export function listCard(mode, repoId, userId) {
|
|
|
|
|
// 发送 POST 请求到获取答题卡列表的接口,携带训练模式、题库 ID 和用户 ID 参数
|
|
|
|
|
return post('/exam/api/user/repo/card', { mode: mode, repoId: repoId, userId: userId })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取下一题
|
|
|
|
|
* @param {string} mode - 训练模式
|
|
|
|
|
* @param {string|number} repoId - 题库的唯一标识
|
|
|
|
|
* @param {string|number} userId - 用户的唯一标识
|
|
|
|
|
* @param {string|number} sequence - 题目序号
|
|
|
|
|
* @returns {Promise} - 返回一个 Promise 对象,用于处理请求结果
|
|
|
|
|
*/
|
|
|
|
|
export function nextQu(mode, repoId, userId, sequence) {
|
|
|
|
|
// 发送 POST 请求到获取下一题的接口,携带训练模式、题库 ID、用户 ID 和题目序号参数
|
|
|
|
|
return post('/exam/api/user/repo/next', { mode: mode, repoId: repoId, userId: userId, sequence: sequence })
|
|
|
|
|
}
|