You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-boot-online-exam/frontend/src/api/exam.js

192 lines
5.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 考试相关的接口,包括考试、问题、选项和评分等接口
import api from './index'
import { axios } from '../utils/request'
// 导出一个函数,用于获取问题列表
export function getQuestionList (parameter) {
// 使用axios发送get请求获取问题列表
return axios({
url: api.ExamQuestionList, // 请求的URL
method: 'get', // 请求的方法
params: parameter // 请求的参数
})
}
// 导出一个函数,用于获取所有题目
export function getQuestionAll () {
// 使用axios发送get请求获取所有题目
return axios({
url: api.ExamQuestionAll,
method: 'get'
})
}
// 导出一个名为questionUpdate的函数参数为parameter
export function questionUpdate (parameter) {
// 打印参数
console.log(parameter)
// 返回一个axios请求请求的url为api.ExamQuestionUpdate请求方法为post请求的数据为parameter
return axios({
url: api.ExamQuestionUpdate,
method: 'post',
data: parameter
})
}
// 导出一个函数,用于获取题目选择
export function getQuestionSelection () {
// 使用axios发送get请求获取题目选择
return axios({
// 请求的URL
url: api.ExamQuestionSelection,
// 请求的方法
method: 'get',
// 请求的头部信息
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
// 导出一个名为questionCreate的函数参数为parameter
export function questionCreate (parameter) {
// 打印参数
console.log(parameter)
// 使用axios发送post请求url为api.ExamQuestionCreate参数为parameter
return axios({
url: api.ExamQuestionCreate,
method: 'post',
data: parameter
})
}
// 导出一个函数,用于获取考试列表
export function getExamList (parameter) {
// 使用axios发送get请求获取考试列表
return axios({
url: api.ExamList,
method: 'get',
params: parameter
})
}
// 导出一个函数,用于获取所有考试
export function getExamAll () {
// 使用axios发送get请求获取所有考试
return axios({
url: api.ExamAll,
method: 'get'
})
}
// 导出一个函数,用于获取所有问题,按照单选、多选和判断进行分类
export function getExamQuestionTypeList () {
// 使用axios发送get请求获取所有问题按照单选、多选和判断进行分类
return axios({
url: api.ExamQuestionTypeList,
method: 'get',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
// 导出一个函数,用于获取考试卡片列表
export function getExamCardList () {
// 使用axios发送get请求获取考试卡片列表
return axios({
url: api.ExamCardList,
method: 'get',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
// 导出一个函数examCreate用于创建考试
export function examCreate (parameter) {
// 打印传入的参数
console.log(parameter)
// 返回一个axios请求请求的url为api.ExamCreate请求方法为post请求的数据为parameter
return axios({
url: api.ExamCreate,
method: 'post',
data: parameter
})
}
// 导出一个函数examUpdate用于更新考试
export function examUpdate (parameter) {
// 打印传入的参数
console.log(parameter)
// 返回一个axios请求请求的url为api.ExamUpdate请求方法为post请求的数据为parameter
return axios({
url: api.ExamUpdate,
method: 'post',
data: parameter
})
}
// 导出一个函数,用于获取考试详情
export function getExamDetail (examId) {
// 使用axios发送get请求获取考试详情
return axios({
url: api.ExamDetail + examId, // 请求的URL拼接了examId
method: 'get', // 请求方法为get
headers: {
'Content-Type': 'application/json;charset=UTF-8' // 设置请求头指定请求体的类型为json
}
})
}
// 导出一个函数,用于获取考试记录详情
export function getExamRecordDetail (recordId) {
// 使用axios发送get请求获取考试记录详情
return axios({
url: api.recordDetail + recordId, // 请求的URL拼接了recordId
method: 'get', // 请求方法为get
headers: {
'Content-Type': 'application/json;charset=UTF-8' // 设置请求头指定请求体的类型为json
}
})
}
// 导出一个函数,用于获取问题详情
export function getQuestionDetail (questionId) {
// 使用axios发送get请求获取问题详情
return axios({
url: api.QuestionDetail + questionId,
method: 'get',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
// 导出一个函数,用于完成考试
export function finishExam (examId, answersMap) {
// 打印答案
console.log(answersMap)
// 使用axios发送post请求完成考试
return axios({
url: api.FinishExam + examId,
method: 'post',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
data: answersMap
})
}
// 导出一个函数,用于获取考试记录列表
export function getExamRecordList () {
// 使用axios发送get请求获取考试记录列表
return axios({
url: api.ExamRecordList,
method: 'get',
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}