- 修复:仅当连接信息(base_url/api_prefix/username/password/verify_ssl)真变化时才清 token + 重连; 保存满分/布局等不应触发登录卷王(bug:之前一律 unlink token.json,导致保存后所有用户都被踢) - 修复:默认满分不再误写当前卷;改为显式 apply_pid + apply_score 才会改 full_scores - 配置双写(DB+文件):避免 DB 不可用时静默回退到出厂默认 admin/123456; ny_save_config 同时写文件+DB;ny_load_config 在 DB 可用但无记录时从文件自动迁回 - 设置弹窗新增:登录账号可编辑、密码 type=password 不回显、留空表示不修改; 保存后根据 ping 自动给出成功/失败反馈(错误密码不再静默) - 抽取比例改为按组人数加权(默认)+ 各组均分 + 自定义比例 + 不分组,最大余额法守恒分配 - 抽出比例 UI:删除 5:5 复选框、改 #balanceMode 下拉 + 按组渲染比例输入框 - Db::lastError() 暴露 DB 错误用于诊断(config_get 返回 db_driver / db_connected / db_error) - e2e:test-draw-alloc 18→29 测试用例(加权/自定义/守恒 fuzz); 新增 test-config-save e2e 27 用例全过(连接信息变化检测 + 自动 ping + 密码不回显 + apply_pid) - mock-server:账户校验从 'admin' 改为 'mock' 接受 e2e 账号
178 lines
7.6 KiB
PHP
178 lines
7.6 KiB
PHP
<?php
|
||
/**
|
||
* NY 问卷考试系统数据平台 - 随机抽取
|
||
* 从名单 / 已提交人员中随机抽取(支持分组均衡 5:5、排除名单、历史记录),
|
||
* 导出为卷王白名单(两列:姓名 / 登陆账号)
|
||
*/
|
||
declare(strict_types=1);
|
||
require __DIR__ . '/bootstrap.php';
|
||
|
||
if (!ny_is_installed()) {
|
||
header('Location: install.php');
|
||
exit;
|
||
}
|
||
if (!ny_is_auth()) {
|
||
header('Location: login.php');
|
||
exit;
|
||
}
|
||
|
||
$rosterCount = Roster::count();
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>随机抽取 · <?= htmlspecialchars(NY_APP_NAME) ?></title>
|
||
<link rel="stylesheet" href="assets/style.css">
|
||
</head>
|
||
<body>
|
||
|
||
<header class="topbar">
|
||
<div class="brand">
|
||
<span class="logo">NY</span>
|
||
<div class="brand-text">
|
||
<strong>随机抽取</strong>
|
||
<small>名单 / 已提交人员 → 卷王白名单</small>
|
||
</div>
|
||
</div>
|
||
<div class="top-right">
|
||
<a class="btn" href="index.php#roster" title="前往主系统管理学号名单">名单管理 <b id="rosterBadge"><?= (int)$rosterCount ?></b></a>
|
||
<button class="btn" id="btnClearLog" title="清空全部历史记录(重置结果不影响历史记录)">清空历史</button>
|
||
<a class="btn" href="index.php">← 返回主系统</a>
|
||
<a class="btn" href="logout.php" title="退出登录">退出</a>
|
||
</div>
|
||
</header>
|
||
|
||
<main class="wrap">
|
||
|
||
<section class="toolbar">
|
||
<div class="field">
|
||
<label>抽取来源</label>
|
||
<select id="sourceSel">
|
||
<option value="roster">学号名单(全部)</option>
|
||
<option value="project">某试卷已提交人员</option>
|
||
</select>
|
||
</div>
|
||
<div class="field grow hidden" id="projectField">
|
||
<label>问卷 / 考试</label>
|
||
<select id="projectSel"><option value="">加载中…</option></select>
|
||
</div>
|
||
<div class="field">
|
||
<label>班级</label>
|
||
<select id="clsSel"><option value="">全部班级</option></select>
|
||
</div>
|
||
<div class="field">
|
||
<label>组别</label>
|
||
<select id="grpSel"><option value="">全部组别</option></select>
|
||
</div>
|
||
<div class="field">
|
||
<label>抽取人数</label>
|
||
<div class="inline">
|
||
<input type="number" id="numInput" min="1" step="1" value="1">
|
||
<button class="btn sm" data-num="1">1</button>
|
||
<button class="btn sm" data-num="5">5</button>
|
||
<button class="btn sm" data-num="10">10</button>
|
||
<button class="btn sm" data-num="all">全部</button>
|
||
</div>
|
||
</div>
|
||
<div class="field btns">
|
||
<label class="chk" title="决定有分组时如何分配名额"><span style="color:var(--text-2);font-size:12px">分组比例</span>
|
||
<select id="balanceMode" style="height:30px;border-radius:8px;border:1px solid var(--border);padding:0 8px;background:#fff;margin-left:4px">
|
||
<option value="weight">按人数加权(默认)</option>
|
||
<option value="even">各组均分(5:5)</option>
|
||
<option value="custom">自定义比例</option>
|
||
<option value="off">不分组(整池随机)</option>
|
||
</select>
|
||
</label>
|
||
<label class="chk" title="再次抽取时不与本次会话已抽中的人重复;「重置结果」后清零"><input type="checkbox" id="excludePicked" checked> 排除已抽中</label>
|
||
<button class="btn" id="btnExclude" title="勾选不参与抽取的人">🚫 排除管理</button>
|
||
<button class="btn btn-primary" id="btnDraw">🎲 开始抽取</button>
|
||
<button class="btn" id="btnReset" title="清空本次结果与累计已抽取(历史记录保留)">重置结果</button>
|
||
</div>
|
||
<div class="field full hidden" id="ratioBox" style="grid-column:1/-1"></div>
|
||
</section>
|
||
|
||
<div id="alert" class="alert hidden"></div>
|
||
|
||
<section class="cards" id="statCards">
|
||
<div class="card accent-blue"><span>候选人数</span><b id="dPool">-</b></div>
|
||
<div class="card accent-green"><span>本次抽取</span><b id="dPicked">-</b></div>
|
||
<div class="card warn accent-orange"><span>累计已抽取</span><b id="dHistory">-</b></div>
|
||
<div class="card accent-red"><span>已排除</span><b id="dExcluded">-</b></div>
|
||
<div class="card accent-gray"><span>抽取来源</span><b id="dSource">学号名单</b></div>
|
||
</section>
|
||
|
||
<section class="panel">
|
||
<div class="panel-head">
|
||
<h2>抽取结果 <small id="drawHint"></small></h2>
|
||
<div class="actions">
|
||
<button class="btn" id="btnLog" title="查看历史抽取批次(重置结果后仍保留)">📜 历史 <b id="logBadge">0</b></button>
|
||
<button class="btn" id="btnDlImport" title="导出为「白名单导入模板.xlsx」">⬇ 白名单导入模板</button>
|
||
<button class="btn btn-primary" id="btnDlList" title="导出为「白名单列表.xlsx」">⬇ 白名单列表</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="draw-stage" id="drawStage">点击「🎲 开始抽取」</div>
|
||
|
||
<div class="table-scroll">
|
||
<table class="grid">
|
||
<thead>
|
||
<tr>
|
||
<th style="width:70px">序号</th>
|
||
<th style="width:26%">学号</th>
|
||
<th style="width:22%">姓名</th>
|
||
<th>班级</th>
|
||
<th>组别</th>
|
||
<th style="width:90px">操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="drawBody"><tr><td colspan="6" class="empty">尚未抽取</td></tr></tbody>
|
||
</table>
|
||
</div>
|
||
<p class="hint">两个下载均为两列「<b>姓名</b> / <b>登陆账号</b>」,登陆账号取名单中导入的「登陆账号」列(缺失时回退学号),按文本格式保存,可直接导入卷王白名单。</p>
|
||
</section>
|
||
</main>
|
||
|
||
<!-- ================= 排除管理 ================= -->
|
||
<div class="modal" id="exclModal">
|
||
<div class="modal-box wide">
|
||
<div class="modal-head"><h3>抽取排除管理</h3><button class="x" data-close>×</button></div>
|
||
<div class="modal-body">
|
||
<div class="roster-bar">
|
||
<input type="text" id="exclSearch" placeholder="搜索学号 / 姓名 / 班级">
|
||
<span class="spacer"></span>
|
||
<span class="hint" id="exclCount">已排除 0 人</span>
|
||
<button class="btn sm danger" id="btnClearExcl">清空排除</button>
|
||
</div>
|
||
<div class="table-scroll mid">
|
||
<table class="grid compact">
|
||
<thead><tr><th style="width:64px">排除</th><th style="width:24%">学号</th><th style="width:22%">姓名</th><th>班级</th><th>组别</th></tr></thead>
|
||
<tbody id="exclBody"><tr><td colspan="5" class="empty">加载中…</td></tr></tbody>
|
||
</table>
|
||
</div>
|
||
<p class="hint">勾选后这些人不再参与抽取(勾选即时生效);仅影响随机抽取,不影响其他功能。</p>
|
||
</div>
|
||
<div class="modal-foot"><span class="spacer"></span><button class="btn btn-primary" data-close>完成</button></div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ================= 历史记录 ================= -->
|
||
<div class="modal" id="logModal">
|
||
<div class="modal-box wide">
|
||
<div class="modal-head"><h3>抽取历史记录</h3><button class="x" data-close>×</button></div>
|
||
<div class="modal-body">
|
||
<div id="logList" class="log-list"><p class="empty" style="text-align:center;padding:30px 0">暂无历史记录</p></div>
|
||
<p class="hint">每次抽取自动记一笔;「重置结果」不会清除历史记录,可随时恢复某一批次重新下载。</p>
|
||
</div>
|
||
<div class="modal-foot">
|
||
<span class="spacer"></span>
|
||
<button class="btn btn-primary" data-close>关闭</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script src="assets/draw.js"></script>
|
||
</body>
|
||
</html>
|