classroom_assessment.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. // pages/classroom_assessment/classroom_assessment.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. baseImgUrl: app.globalData.baseImgUrl,
  9. isClass:true,
  10. starList: [
  11. {
  12. url: '../../assets/star-2@2x.png',
  13. activeUrl: '',
  14. },
  15. {
  16. url: '../../assets/star-2@2x.png',
  17. activeUrl: '',
  18. },
  19. {
  20. url: '../../assets/star-2@2x.png',
  21. activeUrl: '',
  22. },
  23. {
  24. url: '../../assets/star-2@2x.png',
  25. activeUrl: '',
  26. },
  27. {
  28. url: '../../assets/star-2@2x.png',
  29. activeUrl: '',
  30. }
  31. ],
  32. tagList:[
  33. ],
  34. wordList:[],
  35. normalSrc: '../../image/min_star_gay.png',
  36. selectedSrc: '../../image/min_star_red.png',
  37. halfSrc: '../../image/min_star_red.png',
  38. key: 0,//评分
  39. num: '',
  40. content: ''
  41. },
  42. /**
  43. * 生命周期函数--监听页面加载
  44. */
  45. onLoad: function (options) {
  46. this.setData( options )
  47. console.log(options);
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. this.seeEvaluate()
  59. },
  60. /**
  61. * 生命周期函数--监听页面隐藏
  62. */
  63. onHide: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面卸载
  67. */
  68. onUnload: function () {
  69. },
  70. /**
  71. * 页面相关事件处理函数--监听用户下拉动作
  72. */
  73. onPullDownRefresh: function () {
  74. },
  75. /**
  76. * 页面上拉触底事件的处理函数
  77. */
  78. onReachBottom: function () {
  79. },
  80. /**
  81. * 用户点击右上角分享
  82. */
  83. onShareAppMessage: function () {
  84. },
  85. // 批改老师提交
  86. checkTeacher: function () {
  87. const postData = { fn: this.submitAssessment, param: { ...arguments } }
  88. const { lever, lableList, isJudge ,teacherId, homeworkId } = this.data;
  89. console.log(lever, lableList, isJudge, teacherId, homeworkId)
  90. if (isJudge == 1) {
  91. wx.showToast({
  92. title: '已评价,请勿重复评价',
  93. icon: 'none'
  94. });
  95. return
  96. }
  97. if (!lever) {
  98. wx.showToast({
  99. title: '请选择星级',
  100. icon: 'none'
  101. })
  102. return
  103. }
  104. if (!lableList) {
  105. wx.showToast({
  106. title: '请选择评语',
  107. icon: 'none'
  108. })
  109. return
  110. }
  111. app.post('/api/parents/parents/V2/assessCorrectTeacher', {
  112. teacherId,
  113. homeworkId,
  114. level:lever,
  115. lableList
  116. }, 0, postData).then(res => {
  117. wx.showToast({
  118. title: '评价成功',
  119. icon: 'none',
  120. duration: 1000
  121. });
  122. setTimeout((function callback() {
  123. wx.navigateBack({});
  124. }).bind(this), 2000);
  125. })
  126. },
  127. /**
  128. * 查看评价
  129. */
  130. seeEvaluate:function(){
  131. const postData = { fn: this.seeEvaluate, param: { ...arguments } }
  132. const { teacherId, homeworkId } = this.data;
  133. app.post('/api/parents/parents/V2/getCorrectTeacherAssessment', {
  134. teacherId,
  135. homeworkId
  136. }, 0, postData).then(res => {
  137. const { labelList, isJudge, judgeLever } = res.data;
  138. var tagList=[];
  139. for (var i in labelList){
  140. if (judgeLever == labelList[i].lever){
  141. tagList.push(labelList[i])
  142. }
  143. }
  144. this.setData({ labelList, isJudge, lever:judgeLever, tagList})
  145. })
  146. },
  147. //点击整颗星
  148. selectRight: function (e) {
  149. const postData = { fn: this.selectRight, param: { ...arguments } }
  150. const { key} = e.currentTarget.dataset;
  151. const { courseId, isClass, teacherId, homeworkId} = this.data;
  152. console.log(isClass)
  153. this.setData({ lever: key});
  154. var url = !isClass ? '/api/parents/parents/getCourseAssessment' : '/api/parents/parents/V1/getCorrectTeacherAssessment';
  155. var str = !isClass ? { courseId } : { teacherId, homeworkId };
  156. app.post(url, str, 0, postData).then(res => {
  157. const { labelList, isJudge} = res.data;
  158. var tagList=[];
  159. for (var i in labelList){
  160. if (key == labelList[i].lever){
  161. tagList.push(labelList[i].label)
  162. }
  163. }
  164. this.setData({ tagList, isJudge });
  165. })
  166. },
  167. // 选择标签
  168. clickTag:function(e){
  169. const { tagList}=this.data;
  170. const {index}=e.target.dataset;
  171. var temp={};
  172. temp[`tagList[0][${index}].status`] = tagList[0][index].status == 'active' ? "" : 'active';
  173. this.setData(temp);
  174. this.tagList();
  175. },
  176. // 标签内容
  177. tagList:function(){
  178. const { tagList } = this.data;
  179. const lableList = [];
  180. for (var i in tagList[0]) {
  181. if (tagList[0][i].status == "active") {
  182. lableList.push(tagList[0][i].labelName);
  183. }
  184. }
  185. this.setData({ lableList});
  186. },
  187. // 提交
  188. submitAssessment:function(){
  189. const postData = { fn: this.submitAssessment, param: { ...arguments } }
  190. const { lever, lableList, courseId, isJudge}=this.data;
  191. if (isJudge == 1) {
  192. wx.showToast({
  193. title: '已评价,请勿重复评价',
  194. icon: 'none'
  195. });
  196. return
  197. }
  198. if (!lever) {
  199. wx.showToast({
  200. title: '请选择星级',
  201. icon: 'none'
  202. })
  203. return
  204. }
  205. if (!lableList) {
  206. wx.showToast({
  207. title: '请选择评语',
  208. icon: 'none'
  209. })
  210. return
  211. }
  212. app.post('/api/parents/parents/upCourseAssessment', {
  213. courseId,
  214. lever,
  215. lableList
  216. }, 0, postData).then(res => {
  217. wx.showToast({
  218. title: '评价成功',
  219. icon:'none',
  220. duration:1000
  221. });
  222. setTimeout((function callback() {
  223. wx.navigateBack({});
  224. }).bind(this), 2000);
  225. })
  226. }
  227. })