feat: localize course grade analytics

This commit is contained in:
biss committed 2026-10-31 11:13:41 +08:00
1 parent 9635c664c4
commit 00452e6965
3 files changed
+41 -40

No files matched your search

+3
View File
@@ -175,6 +175,9 @@ export default {
plugins: {
title: 'Unified plugin platform', description: 'Manage built-in business capabilities, runtime state, and server-side access boundaries in one place.', runningCount: '/ {total} plugins running', safetyTitle: 'Disabling does not delete data', safetyDescription: 'State changes immediately affect menus, routes, and APIs. Existing business endpoints still enforce role permissions and data scope.', signedPackages: 'Signed plugin packages', packageDescription: 'Uploads enter staging only. Validated packages must still be marked for activation and the service restarted.', selectZip: 'Select ZIP package', selectSignature: 'Select signature file', validateStage: 'Validate and stage', noPackages: 'No signed plugin packages uploaded', pluginVersion: 'Plugin / version', publisher: 'Publisher', verification: 'Verification', status: 'Status', actions: 'Actions', rollback: 'Roll back to this version', activate: 'Activate', delete: 'Delete', awaitingRestart: 'Awaiting restart', running: 'Running', disabled: 'Disabled', navigationCount: '{count} page entries', waitRestart: 'Mark and await restart', cancel: 'Cancel', enable: 'enable', disable: 'disable', bundled: 'Installed with the current system version', packageStatuses: { Staged: 'Staged', PendingActivation: 'Activation pending', Active: 'Active version', Superseded: 'Previous version', Failed: 'Load failed' }, messages: { selectFiles: 'Select the plugin ZIP package and its signature file.', staged: 'Signature verified. The plugin package is now staged.', activateConfirm: 'Version {version} will activate after the next service restart. The active version will be retained for rollback.', activateTitle: 'Activate {name}', activationPending: 'Marked for activation. Restart the service using the maintenance procedure.', deleteConfirm: 'Delete the package record for {name} {version}?', deleteTitle: 'Delete plugin package', deleted: 'Plugin package record deleted.', enableConfirm: 'Users with the existing role permissions will see and be able to use “{name}” again.', disableConfirm: 'The menu, pages, and backend APIs for “{name}” will be disabled. Existing data will not be deleted.', stateTitle: '{action} {name}', confirmState: 'Confirm {action}', stateChanged: '{name} has been {action}d.' },
},
courseStats: {
title: 'Course grade analytics', publishedOnly: 'This page uses formally published grades', back: 'Back', refresh: 'Refresh', generating: 'Statistics are being generated. Refresh shortly.', scope: 'Statistics scope', classStudents: 'Students in this administrative class', myClass: 'My class', classmates: 'Classmates', myMajor: 'My major', majorStudents: 'Students in the major', myCollege: 'My college', collegeStudents: 'Students in the college', university: 'University', universityStudents: 'All university students', peopleCount: '{count} students', scopeAverage: '{scope} average', population: 'Population: {caption} · {count} students', highest: 'Highest score', lowest: 'Lowest score', passed: 'Passed', passRate: 'Pass rate', empty: 'No course statistics available', distributionTitle: '{scope} score distribution', distributionDescription: 'Calculated for the current tab only, with {count} students. Bar labels show counts and percentages.', comparisonTitle: 'Cross-level analysis', comparisonDescription: 'Compare minimum–maximum score ranges, averages, and pass rates across all four levels. The current level is highlighted.', scoreBand: 'Score band', people: 'Students', scopePeople: '{scope} students', scoreRange: 'Score range', average: 'Average', score: 'Score', rangeStart: 'Range start', insights: { lowPass: 'The pass rate is {rate}%. Review coursework and final-exam components for low-scoring students and arrange targeted support.', lowAverage: 'The average is {average}. Review commonly missed topics and teaching pace, then reinforce by score band.', highDeviation: 'Scores vary widely. Review learning differences across classes or groups, grading standards, and teaching support.', stable: 'The average is {average} and the pass rate is {rate}%. Performance is stable; continue following up with lower-scoring students.' }, chart: { distributionTooltip: '<b>{range} points</b><br/>Students {count}<br/>Share {rate}%', barLabel: '{count} students\n{rate}%', comparisonTooltip: '<b>{scope}</b><br/>Highest {highest}<br/>Average {average}<br/>Lowest {lowest}<br/>Pass rate {rate}%' },
},
api: {
'data.constraint_conflict': 'A data constraint conflict occurred.',
'server.unhandled_error': 'The server encountered an error while processing the request.',
+3
View File
@@ -175,6 +175,9 @@ export default {
plugins: {
title: '统一插件平台', description: '集中管理内置业务能力的入口、运行状态和服务端访问边界。', runningCount: '/ {total} 个插件运行中', safetyTitle: '停用不会删除数据', safetyDescription: '状态变更立即作用于菜单、路由和 API;角色权限与数据范围校验仍由原业务接口负责。', signedPackages: '签名插件包', packageDescription: '上传只进入暂存区;校验通过后仍需标记激活并重启服务。', selectZip: '选择 ZIP 包', selectSignature: '选择签名文件', validateStage: '校验并暂存', noPackages: '尚未上传签名插件包', pluginVersion: '插件 / 版本', publisher: '发布者', verification: '校验', status: '状态', actions: '操作', rollback: '回滚到此版本', activate: '激活', delete: '删除', awaitingRestart: '等待重启', running: '运行中', disabled: '已停用', navigationCount: '{count} 个页面入口', waitRestart: '标记并等待重启', cancel: '取消', enable: '启用', disable: '停用', bundled: '随当前系统版本安装', packageStatuses: { Staged: '已暂存', PendingActivation: '待重启激活', Active: '活动版本', Superseded: '历史版本', Failed: '装载失败' }, messages: { selectFiles: '请选择插件 ZIP 包和对应的签名文件。', staged: '签名校验通过,插件包已进入暂存区。', activateConfirm: '版本 {version} 将在下次服务重启时激活。当前活动版本会保留,可用同样方式回滚。', activateTitle: '激活 {name}', activationPending: '已标记为待激活,请按维护流程重启服务。', deleteConfirm: '确认删除 {name} {version} 的包记录?', deleteTitle: '删除插件包', deleted: '插件包记录已删除。', enableConfirm: '启用后,具备原有角色权限的用户将重新看到并可使用“{name}”。', disableConfirm: '停用后,“{name}”的菜单、页面和后端接口都会关闭,已有数据不会删除。', stateTitle: '{action}{name}', confirmState: '确认{action}', stateChanged: '{name}已{action}。' },
},
courseStats: {
title: '课程成绩分析', publishedOnly: '本页数据来自已正式发布成绩', back: '返回', refresh: '刷新', generating: '统计数据正在生成,请稍后刷新。', scope: '统计范围', classStudents: '该行政班学生', myClass: '本班', classmates: '同班同学', myMajor: '本专业', majorStudents: '专业学生', myCollege: '本学院', collegeStudents: '学院学生', university: '本校', universityStudents: '全校学生', peopleCount: '{count} 人', scopeAverage: '{scope}平均分', population: '统计对象:{caption} · {count} 人', highest: '最高分', lowest: '最低分', passed: '合格人数', passRate: '合格率', empty: '暂无可展示的课程统计', distributionTitle: '{scope}分数段分布', distributionDescription: '按当前标签页单独统计,共 {count} 人;柱顶显示人数和占比。', comparisonTitle: '各层级整体分析', comparisonDescription: '同时比较四个层级的最低—最高分区间、平均分和合格率;当前标签对应层级高亮。', scoreBand: '分数段', people: '人数', scopePeople: '{scope}人数', scoreRange: '分数区间', average: '平均分', score: '分数', rangeStart: '区间起点', insights: { lowPass: '合格率为 {rate}%,建议优先复核低分段学生的平时与期末分项,并安排针对性答疑。', lowAverage: '平均分为 {average},建议检查易失分知识点与教学进度,结合分数段安排补强。', highDeviation: '成绩离散度较高,建议关注不同教学班或学生群体的学习差异,核对评价标准与教学支持。', stable: '平均分 {average}、合格率 {rate}%,当前表现稳定;可重点关注低分段学生的持续跟进。' }, chart: { distributionTooltip: '<b>{range} 分</b><br/>人数 {count} 人<br/>占比 {rate}%', barLabel: '{count} 人\n{rate}%', comparisonTooltip: '<b>{scope}</b><br/>最高分 {highest}<br/>平均分 {average}<br/>最低分 {lowest}<br/>合格率 {rate}%' },
},
api: {
'data.constraint_conflict': '数据约束冲突。',
'server.unhandled_error': '服务器处理请求时发生错误。',
+35 -40
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { ArrowLeft, Refresh } from '@element-plus/icons-vue'
import * as echarts from 'echarts/core'
import { BarChart, LineChart } from 'echarts/charts'
@@ -21,6 +22,7 @@ echarts.use([
const route = useRoute()
const router = useRouter()
const { t } = useI18n()
const loading = ref(false)
const report = ref<any | null>(null)
const activeScope = ref('class')
@@ -34,15 +36,15 @@ const rows = computed(() => {
? report.value.classes.map((item: any) => ({
key: `class-${item.classId}`,
label: item.className,
caption: '该行政班学生',
caption: t('courseStats.classStudents'),
value: item.statistics,
}))
: [{ key: 'class', label: '本班', caption: '同班同学', value: report.value?.class }]
: [{ key: 'class', label: t('courseStats.myClass'), caption: t('courseStats.classmates'), value: report.value?.class }]
return [
...classRows,
{ key: 'major', label: '本专业', caption: '专业学生', value: report.value?.major },
{ key: 'college', label: '本学院', caption: '学院学生', value: report.value?.college },
{ key: 'university', label: '本校', caption: '全校学生', value: report.value?.university },
{ key: 'major', label: t('courseStats.myMajor'), caption: t('courseStats.majorStudents'), value: report.value?.major },
{ key: 'college', label: t('courseStats.myCollege'), caption: t('courseStats.collegeStudents'), value: report.value?.college },
{ key: 'university', label: t('courseStats.university'), caption: t('courseStats.universityStudents'), value: report.value?.university },
].filter(item => item.value)
})
@@ -51,10 +53,10 @@ const selectedDistribution = computed(() => selectedRow.value?.value.distributio
const recommendation = computed(() => {
const value = selectedRow.value?.value
if (!value) return ''
if (Number(value.passRate) < 70) return `合格率为 ${score(value.passRate)}%,建议优先复核低分段学生的平时与期末分项,并安排针对性答疑。`
if (Number(value.averageScore) < 70) return `平均分为 ${score(value.averageScore)},建议检查易失分知识点与教学进度,结合分数段安排补强。`
if (Number(value.standardDeviation) > 20) return `成绩离散度较高,建议关注不同教学班或学生群体的学习差异,核对评价标准与教学支持。`
return `平均分 ${score(value.averageScore)}、合格率 ${score(value.passRate)}%,当前表现稳定;可重点关注低分段学生的持续跟进。`
if (Number(value.passRate) < 70) return t('courseStats.insights.lowPass', { rate: score(value.passRate) })
if (Number(value.averageScore) < 70) return t('courseStats.insights.lowAverage', { average: score(value.averageScore) })
if (Number(value.standardDeviation) > 20) return t('courseStats.insights.highDeviation')
return t('courseStats.insights.stable', { average: score(value.averageScore), rate: score(value.passRate) })
})
function score(value: unknown) {
@@ -91,32 +93,32 @@ function drawChart() {
formatter: (params: any) => {
const item = distribution[params[0]?.dataIndex ?? 0]
const rate = item ? Number(item.count) / total * 100 : 0
return `<b>${item?.range ?? ''} 分</b><br/>人数 ${item?.count ?? 0} 人<br/>占比 ${rate.toFixed(1)}%`
return t('courseStats.chart.distributionTooltip', { range: item?.range ?? '', count: item?.count ?? 0, rate: rate.toFixed(1) })
},
},
grid: { left: 42, right: 22, top: 44, bottom: 38 },
xAxis: {
type: 'category',
name: '分数段',
name: t('courseStats.scoreBand'),
data: distribution.map((item: any) => item.range),
axisTick: { show: false },
axisLine: { lineStyle: { color: '#cbd4e1' } },
axisLabel: { color: '#475467', fontWeight: 600 },
},
yAxis: {
type: 'value', min: 0, minInterval: 1, name: '人数',
type: 'value', min: 0, minInterval: 1, name: t('courseStats.people'),
splitLine: { lineStyle: { color: '#edf1f6' } },
},
series: [
{
name: `${selectedRow.value.label}人数`, type: 'bar', barMaxWidth: 62,
name: t('courseStats.scopePeople', { scope: selectedRow.value.label }), type: 'bar', barMaxWidth: 62,
data: distribution.map((item: any, index: number) => ({ value: item.count, itemStyle: { color: palette[index] } })),
itemStyle: { borderRadius: [5, 5, 0, 0] },
label: {
show: true, position: 'top', color: '#344054', fontWeight: 700,
formatter: (params: any) => {
const count = Number(params.value)
return `${count} 人\n${(count / total * 100).toFixed(1)}%`
return t('courseStats.chart.barLabel', { count, rate: (count / total * 100).toFixed(1) })
},
},
},
@@ -136,10 +138,10 @@ function drawComparisonChart() {
trigger: 'axis',
formatter: (params: any) => {
const item = rows.value[params[0]?.dataIndex ?? 0]
return `<b>${item.label}</b><br/>最高分 ${score(item.value.highestScore)}<br/>平均分 ${score(item.value.averageScore)}<br/>最低分 ${score(item.value.lowestScore)}<br/>合格率 ${score(item.value.passRate)}%`
return t('courseStats.chart.comparisonTooltip', { scope: item.label, highest: score(item.value.highestScore), average: score(item.value.averageScore), lowest: score(item.value.lowestScore), rate: score(item.value.passRate) })
},
},
legend: { top: 2, data: ['分数区间', '平均分', '合格率'] },
legend: { top: 2, data: [t('courseStats.scoreRange'), t('courseStats.average'), t('courseStats.passRate')] },
grid: { left: 42, right: 52, top: 56, bottom: 36 },
xAxis: {
type: 'category',
@@ -152,17 +154,17 @@ function drawComparisonChart() {
},
},
yAxis: [
{ type: 'value', min: 0, max: 100, name: '分数', splitLine: { lineStyle: { color: '#edf1f6' } } },
{ type: 'value', min: 0, max: 100, name: '合格率', axisLabel: { formatter: '{value}%' }, splitLine: { show: false } },
{ type: 'value', min: 0, max: 100, name: t('courseStats.score'), splitLine: { lineStyle: { color: '#edf1f6' } } },
{ type: 'value', min: 0, max: 100, name: t('courseStats.passRate'), axisLabel: { formatter: '{value}%' }, splitLine: { show: false } },
],
series: [
{
name: '区间起点', type: 'bar', stack: 'score-range', silent: true,
name: t('courseStats.rangeStart'), type: 'bar', stack: 'score-range', silent: true,
itemStyle: { color: 'transparent' }, emphasis: { disabled: true },
data: rows.value.map(item => item.value.lowestScore),
},
{
name: '分数区间', type: 'bar', stack: 'score-range', barWidth: 22,
name: t('courseStats.scoreRange'), type: 'bar', stack: 'score-range', barWidth: 22,
itemStyle: { borderRadius: 8 },
data: rows.value.map((item, index) => ({
value: item.value.highestScore - item.value.lowestScore,
@@ -170,13 +172,13 @@ function drawComparisonChart() {
})),
},
{
name: '平均分', type: 'line', smooth: true, symbol: 'circle', symbolSize: 10,
name: t('courseStats.average'), type: 'line', smooth: true, symbol: 'circle', symbolSize: 10,
lineStyle: { width: 3, color: '#d58b32' },
itemStyle: { color: '#d58b32', borderColor: '#fff', borderWidth: 2 },
data: rows.value.map(item => item.value.averageScore),
},
{
name: '合格率', type: 'line', yAxisIndex: 1, smooth: true, symbol: 'diamond', symbolSize: 9,
name: t('courseStats.passRate'), type: 'line', yAxisIndex: 1, smooth: true, symbol: 'diamond', symbolSize: 9,
lineStyle: { width: 2, type: 'dashed', color: '#25847a' },
itemStyle: { color: '#25847a' },
data: rows.value.map(item => item.value.passRate),
@@ -203,20 +205,18 @@ onBeforeUnmount(() => {
<section class="page-intro">
<div>
<span class="section-kicker">COURSE INSIGHT</span>
<h2>{{ report?.courseName ?? '课程成绩分析' }}</h2>
<p>{{ report?.courseCode }} · {{ report?.termName }} · 本页数据来自已正式发布成绩</p>
<h2>{{ report?.courseName ?? t('courseStats.title') }}</h2><p>{{ report?.courseCode }} · {{ report?.termName }} · {{ t('courseStats.publishedOnly') }}</p>
</div>
<div class="actions">
<el-button :icon="ArrowLeft" @click="router.back()">返回</el-button>
<el-button :icon="Refresh" @click="load">刷新</el-button>
<el-button :icon="ArrowLeft" @click="router.back()">{{ t('courseStats.back') }}</el-button><el-button :icon="Refresh" @click="load">{{ t('courseStats.refresh') }}</el-button>
</div>
</section>
<el-alert v-if="report?.isRefreshing" type="info" :closable="false"
title="统计数据正在生成,请稍后刷新。" />
:title="t('courseStats.generating')" />
<section v-if="rows.length && selectedRow" class="scope-panel">
<nav class="scope-tabs" aria-label="统计范围">
<nav class="scope-tabs" :aria-label="t('courseStats.scope')">
<button
v-for="item in rows"
:key="item.key"
@@ -225,38 +225,33 @@ onBeforeUnmount(() => {
@click="activeScope = item.key"
>
<span>{{ item.label }}</span>
<small>{{ item.value.studentCount }} 人</small>
<small>{{ t('courseStats.peopleCount', { count: item.value.studentCount }) }}</small>
</button>
</nav>
<article class="scope-summary">
<div class="average-score">
<span>{{ selectedRow.label }}平均分</span>
<span>{{ t('courseStats.scopeAverage', { scope: selectedRow.label }) }}</span>
<strong>{{ score(selectedRow.value.averageScore) }}</strong>
<small>统计对象:{{ selectedRow.caption }} · {{ selectedRow.value.studentCount }} 人</small>
<small>{{ t('courseStats.population', { caption: selectedRow.caption, count: selectedRow.value.studentCount }) }}</small>
</div>
<dl>
<div><dt>最高分</dt><dd>{{ score(selectedRow.value.highestScore) }}</dd></div>
<div><dt>最低分</dt><dd>{{ score(selectedRow.value.lowestScore) }}</dd></div>
<div><dt>合格人数</dt><dd>{{ selectedRow.value.passedCount }} / {{ selectedRow.value.studentCount }}</dd></div>
<div><dt>合格率</dt><dd>{{ score(selectedRow.value.passRate) }}%</dd></div>
<div><dt>{{ t('courseStats.highest') }}</dt><dd>{{ score(selectedRow.value.highestScore) }}</dd></div><div><dt>{{ t('courseStats.lowest') }}</dt><dd>{{ score(selectedRow.value.lowestScore) }}</dd></div><div><dt>{{ t('courseStats.passed') }}</dt><dd>{{ selectedRow.value.passedCount }} / {{ selectedRow.value.studentCount }}</dd></div><div><dt>{{ t('courseStats.passRate') }}</dt><dd>{{ score(selectedRow.value.passRate) }}%</dd></div>
</dl>
</article>
</section>
<section v-if="recommendation" class="action-advice"><span>ACTION ADVICE</span><p>{{ recommendation }}</p></section>
<el-empty v-else-if="!loading" description="暂无可展示的课程统计" />
<el-empty v-else-if="!loading" :description="t('courseStats.empty')" />
<section v-if="rows.length" class="chart-panel">
<div class="chart-heading">
<div><span class="section-kicker">SCORE DISTRIBUTION</span><h3>{{ selectedRow?.label }}分数段分布</h3></div>
<p>按当前标签页单独统计,共 {{ selectedRow?.value.studentCount }} 人;柱顶显示人数和占比。</p>
<div><span class="section-kicker">SCORE DISTRIBUTION</span><h3>{{ t('courseStats.distributionTitle', { scope: selectedRow?.label }) }}</h3></div><p>{{ t('courseStats.distributionDescription', { count: selectedRow?.value.studentCount }) }}</p>
</div>
<div ref="chartElement" class="score-chart" />
</section>
<section v-if="rows.length" class="chart-panel comparison-panel">
<div class="chart-heading">
<div><span class="section-kicker">LEVEL COMPARISON</span><h3>各层级整体分析</h3></div>
<p>同时比较四个层级的最低—最高分区间、平均分和合格率;当前标签对应层级高亮。</p>
<div><span class="section-kicker">LEVEL COMPARISON</span><h3>{{ t('courseStats.comparisonTitle') }}</h3></div><p>{{ t('courseStats.comparisonDescription') }}</p>
</div>
<div ref="comparisonChartElement" class="score-chart" />
</section>