| | |
| | | } |
| | | |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | |
| | | } else { |
| | | this.init() |
| | | } |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | }, ], |
| | | }); |
| | | this.init(); |
| | | } else if (this.data.answerType == 'interaction') { |
| | | this.setData({ |
| | | countdownTime: 2 * 60 * 60 * 1000, |
| | | }); |
| | | this.delinteractionInfo(() => { |
| | | this.getQuestionList() |
| | | this.clearTime(); |
| | | }) |
| | | } else { |
| | | this.init(); |
| | | this.clearTime(); |
| | |
| | | questionDataList: questionList, |
| | | cardList: cardUpdatedList, |
| | | }); |
| | | console.log( |
| | | '题目', this.data.questionDataList |
| | | ); |
| | | }); |
| | | }); |
| | | } |
| | |
| | | const query = { |
| | | start: 0, |
| | | size: 999, |
| | | filterList: [], |
| | | infoTypes: [], |
| | | } |
| | | app.MG.identity.joinedGroupByList(query).then((res) => { |
| | | console.log('班级信息', res); |
| | | res.datas.forEach(async item => { |
| | | item.topicId = null |
| | | const data = await this.getTopicInfo(item.id) |
| | |
| | | item.topicId = data.id |
| | | } |
| | | }) |
| | | |
| | | console.log('班级', res) |
| | | if (res.datas.length) { |
| | | this.setData({ |
| | | classList: res.datas |
| | | }) |
| | | // 判断班级 是否所属于该书 |
| | | const flag = res.datas.some(item => item.linkProductDto.product.id == this.data.bookId) |
| | | if (!flag) { |
| | | this.setData({ |
| | | visible: true, |
| | | }) |
| | | const classData = res.datas.find(item => item.linkProductDto.product.id == this.data.bookId) |
| | | if (classData) { |
| | | if (classData.userState == 'Normal') { |
| | | // 加入班级 |
| | | this.setData({ |
| | | joinGroup: true |
| | | }) |
| | | } else if (classData.userState == 'WaitValid') { |
| | | this.setData({ |
| | | submitStatus: true |
| | | }) |
| | | // 审核中 |
| | | wx.showModal({ |
| | | title: '提示', |
| | | content: '请等待老师审核加入班级后答题', |
| | | confirmColor: "#ff6c00", |
| | | complete: (res) => { |
| | | if (res.cancel) { |
| | | wx.navigateBack() |
| | | } |
| | | if (res.confirm) { |
| | | wx.navigateBack() |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | // 拒绝 |
| | | this.setData({ |
| | | visible: true |
| | | }) |
| | | } |
| | | } else { |
| | | // 未加入班级 |
| | | this.setData({ |
| | | visible: false, |
| | | joinGroup: true |
| | | visible: true |
| | | }) |
| | | } |
| | | } else { |
| | |
| | | }) |
| | | } |
| | | |
| | | // if (res.datas.length) { |
| | | // this.setData({ |
| | | // classList: res.datas, |
| | | // visible: true |
| | | // }) |
| | | // } else { |
| | | // // 未加入班级,唤起加入班级弹窗 |
| | | // this.setData({ |
| | | // joinGroup: false, |
| | | // visible: true |
| | | // }) |
| | | // } |
| | | }) |
| | | }, |
| | | // 加入班级 |
| | | joinClass(e) { |
| | | wx.showLoading({ |
| | | title: '加载中' |
| | | }) |
| | | const data = { |
| | | refCode: e.detail.value |
| | | } |
| | | app.MG.identity.joinGroupByRefCode(data).then((res) => { |
| | | wx.hideLoading() |
| | | if (res == '组不存在') { |
| | | wx.showToast({ |
| | | icon: 'error', |
| | |
| | | let value = JSON.parse(res[0].value); |
| | | const scoreData = value.dataList.find(item => item.name == "客观题得分" && item.path == this.data.productLinkPath) |
| | | this.setData({ |
| | | submitStatus: value.submitStatus, |
| | | currentIndex: value.currentIndex, |
| | | subjectiveNum: scoreData ? scoreData.score : 0 |
| | | currentIndex: value.currentIndex ? value.currentIndex : 0, |
| | | subjectiveNum: scoreData ? scoreData.score : 0, |
| | | submitStatus: true |
| | | }); |
| | | // 携带答题记录 获取题目 |
| | | this.getQuestionList(value.dataList); |
| | |
| | | }); |
| | | }, |
| | | // 提交教学互动答题数据 |
| | | setinteractionInfo(submitStatus) { |
| | | setinteractionInfo() { |
| | | const list = [] |
| | | this.data.cardList.forEach(item => { |
| | | list.push({ |
| | |
| | | score: this.data.subjectiveNum, |
| | | path: this.data.productLinkPath, |
| | | }) |
| | | console.log('提交数据', list); |
| | | app.MG.identity |
| | | .setUserKey({ |
| | | setKeyRequests: [{ |
| | | domain: "interactionData", |
| | | key: this.data.productLinkPath, |
| | | value: JSON.stringify({ |
| | | submitStatus, |
| | | currentIndex: this.data.currentIndex, |
| | | dataList: list |
| | | }), |
| | |
| | | }, |
| | | // 处理教学互动答题 |
| | | handleClassQuestion() { |
| | | console.log(1, this.data.questionDataList); |
| | | const flag = this.data.questionDataList.some(item => !item.userAnswer) |
| | | if (flag) { |
| | | // 没做完,保存即可 |
| | | const isAnswer = this.data.questionDataList.some(item => item.userAnswer) |
| | | if (isAnswer) this.setinteractionInfo(false) |
| | | if (isAnswer) this.setinteractionInfo() |
| | | } else { |
| | | // 做完了且加入了班级,提交到message |
| | | if (this.data.classList.length && this.data.joinGroup) { |
| | | this.data.classList.forEach(item => { |
| | | if (item.linkProductDto.product.id == this.data.bookId) |
| | | if (item.linkProductDto.product.id == this.data.bookId && item.topicId) |
| | | this.newTopicMessage(item.topicId) |
| | | }) |
| | | this.setinteractionInfo(true) |
| | | this.setinteractionInfo() |
| | | } else { |
| | | // 做完了,没加入班级 |
| | | this.setinteractionInfo(false) |
| | | this.setinteractionInfo() |
| | | } |
| | | this.setData({ |
| | | isShowDialog: true |
| | |
| | | state: citem.questionType == 'shortAnswer' ? 'none' : citem.isRight, |
| | | type: citem.questionType |
| | | }) |
| | | } |
| | | const data = { |
| | | description: '', |
| | | icon: '', |
| | | state: 'Normal', |
| | | topicIdOrRefCode: String(topicId), |
| | | name: this.data.answerTitle, |
| | | content: JSON.stringify({ |
| | | bookId: this.data.bookId, |
| | | userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name, |
| | | path: this.data.productLinkPath, |
| | | content |
| | | }), |
| | | type: 'Normal', |
| | | cmsTypeRefCode: '', |
| | | newDataListRequest: [] |
| | | } |
| | | app.MG.ugc.newTopicMessage(data).then((res) => { |
| | | if (res) { |
| | | this.setData({ |
| | | isShowDialog: true |
| | | }) |
| | | const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | const data = { |
| | | description: '', |
| | | icon: '', |
| | | state: 'Normal', |
| | | topicIdOrRefCode: String(topicId), |
| | | name: this.data.answerTitle, |
| | | content: JSON.stringify({ |
| | | bookId: this.data.bookId, |
| | | userName: userInfo.name ? userInfo.name : userInfo.nickName ? userInfo.nickName : '-', |
| | | path: this.data.productLinkPath, |
| | | content |
| | | }), |
| | | type: 'Normal', |
| | | cmsTypeRefCode: '', |
| | | newDataListRequest: [] |
| | | } |
| | | }) |
| | | app.MG.ugc.newTopicMessage(data).then((res) => { |
| | | if (res) { |
| | | this.setData({ |
| | | isShowDialog: true |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | // 新建子topicMessage |
| | | // newTopicSubMessage(parentId,topicId) { |
| | | // const data = { |
| | | // description: '', |
| | | // icon: '', |
| | | // parentId, |
| | | // state: 'Normal', |
| | | // topicIdOrRefCode: String(topicId), |
| | | // name: this.data.answerTitle, |
| | | // content: '', |
| | | // type: 'Normal', |
| | | // cmsTypeRefCode: '', |
| | | // newDataListRequest: [] |
| | | // } |
| | | // MG.ugc.newTopicMessage(data).then((res) => { |
| | | // if (res) { |
| | | |
| | | // } |
| | | // }) |
| | | // }, |
| | | }); |
| | | // 删除教学互动答题记录 |
| | | delinteractionInfo(callback) { |
| | | app.MG.identity |
| | | .delUserKey({ |
| | | domain: 'interactionData', |
| | | keys: [this.data.productLinkPath] |
| | | }) |
| | | .then((res) => { |
| | | if (callback) callback() |
| | | }) |
| | | } |
| | | }) |