examwork-course.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { httpApp } from "@/plugins/axiosIndex";
  2. import { pickBy } from "lodash-es";
  3. import { object2QueryString } from "@/utils/utils";
  4. export function searchCourses({
  5. id = "",
  6. examId = "",
  7. code = "",
  8. hasPaper = "",
  9. pageNumber = 1,
  10. pageSize = 10,
  11. }) {
  12. const data = pickBy(
  13. { id, examId, code, hasPaper, pageNumber, pageSize },
  14. (v) => v !== ""
  15. );
  16. if (data.examId || data.id)
  17. return httpApp.post(
  18. "/api/admin/exam/course/query?" + object2QueryString(data)
  19. );
  20. }
  21. export function searchPapers({ examId = "", courseCode = "" }) {
  22. const data = pickBy({ examId, courseCode }, (v) => v !== "");
  23. return httpApp.post(
  24. "/api/admin/exam/paper/query?" + object2QueryString(data)
  25. );
  26. }
  27. export function saveCourse({
  28. examId = "",
  29. courseCode = "",
  30. objectiveShuffle = "",
  31. optionShuffle = "",
  32. }) {
  33. const data = pickBy(
  34. {
  35. examId,
  36. courseCode,
  37. objectiveShuffle,
  38. optionShuffle,
  39. },
  40. (v) => v !== ""
  41. );
  42. return httpApp.post("/api/admin/exam/course/save", data);
  43. }
  44. export function savePaper({ id = "", weight = "", audioPlayCount = "" }) {
  45. const data = pickBy(
  46. {
  47. id,
  48. weight,
  49. audioPlayCount,
  50. },
  51. (v) => v !== ""
  52. );
  53. return httpApp.post("/api/admin/exam/paper/save", data);
  54. }
  55. /**
  56. *
  57. * @param {Object[]} papers
  58. * @param {String} papers.id
  59. * @param {Number} papers.weight
  60. * @param {Number} papers.audioPlayCount
  61. */
  62. export function savePapers(papers) {
  63. return httpApp.post("/api/admin/exam/paper/save", papers);
  64. }