import BaseStore from '@src/stores/base';

export default class QuestionStore extends BaseStore {
  /**
   * 获取课程进度
   */
  getClassProcess() {
    return this.apiGet('/question/class/process');
  }

  /**
   * 获取预习作业列表
   * @param {*} page
   * @param {*} size
   * @param {*} category
   * @param {*} endTime
   * @param {*} finish
   */
  listPreview(page, size, category, endTime, finish) {
    return this.apiGet('/question/preview/list', { page, size, category, endTime, finish });
  }

  getPaper(id) {
    return this.apiGet('/question/class/process', { id });
  }

  /**
   * 练习进度
   * @param {*} page
   * @param {*} size
   */
  getExerciseProcess(page, size) {
    return this.apiGet('/question/exercise/process', { page, size });
  }

  /**
   * 练习组卷
   * @param {*} page
   * @param {*} size
   */
  getExercisePaper(page, size) {
    return this.apiGet('/question/exercise/paper', { page, size });
  }

  /**
   * 模考进度
   * @param {*} page
   * @param {*} size
   */
  getExaminationProcess(page, size) {
    return this.apiGet('/question/examination/process', { page, size });
  }

  /**
   * 模考组卷
   * @param {*} page
   * @param {*} size
   */
  getExaminationPaper(page, size) {
    return this.apiGet('/question/examination/paper', { page, size });
  }

  /**
   * 获取题目详情
   * @param {*} questionNoId
   */
  getDetail(questionNoId) {
    return this.apiGet('/question/detail', { questionNoId });
  }

  /**
   * 开始考试
   * @param {*} type
   * @param {*} paperId
   * @param {*} disorder
   */
  start(type, paperId, disorder) {
    return this.apiPost(`/question/${type}/start`, { paperId, disorder });
  }

  /**
   * 下一题
   * @param {*} userReportId
   */
  next(userReportId) {
    return this.apiPost('/question/next', { userReportId });
  }

  /**
   * 提交题目答案
   * @param {*} userQuestionId
   * @param {*} answer
   */
  submit(userQuestionId, answer) {
    return this.apiPost('/question/submit', { userQuestionId, answer });
  }

  /**
   * 完成考试
   * @param {*} userReportId
   */
  finish(userReportId) {
    return this.apiPost('/question/finish', { userReportId });
  }

  /**
   * 继续考试
   * @param {*} userPaperId
   */
  continue(userPaperId) {
    return this.apiPost('/question/continue', { userPaperId });
  }

  /**
   * 重新考试
   * @param {*} userPaperId
   */
  restart(userPaperId) {
    return this.apiPost('/question/restart', { userPaperId });
  }
}

export const Question = new QuestionStore({ key: 'question' });
