feat(题目): 语法没过时把代码里每一处中文标点都标出来,和「换成英文(N 处)」对得上
- 原来编辑器里只标报错点名的第一处,按钮却写着「4 处」,学生对不上、也不知道一键替换 会改哪里。字符串和注释里的中文标点是合法的,不标(和一键替换同一套判断) - 这种情况下没交上去:结果页签那一段叫「交之前检查」,标题写「还没有交上去」, 不再叫「提交结果」 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5d2f1589e
commit
11ff340110
3 files changed
+56
-4
No files matched your search
@@ -1,7 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
import { findChinesePunctuation } from "oj/problem/utils/chinesePunctuation"
|
||||
import { applyFixes, clearErrorMark, currentCode, showErrorMark } from "oj/problem/utils/errorMark"
|
||||
import {
|
||||
applyFixes,
|
||||
clearErrorMark,
|
||||
currentCode,
|
||||
showErrorMark,
|
||||
showPunctuationMarks,
|
||||
} from "oj/problem/utils/errorMark"
|
||||
import { explainPythonCompileError } from "oj/problem/utils/pythonError"
|
||||
|
||||
/**
|
||||
@@ -55,6 +61,9 @@ watch(
|
||||
fixedCount.value = null
|
||||
if (ex?.line) showErrorMark(ex.line, ex.sourceLine, ex.caret)
|
||||
else clearErrorMark()
|
||||
// 中文标点一处不漏地标出来,和按钮上的「N 处」对得上
|
||||
const code = ex?.punctuation ? currentCode() : null
|
||||
if (code !== null) showPunctuationMarks(findChinesePunctuation(code))
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
@@ -45,7 +45,10 @@ const canTrial = computed(() => {
|
||||
<FlowchartResult v-if="drawing" />
|
||||
<div v-show="!drawing" class="result-pane">
|
||||
<n-radio-group v-if="canTrial" v-model:value="resultSegment" size="small" class="segments">
|
||||
<n-radio-button value="submit">提交结果</n-radio-button>
|
||||
<!-- 语法没过就没交上去:那一段不叫「提交结果」 -->
|
||||
<n-radio-button value="submit">{{
|
||||
syntaxErrorInfo ? "交之前检查" : "提交结果"
|
||||
}}</n-radio-button>
|
||||
<n-radio-button value="samples">运行例子</n-radio-button>
|
||||
<n-radio-button value="custom">自己输入</n-radio-button>
|
||||
</n-radio-group>
|
||||
@@ -53,7 +56,7 @@ const canTrial = computed(() => {
|
||||
<!-- 提交结果用 v-show:切去看运行例子时不卸载,挂着的错误说明在编辑器里标着红 -->
|
||||
<div v-show="resultSegment === 'submit' || !canTrial">
|
||||
<n-flex v-if="syntaxErrorInfo" vertical>
|
||||
<n-alert type="warning" title="代码有语法错误,还没有提交" />
|
||||
<n-alert type="warning" title="代码有语法错误,还没有交上去" />
|
||||
<PythonErrorExplain :err-info="syntaxErrorInfo" />
|
||||
</n-flex>
|
||||
<template v-else-if="submission">
|
||||
|
||||
Reference in new issue
Block a user