fix: 全量提示改为顶部 toast 飘窗 + 修复卷王 token 失效跳转死循环 + 调整行点击防御

- 所有 showAlert 改为 showToast 顶部飘窗(首屏 / 抽取页统一,含空消息守卫)
- 导出排序新增 成绩升序 / 成绩降序 两种(前后端 + 设置弹窗都支持)
- 设置保存:仅连接信息真变化才 reload projects,避免非连接改动导致持续刷新失败
- 强化历史成绩弹窗排序与兜底(缺 submit_ts 时按 idx 倒序)
- 行点击事件加防御:要求父节点是 #tbody,避免被无关 tr 误触发
- 卷王 token 失效时:先 fetch logout 清会话再跳 login.php,登录页也加 token 探测兜底,根治"跳不过去"死循环
- 移除 index.php / draw.php 中已无用的内联 #alert DOM
- 兼容 config_get 缺 export_sort 时回退 time 的 4 模式归一化
This commit is contained in:
2026-09-10 12:30:00 +08:00
parent 137e2cb665
commit 6def49b969
7 changed files with 160 additions and 33 deletions
+21 -4
View File
@@ -72,9 +72,10 @@ try {
if (array_key_exists('history_display', $in)) {
$new['history_display'] = ($in['history_display'] === 'inline') ? 'inline' : 'click';
}
// 成绩导出排序:time(按提交时间降序,默认) / sid(按学号)
// 成绩导出排序:time(按提交时间降序,默认)/ sid(按学号)/ score_desc(成绩降序)/ score_asc(成绩升序)
if (array_key_exists('export_sort', $in)) {
$new['export_sort'] = ($in['export_sort'] === 'sid') ? 'sid' : 'time';
$v = (string)$in['export_sort'];
$new['export_sort'] = in_array($v, ['time','sid','score_desc','score_asc'], true) ? $v : 'time';
}
// 各试卷独立满分(覆盖整个 full_scores 映射)
if (array_key_exists('full_scores', $in) && is_array($in['full_scores'])) {
@@ -500,11 +501,27 @@ try {
} else {
// 导出全部考试记录(同一学号考了 N 次就有 N 行),并保留"考试次数"
$sortMode = (string)($_GET['sort'] ?? '');
$sortMode = ($sortMode === 'sid') ? 'sid' : 'time';
$all = DataService::expandAttempts($rows, true);
// time=按提交时间降序;sid=按学号(同学号内按提交时间降序)
$all = DataService::sortForExport($all, $sortMode);
// score_desc=按成绩降序(同分按提交时间);score_asc=按成绩升序
if ($sortMode === 'score_desc' || $sortMode === 'score_asc') {
$dir = ($sortMode === 'score_desc') ? -1 : 1;
usort($all, static function (array $x, array $y) use ($dir): int {
// null 成绩排末尾
$xn = ($x['score'] === null);
$yn = ($y['score'] === null);
if ($xn && $yn) return 0;
if ($xn) return 1;
if ($yn) return -1;
$d = ($x['score'] <=> $y['score']) * $dir;
if ($d !== 0) return $d;
// 同分按提交时间降序
return ((int)($y['submit_ts'] ?? 0)) <=> ((int)($x['submit_ts'] ?? 0));
});
} else {
$all = DataService::sortForExport($all, ($sortMode === 'sid') ? 'sid' : 'time');
}
fputcsv($out, ['学号', '姓名', '班级', '组别', '成绩', '考试次数', '第几次', '提交时间', '考试时长', '考试时长(秒)']);
foreach ($all as $r) {