mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-18 15:26:45 +08:00
Compare commits
4 Commits
fix_1127
...
master-bug
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b517d92347 | ||
|
|
406c9fbf7c | ||
|
|
b4b090e5c0 | ||
|
|
02aafc8fa9 |
@@ -167,7 +167,7 @@
|
|||||||
import simplePaper from "@/components/Course/simpleTestPaper.vue";
|
import simplePaper from "@/components/Course/simpleTestPaper.vue";
|
||||||
import apiCourse from '../../api/modules/course.js';
|
import apiCourse from '../../api/modules/course.js';
|
||||||
import apiExamPaper from '../../api/modules/paper.js';
|
import apiExamPaper from '../../api/modules/paper.js';
|
||||||
import { deepClone } from "../../utils";
|
import { deepClone, safeJsonParse } from "../../utils";
|
||||||
export default{
|
export default{
|
||||||
components:{simplePaper},
|
components:{simplePaper},
|
||||||
props:{
|
props:{
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
this.examInfo=res.result;
|
this.examInfo=res.result;
|
||||||
if(res.result.paperType==1){
|
if(res.result.paperType==1){
|
||||||
this.examInfo.paperContent=res.result.paperContent;
|
this.examInfo.paperContent=res.result.paperContent;
|
||||||
this.examPaper=JSON.parse(res.result.paperContent);
|
this.examPaper = safeJsonParse(res.result.paperContent, { items: [] });
|
||||||
}else{
|
}else{
|
||||||
apiExamPaper.detail(this.examInfo.paperId).then(rs=>{
|
apiExamPaper.detail(this.examInfo.paperId).then(rs=>{
|
||||||
if(rs.status==200){
|
if(rs.status==200){
|
||||||
|
|||||||
@@ -1218,7 +1218,7 @@ export default {
|
|||||||
});
|
});
|
||||||
this.teacherValues = tlist;
|
this.teacherValues = tlist;
|
||||||
this.teacherDownList = tlist;
|
this.teacherDownList = tlist;
|
||||||
if (this.courseInfo.tags != '') {
|
if (this.courseInfo.tags) {
|
||||||
this.showTags = this.courseInfo.tags.split(',');
|
this.showTags = this.courseInfo.tags.split(',');
|
||||||
}
|
}
|
||||||
this.$nextTick(function() {
|
this.$nextTick(function() {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ import apiCourse from '@/api/modules/course.js';
|
|||||||
import apiExamPaper from '@/api/modules/paper.js';
|
import apiExamPaper from '@/api/modules/paper.js';
|
||||||
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
||||||
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
||||||
|
import { safeJsonParse } from '@/utils/index.js';
|
||||||
export default {
|
export default {
|
||||||
props:{
|
props:{
|
||||||
studyId: {
|
studyId: {
|
||||||
@@ -216,8 +217,12 @@ export default {
|
|||||||
apiCourse.getExam(this.content.id).then(res=>{
|
apiCourse.getExam(this.content.id).then(res=>{
|
||||||
if(res.status==200){
|
if(res.status==200){
|
||||||
this.info=res.result;
|
this.info=res.result;
|
||||||
if(this.showTest) {
|
if(this.showTest) {
|
||||||
let paper= JSON.parse(this.info.paperContent);
|
let paper = safeJsonParse(this.info.paperContent, { items: [] });
|
||||||
|
if(!paper.items || paper.items.length === 0){
|
||||||
|
this.viewTest = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
paper.items.forEach(item=>{
|
paper.items.forEach(item=>{
|
||||||
//console.log(item);
|
//console.log(item);
|
||||||
if(item.type==101){
|
if(item.type==101){
|
||||||
|
|||||||
@@ -575,7 +575,7 @@
|
|||||||
import apiExamPaper from '../../api/modules/paper.js';
|
import apiExamPaper from '../../api/modules/paper.js';
|
||||||
import audioPlayer from '@/components/AudioPlayer/index.vue';
|
import audioPlayer from '@/components/AudioPlayer/index.vue';
|
||||||
import {getType} from '../../utils/tools.js';
|
import {getType} from '../../utils/tools.js';
|
||||||
import { deepClone } from "../../utils";
|
import { deepClone, safeJsonParse } from "../../utils";
|
||||||
export default{
|
export default{
|
||||||
components:{WxEditor,simplePaper,FileUpload,pdfPreview,audioPlayer,chooseCourseFile},
|
components:{WxEditor,simplePaper,FileUpload,pdfPreview,audioPlayer,chooseCourseFile},
|
||||||
props: {
|
props: {
|
||||||
@@ -921,7 +921,7 @@
|
|||||||
if(res.status==200){
|
if(res.status==200){
|
||||||
this.exam.info=res.result;
|
this.exam.info=res.result;
|
||||||
if(res.result.paperType==1){
|
if(res.result.paperType==1){
|
||||||
this.exam.paperJson=JSON.parse(res.result.paperContent);
|
this.exam.paperJson = safeJsonParse(res.result.paperContent, { items: [] });
|
||||||
}else{
|
}else{
|
||||||
apiExamPaper.detail(this.exam.info.paperId).then(rs=>{
|
apiExamPaper.detail(this.exam.info.paperId).then(rs=>{
|
||||||
if(rs.status==200){
|
if(rs.status==200){
|
||||||
|
|||||||
@@ -109,6 +109,7 @@
|
|||||||
import imgupload from '@/components/ImageUpload/single.vue';
|
import imgupload from '@/components/ImageUpload/single.vue';
|
||||||
import apiExamTask from '@/api/modules/examTask.js';
|
import apiExamTask from '@/api/modules/examTask.js';
|
||||||
import examQuestionApi from "@/api/modules/question";
|
import examQuestionApi from "@/api/modules/question";
|
||||||
|
import { safeJsonParse } from '../../utils';
|
||||||
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
||||||
export default {
|
export default {
|
||||||
name: 'comEditPaper',
|
name: 'comEditPaper',
|
||||||
@@ -163,7 +164,7 @@
|
|||||||
if(res.status === 200) {
|
if(res.status === 200) {
|
||||||
this.paper=res.result;
|
this.paper=res.result;
|
||||||
//转化试题
|
//转化试题
|
||||||
this.qitems=JSON.parse(res.result.paperContent);
|
this.qitems = safeJsonParse(res.result.paperContent, []);
|
||||||
//console.log(this.qitems,this.qitems)
|
//console.log(this.qitems,this.qitems)
|
||||||
this.tempItems=this.qitems;
|
this.tempItems=this.qitems;
|
||||||
this.paperCalculation();
|
this.paperCalculation();
|
||||||
|
|||||||
@@ -106,7 +106,8 @@
|
|||||||
>贡献者大会</span
|
>贡献者大会</span
|
||||||
>
|
>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item command="three">2024</el-dropdown-item>
|
<!-- <el-dropdown-item command="four">2025</el-dropdown-item>-->
|
||||||
|
<el-dropdown-item command="three" divided>2024</el-dropdown-item>
|
||||||
<el-dropdown-item command="one" divided>2023</el-dropdown-item>
|
<el-dropdown-item command="one" divided>2023</el-dropdown-item>
|
||||||
<el-dropdown-item command="two" divided>2022</el-dropdown-item>
|
<el-dropdown-item command="two" divided>2022</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
@@ -421,6 +422,7 @@ export default {
|
|||||||
one: urlPre + "/web/contributornew/index",
|
one: urlPre + "/web/contributornew/index",
|
||||||
two: urlPre + "/web/contributor/index",
|
two: urlPre + "/web/contributor/index",
|
||||||
three: urlPre + "/web/contributor_2024/index",
|
three: urlPre + "/web/contributor_2024/index",
|
||||||
|
four: urlPre + "/web/contributor_2025/index",
|
||||||
};
|
};
|
||||||
window.open(obj[val]);
|
window.open(obj[val]);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -310,6 +310,42 @@ export function deepClone(source) {
|
|||||||
return targetObj
|
return targetObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { Message } from 'element-ui';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全解析 JSON 字符串,统一处理错误日志和 UI 提示
|
||||||
|
* @param {string|object} text 待解析的字符串(或对象)
|
||||||
|
* @param {*} fallback 解析失败或为空时的回退值,默认为空对象 {}
|
||||||
|
* @param {string} errorMessage UI 提示信息,默认为试卷格式错误提示
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export function safeJsonParse(text, fallback = {}, errorMessage = '试卷内容格式有误,请联系管理员检查试卷数据') {
|
||||||
|
// 1. 如果已经是对象或数组,直接返回
|
||||||
|
if (typeof text === 'object' && text !== null) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 处理空值情况
|
||||||
|
if (text === null || text === undefined || text === '') {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 尝试解析
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch (error) {
|
||||||
|
// 4. 统一日志和报错
|
||||||
|
console.error('JSON 解析失败:', {
|
||||||
|
input: text,
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
if (errorMessage) {
|
||||||
|
Message.error(errorMessage);
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array} arr
|
* @param {Array} arr
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<el-container>
|
<el-container>
|
||||||
<el-header style="height:70px;padding: 12px 20px 10px 20px;" >
|
<el-header style="height:70px;padding: 12px 20px 10px 20px;" >
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="4">
|
<!-- <el-col :span="4">
|
||||||
<el-cascader
|
<el-cascader
|
||||||
:options="resOwnerListMap"
|
:options="resOwnerListMap"
|
||||||
v-model="params.ownership"
|
v-model="params.ownership"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
clearable
|
clearable
|
||||||
:props="resourceProps">
|
:props="resourceProps">
|
||||||
</el-cascader>
|
</el-cascader>
|
||||||
</el-col>
|
</el-col> -->
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-select v-model="params.type" clearable placeholder="类型" >
|
<el-select v-model="params.type" clearable placeholder="类型" >
|
||||||
<el-option v-for="item in optionsList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
<el-option v-for="item in optionsList" :key="item.value" :label="item.label" :value="item.value"> </el-option>
|
||||||
@@ -47,13 +47,13 @@
|
|||||||
<span class="previewStyle" @click="viewTopic(scope.row)">{{ scope.row.title }}</span>
|
<span class="previewStyle" @click="viewTopic(scope.row)">{{ scope.row.title }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="resSysId" label="资源归属" width="240px" show-overflow-tooltip>
|
<!-- <el-table-column prop="resSysId" label="资源归属" width="240px" show-overflow-tooltip>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{resOwnerName(scope.row.resOwner1)}}</span>
|
<span>{{resOwnerName(scope.row.resOwner1)}}</span>
|
||||||
<span v-if="scope.row.resOwner2 != ''">/{{resOwnerName(scope.row.resOwner2)}}</span>
|
<span v-if="scope.row.resOwner2 != ''">/{{resOwnerName(scope.row.resOwner2)}}</span>
|
||||||
<span v-if="scope.row.resOwner3 != ''">/{{resOwnerName(scope.row.resOwner3)}}</span>
|
<span v-if="scope.row.resOwner3 != ''">/{{resOwnerName(scope.row.resOwner3)}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column> -->
|
||||||
<el-table-column prop="type" label="类型" width="70px">
|
<el-table-column prop="type" label="类型" width="70px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ scope.row.type == 1 ? "单选" : scope.row.type == 2 ? "多选" : scope.row.type == 3 ? "判断题" : "" }}
|
{{ scope.row.type == 1 ? "单选" : scope.row.type == 2 ? "多选" : scope.row.type == 3 ? "判断题" : "" }}
|
||||||
@@ -92,9 +92,9 @@
|
|||||||
<div style="padding-top: 10px; overflow: auto">
|
<div style="padding-top: 10px; overflow: auto">
|
||||||
<div>
|
<div>
|
||||||
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
||||||
<el-form-item label="资源归属">
|
<!-- <el-form-item label="资源归属">
|
||||||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps"></el-cascader>
|
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps"></el-cascader>
|
||||||
</el-form-item>
|
</el-form-item> -->
|
||||||
<el-form-item label="题干" prop="title">
|
<el-form-item label="题干" prop="title">
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
||||||
@@ -180,9 +180,9 @@
|
|||||||
<div style="padding-top: 10px; overflow: auto">
|
<div style="padding-top: 10px; overflow: auto">
|
||||||
<div>
|
<div>
|
||||||
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
<el-form size="mini" label-width="80px" :model="question" ref="questionForm" :rules="questionRules">
|
||||||
<el-form-item label="资源归属">
|
<!-- <el-form-item label="资源归属">
|
||||||
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps" ></el-cascader>
|
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps" ></el-cascader>
|
||||||
</el-form-item>
|
</el-form-item> -->
|
||||||
<el-form-item label="题干" prop="title">
|
<el-form-item label="题干" prop="title">
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
<el-input class="inputclass" type="textarea" :rows="5" maxlength="500" show-word-limit v-model="question.title" placeholder="请输入题干"></el-input>
|
||||||
@@ -278,7 +278,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div>【判断题】{{question.title}}({{question.defaultScore}}分)</div>
|
<div>【判断题】{{question.title}}({{question.defaultScore}}分)</div>
|
||||||
<div v-if="question.images" style="padding-left: 40px;"><el-image :src="imageBaseUrl+question.images" style="width: 60px;height: 50px;"></el-image> </div>
|
<div v-if="question.images" style="padding-left: 40px;"><el-image :src="imageBaseUrl+question.images" style="width: 60px;height: 50px;"></el-image> </div>
|
||||||
</div>
|
</div>
|
||||||
<el-radio disabled :value="question.answer" :label="true" style="margin-right: 0px;"> </el-radio><span style="margin-right: 30px;">正确</span>
|
<el-radio disabled :value="question.answer" :label="true" style="margin-right: 0px;"> </el-radio><span style="margin-right: 30px;">正确</span>
|
||||||
<el-radio disabled :value="question.answer" :label="false" style="margin-right: 0px;"> </el-radio><span>错误</span>
|
<el-radio disabled :value="question.answer" :label="false" style="margin-right: 0px;"> </el-radio><span>错误</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -296,7 +296,7 @@
|
|||||||
import apiPaper from '@/api/modules/paper.js';
|
import apiPaper from '@/api/modules/paper.js';
|
||||||
import apiExamTask from '@/api/modules/examTask.js';
|
import apiExamTask from '@/api/modules/examTask.js';
|
||||||
import examQuestionApi from "@/api/modules/question";
|
import examQuestionApi from "@/api/modules/question";
|
||||||
import { deepClone } from '../../utils';
|
import { deepClone, safeJsonParse } from '../../utils';
|
||||||
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
||||||
import { mapGetters,mapActions} from 'vuex';
|
import { mapGetters,mapActions} from 'vuex';
|
||||||
import editPaper from "@/components/Exam/EditPaper";
|
import editPaper from "@/components/Exam/EditPaper";
|
||||||
@@ -689,7 +689,7 @@ export default {
|
|||||||
this.viewVolumeShow=true;
|
this.viewVolumeShow=true;
|
||||||
apiPaper.detail(row.id).then(res=>{
|
apiPaper.detail(row.id).then(res=>{
|
||||||
if(res.status === 200) {
|
if(res.status === 200) {
|
||||||
this.viewShowData = JSON.parse(res.result.paperContent);
|
this.viewShowData = safeJsonParse(res.result.paperContent, { items: [] });
|
||||||
console.log(this.viewShowData,'lll')
|
console.log(this.viewShowData,'lll')
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.message);
|
this.$message.error(res.message);
|
||||||
@@ -720,8 +720,9 @@ export default {
|
|||||||
apiPaper.detail(row.id).then(res=>{
|
apiPaper.detail(row.id).then(res=>{
|
||||||
if(res.status === 200) {
|
if(res.status === 200) {
|
||||||
this.paper = res.result;
|
this.paper = res.result;
|
||||||
this.paper.data = JSON.parse(res.result.paperContent);
|
const parsedValue = safeJsonParse(res.result.paperContent, []);
|
||||||
this.paperData = JSON.parse(res.result.paperContent);
|
this.paper.data = parsedValue;
|
||||||
|
this.paperData = parsedValue;
|
||||||
this.paper.paperType = Number(res.result.paperType);
|
this.paper.paperType = Number(res.result.paperType);
|
||||||
if(res.result.resOwner3) {
|
if(res.result.resOwner3) {
|
||||||
this.resOwner = [res.result.resOwner1,res.result.resOwner2,res.result.resOwner3];
|
this.resOwner = [res.result.resOwner1,res.result.resOwner2,res.result.resOwner3];
|
||||||
|
|||||||
@@ -357,16 +357,17 @@ import apiCourse from "@/api/modules/course.js";
|
|||||||
import apiCourseFile from "@/api/modules/courseFile.js";
|
import apiCourseFile from "@/api/modules/courseFile.js";
|
||||||
import apiCoursePortal from "@/api/modules/coursePortal.js";
|
import apiCoursePortal from "@/api/modules/coursePortal.js";
|
||||||
import apiUser from '@/api/system/user.js';
|
import apiUser from '@/api/system/user.js';
|
||||||
import {
|
import {
|
||||||
formatDate,
|
formatDate,
|
||||||
resListMap,
|
resListMap,
|
||||||
toScore,
|
toScore,
|
||||||
courseType,
|
courseType,
|
||||||
getType,
|
getType,
|
||||||
numberToLetter,
|
numberToLetter,
|
||||||
correctJudgment
|
correctJudgment
|
||||||
} from "@/utils/tools.js";
|
} from "@/utils/tools.js";
|
||||||
import apicourseStudy from "@/api/modules/courseStudy.js";
|
import { safeJsonParse } from "@/utils";
|
||||||
|
import apicourseStudy from "@/api/modules/courseStudy.js";
|
||||||
import apiCourseGrade from "@/api/modules/courseGrade.js";
|
import apiCourseGrade from "@/api/modules/courseGrade.js";
|
||||||
import apiPraises from "@/api/modules/praises.js";
|
import apiPraises from "@/api/modules/praises.js";
|
||||||
import apiTrample from "@/api/modules/trample.js";
|
import apiTrample from "@/api/modules/trample.js";
|
||||||
@@ -716,7 +717,7 @@ export default {
|
|||||||
apiCourse.getExam(this.examInfo.content.id).then(res => {
|
apiCourse.getExam(this.examInfo.content.id).then(res => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
this.examInfo.info = res.result;
|
this.examInfo.info = res.result;
|
||||||
this.examInfo.paper = JSON.parse(res.result.paperContent);
|
this.examInfo.paper = safeJsonParse(res.result.paperContent, { items: [] });
|
||||||
} else if (res.status == 404) {
|
} else if (res.status == 404) {
|
||||||
//没有找到考试信息
|
//没有找到考试信息
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user