import BaseAPI from './base_api'

export default class PlayerAPI extends BaseAPI {
  /**
   * 获取章节列表信息
   * @param {[string]} cur_course_id -> cid
   * @param {[string]} cur_video_id -> vid
   */
  getChapterList = (cid, sid, vid) => this.get(`/api/lms/v2/education/courses/${cid}`, {})
  /**
   * 获取对应某个章节的详细信息
   * @param {[string]} vid
   */
  getCurrentChapterDetail = (vid) => this.post('/api/lms/v2/education/video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
  /**
   * 获取对应某个章节的详细信息
   * @param {[string]} vid
   */
  getCurrentChapterDetailAliyun = (vid) => this.post('/api/lms/v2/education/aliyun-video-streaming', { vid }, { headers: { 'Content-Type': 'application/json' } })
  /**
   * 获取进度信息
   * @param {[string]} vid
   * @param {[string]} did
   */
  getProgress = (vid, did, sid) => this.get(`/api/lms/v2/education/video/${vid}/device`, { device_id: did })
  /**
   * 提交进度信息
   * @param {[object]} obj
   * d: obj.did,
      i: obj.did,
      c: obj.cid,
      s: obj.sid,
      v: obj.vid,
      _p: obj.pt, // 累计时间
      _m: obj.mpt, // 当前播放最大时间
      _c: obj.cpt // 当前播放位置
   */
  updateProgress = (obj = {}) => this.get('/api/lms/v2/analytics/upload-video', obj)
  /**
   * 获取试题信息
   * @param {[string]} eid
   */
  getExamDetail = (sid, cid, eid) => this.get(`/api/lms/v2/education/homeworks/${eid}`, {})
  /**
   * 提交考试信息
   * @param {[object]} param
   */
  submitExamDetail = (param) => this.post('/api/lms/v2/education/homeworks', param, { headers: { 'Content-Type': 'application/json' } })
  /**
   * 获取试题信息 - 课程后考试
   * @param {[string]} eid
   */
  getExamDetailAfterCourse = (sid, cid, eid) => this.get(`/api/lms/v2/education/examinations/${cid}/${eid}`, {})
  /**
   * 提交考试信息 - 课程后考试
   * @param {[object]} param
   */
  submitExamDetailAfterCourse = (param) => this.post('/api/lms/v2/education/examinations', param)
  /**
   * 获取对应 作业或问题 回答
   * @param {[string]} id resource_id
   */
  getHomework = (sid, cid, id) => this.get(`/api/lms/v2/education/homeworks/${id}`, {})
  /**
   * 文件提交
   * @param {[object]} obj
   */
  uploadFile = (obj = {}) => this.post('/api/lms/util/upload-file', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
  /**
   * 提交课程 作业或问题
   */
  updateHomework = (obj = {}) => this.post('/api/lms/v2/education/homeworks', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
  /**
   * 课程作业截止时间
   */
  getHomeworkStopTime = (sid, cid, chapterId) => this.get(`/api/lms/v2/education/homeworks/${cid}/${chapterId}/deadline`, {})
  /**
   * 获取对应 大作业 回答
   * @param {[string]} cid
   */
  getCourseHomework = (sid, cid) => this.get(`/api/lms/v2/education/courses/${cid}/essay`, {})
  /**
   * 提交课程 大作业
   * @param {[string]} cid
   */
  updateCourseHomework = (sid, cid, obj = {}) => this.post(`/api/lms/v2/education/courses/${cid}/essay`, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
  /**
   * 提交 课程考核
   * @param {[string]} obj.cid
   * @param {[string]} obj.raw (base64)
   */
  updateSurveyAnswer = (obj) => this.post('/api/lms/v2/education/survey/answer', obj, { headers: { 'Content-Type': 'application/json' } })
  /**
   * 手机端 获取实时最新直播接口
   */
  getNewLiveMsg = (obj = {}) => this.get('/api/lms/v2/education/lives/latest', obj)
  /**
   * 手机端 获取列表接口
   */
  getLiveList = (obj = {}) => this.get('/api/lms/v2/education/lives/courses', obj)
  /**
   * 跨域接口请求 - 直接获取云课堂设置
   */
  getCloudUrl = (obj = {}) => this.get('https://node-server.ezijing.com/get/cloud-class', obj)
  /**
   * 获取考卷信息
   * @param {[string]} course_id -> cid
   * @param {[string]} semester_id -> sid
   */
  getExamInfo = (cid, sid) => this.get(`/api/lms/v2/education/${cid}/examination`, {})
  /**
   * 获取考卷结果
   * @param {[string]} course_id -> cid
   * @param {[string]} semester_id -> sid
   * @param {[string]} exam_id -> eid
   */
  getExamAnswer = (cid, sid, eid) => this.get(`/api/lms/v2/education/${cid}/examination/${eid}/sheet`, {})
  /**
   * 获取考试状态
   * @param {[string]} course_id -> cid
   * @param {[string]} semester_id -> sid
   * @param {[string]} exam_id -> eid
   */
  getExamStatus = (cid, sid, eid) => this.get(`/api/lms/v2/education/${cid}/examination/${eid}/status`, {})
  /**
   * 提交考卷
   * @param {[string]} course_id -> cid
   * @param {[string]} semester_id -> sid
   * @param {[string]} exam_id -> eid
   * @param {[object]} obj -> 提交对象类
   */
  submitExam = (cid, sid, eid, obj = {}) => this.post(`/api/lms/v2/education/${cid}/examination/${eid}/sheet`, obj, { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
}
