feat(协作): 老师协作时右栏顶上一条协作条,结果页签先摆学生最近一次交的,抽屉变成「他的提交」

- 协作条:「正在帮 谁 · 语言 · 看他交过什么 ↗ · 结束协作」,从工具栏里挪出来,一眼看得出
  编辑器里是学生的代码。「看他交过什么」带上学生用户名、开新标签(原来只带题号,还得再筛一遍)
- 老师接单后「结果」页签原来是空的:现在摆学生在这道题上最近一次交的结果,可刷新;
  不给 AI 提示(那是按登录的人自己的失败次数解锁的)
- 抽屉「我的提交」在协作中变成「他的提交」,列的是学生的提交,只能复制、不能放回编辑器
  (放回去会经协作通道直接盖掉学生正在写的代码),也不显示老师自己的排名
- 学生排队求助中、或者老师正在帮他时换题:先确认一句。换题会断开协作 / 撤掉举手,
  原来一点「下一题」就把正在帮他的老师踢出去了
- 求助按钮文案:「举手求助」→「已举手 · 前面 2 人」→「某某 老师在帮你」
- 提交列表加 exactUsername=1:用户名精确匹配。原来只有「包含」,ks24a1 会把 ks24a10 的提交
  也捞进来

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-09-28 18:28:53 +08:00
1 parent 11368813cc
commit 0c2ff68e9b
13 files changed
+287 -45

No files matched your search

@@ -1,8 +1,6 @@
<script lang="ts" setup>
import { storeToRefs } from "pinia"
import { getRankOfProblem, getSubmission, getSubmissions } from "oj/api"
import { useCodeStore } from "oj/store/code"
import { useProblemStore } from "oj/store/problem"
import Pagination from "shared/components/Pagination.vue"
import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
import { useCollabStore } from "shared/store/collab"
@@ -12,6 +10,7 @@ import { copyToClipboard, parseTime } from "utils/functions"
import type { ProblemRank } from "@oj2/contract"
import type { LANGUAGE, SubmissionListItem } from "utils/types"
import { useProblemPageContext } from "../composables/problemPageContext"
import { useTeacherCollab } from "../composables/teacherCollab"
/**
* 「我的提交」抽屉:这道题自己交过的每一次。
@@ -24,7 +23,6 @@ import { useProblemPageContext } from "../composables/problemPageContext"
const userStore = useUserStore()
const codeStore = useCodeStore()
const collabStore = useCollabStore()
const { problem } = storeToRefs(useProblemStore())
const ctx = useProblemPageContext()
const route = useRoute()
const router = useRouter()
@@ -36,12 +34,10 @@ const problemDisplayId = computed(() => String(route.params.problemID ?? ""))
* 协作中的教师:编辑器里是学生的代码,「放回编辑器」会经 Yjs 直接盖掉学生正在写的
* 那一份,所以不给(设计文档第 9 节)。
*/
const teacherCollab = computed(
() =>
userStore.isTeacherOrAbove &&
collabStore.room !== null &&
collabStore.room.problemId === problem.value?._id,
)
const teacherCollab = useTeacherCollab()
/** 协作中看的是学生的提交(设计文档第 9 节):房间里的 peerName 就是学生的用户名 */
const peer = computed(() => (teacherCollab.value ? (collabStore.room?.peerName ?? null) : null))
// ==================== 班上第几个做对的 ====================
// 只在题库入口给:比赛有自己的排名,题单里整个抽屉都不出现
@@ -98,7 +94,9 @@ const blocked = computed(() => {
async function listSubmissions() {
const res = await getSubmissions({
...query,
myself: "1",
...(peer.value
? { username: peer.value, exactUsername: "1" as const }
: { myself: "1" as const }),
offset: query.limit * (query.page - 1),
problemDisplayId: problemDisplayId.value,
contestId: ctx.value.contestId,
@@ -165,7 +163,8 @@ function openDetail(id: string) {
onMounted(() => {
if (blocked.value) return
listSubmissions()
if (ctx.value.entry === "problem") {
// 排名是按当前登录的人算的,协作中那是老师自己的,不给
if (ctx.value.entry === "problem" && !peer.value) {
getRankOfProblem(problemDisplayId.value)
.then((res) => {
rank.value = res
@@ -190,7 +189,11 @@ watch(query, () => {
</n-button>
</div>
<n-empty v-if="listed && !submissions.length" class="empty" description="这道题你还没有交过" />
<n-empty
v-if="listed && !submissions.length"
class="empty"
:description="peer ? '他还没有交过这道题' : '这道题你还没有交过'"
/>
<ul v-else class="list">
<li v-for="(row, index) in submissions" :key="row.id" class="item">