topic.vue 17 KB

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