mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-18 15:26:45 +08:00
Compare commits
1 Commits
master-bug
...
fix_1127
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f403efa9a |
@@ -167,7 +167,7 @@
|
||||
import simplePaper from "@/components/Course/simpleTestPaper.vue";
|
||||
import apiCourse from '../../api/modules/course.js';
|
||||
import apiExamPaper from '../../api/modules/paper.js';
|
||||
import { deepClone, safeJsonParse } from "../../utils";
|
||||
import { deepClone } from "../../utils";
|
||||
export default{
|
||||
components:{simplePaper},
|
||||
props:{
|
||||
@@ -253,7 +253,7 @@
|
||||
this.examInfo=res.result;
|
||||
if(res.result.paperType==1){
|
||||
this.examInfo.paperContent=res.result.paperContent;
|
||||
this.examPaper = safeJsonParse(res.result.paperContent, { items: [] });
|
||||
this.examPaper=JSON.parse(res.result.paperContent);
|
||||
}else{
|
||||
apiExamPaper.detail(this.examInfo.paperId).then(rs=>{
|
||||
if(rs.status==200){
|
||||
|
||||
@@ -1218,7 +1218,7 @@ export default {
|
||||
});
|
||||
this.teacherValues = tlist;
|
||||
this.teacherDownList = tlist;
|
||||
if (this.courseInfo.tags) {
|
||||
if (this.courseInfo.tags != '') {
|
||||
this.showTags = this.courseInfo.tags.split(',');
|
||||
}
|
||||
this.$nextTick(function() {
|
||||
|
||||
@@ -132,7 +132,6 @@ import apiCourse from '@/api/modules/course.js';
|
||||
import apiExamPaper from '@/api/modules/paper.js';
|
||||
import {formatDate,formatSeconds} from '@/utils/datetime.js';
|
||||
import {testType,correctJudgment,numberToLetter} from '@/utils/tools.js';
|
||||
import { safeJsonParse } from '@/utils/index.js';
|
||||
export default {
|
||||
props:{
|
||||
studyId: {
|
||||
@@ -217,12 +216,8 @@ export default {
|
||||
apiCourse.getExam(this.content.id).then(res=>{
|
||||
if(res.status==200){
|
||||
this.info=res.result;
|
||||
if(this.showTest) {
|
||||
let paper = safeJsonParse(this.info.paperContent, { items: [] });
|
||||
if(!paper.items || paper.items.length === 0){
|
||||
this.viewTest = [];
|
||||
return;
|
||||
}
|
||||
if(this.showTest) {
|
||||
let paper= JSON.parse(this.info.paperContent);
|
||||
paper.items.forEach(item=>{
|
||||
//console.log(item);
|
||||
if(item.type==101){
|
||||
|
||||
@@ -575,7 +575,7 @@
|
||||
import apiExamPaper from '../../api/modules/paper.js';
|
||||
import audioPlayer from '@/components/AudioPlayer/index.vue';
|
||||
import {getType} from '../../utils/tools.js';
|
||||
import { deepClone, safeJsonParse } from "../../utils";
|
||||
import { deepClone } from "../../utils";
|
||||
export default{
|
||||
components:{WxEditor,simplePaper,FileUpload,pdfPreview,audioPlayer,chooseCourseFile},
|
||||
props: {
|
||||
@@ -921,7 +921,7 @@
|
||||
if(res.status==200){
|
||||
this.exam.info=res.result;
|
||||
if(res.result.paperType==1){
|
||||
this.exam.paperJson = safeJsonParse(res.result.paperContent, { items: [] });
|
||||
this.exam.paperJson=JSON.parse(res.result.paperContent);
|
||||
}else{
|
||||
apiExamPaper.detail(this.exam.info.paperId).then(rs=>{
|
||||
if(rs.status==200){
|
||||
|
||||
@@ -109,7 +109,6 @@
|
||||
import imgupload from '@/components/ImageUpload/single.vue';
|
||||
import apiExamTask from '@/api/modules/examTask.js';
|
||||
import examQuestionApi from "@/api/modules/question";
|
||||
import { safeJsonParse } from '../../utils';
|
||||
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
||||
export default {
|
||||
name: 'comEditPaper',
|
||||
@@ -164,7 +163,7 @@
|
||||
if(res.status === 200) {
|
||||
this.paper=res.result;
|
||||
//转化试题
|
||||
this.qitems = safeJsonParse(res.result.paperContent, []);
|
||||
this.qitems=JSON.parse(res.result.paperContent);
|
||||
//console.log(this.qitems,this.qitems)
|
||||
this.tempItems=this.qitems;
|
||||
this.paperCalculation();
|
||||
|
||||
@@ -106,8 +106,7 @@
|
||||
>贡献者大会</span
|
||||
>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<!-- <el-dropdown-item command="four">2025</el-dropdown-item>-->
|
||||
<el-dropdown-item command="three" divided>2024</el-dropdown-item>
|
||||
<el-dropdown-item command="three">2024</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-menu>
|
||||
@@ -422,7 +421,6 @@ export default {
|
||||
one: urlPre + "/web/contributornew/index",
|
||||
two: urlPre + "/web/contributor/index",
|
||||
three: urlPre + "/web/contributor_2024/index",
|
||||
four: urlPre + "/web/contributor_2025/index",
|
||||
};
|
||||
window.open(obj[val]);
|
||||
},
|
||||
|
||||
@@ -310,42 +310,6 @@ export function deepClone(source) {
|
||||
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
|
||||
* @returns {Array}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<el-container>
|
||||
<el-header style="height:70px;padding: 12px 20px 10px 20px;" >
|
||||
<el-row>
|
||||
<!-- <el-col :span="4">
|
||||
<el-col :span="4">
|
||||
<el-cascader
|
||||
:options="resOwnerListMap"
|
||||
v-model="params.ownership"
|
||||
@@ -11,7 +11,7 @@
|
||||
clearable
|
||||
:props="resourceProps">
|
||||
</el-cascader>
|
||||
</el-col> -->
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<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>
|
||||
@@ -47,13 +47,13 @@
|
||||
<span class="previewStyle" @click="viewTopic(scope.row)">{{ scope.row.title }}</span>
|
||||
</template>
|
||||
</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">
|
||||
<span>{{resOwnerName(scope.row.resOwner1)}}</span>
|
||||
<span v-if="scope.row.resOwner2 != ''">/{{resOwnerName(scope.row.resOwner2)}}</span>
|
||||
<span v-if="scope.row.resOwner3 != ''">/{{resOwnerName(scope.row.resOwner3)}}</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="类型" width="70px">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.type == 1 ? "单选" : scope.row.type == 2 ? "多选" : scope.row.type == 3 ? "判断题" : "" }}
|
||||
@@ -92,9 +92,9 @@
|
||||
<div style="padding-top: 10px; overflow: auto">
|
||||
<div>
|
||||
<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-form-item> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="题干" prop="title">
|
||||
<el-col :span="15">
|
||||
<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>
|
||||
<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-form-item> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="题干" prop="title">
|
||||
<el-col :span="15">
|
||||
<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>【判断题】{{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>
|
||||
</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="false" style="margin-right: 0px;"> </el-radio><span>错误</span>
|
||||
</div>
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
import apiPaper from '@/api/modules/paper.js';
|
||||
import apiExamTask from '@/api/modules/examTask.js';
|
||||
import examQuestionApi from "@/api/modules/question";
|
||||
import { deepClone, safeJsonParse } from '../../utils';
|
||||
import { deepClone } from '../../utils';
|
||||
import {numberToLetter, deepCopy} from '../../utils/tools.js';
|
||||
import { mapGetters,mapActions} from 'vuex';
|
||||
import editPaper from "@/components/Exam/EditPaper";
|
||||
@@ -689,7 +689,7 @@ export default {
|
||||
this.viewVolumeShow=true;
|
||||
apiPaper.detail(row.id).then(res=>{
|
||||
if(res.status === 200) {
|
||||
this.viewShowData = safeJsonParse(res.result.paperContent, { items: [] });
|
||||
this.viewShowData = JSON.parse(res.result.paperContent);
|
||||
console.log(this.viewShowData,'lll')
|
||||
} else {
|
||||
this.$message.error(res.message);
|
||||
@@ -720,9 +720,8 @@ export default {
|
||||
apiPaper.detail(row.id).then(res=>{
|
||||
if(res.status === 200) {
|
||||
this.paper = res.result;
|
||||
const parsedValue = safeJsonParse(res.result.paperContent, []);
|
||||
this.paper.data = parsedValue;
|
||||
this.paperData = parsedValue;
|
||||
this.paper.data = JSON.parse(res.result.paperContent);
|
||||
this.paperData = JSON.parse(res.result.paperContent);
|
||||
this.paper.paperType = Number(res.result.paperType);
|
||||
if(res.result.resOwner3) {
|
||||
this.resOwner = [res.result.resOwner1,res.result.resOwner2,res.result.resOwner3];
|
||||
|
||||
@@ -357,17 +357,16 @@ import apiCourse from "@/api/modules/course.js";
|
||||
import apiCourseFile from "@/api/modules/courseFile.js";
|
||||
import apiCoursePortal from "@/api/modules/coursePortal.js";
|
||||
import apiUser from '@/api/system/user.js';
|
||||
import {
|
||||
formatDate,
|
||||
resListMap,
|
||||
toScore,
|
||||
courseType,
|
||||
getType,
|
||||
numberToLetter,
|
||||
correctJudgment
|
||||
} from "@/utils/tools.js";
|
||||
import { safeJsonParse } from "@/utils";
|
||||
import apicourseStudy from "@/api/modules/courseStudy.js";
|
||||
import {
|
||||
formatDate,
|
||||
resListMap,
|
||||
toScore,
|
||||
courseType,
|
||||
getType,
|
||||
numberToLetter,
|
||||
correctJudgment
|
||||
} from "@/utils/tools.js";
|
||||
import apicourseStudy from "@/api/modules/courseStudy.js";
|
||||
import apiCourseGrade from "@/api/modules/courseGrade.js";
|
||||
import apiPraises from "@/api/modules/praises.js";
|
||||
import apiTrample from "@/api/modules/trample.js";
|
||||
@@ -717,7 +716,7 @@ export default {
|
||||
apiCourse.getExam(this.examInfo.content.id).then(res => {
|
||||
if (res.status == 200) {
|
||||
this.examInfo.info = res.result;
|
||||
this.examInfo.paper = safeJsonParse(res.result.paperContent, { items: [] });
|
||||
this.examInfo.paper = JSON.parse(res.result.paperContent);
|
||||
} else if (res.status == 404) {
|
||||
//没有找到考试信息
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user