import fetch from '@/utils/fetch'

/**
 * 【查】获课程评价
 */
export const getCourseEvaluate = ({ courseId, ...data }) => {
  return fetch({ url: 'online-course/course-evaluate/' + courseId, method: 'get', params: data })
}
/**
 * 获取所有课程列表
 * @param page
 * @param pageSize
 */
export const getMyCourseListAllAPI = (data) => {
  return fetch({ url: 'my-course', method: 'post', data })
}

/**
 * 【查】获取某学习记录下，课程的习题信息
 * @param {number} recordId
 */
export const getOneRecordExercisesAPI = (recordId) => {
  return fetch({ url: 'my-course/exercise/' + recordId, method: 'get' })
}
/**
 * 【查】获取某学习记录下，课程的习题信息
 * @param {number} recordId
 */
export const getCommentByCourseIdApi = (courseId) => {
  return fetch({ url: 'my-course/comment/' + courseId, method: 'get' })
}

/**
 * 获取分类课程列表
 * @param {number} page
 * @param {number} pageSize
 * @param {number} type
 * @returns
 */
export const getMyCourseListTypeAPI = (data) => {
  return fetch({ url: 'my-course/type', method: 'post', data })
}
/**
 * 获取某个课程的详细信息
 */
export const getCourseInfoAPI = (id) => {
  return fetch({ url: `my-course/${id}`, method: 'get' })
}

/**
 * 更新或保存课程的评价信息
 */

export const updateEvealuateAPI = (data) => {
  return fetch({ url: 'my-course/eveal', method: 'post', data })
}

/**
 * 更新课件学习信息
 */

export const updateCourewareAPI = (data) => {
  return fetch({ url: 'my-course/ware', method: 'post', data })
}

/**
 *  【改】更新课件学习信息
 * @param {Array} answer
 */
export const submitAnswerAPI = (data) => {
  return fetch({ url: '/my-course/exercise', method: 'post', data })
}

/**
 *  【增】【改】更新讨论学习信息
 * @param {number}  recordId
 * @param {Anumber|null}        replyId
 * @param {Anumber|null}        replyUserId
  * @param {string}       content
  * @param {Anumber|null}       replyUserInfo
 */

export const submitDisAPI = (data) => {
  return fetch({ url: 'my-course/discussion', method: 'post', data })
}

/**
 *  【增】【改】提交讨论学习信息
 * @param {number|null}  id
 * @param {number|null}  recordId
 * @param {number|null} disId
 * @param {number} type
 */

export const submitDisKudosAPI = (data) => {
  return fetch({ url: 'my-course/discussion/kudos', method: 'post', data })
}
