topic.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div class="c_box">
  3. <div class="c_box_title">{{ title }}</div>
  4. <div class="c_box_brief" :style="isN==1?'text-align:center':''" v-if="brief">{{ brief }}</div>
  5. <div class="c_box_score" v-if="isN!=1">
  6. <span>总分:{{ score }}</span>
  7. <span v-if="name" style="margin-left: 10px;">答题人:{{ name }}</span>
  8. <span style="margin-left: 10px;">总得分:{{ score2 }}</span>
  9. </div>
  10. <div class="c_body" v-if="isloading">
  11. <div v-if="type == 3">
  12. <div v-for="(item, index) in checkArray[page].array" :key="index" class="check_box">
  13. <div class="title" v-if="item.ttype != 1 || (!item.json && item.ttype == 1)"
  14. :style="{ fontSize: item.ttype == 1 && '16px' }">{{ selectType(item, index) }}</div>
  15. <div v-if="item.ttype == 1" class="answerBox">
  16. <choiceV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-if="item.type == 1" :see="see"
  17. :isTeacher="isTeacher"></choiceV>
  18. <gapV ref="gapVRef" :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 3" :see="see"
  19. :isTeacher="isTeacher"></gapV>
  20. <fileV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 5" :see="see"
  21. :isTeacher="isTeacher"></fileV>
  22. <courseV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 6"
  23. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV>
  24. <evaV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 7" :see="see"
  25. :isTeacher="isTeacher"></evaV>
  26. <timeV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 8" :see="see"
  27. :isTeacher="isTeacher"></timeV>
  28. <courseV2 :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 11"
  29. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV2>
  30. <sweep :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 12"
  31. :see="see" :isTeacher="isTeacher"></sweep>
  32. <number :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 13"
  33. :see="see" :isTeacher="isTeacher"></number>
  34. <!-- <span v-else>暂未设置题目</span> -->
  35. </div>
  36. <div v-for="(item2, index2) in item.array" :key="`${index}-${index2}`" class="check_box_xia">
  37. <div class="title" v-if="item2.ttype != 1 || (!item2.json && item2.ttype == 1)"
  38. :style="{ fontSize: item2.ttype == 1 && '16px' }">{{ selectType(item2, index2) }}</div>
  39. <div v-if="item2.ttype == 1" class="answerBox">
  40. <choiceV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-if="item2.type == 1"
  41. :see="see" :isTeacher="isTeacher"></choiceV>
  42. <gapV ref="gapVRef" :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 3"
  43. :see="see" :isTeacher="isTeacher"></gapV>
  44. <fileV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 5"
  45. :see="see" :isTeacher="isTeacher"></fileV>
  46. <courseV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 6"
  47. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV>
  48. <evaV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 7"
  49. :see="see" :isTeacher="isTeacher"></evaV>
  50. <timeV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 8"
  51. :see="see" :isTeacher="isTeacher"></timeV>
  52. <sweep :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 12"
  53. :see="see" :isTeacher="isTeacher"></sweep>
  54. <number :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 13"
  55. :see="see" :isTeacher="isTeacher"></number>
  56. <!-- <span v-else>暂未设置题目</span> -->
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div v-else>
  62. <div v-for="(item, index) in checkArray" :key="index" class="check_box">
  63. <div class="title" v-if="item.ttype != 1 || (!item.json && item.ttype == 1)"
  64. :style="{ fontSize: item.ttype == 1 && '16px' }">{{ selectType(item, index) }}</div>
  65. <div v-if="item.ttype == 1" class="answerBox">
  66. <choiceV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-if="item.type == 1" :see="see"
  67. :isTeacher="isTeacher"></choiceV>
  68. <gapV ref="gapVRef" :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 3" :see="see"
  69. :isTeacher="isTeacher"></gapV>
  70. <fileV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 5" :see="see"
  71. :isTeacher="isTeacher"></fileV>
  72. <courseV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 6"
  73. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV>
  74. <evaV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 7" :see="see"
  75. :isTeacher="isTeacher"></evaV>
  76. <timeV :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 8" :see="see"
  77. :isTeacher="isTeacher"></timeV>
  78. <courseV2 :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 11"
  79. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV2>
  80. <sweep :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 12"
  81. :see="see" :isTeacher="isTeacher"></sweep>
  82. <number :tindex="index" :cJson.sync="item.json" :checktype="checktype" v-else-if="item.type == 13"
  83. :see="see" :isTeacher="isTeacher"></number>
  84. <!-- <span v-else>暂未设置题目</span> -->
  85. </div>
  86. <div v-for="(item2, index2) in item.array" :key="`${index}-${index2}`" class="check_box_xia">
  87. <div class="title" v-if="item2.ttype != 1 || (!item2.json && item2.ttype == 1)"
  88. :style="{ fontSize: item2.ttype == 1 && '16px' }">{{ selectType(item2, index2) }}</div>
  89. <div v-if="item2.ttype == 1" class="answerBox">
  90. <choiceV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-if="item2.type == 1"
  91. :see="see" :isTeacher="isTeacher"></choiceV>
  92. <gapV ref="gapVRef" :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 3"
  93. :see="see" :isTeacher="isTeacher"></gapV>
  94. <fileV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 5"
  95. :see="see" :isTeacher="isTeacher"></fileV>
  96. <courseV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 6"
  97. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV>
  98. <evaV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 7"
  99. :see="see" :isTeacher="isTeacher"></evaV>
  100. <timeV :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 8"
  101. :see="see" :isTeacher="isTeacher"></timeV>
  102. <courseV2 :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 11"
  103. :see="see" :isTeacher="isTeacher" @getTestWorkByCid="getTestWorkByCid" @publish2="publish2" :issetPage.sync="issetPage" :tid="tid"></courseV2>
  104. <sweep :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 12"
  105. :see="see" :isTeacher="isTeacher"></sweep>
  106. <number :tindex="index2" :cJson.sync="item2.json" :checktype="checktype" v-else-if="item2.type == 13"
  107. :see="see" :isTeacher="isTeacher"></number>
  108. <!-- <span v-else>暂未设置题目</span> -->
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <div v-if="checkArray.length > 1 && type == 3" class="page">
  114. <el-button type="primary" size="mini" :disabled="page == 0" @click="setPage('-1')">上一页</el-button>
  115. <div class="p_page">
  116. <span>{{ page + 1 }}</span><span>/</span><span>{{ checkArray.length }}</span>
  117. </div>
  118. <el-button type="primary" size="mini" :disabled="page == checkArray.length - 1"
  119. @click="setPage('1')">下一页</el-button>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. import choiceV from "./choice.vue";
  126. import gapV from './gap.vue';
  127. import fileV from './file.vue';
  128. import courseV from './course.vue';
  129. import evaV from './eva.vue';
  130. import timeV from './time.vue';
  131. import courseV2 from './course2.vue';
  132. import sweep from './sweep'
  133. import number from "./number.vue";
  134. export default {
  135. props: {
  136. cJson: {
  137. type: Array,
  138. },
  139. title: {
  140. type: String,
  141. },
  142. brief: {
  143. type: String
  144. },
  145. checktype: {
  146. type: Number,
  147. default: 1,
  148. },
  149. see: {
  150. type: Boolean,
  151. default: false
  152. },
  153. isTeacher: {
  154. type: Number,
  155. default: 2
  156. },
  157. name: {
  158. type: String,
  159. default: ''
  160. },
  161. tid: {
  162. type: String,
  163. default: ''
  164. },
  165. gcourseid: {
  166. type: String,
  167. default: ''
  168. }
  169. },
  170. components: {
  171. choiceV,
  172. gapV,
  173. fileV,
  174. courseV,
  175. evaV,
  176. timeV,
  177. courseV2,
  178. sweep,
  179. number
  180. },
  181. data() {
  182. return {
  183. checkArray: [],
  184. type: 1,
  185. page: 0,
  186. isN: this.$route.query.isN,
  187. options2: {
  188. 1: "选择题",
  189. // 2: "问答题",
  190. 3: "问答题",
  191. 4: "添加文档",
  192. 5: "附件",
  193. 6: "课程",
  194. 7: "评分",
  195. },
  196. isloading: true,
  197. issetPage: false
  198. };
  199. },
  200. computed: {
  201. selectType() {
  202. return function (item, index) {
  203. if (item.ttype == 1) {
  204. return index + 1 + "、" + this.options2[item.type];
  205. } else if (item.ttype == 2) {
  206. return `${item.name ? item.name : `第${index + 1}组`}(共${item.array.length}题)`;
  207. } else if (item.ttype == 3) {
  208. return `分页${index + 1}`;
  209. }
  210. };
  211. },
  212. score() {
  213. let score = 0
  214. this.checkArray.forEach(el => {
  215. if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
  216. el.array.forEach(item => {
  217. if (item.ttype == 2 && item.array.length > 0) {
  218. item.array.forEach(item2 => {
  219. if (item2.ttype == 1 && item2.json) {
  220. score += item2.json.score ? parseFloat(item2.json.score) : 0
  221. }
  222. })
  223. } else if (item.ttype == 1 && item.json) {
  224. score += item.json.score ? parseFloat(item.json.score) : 0
  225. }
  226. })
  227. } else if (el.ttype == 1 && el.json) {
  228. score += el.json.score ? parseFloat(el.json.score) : 0
  229. }
  230. })
  231. return score > 0 ? score + '分' : '未设置分数'
  232. },
  233. score2() {
  234. let score = 0
  235. // let type = 1
  236. this.checkArray.forEach(el => {
  237. if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
  238. el.array.forEach(item => {
  239. if (item.ttype == 2 && item.array.length > 0) {
  240. item.array.forEach(item2 => {
  241. if (item2.ttype == 1 && item2.json) {
  242. score += item2.json.score2 ? parseFloat(item2.json.score2) : 0
  243. }
  244. })
  245. } else if (item.ttype == 1 && item.json) {
  246. score += item.json.score2 ? parseFloat(item.json.score2) : 0
  247. }
  248. })
  249. } else if (el.ttype == 1 && el.json) {
  250. score += el.json.score2 ? parseFloat(el.json.score2) : 0
  251. }
  252. })
  253. return score + '分'
  254. }
  255. },
  256. watch: {
  257. cJson: {
  258. handler(newVal, oldVal) {
  259. console.log(newVal);
  260. console.log(oldVal);
  261. this.checkArray = this.setJson(this.depthCopy(newVal));
  262. this.$forceUpdate()
  263. },
  264. deep: true,
  265. },
  266. },
  267. methods: {
  268. setPage(index) {
  269. this.issetPage = true
  270. this.isloading = false
  271. if (index == '1') {
  272. this.page++
  273. } else if (index == '-1') {
  274. this.page--
  275. }
  276. setTimeout(() => {
  277. this.isloading = true
  278. }, 50)
  279. this.$forceUpdate()
  280. },
  281. depthCopy(s) {
  282. return JSON.parse(JSON.stringify(s));
  283. },
  284. setJson(json) {
  285. if (json.length > 0) {
  286. let _json = this.depthCopy(json);
  287. this.type = _json[0].ttype;
  288. let checkArray = _json.filter((item) => {
  289. if (item.array) {
  290. item.array = item.array.filter((item2) => {
  291. if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.type != 6 && item2.type != 7 && item2.type != 8 && item2.type != 12 && item2.type != 13) {
  292. item2.json.answer2 = [];
  293. } else if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.type == 6) {
  294. item2.json.answer2 = this.gcourseid ? this.gcourseid : item2.json.courses[0];
  295. } else if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.json.answer2 !== 0 && item2.type == 7) {
  296. item2.json.answer2 = '';
  297. } else if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.json.answer2 !== 0 && item2.type == 8 ) {
  298. item2.json.answer2 = '';
  299. }else if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.json.answer2 !== 0 && item2.type == 12 ) {
  300. item2.json.answer2 = '';
  301. }else if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.json.answer2 !== 0 && item2.type == 13 ) {
  302. item2.json.answer2 = '';
  303. }
  304. if (item2.array) {
  305. item2.array = item2.array.filter((item3) => {
  306. if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.type != 6 && item3.type != 7 && item3.type != 8 && item3.type != 12 && item3.type != 13) {
  307. item3.json.answer2 = [];
  308. } else if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.type == 6) {
  309. item3.json.answer2 = this.gcourseid ? this.gcourseid : item3.json.courses[0];
  310. } else if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.json.answer2 !== 0 && item3.type == 7) {
  311. item3.json.answer2 = '';
  312. } else if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.json.answer2 !== 0 && item3.type == 8) {
  313. item3.json.answer2 = '';
  314. }else if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.json.answer2 !== 0 && item3.type == 12) {
  315. item3.json.answer2 = '';
  316. }else if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.json.answer2 !== 0 && item3.type == 13) {
  317. item3.json.answer2 = '';
  318. }
  319. return item3;
  320. });
  321. }
  322. return (
  323. (item2.ttype != 1 && item2.array.length > 0) || item2.ttype == 1
  324. );
  325. });
  326. }
  327. if (item.ttype == 1 && item.json && !item.json.answer2 && item.type != 6 && item.type != 7 && item.type != 8 && item.type != 12 && item.type != 13) {
  328. item.json.answer2 = [];
  329. } else if (item.ttype == 1 && item.json && !item.json.answer2 && item.type == 6) {
  330. item.json.answer2 = this.gcourseid ? this.gcourseid : item.json.courses[0];
  331. } else if (item.ttype == 1 && item.json && !item.json.answer2 && item.json.answer2 !== 0 && item.type == 7) {
  332. item.json.answer2 = '';
  333. } else if (item.ttype == 1 && item.json && !item.json.answer2 && item.json.answer2 !== 0 && item.type == 8) {
  334. item.json.answer2 = '';
  335. }else if (item.ttype == 1 && item.json && !item.json.answer2 && item.json.answer2 !== 0 && item.type == 12) {
  336. item.json.answer2 = '';
  337. }else if (item.ttype == 1 && item.json && !item.json.answer2 && item.json.answer2 !== 0 && item.type == 13) {
  338. item.json.answer2 = '';
  339. }
  340. console.log(item.array);
  341. return (item.ttype != 1 && item.array.length > 0) || item.ttype == 1;
  342. });
  343. console.log(checkArray);
  344. return checkArray;
  345. } else {
  346. return [];
  347. }
  348. },
  349. getTestWorkByCid(cid){
  350. this.$emit('getTestWorkByCid', cid)
  351. },
  352. publish2(){
  353. this.$emit('publish2')
  354. },
  355. autoFillGapV(){
  356. // console.log(this.$refs["gapVRef"])
  357. this.$refs["gapVRef"].forEach(i=>{
  358. i.autoFill();
  359. })
  360. }
  361. },
  362. mounted() {
  363. this.checkArray = this.setJson(this.depthCopy(this.cJson));
  364. },
  365. };
  366. </script>
  367. <style scoped>
  368. .c_box {
  369. width: 95%;
  370. margin: 0 auto;
  371. background: #fff;
  372. height: calc(100% - 55px);
  373. overflow: auto;
  374. }
  375. .c_box_title {
  376. width: 90%;
  377. text-align: center;
  378. font-size: 24px;
  379. font-weight: bold;
  380. word-break: break-all;
  381. margin: 10px auto;
  382. }
  383. .c_box_brief {
  384. width: 90%;
  385. text-align: left;
  386. font-size: 14px;
  387. word-break: break-all;
  388. margin: 10px auto;
  389. color: #373737;
  390. }
  391. .c_box_score {
  392. width: 90%;
  393. text-align: center;
  394. word-break: break-all;
  395. margin: 0 auto 20px;
  396. font-size: 16px;
  397. color: #373737;
  398. }
  399. .c_body {
  400. width: 90%;
  401. margin: 0 auto;
  402. }
  403. .check_box {}
  404. .check_box+.check_box {
  405. margin-top: 10px;
  406. padding-top: 10px;
  407. /* border-top: 1px solid #eee; */
  408. }
  409. .check_box>.title {
  410. font-size: 24px;
  411. word-break: break-all;
  412. font-weight: bold;
  413. padding-left: 45px;
  414. }
  415. .check_box>.answerBox {
  416. margin-top: 10px;
  417. }
  418. .check_box>.noanswerBox {
  419. margin-top: 10px;
  420. }
  421. .check_box_xia {
  422. padding: 15px 0;
  423. }
  424. .check_box_xia+.check_box_xia {
  425. /* border-top: 1px solid #eee; */
  426. }
  427. .check_box_xia>.title {
  428. font-size: 22px;
  429. font-weight: bold;
  430. padding-left: 45px;
  431. }
  432. .check_box_xia>.answerBox {
  433. margin-top: 10px;
  434. }
  435. .check_box_xia>.noanswerBox {
  436. margin-top: 10px;
  437. }
  438. .page {
  439. margin: 20px;
  440. display: flex;
  441. align-items: center;
  442. justify-content: center;
  443. }
  444. .p_page {
  445. margin: 0 10px;
  446. }
  447. </style>