|
@@ -1,61 +1,54 @@
|
|
|
<template>
|
|
|
<div class="ev-container">
|
|
|
- <h1>新建习题</h1>
|
|
|
+ <h1>新建测试</h1>
|
|
|
<Divider />
|
|
|
<div class="exersices-attr display-flex">
|
|
|
<div class="exersices-attr-type my-radio-style">
|
|
|
- <IconText :text="'选择题型'" :color="'green'" :icon="'md-apps'"></IconText>
|
|
|
+ <IconText :text="'测试情景'" :color="'green'" :icon="'md-apps'"></IconText>
|
|
|
<RadioGroup v-model="exersicesType" type="button" @on-change="typeChange">
|
|
|
- <Radio label="single">单选</Radio>
|
|
|
- <Radio label="multiple">多选</Radio>
|
|
|
- <Radio label="judge">判断</Radio>
|
|
|
- <Radio label="complete">填空</Radio>
|
|
|
- <Radio label="subjective">问答</Radio>
|
|
|
+ <Radio label="single" :disabled="isEdit">模拟</Radio>
|
|
|
+ <Radio label="multiple" :disabled="isEdit">段考</Radio>
|
|
|
+ <Radio label="judge" :disabled="isEdit">周考</Radio>
|
|
|
+ <Radio label="complete" :disabled="isEdit">小考</Radio>
|
|
|
+ <Radio label="subjective" :disabled="isEdit">自定</Radio>
|
|
|
</RadioGroup>
|
|
|
</div>
|
|
|
<div class="exersices-attr-diff my-radio-style">
|
|
|
- <IconText :text="'题目难度'" :color="'red'" :icon="'md-pulse'"></IconText>
|
|
|
+ <IconText :text="'测试类型'" :color="'red'" :icon="'md-pulse'"></IconText>
|
|
|
<RadioGroup v-model="exersicesDiff" type="button">
|
|
|
- <Radio label="0" @click.native="diffChange($event,'0')">容易</Radio>
|
|
|
- <Radio label="1" @click.native="diffChange($event,'1')">较易</Radio>
|
|
|
- <Radio label="2" @click.native="diffChange($event,'2')">一般</Radio>
|
|
|
- <Radio label="3" @click.native="diffChange($event,'3')">较难</Radio>
|
|
|
- <Radio label="4" @click.native="diffChange($event,'4')">困难</Radio>
|
|
|
+ <Radio label="0" @click.native="diffChange($event,'0')">正式成绩</Radio>
|
|
|
+ <Radio label="1" @click.native="diffChange($event,'1')">练习成绩</Radio>
|
|
|
+ <Radio label="2" @click.native="diffChange($event,'2')">统计(问卷)</Radio>
|
|
|
</RadioGroup>
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <BaseSingle v-if="exersicesType=='single'" ref="single"></BaseSingle>
|
|
|
- <BaseMultiple v-else-if="exersicesType=='multiple'" ref="multiple"></BaseMultiple>
|
|
|
- <BaseJudge v-else-if="exersicesType=='judge'" ref="judge"></BaseJudge>
|
|
|
- <BaseCompletion v-else-if="exersicesType=='complete'" ref="complete"></BaseCompletion>
|
|
|
- <BaseSubjective v-else-if="exersicesType=='subjective'" ref="subjective"></BaseSubjective>
|
|
|
-
|
|
|
- <div class="exersices-analysis">
|
|
|
- <IconText :text="'解析'" :color="'#2892DD'" :icon="'md-list'" style="margin-bottom:15px;"></IconText>
|
|
|
- <Upload action="/api/file/uploadWangEditor" name="files" :show-upload-list="false" :on-success="handleSuccess">
|
|
|
- <Button icon="ios-cloud-upload-outline" class="btn-upload" type="primary">上传文件</Button>
|
|
|
- </Upload>
|
|
|
- <div>
|
|
|
- <div ref="analysisEditor" style="text-align:left"></div>
|
|
|
+ <div class="exersices-attr display-flex">
|
|
|
+ <div class="exersices-attr-type my-radio-style">
|
|
|
+ <IconText :text="'测试对象'" :color="'green'" :icon="'md-apps'"></IconText>
|
|
|
+ <RadioGroup v-model="exersicesType" type="button" @on-change="typeChange">
|
|
|
+ <Radio label="single" :disabled="isEdit">同年级</Radio>
|
|
|
+ <Radio label="multiple" :disabled="isEdit">跨年级</Radio>
|
|
|
+ <Radio label="judge" :disabled="isEdit">跨学校</Radio>
|
|
|
+ </RadioGroup>
|
|
|
+ </div>
|
|
|
+ <div class="exersices-attr-diff my-radio-style" style="margin-top:30px;">
|
|
|
+ <IconText :text="'创建方式'" :color="'red'" :icon="'md-pulse'"></IconText>
|
|
|
+ <RadioGroup v-model="exersicesDiff" type="button">
|
|
|
+ <Radio label="0" @click.native="diffChange($event,'0')">题库挑选</Radio>
|
|
|
+ <Radio label="1" @click.native="diffChange($event,'1')">自动组题</Radio>
|
|
|
+ <Radio label="2" @click.native="diffChange($event,'2')">批量导入</Radio>
|
|
|
+ </RadioGroup>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="save-wrap display-flex">
|
|
|
+ <div class="save-wrap display-flex" style="display:none;">
|
|
|
<Button type="success" @click="getContent(exersicesType)">保存</Button>
|
|
|
<Button type="success" @click="resetEditor" style="margin-left:10px">重置</Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
- import "videojs-contrib-hls.js/src/videojs.hlsjs"
|
|
|
+ //默认创建测试模板
|
|
|
import IconText from '@/components/evaluation/IconText.vue'
|
|
|
- import BaseSingle from '@/view/evaluation/types/BaseSingle.vue'
|
|
|
- import BaseMultiple from '@/view/evaluation/types/BaseMultiple.vue'
|
|
|
- import BaseCompletion from '@/view/evaluation/types/BaseCompletion.vue'
|
|
|
- import BaseJudge from '@/view/evaluation/types/BaseJudge.vue'
|
|
|
- import BaseSubjective from '@/view/evaluation/types/BaseSubjective.vue'
|
|
|
- import E from 'wangeditor'
|
|
|
- //默认创建题目模板
|
|
|
const defaultExercise = {
|
|
|
question: "",
|
|
|
options: [],
|
|
@@ -66,33 +59,14 @@
|
|
|
}
|
|
|
export default {
|
|
|
components: {
|
|
|
- IconText, BaseSingle,BaseJudge,BaseMultiple,BaseCompletion,BaseSubjective
|
|
|
+ IconText
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- exersicesType: 'single',
|
|
|
- exersicesDiff: "0",
|
|
|
- analysisContent: "",
|
|
|
- stemContent: "",
|
|
|
- analysisEditor: null,
|
|
|
- videoHtml: "",
|
|
|
- playerOptions: {
|
|
|
- playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
|
|
|
- autoplay: false, //如果true,浏览器准备好时开始回放。
|
|
|
- controls: true, //控制条
|
|
|
- preload: 'auto', //视频预加载
|
|
|
- muted: false, //默认情况下将会消除任何音频。
|
|
|
- loop: false, //导致视频一结束就重新开始。
|
|
|
- language: 'zh-CN',
|
|
|
- aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
|
|
|
- fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
|
|
|
- sources: [{
|
|
|
- //type: 'application/x-mpegURL',
|
|
|
- src: "https://teammodelstorage.blob.core.chinacloudapi.cn/teammodelcontest/20190517/history/history.m3u8"
|
|
|
- }],
|
|
|
- //poster: "http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg", //你的封面地址
|
|
|
- width: document.documentElement.clientWidth,
|
|
|
- notSupportedMessage: '此视频暂无法播放,请稍后再试' //允许覆盖Video.js无法播放媒体源时显示的默认信息。
|
|
|
+ testModel: {
|
|
|
+ passwd: '',
|
|
|
+ passwdCheck: '',
|
|
|
+ age: ''
|
|
|
},
|
|
|
}
|
|
|
},
|
|
@@ -100,140 +74,11 @@
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
- getContent: function (type) {
|
|
|
- let exerciseItem = Object.assign({}, defaultExercise);
|
|
|
- switch (type) {
|
|
|
- case "single":
|
|
|
- exerciseItem.question = this.$refs.single._data.stemContent;
|
|
|
- exerciseItem.options = this.$refs.single._data.optionsContent.length == this.$refs.single._data.options.length ? this.$refs.single._data.optionsContent : null;
|
|
|
- exerciseItem.type = this.exersicesType;
|
|
|
- exerciseItem.difficulty = this.exersicesDiff;
|
|
|
- exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = [String.fromCharCode(64 + parseInt(this.$refs.single._data.trueIndex+1))];
|
|
|
- break;
|
|
|
- case "multiple":
|
|
|
- exerciseItem.question = this.$refs.multiple._data.stemContent;
|
|
|
- exerciseItem.options = this.$refs.multiple._data.optionsContent.length == this.$refs.multiple._data.options.length ? this.$refs.multiple._data.optionsContent : null;
|
|
|
- exerciseItem.type = this.exersicesType;
|
|
|
- exerciseItem.difficulty = this.exersicesDiff;
|
|
|
- exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = this.$refs.multiple._data.transferArr;
|
|
|
- break;
|
|
|
- case "judge":
|
|
|
- exerciseItem.question = this.$refs.judge._data.stemContent;
|
|
|
- exerciseItem.options = [];
|
|
|
- exerciseItem.type = this.exersicesType;
|
|
|
- exerciseItem.difficulty = this.exersicesDiff;
|
|
|
- exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = this.$refs.judge._data.trueAnswer;
|
|
|
- break;
|
|
|
- case "complete":
|
|
|
- exerciseItem.question = this.$refs.complete._data.stemContent;
|
|
|
- exerciseItem.options = [];
|
|
|
- exerciseItem.type = this.exersicesType;
|
|
|
- exerciseItem.difficulty = this.exersicesDiff;
|
|
|
- exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = this.$refs.complete._data.optionsContent.map(item => item.value);
|
|
|
- break;
|
|
|
- case "subjective":
|
|
|
- exerciseItem.question = this.$refs.subjective._data.stemContent;
|
|
|
- exerciseItem.options = [];
|
|
|
- exerciseItem.type = this.exersicesType;
|
|
|
- exerciseItem.difficulty = this.exersicesDiff;
|
|
|
- exerciseItem.explain = this.analysisContent;
|
|
|
- exerciseItem.answer = this.$refs.subjective._data.answerContent;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- //判断获取的数据是否有空数据以及是否为空字符串
|
|
|
- if (this.checkContent(exerciseItem) && this.getSimpleText(exerciseItem.question) && this.getSimpleText(exerciseItem.explain)) {
|
|
|
- this.$router.push({
|
|
|
- name: 'exercisesList',
|
|
|
- params:{
|
|
|
- exerciseItem: exerciseItem,
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(exerciseItem);
|
|
|
- console.log(exerciseItem.question);
|
|
|
- } else {
|
|
|
- this.$Message.warning("请将题目填写完整!");
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- //题目类型转换
|
|
|
- typeChange(val) {
|
|
|
- this.exersicesType = val;
|
|
|
- this.analysisEditor.txt.clear();
|
|
|
- },
|
|
|
-
|
|
|
- //难度与背景颜色切换
|
|
|
- diffChange(e, type) {
|
|
|
- this.exersicesDiff = type;
|
|
|
- e.preventDefault();
|
|
|
- let colorArr = ['#32CF74', '#E8BE15', '#F19300','#EB5E00', '#D30000'];
|
|
|
- let ac = document.getElementsByClassName('exersices-attr-diff')[0].children[1].children;
|
|
|
- for (let i = 0; i < ac.length;i++) {
|
|
|
- ac[i].style.background = "#fff";
|
|
|
- ac[i].style.color = "#515a6e";
|
|
|
- }
|
|
|
- e.target.style.background = colorArr[type];
|
|
|
- e.target.style.color = "#fff";
|
|
|
- },
|
|
|
-
|
|
|
- //提取富文本内容中的文本
|
|
|
- getSimpleText(html){
|
|
|
- var msg = html.replace(/<(?!img|video).*?>/g, '');//执行替换成空字符
|
|
|
- return msg.replace(/ /ig, "");
|
|
|
- },
|
|
|
- //排除对象空属性
|
|
|
- checkContent(Obj) {
|
|
|
- let flag = true;
|
|
|
- for (let key in Obj) {
|
|
|
- if(!Obj[key]) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- }
|
|
|
- return flag;
|
|
|
- },
|
|
|
-
|
|
|
- //重置编辑器
|
|
|
- resetEditor() {
|
|
|
- this.analysisEditor.txt.clear();
|
|
|
- this.analysisContent = "";
|
|
|
- },
|
|
|
-
|
|
|
- insertAfter( newElement, targetElement ){ // newElement是要追加的元素 targetElement 是指定元素的位置
|
|
|
- var parent = targetElement.parentNode; // 找到指定元素的父节点
|
|
|
- if( parent.lastChild == targetElement ){ // 判断指定元素的是否是节点中的最后一个位置 如果是的话就直接使用appendChild方法
|
|
|
- parent.appendChild( newElement, targetElement );
|
|
|
- }else{
|
|
|
- parent.insertBefore( newElement, targetElement.nextSibling );
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- //文件上传成功回调
|
|
|
- handleSuccess(res, file) {
|
|
|
- this.videoHtml = "<br><iframe src='https://teammodelstorage.blob.core.chinacloudapi.cn/wechatfilescontainer/wechatfilescontainer/HilearningMobile_function_10.mp4' frameborder='0' allowfullscreen='true'></iframe><br>";
|
|
|
- this.analysisContent = this.analysisContent + this.videoHtml;
|
|
|
- this.analysisEditor.txt.append(this.videoHtml);
|
|
|
- console.log(this.analysisContent);
|
|
|
- },
|
|
|
+
|
|
|
|
|
|
},
|
|
|
mounted() {
|
|
|
- let analysisEditor = new E(this.$refs.analysisEditor)
|
|
|
- analysisEditor.customConfig.onchange = (html) => {
|
|
|
- this.analysisContent = html
|
|
|
- },
|
|
|
- analysisEditor.customConfig.uploadImgServer = '/api/file/uploadWangEditor'
|
|
|
- analysisEditor.customConfig.showLinkImg = false;
|
|
|
- analysisEditor.customConfig.uploadFileName = 'files'
|
|
|
- analysisEditor.create();
|
|
|
- this.analysisEditor = analysisEditor;
|
|
|
-
|
|
|
- //let parm = "<div class='w-e-menu' style='z-index:10001;'><i class='w-e-icon-strikethrough'></i></div>";
|
|
|
- //let bar = document.getElementsByClassName('w-e-toolbar')[5]
|
|
|
- //this.insertAfter(parm, bar);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
</script>
|