@@ -346,7 +346,7 @@ export function getProblemSetSubmissions(
|
|||||||
language?: string
|
language?: string
|
||||||
offset?: number
|
offset?: number
|
||||||
limit?: number
|
limit?: number
|
||||||
} = {}
|
} = {},
|
||||||
) {
|
) {
|
||||||
return http.get(`problemset/${problemSetId}/submissions`, {
|
return http.get(`problemset/${problemSetId}/submissions`, {
|
||||||
params,
|
params,
|
||||||
@@ -359,15 +359,10 @@ export function getProblemSetStatistics(problemSetId: number) {
|
|||||||
|
|
||||||
export function updateProblemSetProgress(
|
export function updateProblemSetProgress(
|
||||||
problemSetId: number,
|
problemSetId: number,
|
||||||
data: {
|
problemId: number,
|
||||||
problem_id: number
|
|
||||||
status: string
|
|
||||||
score?: number
|
|
||||||
submit_time?: string
|
|
||||||
}
|
|
||||||
) {
|
) {
|
||||||
return http.put("problemset/progress", {
|
return http.put("problemset/progress", {
|
||||||
problemset_id: problemSetId,
|
problemset_id: problemSetId,
|
||||||
...data,
|
problem_id: problemId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const problemStore = useProblemStore()
|
|||||||
const { problem } = storeToRefs(problemStore)
|
const { problem } = storeToRefs(problemStore)
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const contestID = <string>route.params.contestID ?? ""
|
const contestID = <string>route.params.contestID ?? ""
|
||||||
const problemsetID = computed(() => route.params.problemSetId as string || "")
|
const problemSetID = computed(() => route.params.problemSetID as string || "")
|
||||||
const [commentPanel] = useToggle()
|
const [commentPanel] = useToggle()
|
||||||
|
|
||||||
const { isDesktop } = useBreakpoints()
|
const { isDesktop } = useBreakpoints()
|
||||||
@@ -100,6 +100,9 @@ async function submit() {
|
|||||||
if (contestID) {
|
if (contestID) {
|
||||||
data.contest_id = parseInt(contestID)
|
data.contest_id = parseInt(contestID)
|
||||||
}
|
}
|
||||||
|
if (problemSetID.value) {
|
||||||
|
data.problemset_id = parseInt(problemSetID.value)
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 提交代码到后端
|
// 2. 提交代码到后端
|
||||||
const res = await submitCode(data)
|
const res = await submitCode(data)
|
||||||
@@ -119,16 +122,10 @@ watch(
|
|||||||
// 1. 刷新题目状态
|
// 1. 刷新题目状态
|
||||||
problem.value!.my_status = 0
|
problem.value!.my_status = 0
|
||||||
|
|
||||||
// 2. 更新题单进度(如果来自题单)
|
// 2. 更新题单进度
|
||||||
if (problemsetID.value) {
|
if (problemSetID.value) {
|
||||||
try {
|
try {
|
||||||
await updateProblemSetProgress(Number(problemsetID.value), {
|
await updateProblemSetProgress(Number(problemSetID.value), problem.value!.id)
|
||||||
problem_id: problem.value!.id,
|
|
||||||
status: "completed",
|
|
||||||
score: 100, // 通过得满分
|
|
||||||
submit_time: new Date().toISOString(),
|
|
||||||
})
|
|
||||||
console.log(`[ProblemSet] 题单进度已更新: problemset=${problemsetID.value}, problem=${problem.value!.id}`)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新题单进度失败:", error)
|
console.error("更新题单进度失败:", error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ const { convertToMermaid } = useMermaidConverter()
|
|||||||
const { renderError, renderFlowchart } = useMermaid()
|
const { renderError, renderFlowchart } = useMermaid()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
// 获取题单ID
|
|
||||||
const problemsetID = computed(() => route.params.problemSetId as string || "")
|
|
||||||
|
|
||||||
// 状态管理
|
// 状态管理
|
||||||
const rendering = ref(false)
|
const rendering = ref(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -66,7 +63,7 @@ const evaluation = ref<Evaluation>({
|
|||||||
|
|
||||||
// ==================== WebSocket 相关函数 ====================
|
// ==================== WebSocket 相关函数 ====================
|
||||||
// 处理 WebSocket 消息
|
// 处理 WebSocket 消息
|
||||||
const handleWebSocketMessage = async (data: FlowchartEvaluationUpdate) => {
|
const handleWebSocketMessage = (data: FlowchartEvaluationUpdate) => {
|
||||||
console.log("收到流程图评分更新:", data)
|
console.log("收到流程图评分更新:", data)
|
||||||
|
|
||||||
if (data.type === "flowchart_evaluation_completed") {
|
if (data.type === "flowchart_evaluation_completed") {
|
||||||
@@ -76,21 +73,6 @@ const handleWebSocketMessage = async (data: FlowchartEvaluationUpdate) => {
|
|||||||
grade: data.grade || "",
|
grade: data.grade || "",
|
||||||
}
|
}
|
||||||
message.success(`流程图评分完成!得分: ${data.score}分 (${data.grade}级)`)
|
message.success(`流程图评分完成!得分: ${data.score}分 (${data.grade}级)`)
|
||||||
|
|
||||||
// 更新题单进度(如果来自题单)
|
|
||||||
if (problemsetID.value) {
|
|
||||||
try {
|
|
||||||
await updateProblemSetProgress(Number(problemsetID.value), {
|
|
||||||
problem_id: problem.value!.id,
|
|
||||||
status: "completed",
|
|
||||||
score: data.score || 0,
|
|
||||||
submit_time: new Date().toISOString(),
|
|
||||||
})
|
|
||||||
console.log(`[ProblemSet] 题单进度已更新: problemset=${problemsetID.value}, problem=${problem.value!.id}, score=${data.score}`)
|
|
||||||
} catch (error) {
|
|
||||||
console.error("更新题单进度失败:", error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (data.type === "flowchart_evaluation_failed") {
|
} else if (data.type === "flowchart_evaluation_failed") {
|
||||||
console.log("处理评分失败消息")
|
console.log("处理评分失败消息")
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
@@ -33,21 +33,18 @@ const ProblemFlowchart = defineAsyncComponent(
|
|||||||
interface Props {
|
interface Props {
|
||||||
problemID: string
|
problemID: string
|
||||||
contestID?: string
|
contestID?: string
|
||||||
problemSetId?: string
|
problemSetID?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
contestID: "",
|
contestID: "",
|
||||||
problemSetId: "",
|
problemSetID: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
const errMsg = ref("无数据")
|
const errMsg = ref("无数据")
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
// 从路由参数中获取题单ID
|
|
||||||
const problemsetID = computed(() => props.problemSetId || route.params.problemSetId as string)
|
|
||||||
|
|
||||||
const problemStore = useProblemStore()
|
const problemStore = useProblemStore()
|
||||||
const screenModeStore = useScreenModeStore()
|
const screenModeStore = useScreenModeStore()
|
||||||
const { problem } = storeToRefs(problemStore)
|
const { problem } = storeToRefs(problemStore)
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ export interface SubmitCodePayload {
|
|||||||
language: LANGUAGE
|
language: LANGUAGE
|
||||||
code: string
|
code: string
|
||||||
contest_id?: number
|
contest_id?: number
|
||||||
|
problemset_id?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 流程图相关类型 ====================
|
// ==================== 流程图相关类型 ====================
|
||||||
|
|||||||
Reference in New Issue
Block a user