123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import { findCurrentTaskMarkResult } from "@/features/mark/store";
- import { httpApp } from "@/plugins/axiosApp";
- import { Setting, UISetting } from "@/types";
- /** 清除评卷任务(之前锁住的任务之类的) */
- export async function clearMarkTask() {
- return httpApp.post("/mark/clear");
- }
- /** 获取评卷设置 */
- export async function getSetting() {
- return httpApp.post("/mark/getSetting");
- }
- /** 获取评卷状态 */
- export async function getStatus() {
- return httpApp.post("/mark/getStatus");
- }
- /** 获取评卷分组 */
- export async function getGroup() {
- return httpApp.post("/mark/getGroup");
- }
- /** 获取评卷任务 */
- export async function getTask() {
- const res = await httpApp.post("/mark/getTask");
- // if (res.data.questionList) {
- // const task = res.data as Task;
- // if (!isNull(task.objectiveScore)) {
- // task.objectiveScore = Math.round(task.objectiveScore * 100);
- // }
- // if (!isNull(task.markerScore)) {
- // task.markerScore = Math.round(task.markerScore * 100);
- // }
- // if (task.questionList.length > 0) {
- // task.questionList = task.questionList.map((q) => {
- // if (!isNull(q.intervalScore)) {
- // q.intervalScore = Math.round(q.intervalScore * 100);
- // }
- // if (!isNull(q.defaultScore)) {
- // q.defaultScore = Math.round(q.defaultScore * 100);
- // }
- // if (!isNull(q.minScore)) {
- // q.minScore = Math.round(q.minScore * 100);
- // }
- // if (!isNull(q.maxScore)) {
- // q.maxScore = Math.round(q.maxScore * 100);
- // }
- // if (!isNull(q.score)) {
- // q.score = Math.round(q.score * 100);
- // }
- // if (q.trackList?.length > 0) {
- // q.trackList = q.trackList.map((t) => {
- // if (!isNull(t.score)) {
- // t.score = Math.round(t.score * 100);
- // }
- // return t;
- // });
- // }
- // return q;
- // });
- // }
- // }
- return res;
- }
- /** 更新评卷UI */
- export async function updateUISetting(
- mode?: Setting["mode"],
- uiSetting?: UISetting
- ) {
- const form = new FormData();
- uiSetting && form.append("uiSetting", JSON.stringify(uiSetting));
- mode && form.append("mode", mode);
- return httpApp.post("/mark/updateSetting", form);
- }
- /** 获取评卷历史任务 */
- export async function getHistoryTask({
- pageNumber = 1,
- pageSize = 10,
- order = "markerTime",
- sort = "DESC",
- secretNumber = null,
- }: {
- pageNumber?: number; // 从1开始
- pageSize?: number;
- order?: "markerTime" | "markerScore";
- sort?: "ASC" | "DESC";
- secretNumber?: string | null;
- }) {
- const form = new FormData();
- form.append("pageNumber", pageNumber + "");
- form.append("pageSize", pageSize + "");
- form.append("order", order);
- form.append("sort", sort);
- secretNumber && form.append("secretNumber", secretNumber);
- return httpApp.post("/mark/getHistory", form);
- }
- /** 保存评卷任务 */
- export async function saveTask() {
- const markResult = findCurrentTaskMarkResult();
- if (markResult) {
- markResult.specialTagList = [];
- markResult.problem = false;
- if (markResult.spent > 24 * 60 * 60 * 1000)
- markResult.spent = Date.now() - markResult.spent;
- return httpApp.post("/mark/saveTask", markResult);
- }
- }
- /** 获取分组列表 */
- export async function getGroups() {
- return httpApp.post("/mark/getGroup");
- }
- /** 切换分组 */
- export async function switchGroup(markerId: number) {
- const form = new FormData();
- form.append("markerId", markerId + "");
- return httpApp.post("/mark/subjectSelect", form);
- }
- /** 获取用户信息 */
- export async function changeUserInfo(name: string, password?: string) {
- const form = new FormData();
- form.append("name", name);
- password && form.append("password", password);
- return httpApp.post("/mark/changeName", form);
- }
- /** 评卷用户退出 */
- export async function doLogout() {
- window.location.href = "/mark/logout";
- }
- /** 评卷用户选择分组 */
- export async function doSwitchGroup(markerId: number) {
- const form = new FormData();
- form.append("markerId", "" + markerId);
- return httpApp.post("/mark/subjectSelect", form);
- }
- /** 评卷用户选择试卷的问题类型 */
- export async function doProblemType(problemId: number) {
- const markResult = findCurrentTaskMarkResult();
- if (markResult) {
- markResult.problem = true;
- markResult.problemTypeId = problemId;
- // @ts-ignore FIXME: should allow null
- markResult.markerScore = null;
- markResult.scoreList = [];
- markResult.specialTagList = [];
- markResult.trackList = [];
- if (markResult.spent > 24 * 60 * 60 * 1000)
- markResult.spent = Date.now() - markResult.spent;
- }
- return httpApp.post("/mark/saveTask", markResult);
- }
|