TestPaper.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <div class="paper-container">
  3. <div class="ev-header">
  4. <Icon type="md-paper" size="30" color="rgb(16, 171, 231)" />
  5. <span class="ev-title" @click="backToAdd">测试组卷</span>
  6. <span class="ev-length">共 {{paperInfo.ItemId.length}} 道题</span>
  7. </div>
  8. <!-- 试卷编辑工具栏 -->
  9. <div class="paper-toolbar filter-wrap">
  10. <!--<div class="filter-item">
  11. <span class="filter-title">测试用途:</span>
  12. <RadioGroup v-model="testAttr.testType" type="button" @on-change="filterTypeChange">
  13. <Radio label="0">正式考试</Radio>
  14. <Radio label="1">普通测试</Radio>
  15. <Radio label="2">统计</Radio>
  16. </RadioGroup>
  17. </div>
  18. <div class="filter-item">
  19. <span class="filter-title">测试情景:</span>
  20. <RadioGroup v-model="testAttr.testScene" type="button" @on-change="filterSceneChange">
  21. <Radio label="0">模拟</Radio>
  22. <Radio label="1">段考</Radio>
  23. <Radio label="2">周考</Radio>
  24. <Radio label="3">小考</Radio>
  25. <Radio label="4">自定义</Radio>
  26. </RadioGroup>
  27. </div>-->
  28. <!--<div class="filter-item">
  29. <span class="filter-title">测试对象:</span>
  30. <RadioGroup v-model="testAttr.testTarget" type="button" @on-change="filterTargetChange">
  31. <Radio label="0">同年级</Radio>
  32. <Radio label="1">跨年级</Radio>
  33. <Radio label="2">跨学校</Radio>
  34. </RadioGroup>
  35. </div>-->
  36. <!--<div class="filter-item">
  37. <span class="filter-title">创建方式:</span>
  38. <RadioGroup v-model="testAttr.createType" type="button" @on-change="filterCreateChange">
  39. <Radio label="0">自动组题</Radio>
  40. <Radio label="1">批量导入</Radio>
  41. <Radio label="2">题库挑选</Radio>
  42. </RadioGroup>
  43. </div>-->
  44. <div class="paper-tools">
  45. <Checkbox v-model="isShowAnswer" @on-change="changeShowAnswer">展示答案与解析</Checkbox>
  46. </div>
  47. </div>
  48. <!-- 试卷内容 -->
  49. <div class="paper-content">
  50. <!--<div class="paper-line">
  51. <div id="pui_seal" title="点击设置&quot;装订线&quot;" style="display: block;">
  52. <img alt="装订线" title="装订线" src="http://zujuan.xkw.com/resource/image/v2/peal_line.png" width="58" height="">
  53. </div>
  54. </div>-->
  55. <div class="paper-body">
  56. <!-- 试卷头部信息 -->
  57. <div class="paper-header flex-col-center">
  58. <p class="paper-title">{{paperInfo.title}}</p>
  59. <p class="paper-subTitle">{{paperInfo.subTitle}}</p>
  60. <p class="paper-info">考试时间:{{paperInfo.time}} 出卷人:{{paperInfo.builder}}</p>
  61. </div>
  62. <!-- 题目类型及列表 -->
  63. <div class="paper-part" v-for="(item,order) in paperInfo.parts">
  64. <div class="paper-content-section">{{numberConvertToUppercase(order)+'、'+item.name}}<span>(共6题,每题5分,共30分)</span></div>
  65. <div v-if="list.length == 0">暂无数据</div>
  66. <div class="content-wrap" v-else>
  67. <div class="exercise-item" v-for="(question,index) of item.questions" @mouseenter="exerciseMouseover($event)" @mouseleave="exerciseMouseleave($event)">
  68. <div class="item-tools">
  69. <div class="item-tools-t flex-row-center"><Icon type="ios-list-box-outline" />试题挑错</div>
  70. <div class="item-tools-t flex-row-center"><Icon type="ios-brush-outline" />编辑</div>
  71. <div class="item-tools-t flex-row-center"><Icon type="ios-archive-outline" />删除</div>
  72. <div class="item-tools-t flex-row-center"><Icon type="md-arrow-up" />上移</div>
  73. <div class="item-tools-t flex-row-center"><Icon type="md-arrow-down" />下移</div>
  74. </div>
  75. <div class="item-question">
  76. <p>{{index+1}} : <span v-html="question.question"></span></p>
  77. </div>
  78. <div v-for="(option,optionIndex) in question.option">
  79. <p>{{String.fromCharCode(64 + parseInt(optionIndex+1))}} : <span v-html="option.value"></span></p>
  80. </div>
  81. <!-- 如果是组合题 -->
  82. <div v-for="(childQuestion,childIndex) in question.children" v-if="question.children.length">
  83. <div class="item-question">
  84. <p>{{childIndex+1}} : <span v-html="childQuestion.question"></span></p>
  85. </div>
  86. <div v-for="(childOption,childOptionIndex) in childQuestion.option">
  87. <p>{{String.fromCharCode(64 + parseInt(childOptionIndex+1))}} : <span v-html="childOption.value"></span></p>
  88. </div>
  89. <div class="item-answer" v-show="isShowAnswer">
  90. <span style="color:#01b4ef">【答案】:</span>
  91. <span v-html="childQuestion.answer[0] || childQuestion.answer" v-if="childQuestion.type == 'Subjective'"></span>
  92. <span :class="[ childQuestion.type == 'Complete' ? 'item-answer-item':'']" v-for="answer in childQuestion.answer" v-else-if="childQuestion.type == 'Complete'" v-html="answer"></span>
  93. <span :class="[ childQuestion.type == 'Complete' ? 'item-answer-item':'']" v-for="answer in childQuestion.answer" v-else>{{answer}}</span>
  94. </div>
  95. <div class="item-explain" v-show="isShowAnswer">
  96. <span style="color:#01b4ef">【解析】:</span>
  97. <span v-html="childQuestion.explain"></span>
  98. </div>
  99. </div>
  100. <!-- 答案与解析部分选择是否展示 -->
  101. <div class="item-answer" v-show="isShowAnswer && question.type != 'Compose'">
  102. <span style="color:#01b4ef">【答案】:</span>
  103. <span v-html="question.answer[0] || question.answer" v-if="question.type == 'Subjective'"></span>
  104. <span :class="[ question.type == 'Complete' ? 'item-answer-item':'']" v-for="answer in question.answer" v-else-if="question.type == 'Complete'" v-html="answer"></span>
  105. <span :class="[ question.type == 'Complete' ? 'item-answer-item':'']" v-for="answer in question.answer" v-else>{{answer}}</span>
  106. </div>
  107. <div class="item-explain" v-show="isShowAnswer && question.type != 'Compose'">
  108. <span style="color:#01b4ef">【解析】:</span>
  109. <span v-html="question.explain"></span>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="paper-footer">
  117. <Button type="primary">保存试卷</Button>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import questions from './list.json'
  123. import paper from './paper.json'
  124. export default {
  125. data() {
  126. return {
  127. list: [],
  128. paperInfo: {},
  129. exersicesType: {
  130. single: "单选",
  131. multiple: "多选",
  132. judge: "判断",
  133. complete: "填空",
  134. subjective: "问答"
  135. },
  136. testAttr: {
  137. testScene: '0',
  138. testType: '0',
  139. testTarget: '0',
  140. testMode: '0',
  141. createType: '0',
  142. questionFilter: []
  143. },
  144. exersicesDiff: ["容易", "较易", "一般", "较难", "困难"],
  145. diffColors: ['#32CF74', '#E8BE15', '#F19300', '#EB5E00', '#D30000'],
  146. filterType: "0",
  147. filterDiff: "0",
  148. filterSort: "0",
  149. pageSize: 5,
  150. pageNum: 1,
  151. totalNum: 100,
  152. allList: questions.list,
  153. isShowAnswer: false
  154. }
  155. },
  156. created() {
  157. this.list = questions.list;
  158. this.paperInfo = paper;
  159. let flag = this.$route.params.flag;
  160. if (flag == 1) {
  161. console.log(JSON.parse(localStorage.getItem('questions')));
  162. this.paperInfo.parts[0].questions = JSON.parse(localStorage.getItem('questions'))
  163. }
  164. },
  165. methods: {
  166. //返回创建评测页面
  167. backToAdd() {
  168. this.$router.push({
  169. path: '/testPaperList',//或者路径跳转path: '/addCreditCards',
  170. })
  171. },
  172. //数字与中文转换
  173. numberConvertToUppercase(num) {
  174. num = Number(num + 1);
  175. var upperCaseNumber = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '百', '千', '万', '亿'];
  176. var length = String(num).length;
  177. if (length == 1) {
  178. return upperCaseNumber[num];
  179. } else if (length == 2) {
  180. if (num == 10) {
  181. return upperCaseNumber[num];
  182. } else if (num > 10 && num < 20) {
  183. return '十' + upperCaseNumber[String(num).charAt(1)];
  184. } else {
  185. return upperCaseNumber[String(num).charAt(0)] + '十' + upperCaseNumber[String(num).charAt(1)].replace('零', '');
  186. }
  187. }
  188. },
  189. //切换页码
  190. pageChange(page) {
  191. let start = this.pageSize * (page - 1);
  192. let end = this.pageSize * page;
  193. let list = questions.list;
  194. this.list = list.slice(start, end);
  195. window.scroll(0, 0);
  196. },
  197. //切换分页Size
  198. pageSizeChange(val) {
  199. this.pageSize = val;
  200. this.pageChange(1);
  201. },
  202. //题目鼠标滑过事件
  203. exerciseMouseover(e) {
  204. e.preventDefault();
  205. e.target.children[0].style.display = "block";
  206. },
  207. //题目鼠标移出事件
  208. exerciseMouseleave(e) {
  209. e.preventDefault();
  210. e.target.children[0].style.display = "none";
  211. },
  212. //测试用途
  213. filterTypeChange(val) {
  214. },
  215. //测试情景
  216. filterSceneChange(val) {
  217. },
  218. //测试对象
  219. filterTargetChange(val) {
  220. },
  221. //创建方式
  222. filterCreateChange(val) {
  223. },
  224. changeShowAnswer(val) {
  225. console.log(this.isShowAnswer);
  226. }
  227. },
  228. mounted() {
  229. }
  230. }
  231. </script>
  232. <style src="../index/ExercisesList.css" scoped></style>
  233. <style src="../index/TestPaper.css" scoped></style>
  234. <style>
  235. .content-wrap .exercise-item p {
  236. margin: 10px 0;
  237. display: inherit;
  238. word-break: break-all;
  239. }
  240. .complete-line {
  241. padding: 0 45px;
  242. border-bottom: 2px solid rgb(128, 128, 128);
  243. }
  244. </style>