import { httpApp } from "@/plugins/axiosIndex";
import { pickBy } from "lodash-es";
import { object2QueryString } from "@/utils/utils";

export function searchMarkResult({
  examId = "",
  examActivityId = "",
  courseCode = "",
  name = "",
  identity = "",
  pageNumber = 1,
  pageSize = 10,
}) {
  const data = pickBy(
    {
      examId,
      examActivityId,
      name,
      courseCode,
      identity,
      pageNumber,
      pageSize,
    },
    (v) => v !== "" && v !== null
  );
  return httpApp.post(
    "/api/admin/examStudent/mark/result?" + object2QueryString(data)
  );
}

export function exportMarkResult({
  examId = "",
  examActivityId = "",
  courseCode = "",
  name = "",
  identity = "",
  type = "",
}) {
  const data = pickBy(
    {
      examId,
      examActivityId,
      name,
      courseCode,
      identity,
      type,
    },
    (v) => v !== "" && v !== null
  );
  return httpApp.post(
    `/api/admin/examStudent/mark/result/${type}/export?` +
      object2QueryString(data)
  );
}
