markPage.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { findCurrentTaskMarkResult } from "@/features/mark/store";
  2. import { httpApp } from "@/plugins/axiosApp";
  3. import { Setting, UISetting } from "@/types";
  4. /** 清除评卷任务(之前锁住的任务之类的) */
  5. export async function clearMarkTask() {
  6. return httpApp.post("/mark/clear");
  7. }
  8. /** 获取评卷设置 */
  9. export async function getSetting() {
  10. return httpApp.post("/mark/getSetting");
  11. }
  12. /** 获取评卷状态 */
  13. export async function getStatus() {
  14. return httpApp.post("/mark/getStatus");
  15. }
  16. /** 获取评卷分组 */
  17. export async function getGroup() {
  18. return httpApp.post("/mark/getGroup");
  19. }
  20. /** 获取评卷任务 */
  21. export async function getTask() {
  22. const res = await httpApp.post("/mark/getTask");
  23. // if (res.data.questionList) {
  24. // const task = res.data as Task;
  25. // if (!isNull(task.objectiveScore)) {
  26. // task.objectiveScore = Math.round(task.objectiveScore * 100);
  27. // }
  28. // if (!isNull(task.markerScore)) {
  29. // task.markerScore = Math.round(task.markerScore * 100);
  30. // }
  31. // if (task.questionList.length > 0) {
  32. // task.questionList = task.questionList.map((q) => {
  33. // if (!isNull(q.intervalScore)) {
  34. // q.intervalScore = Math.round(q.intervalScore * 100);
  35. // }
  36. // if (!isNull(q.defaultScore)) {
  37. // q.defaultScore = Math.round(q.defaultScore * 100);
  38. // }
  39. // if (!isNull(q.minScore)) {
  40. // q.minScore = Math.round(q.minScore * 100);
  41. // }
  42. // if (!isNull(q.maxScore)) {
  43. // q.maxScore = Math.round(q.maxScore * 100);
  44. // }
  45. // if (!isNull(q.score)) {
  46. // q.score = Math.round(q.score * 100);
  47. // }
  48. // if (q.trackList?.length > 0) {
  49. // q.trackList = q.trackList.map((t) => {
  50. // if (!isNull(t.score)) {
  51. // t.score = Math.round(t.score * 100);
  52. // }
  53. // return t;
  54. // });
  55. // }
  56. // return q;
  57. // });
  58. // }
  59. // }
  60. return res;
  61. }
  62. /** 更新评卷UI */
  63. export async function updateUISetting(
  64. mode?: Setting["mode"],
  65. uiSetting?: UISetting
  66. ) {
  67. const form = new FormData();
  68. uiSetting && form.append("uiSetting", JSON.stringify(uiSetting));
  69. mode && form.append("mode", mode);
  70. return httpApp.post("/mark/updateSetting", form);
  71. }
  72. /** 获取评卷历史任务 */
  73. export async function getHistoryTask({
  74. pageNumber = 1,
  75. pageSize = 10,
  76. order = "markerTime",
  77. sort = "DESC",
  78. secretNumber = null,
  79. }: {
  80. pageNumber?: number; // 从1开始
  81. pageSize?: number;
  82. order?: "markerTime" | "markerScore";
  83. sort?: "ASC" | "DESC";
  84. secretNumber?: string | null;
  85. }) {
  86. const form = new FormData();
  87. form.append("pageNumber", pageNumber + "");
  88. form.append("pageSize", pageSize + "");
  89. form.append("order", order);
  90. form.append("sort", sort);
  91. secretNumber && form.append("secretNumber", secretNumber);
  92. return httpApp.post("/mark/getHistory", form);
  93. }
  94. /** 保存评卷任务 */
  95. export async function saveTask() {
  96. const markResult = findCurrentTaskMarkResult();
  97. if (markResult) {
  98. markResult.specialTagList = [];
  99. markResult.problem = false;
  100. if (markResult.spent > 24 * 60 * 60 * 1000)
  101. markResult.spent = Date.now() - markResult.spent;
  102. return httpApp.post("/mark/saveTask", markResult);
  103. }
  104. }
  105. /** 获取分组列表 */
  106. export async function getGroups() {
  107. return httpApp.post("/mark/getGroup");
  108. }
  109. /** 切换分组 */
  110. export async function switchGroup(markerId: number) {
  111. const form = new FormData();
  112. form.append("markerId", markerId + "");
  113. return httpApp.post("/mark/subjectSelect", form);
  114. }
  115. /** 获取用户信息 */
  116. export async function changeUserInfo(name: string, password?: string) {
  117. const form = new FormData();
  118. form.append("name", name);
  119. password && form.append("password", password);
  120. return httpApp.post("/mark/changeName", form);
  121. }
  122. /** 评卷用户退出 */
  123. export async function doLogout() {
  124. window.location.href = "/mark/logout";
  125. }
  126. /** 评卷用户选择分组 */
  127. export async function doSwitchGroup(markerId: number) {
  128. const form = new FormData();
  129. form.append("markerId", "" + markerId);
  130. return httpApp.post("/mark/subjectSelect", form);
  131. }
  132. /** 评卷用户选择试卷的问题类型 */
  133. export async function doProblemType(problemId: number) {
  134. const markResult = findCurrentTaskMarkResult();
  135. if (markResult) {
  136. markResult.problem = true;
  137. markResult.problemTypeId = problemId;
  138. // @ts-ignore FIXME: should allow null
  139. markResult.markerScore = null;
  140. markResult.scoreList = [];
  141. markResult.specialTagList = [];
  142. markResult.trackList = [];
  143. if (markResult.spent > 24 * 60 * 60 * 1000)
  144. markResult.spent = Date.now() - markResult.spent;
  145. }
  146. return httpApp.post("/mark/saveTask", markResult);
  147. }