|
|
|
@ -71,7 +71,7 @@ |
|
|
|
|
<el-tabs> |
|
|
|
|
<el-tab-pane label="参考答案"> |
|
|
|
|
<div :class="['answer-wrap', {client: !fromManager}]" |
|
|
|
|
v-html="answer"></div> |
|
|
|
|
v-html="correctAnswer"></div> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
</el-tabs> |
|
|
|
|
</el-dialog> |
|
|
|
@ -142,6 +142,12 @@ |
|
|
|
|
width="1200px" |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
custom-class="code-dia"> |
|
|
|
|
<el-tooltip class="item" |
|
|
|
|
content="列表中展示当前课程已提交的实验代码" |
|
|
|
|
placement="right"> |
|
|
|
|
<i class="info el-icon-warning" |
|
|
|
|
style="margin-right: 10px"></i> |
|
|
|
|
</el-tooltip> |
|
|
|
|
<div class="tool"> |
|
|
|
|
<el-input style="width: 250px" |
|
|
|
|
placeholder="请输入项目名称、判分点名称" |
|
|
|
@ -308,7 +314,7 @@ import config from '@/config' |
|
|
|
|
import { saveAs } from 'file-saver' |
|
|
|
|
const CANCEL_TOKEN = axios.CancelToken // 用于input中中断请求 |
|
|
|
|
export default { |
|
|
|
|
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl'], |
|
|
|
|
props: ['judgmentId', 'code', 'codeId', 'projectId', 'systemId', 'retResult', 'modelIsShow', 'photoUrl', 'answer'], |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
token: Cookie.get('admin-token'), |
|
|
|
@ -318,10 +324,10 @@ export default { |
|
|
|
|
courseId: Cookie.get('admin-courseId'), // 课程id |
|
|
|
|
mallId: Cookie.get('admin-mallId'), |
|
|
|
|
isPrac: false, // 练习 |
|
|
|
|
answer: '', // 正确答案 |
|
|
|
|
correctAnswer: '', // 正确答案 |
|
|
|
|
codeVal: this.code, |
|
|
|
|
runResult: '', // 运行结果 |
|
|
|
|
isError: false, // 运行正确与否 |
|
|
|
|
runResult: this.answer, // 运行结果 |
|
|
|
|
isError: this.retResult, // 运行正确与否 |
|
|
|
|
errLine: '', // 错误代码的位置 |
|
|
|
|
isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, // 是否提交的标识 |
|
|
|
|
runEnable: false, // 是否禁用运行按钮 |
|
|
|
@ -431,6 +437,12 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
mounted () { |
|
|
|
|
// 缓存里返回了运行结果并且是错误的运行,则获取第几行有错误 |
|
|
|
|
if (this.runResult && this.isError === 0) this.errLine = this.getErrLine(this.runResult) |
|
|
|
|
|
|
|
|
|
// 缓存里返回了图片则分割成数组 |
|
|
|
|
if (this.photoUrl) this.picSrcList = this.photoUrl.split(',') |
|
|
|
|
|
|
|
|
|
if (!this.assessmentId && !this.competitionId) this.isPrac = true |
|
|
|
|
//兄弟组件传值 |
|
|
|
|
newmain.$on("isSubmit", isSubmit => { |
|
|
|
@ -587,7 +599,7 @@ export default { |
|
|
|
|
const result = data.runResult |
|
|
|
|
if (result.includes('File ')) { |
|
|
|
|
this.runResult = result |
|
|
|
|
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length)) |
|
|
|
|
this.errLine = this.getErrLine(result) |
|
|
|
|
this.isError = data.retResult |
|
|
|
|
} else if (result.includes('validing:')) { |
|
|
|
|
this.isError = 1 |
|
|
|
@ -608,6 +620,10 @@ export default { |
|
|
|
|
|
|
|
|
|
}).catch(err => { }) |
|
|
|
|
}, |
|
|
|
|
// 获取第几行代码有错误 |
|
|
|
|
getErrLine (result) { |
|
|
|
|
return parseInt(result.substring(result.indexOf('line') + 4, result.length)) || 1 |
|
|
|
|
}, |
|
|
|
|
// 运行代码 |
|
|
|
|
runCode (isWhile) { // isWhile为true表示代码里有while循环,右边的运行结果需要拼接展示,而不是直接覆盖 |
|
|
|
|
if (!this.isSubmit) { |
|
|
|
@ -652,7 +668,7 @@ export default { |
|
|
|
|
} else { |
|
|
|
|
this.runResult = result |
|
|
|
|
} |
|
|
|
|
this.errLine = parseInt(result.substring(result.indexOf('line') + 4, result.length)) |
|
|
|
|
this.errLine = this.getErrLine(result) |
|
|
|
|
this.isError = data.retResult |
|
|
|
|
} else if (result.includes('validing:')) { |
|
|
|
|
this.isError = 1 |
|
|
|
@ -709,7 +725,7 @@ export default { |
|
|
|
|
const text = result.replace(photo, '') // 结果里包含了图片路径,所以要把图片路径给去掉 |
|
|
|
|
this.runResult = text |
|
|
|
|
this.picSrcList = photo.split(',') |
|
|
|
|
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length)) |
|
|
|
|
this.errLine = this.getErrLine(result) |
|
|
|
|
} else if (imgList instanceof Array && imgList.length && typeof firtImg === 'string' && (firtImg.includes('.jpg') || firtImg.includes('.png') || firtImg.includes('img'))) { |
|
|
|
|
/** |
|
|
|
|
* 这段是为要下载图片的项目案例写的,后端会返回图片名称的数组,前端负责循环这个数组,然后下载下来 |
|
|
|
@ -722,7 +738,7 @@ export default { |
|
|
|
|
} else { |
|
|
|
|
this.isError = data.retResult |
|
|
|
|
this.runResult = result |
|
|
|
|
this.errLine = parseInt(result.substring(result.indexOf("line") + 4, result.length)) |
|
|
|
|
this.errLine = this.getErrLine(result) |
|
|
|
|
} |
|
|
|
|
} else if (res.data && res.data.current) { |
|
|
|
|
// 进入运行队列 |
|
|
|
@ -763,7 +779,7 @@ export default { |
|
|
|
|
this.$get(this.api.queryBcJudgmentByBcId, { |
|
|
|
|
bcId: this.judgmentId |
|
|
|
|
}).then(res => { |
|
|
|
|
this.answer = res.experimentCode |
|
|
|
|
this.correctAnswer = res.experimentCode |
|
|
|
|
}).catch(err => { }) |
|
|
|
|
}, |
|
|
|
|
// 中间拖拽 |
|
|
|
@ -1104,6 +1120,12 @@ export default { |
|
|
|
|
.el-dialog__body { |
|
|
|
|
padding: 0 20px; |
|
|
|
|
} |
|
|
|
|
.info { |
|
|
|
|
position: absolute; |
|
|
|
|
top: 18px; |
|
|
|
|
left: 100px; |
|
|
|
|
color: #88aef5; |
|
|
|
|
} |
|
|
|
|
.code-tab { |
|
|
|
|
.el-tabs__item.is-active { |
|
|
|
|
color: #333 !important; |
|
|
|
|