feat: 多题目评分支持
This commit is contained in:
@@ -80,6 +80,28 @@ async function selectImage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function gradeQuestion(questionIdx: number) {
|
||||||
|
const questions = gradingStore.questions
|
||||||
|
if (!questions.length) {
|
||||||
|
ElMessage.warning('请先在评分标准中添加题目')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const q = questions[Math.min(questionIdx, questions.length - 1)]
|
||||||
|
const result = await window.electronAPI.ai.grade({
|
||||||
|
imageBase64: gradingStore.currentImage,
|
||||||
|
rubric: q.rubric || `请根据答案内容评分,满分${q.maxScore}分`,
|
||||||
|
maxScore: q.maxScore,
|
||||||
|
referenceAnswer: q.referenceAnswer,
|
||||||
|
questionTitle: q.questionTitle,
|
||||||
|
apiConfig: {
|
||||||
|
apiKey: settingsStore.settings.apiKey,
|
||||||
|
baseUrl: settingsStore.settings.baseUrl,
|
||||||
|
model: settingsStore.settings.model
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
async function startGrading() {
|
async function startGrading() {
|
||||||
if (!gradingStore.currentImage) {
|
if (!gradingStore.currentImage) {
|
||||||
ElMessage.info('请先截图或选择图片')
|
ElMessage.info('请先截图或选择图片')
|
||||||
@@ -91,44 +113,28 @@ async function startGrading() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load rubric data
|
||||||
|
const rubricData = await window.electronAPI?.rubric.getData()
|
||||||
|
const questions = rubricData?.questions?.length
|
||||||
|
? JSON.parse(JSON.stringify(rubricData.questions))
|
||||||
|
: [{ questionTitle: '', maxScore: 100, referenceAnswer: '', rubric: '' }]
|
||||||
|
gradingStore.setQuestions(questions)
|
||||||
|
gradingStore.setCurrentQuestionIndex(0)
|
||||||
|
|
||||||
appStore.isGrading = true
|
appStore.isGrading = true
|
||||||
try {
|
try {
|
||||||
// load latest rubric data from main process (may have been updated by rubric dialog)
|
const q = questions[0]
|
||||||
const rubricData = await window.electronAPI?.rubric.getData()
|
const result = await gradeQuestion(0)
|
||||||
if (rubricData) {
|
if (!result) return
|
||||||
if (rubricData.rubric) gradingStore.setRubric(rubricData.rubric)
|
|
||||||
if (rubricData.questionTitle) gradingStore.setQuestionTitle(rubricData.questionTitle)
|
|
||||||
if (rubricData.maxScore) gradingStore.setMaxScore(rubricData.maxScore)
|
|
||||||
if (rubricData.referenceAnswer) gradingStore.setReferenceAnswer(rubricData.referenceAnswer)
|
|
||||||
}
|
|
||||||
const result = await window.electronAPI.ai.grade({
|
|
||||||
imageBase64: gradingStore.currentImage,
|
|
||||||
rubric: gradingStore.rubric || `请根据答案内容评分,满分${gradingStore.maxScore}分`,
|
|
||||||
maxScore: gradingStore.maxScore,
|
|
||||||
referenceAnswer: gradingStore.referenceAnswer,
|
|
||||||
questionTitle: gradingStore.questionTitle,
|
|
||||||
apiConfig: {
|
|
||||||
apiKey: settingsStore.settings.apiKey,
|
|
||||||
baseUrl: settingsStore.settings.baseUrl,
|
|
||||||
model: settingsStore.settings.model
|
|
||||||
}
|
|
||||||
})
|
|
||||||
gradingStore.setResult(result)
|
gradingStore.setResult(result)
|
||||||
if (window.electronAPI) {
|
if (window.electronAPI) {
|
||||||
|
// store grading data for result window
|
||||||
await window.electronAPI.grading.storeData({
|
await window.electronAPI.grading.storeData({
|
||||||
result,
|
result,
|
||||||
image: gradingStore.currentImage,
|
image: gradingStore.currentImage,
|
||||||
rubric: gradingStore.rubric,
|
questions,
|
||||||
questionTitle: gradingStore.questionTitle,
|
currentQuestionIndex: 0
|
||||||
maxScore: gradingStore.maxScore,
|
|
||||||
referenceAnswer: gradingStore.referenceAnswer
|
|
||||||
})
|
|
||||||
// also update rubric bridge
|
|
||||||
await window.electronAPI.rubric.storeData({
|
|
||||||
questionTitle: gradingStore.questionTitle,
|
|
||||||
maxScore: gradingStore.maxScore,
|
|
||||||
referenceAnswer: gradingStore.referenceAnswer,
|
|
||||||
rubric: gradingStore.rubric
|
|
||||||
})
|
})
|
||||||
await window.electronAPI.dialog.open('result')
|
await window.electronAPI.dialog.open('result')
|
||||||
}
|
}
|
||||||
|
|||||||
+106
-44
@@ -7,6 +7,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="drawer-body" v-if="gradingStore.currentResult">
|
<div class="drawer-body" v-if="gradingStore.currentResult">
|
||||||
|
<div class="question-nav" v-if="questions.length > 1">
|
||||||
|
<el-button size="small" @click="prevQuestion" :disabled="isGrading">上一题</el-button>
|
||||||
|
<span class="question-indicator">{{ currentIdx + 1 }} / {{ questions.length }}</span>
|
||||||
|
<el-button size="small" @click="nextQuestion" :disabled="isGrading">{{ currentIdx === questions.length - 1 ? '回到首题' : '下一题' }}</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="question-title" v-if="currentQuestion.questionTitle">
|
||||||
|
{{ currentQuestion.questionTitle }}
|
||||||
|
</div>
|
||||||
|
<div class="question-maxscore" v-if="currentQuestion.maxScore">
|
||||||
|
满分:{{ currentQuestion.maxScore }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="result-score">
|
<div class="result-score">
|
||||||
<div class="score-value">{{ gradingStore.currentResult.score }}</div>
|
<div class="score-value">{{ gradingStore.currentResult.score }}</div>
|
||||||
<div class="score-label">建议分数</div>
|
<div class="score-label">建议分数</div>
|
||||||
@@ -34,29 +47,18 @@
|
|||||||
<div class="result-section">
|
<div class="result-section">
|
||||||
<div class="section-title">教师评分(可修改)</div>
|
<div class="section-title">教师评分(可修改)</div>
|
||||||
<div class="teacher-score-input">
|
<div class="teacher-score-input">
|
||||||
<el-input-number
|
<el-input-number v-model="teacherScore" :min="0" :max="currentQuestion.maxScore" size="small" />
|
||||||
v-model="teacherScore"
|
|
||||||
:min="0"
|
|
||||||
:max="100"
|
|
||||||
size="small"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-section">
|
<div class="result-section">
|
||||||
<div class="section-title">教师评语</div>
|
<div class="section-title">教师评语</div>
|
||||||
<el-input
|
<el-input v-model="teacherComment" type="textarea" :rows="2" size="small" placeholder="输入评语(可选)" />
|
||||||
v-model="teacherComment"
|
|
||||||
type="textarea"
|
|
||||||
:rows="2"
|
|
||||||
size="small"
|
|
||||||
placeholder="输入评语(可选)"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="drawer-footer">
|
<div class="drawer-footer">
|
||||||
<el-button size="small" @click="reGrade">重新评分</el-button>
|
<el-button size="small" @click="reGrade" :loading="isGrading">重新评分</el-button>
|
||||||
<el-button type="primary" size="small" @click="confirmScore">确认评分</el-button>
|
<el-button type="primary" size="small" @click="confirmScore">确认评分</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -65,23 +67,30 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch, computed } from 'vue'
|
||||||
import { useAppStore } from '@/stores/app'
|
import { useAppStore } from '@/stores/app'
|
||||||
import { useGradingStore } from '@/stores/grading'
|
import { useGradingStore } from '@/stores/grading'
|
||||||
import { useSettingsStore } from '@/stores/settings'
|
import { useSettingsStore } from '@/stores/settings'
|
||||||
|
import type { QuestionItem } from '@/types'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const gradingStore = useGradingStore()
|
const gradingStore = useGradingStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
|
const isGrading = ref(false)
|
||||||
const teacherScore = ref(0)
|
const teacherScore = ref(0)
|
||||||
const teacherComment = ref('')
|
const teacherComment = ref('')
|
||||||
|
const questions = ref<QuestionItem[]>([])
|
||||||
|
const currentIdx = ref(0)
|
||||||
|
|
||||||
|
const currentQuestion = computed(() => questions.value[currentIdx.value] || { questionTitle: '', maxScore: 100, referenceAnswer: '', rubric: '' })
|
||||||
|
|
||||||
watch(() => appStore.isResultDrawerOpen, (val) => {
|
watch(() => appStore.isResultDrawerOpen, (val) => {
|
||||||
visible.value = val
|
visible.value = val
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// load grading data from bridge when result window opens
|
||||||
watch(() => gradingStore.currentResult, (val) => {
|
watch(() => gradingStore.currentResult, (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
teacherScore.value = val.score
|
teacherScore.value = val.score
|
||||||
@@ -89,20 +98,40 @@ watch(() => gradingStore.currentResult, (val) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// listen for grading data when window becomes visible
|
||||||
|
watch(visible, async (val) => {
|
||||||
|
if (val) {
|
||||||
|
const data = await window.electronAPI?.grading.getData()
|
||||||
|
if (data) {
|
||||||
|
gradingStore.setImage(data.image || '')
|
||||||
|
if (data.questions) {
|
||||||
|
questions.value = JSON.parse(JSON.stringify(data.questions))
|
||||||
|
gradingStore.setQuestions(data.questions)
|
||||||
|
}
|
||||||
|
currentIdx.value = data.currentQuestionIndex ?? 0
|
||||||
|
gradingStore.setCurrentQuestionIndex(currentIdx.value)
|
||||||
|
if (data.result) {
|
||||||
|
gradingStore.setResult(data.result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function closeDrawer() {
|
function closeDrawer() {
|
||||||
window.electronAPI?.dialog.close()
|
window.electronAPI?.dialog.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reGrade() {
|
async function gradeAt(idx: number) {
|
||||||
if (!gradingStore.currentImage) return
|
if (!gradingStore.currentImage) return
|
||||||
appStore.isGrading = true
|
isGrading.value = true
|
||||||
try {
|
try {
|
||||||
|
const q = questions.value[idx]
|
||||||
const result = await window.electronAPI.ai.grade({
|
const result = await window.electronAPI.ai.grade({
|
||||||
imageBase64: gradingStore.currentImage,
|
imageBase64: gradingStore.currentImage,
|
||||||
rubric: gradingStore.rubric || `请根据答案内容评分,满分${gradingStore.maxScore}分`,
|
rubric: q.rubric || `请根据答案内容评分,满分${q.maxScore}分`,
|
||||||
maxScore: gradingStore.maxScore,
|
maxScore: q.maxScore,
|
||||||
referenceAnswer: gradingStore.referenceAnswer,
|
referenceAnswer: q.referenceAnswer,
|
||||||
questionTitle: gradingStore.questionTitle,
|
questionTitle: q.questionTitle,
|
||||||
apiConfig: {
|
apiConfig: {
|
||||||
apiKey: settingsStore.settings.apiKey,
|
apiKey: settingsStore.settings.apiKey,
|
||||||
baseUrl: settingsStore.settings.baseUrl,
|
baseUrl: settingsStore.settings.baseUrl,
|
||||||
@@ -110,14 +139,42 @@ async function reGrade() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
gradingStore.setResult(result)
|
gradingStore.setResult(result)
|
||||||
ElMessage.success('重新评分完成')
|
currentIdx.value = idx
|
||||||
|
gradingStore.setCurrentQuestionIndex(idx)
|
||||||
|
// update rubric bridge currentIndex
|
||||||
|
await window.electronAPI?.rubric.storeData({
|
||||||
|
questions: questions.value,
|
||||||
|
currentIndex: idx
|
||||||
|
})
|
||||||
|
// update grading bridge
|
||||||
|
await window.electronAPI?.grading.storeData({
|
||||||
|
result,
|
||||||
|
image: gradingStore.currentImage,
|
||||||
|
questions: questions.value,
|
||||||
|
currentQuestionIndex: idx
|
||||||
|
})
|
||||||
|
ElMessage.success(`第 ${idx + 1} 题评分完成`)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ElMessage.error('重新评分失败:' + (err as Error).message)
|
ElMessage.error('评分失败:' + (err as Error).message)
|
||||||
} finally {
|
} finally {
|
||||||
appStore.isGrading = false
|
isGrading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function nextQuestion() {
|
||||||
|
const next = (currentIdx.value + 1) % questions.value.length
|
||||||
|
await gradeAt(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function prevQuestion() {
|
||||||
|
const prev = (currentIdx.value - 1 + questions.value.length) % questions.value.length
|
||||||
|
await gradeAt(prev)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reGrade() {
|
||||||
|
await gradeAt(currentIdx.value)
|
||||||
|
}
|
||||||
|
|
||||||
async function confirmScore() {
|
async function confirmScore() {
|
||||||
const result = gradingStore.currentResult
|
const result = gradingStore.currentResult
|
||||||
if (!result) return
|
if (!result) return
|
||||||
@@ -149,16 +206,14 @@ async function confirmScore() {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-panel {
|
.drawer-panel {
|
||||||
width: 360px;
|
width: 400px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
|
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-header {
|
.drawer-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -166,79 +221,88 @@ async function confirmScore() {
|
|||||||
padding: 16px;
|
padding: 16px;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-title {
|
.drawer-title {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-body {
|
.drawer-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
.question-nav {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.question-indicator {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #409EFF;
|
||||||
|
}
|
||||||
|
.question-title {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
.question-maxscore {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
.result-score {
|
.result-score {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 20px 0;
|
padding: 16px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.score-value {
|
.score-value {
|
||||||
font-size: 48px;
|
font-size: 48px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #409EFF;
|
color: #409EFF;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.score-label {
|
.score-label {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #999;
|
color: #999;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-confidence {
|
.result-confidence {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confidence-bar {
|
.confidence-bar {
|
||||||
height: 6px;
|
height: 6px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confidence-fill {
|
.confidence-fill {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: linear-gradient(90deg, #67C23A, #409EFF);
|
background: linear-gradient(90deg, #67C23A, #409EFF);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
transition: width 0.3s;
|
transition: width 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confidence-text {
|
.confidence-text {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #999;
|
color: #999;
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-section {
|
.result-section {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.deduction-item {
|
.deduction-item {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #F56C6C;
|
color: #F56C6C;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-text {
|
.comment-text {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@@ -247,11 +311,9 @@ async function confirmScore() {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.teacher-score-input {
|
.teacher-score-input {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drawer-footer {
|
.drawer-footer {
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
border-top: 1px solid #eee;
|
border-top: 1px solid #eee;
|
||||||
@@ -259,4 +321,4 @@ async function confirmScore() {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,34 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="visible" title="评分标准" width="520px" :modal="false" @close="handleClose">
|
<el-dialog v-model="visible" title="评分标准" width="600px" :modal="false" @close="handleClose">
|
||||||
<el-form :model="form" size="small">
|
<div class="question-tabs">
|
||||||
<el-form-item label="题目">
|
<div class="tab-list">
|
||||||
<el-input
|
<div
|
||||||
v-model="form.questionTitle"
|
v-for="(q, idx) in questions"
|
||||||
type="textarea"
|
:key="idx"
|
||||||
:rows="2"
|
class="tab-item"
|
||||||
placeholder="输入题目内容"
|
:class="{ active: idx === activeIndex }"
|
||||||
/>
|
@click="activeIndex = idx"
|
||||||
</el-form-item>
|
>
|
||||||
<el-form-item label="满分">
|
<span>题目 {{ idx + 1 }}</span>
|
||||||
<el-input-number v-model="form.maxScore" :min="1" :max="1000" />
|
<el-button text size="small" @click.stop="removeQuestion(idx)" v-if="questions.length > 1">✕</el-button>
|
||||||
</el-form-item>
|
</div>
|
||||||
<el-form-item label="参考答案">
|
<el-button size="small" @click="addQuestion">+ 添加题目</el-button>
|
||||||
<el-input
|
</div>
|
||||||
v-model="form.referenceAnswer"
|
|
||||||
type="textarea"
|
<div class="tab-content" v-if="questions[activeIndex]">
|
||||||
:rows="3"
|
<el-form :model="questions[activeIndex]" size="small" label-width="80px">
|
||||||
placeholder="输入参考答案(可选)"
|
<el-form-item label="题目">
|
||||||
/>
|
<el-input v-model="questions[activeIndex].questionTitle" type="textarea" :rows="2" placeholder="输入题目内容" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="评分标准">
|
<el-form-item label="满分">
|
||||||
<el-input
|
<el-input-number v-model="questions[activeIndex].maxScore" :min="1" :max="1000" />
|
||||||
v-model="form.rubric"
|
</el-form-item>
|
||||||
type="textarea"
|
<el-form-item label="参考答案">
|
||||||
:rows="8"
|
<el-input v-model="questions[activeIndex].referenceAnswer" type="textarea" :rows="3" placeholder="输入参考答案(可选)" />
|
||||||
placeholder="输入评分标准,如: 实体识别完整(3分) 联系类型正确(4分) 图形规范(2分)"
|
</el-form-item>
|
||||||
/>
|
<el-form-item label="评分标准">
|
||||||
</el-form-item>
|
<el-input v-model="questions[activeIndex].rubric" type="textarea" :rows="6" placeholder="输入评分标准" />
|
||||||
</el-form>
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button size="small" @click="handleClose">取消</el-button>
|
<el-button size="small" @click="handleClose">取消</el-button>
|
||||||
<el-button type="primary" size="small" @click="handleSave">应用</el-button>
|
<el-button type="primary" size="small" @click="handleSave">应用</el-button>
|
||||||
@@ -41,40 +45,49 @@ import { ref, watch } from 'vue'
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { useAppStore } from '@/stores/app'
|
import { useAppStore } from '@/stores/app'
|
||||||
import { useGradingStore } from '@/stores/grading'
|
import { useGradingStore } from '@/stores/grading'
|
||||||
|
import type { QuestionItem } from '@/types'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const gradingStore = useGradingStore()
|
const gradingStore = useGradingStore()
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
const form = ref({ questionTitle: '', maxScore: 100, referenceAnswer: '', rubric: '' })
|
const activeIndex = ref(0)
|
||||||
|
const questions = ref<QuestionItem[]>([])
|
||||||
|
|
||||||
|
function emptyQuestion(): QuestionItem {
|
||||||
|
return { questionTitle: '', maxScore: 100, referenceAnswer: '', rubric: '' }
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => appStore.isRubricEditorOpen, async (val) => {
|
watch(() => appStore.isRubricEditorOpen, async (val) => {
|
||||||
visible.value = val
|
visible.value = val
|
||||||
if (val) {
|
if (val) {
|
||||||
// load rubric data from main process (set by toolbar window before opening)
|
|
||||||
const data = await window.electronAPI?.rubric.getData()
|
const data = await window.electronAPI?.rubric.getData()
|
||||||
if (data) {
|
if (data?.questions?.length) {
|
||||||
form.value = {
|
questions.value = JSON.parse(JSON.stringify(data.questions))
|
||||||
questionTitle: data.questionTitle || '',
|
activeIndex.value = data.currentIndex ?? 0
|
||||||
maxScore: data.maxScore ?? 100,
|
} else {
|
||||||
referenceAnswer: data.referenceAnswer || '',
|
questions.value = [emptyQuestion()]
|
||||||
rubric: data.rubric || ''
|
activeIndex.value = 0
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function addQuestion() {
|
||||||
|
questions.value.push(emptyQuestion())
|
||||||
|
activeIndex.value = questions.value.length - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeQuestion(idx: number) {
|
||||||
|
questions.value.splice(idx, 1)
|
||||||
|
if (activeIndex.value >= questions.value.length) {
|
||||||
|
activeIndex.value = questions.value.length - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleSave() {
|
async function handleSave() {
|
||||||
// update local store
|
gradingStore.setQuestions(JSON.parse(JSON.stringify(questions.value)))
|
||||||
gradingStore.setQuestionTitle(form.value.questionTitle)
|
|
||||||
gradingStore.setRubric(form.value.rubric)
|
|
||||||
gradingStore.setMaxScore(form.value.maxScore)
|
|
||||||
gradingStore.setReferenceAnswer(form.value.referenceAnswer)
|
|
||||||
// persist to main process so toolbar window can read it
|
|
||||||
await window.electronAPI?.rubric.storeData({
|
await window.electronAPI?.rubric.storeData({
|
||||||
questionTitle: form.value.questionTitle,
|
questions: questions.value,
|
||||||
maxScore: form.value.maxScore,
|
currentIndex: 0
|
||||||
referenceAnswer: form.value.referenceAnswer,
|
|
||||||
rubric: form.value.rubric
|
|
||||||
})
|
})
|
||||||
ElMessage.success('评分标准已应用')
|
ElMessage.success('评分标准已应用')
|
||||||
handleClose()
|
handleClose()
|
||||||
@@ -84,3 +97,38 @@ function handleClose() {
|
|||||||
window.electronAPI?.dialog.close()
|
window.electronAPI?.dialog.close()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.question-tabs {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
.tab-list {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.tab-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border: 1px solid #e4e7ed;
|
||||||
|
}
|
||||||
|
.tab-item.active {
|
||||||
|
background: #409EFF;
|
||||||
|
color: #fff;
|
||||||
|
border-color: #409EFF;
|
||||||
|
}
|
||||||
|
.tab-content {
|
||||||
|
border: 1px solid #e4e7ed;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+10
-1
@@ -1,10 +1,12 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { GradeResult } from '@/types'
|
import type { GradeResult, QuestionItem } from '@/types'
|
||||||
|
|
||||||
export const useGradingStore = defineStore('grading', () => {
|
export const useGradingStore = defineStore('grading', () => {
|
||||||
const currentImage = ref<string | null>(null)
|
const currentImage = ref<string | null>(null)
|
||||||
const currentResult = ref<GradeResult | null>(null)
|
const currentResult = ref<GradeResult | null>(null)
|
||||||
|
const questions = ref<QuestionItem[]>([])
|
||||||
|
const currentQuestionIndex = ref(0)
|
||||||
const rubric = ref('')
|
const rubric = ref('')
|
||||||
const questionTitle = ref('')
|
const questionTitle = ref('')
|
||||||
const maxScore = ref(100)
|
const maxScore = ref(100)
|
||||||
@@ -28,6 +30,9 @@ export const useGradingStore = defineStore('grading', () => {
|
|||||||
function setMaxScore(val: number) { maxScore.value = val }
|
function setMaxScore(val: number) { maxScore.value = val }
|
||||||
function setReferenceAnswer(val: string) { referenceAnswer.value = val }
|
function setReferenceAnswer(val: string) { referenceAnswer.value = val }
|
||||||
|
|
||||||
|
function setQuestions(list: QuestionItem[]) { questions.value = list }
|
||||||
|
function setCurrentQuestionIndex(idx: number) { currentQuestionIndex.value = idx }
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
currentImage.value = null
|
currentImage.value = null
|
||||||
currentResult.value = null
|
currentResult.value = null
|
||||||
@@ -38,6 +43,8 @@ export const useGradingStore = defineStore('grading', () => {
|
|||||||
return {
|
return {
|
||||||
currentImage,
|
currentImage,
|
||||||
currentResult,
|
currentResult,
|
||||||
|
questions,
|
||||||
|
currentQuestionIndex,
|
||||||
rubric,
|
rubric,
|
||||||
questionTitle,
|
questionTitle,
|
||||||
maxScore,
|
maxScore,
|
||||||
@@ -50,6 +57,8 @@ export const useGradingStore = defineStore('grading', () => {
|
|||||||
setQuestionTitle,
|
setQuestionTitle,
|
||||||
setMaxScore,
|
setMaxScore,
|
||||||
setReferenceAnswer,
|
setReferenceAnswer,
|
||||||
|
setQuestions,
|
||||||
|
setCurrentQuestionIndex,
|
||||||
reset
|
reset
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
export interface QuestionItem {
|
||||||
|
questionTitle: string
|
||||||
|
maxScore: number
|
||||||
|
referenceAnswer: string
|
||||||
|
rubric: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface GradeResult {
|
export interface GradeResult {
|
||||||
score: number
|
score: number
|
||||||
confidence: number
|
confidence: number
|
||||||
|
|||||||
Reference in New Issue
Block a user