- Complete survey management system with web interface - Question generation tools and prompts - Report generation and analysis capabilities - Docker configuration for deployment - Database initialization scripts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
689 lines
22 KiB
HTML
689 lines
22 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>测评报告列表</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Microsoft YaHei', sans-serif;
|
|
}
|
|
|
|
body {
|
|
background-color: #f5f7fa;
|
|
color: #333;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.container {
|
|
width: 100%;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.header {
|
|
background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 50%, #ff7e5f 100%);
|
|
color: white;
|
|
padding: 30px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
box-shadow: 0 4px 20px rgba(255, 126, 95, 0.3);
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 32px;
|
|
margin-bottom: 10px;
|
|
position: relative;
|
|
z-index: 2;
|
|
text-align: center;
|
|
}
|
|
|
|
.header p {
|
|
text-align: center;
|
|
position: relative;
|
|
z-index: 2;
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.content {
|
|
padding: 30px;
|
|
}
|
|
|
|
.table-container {
|
|
background: white;
|
|
border-radius: 10px;
|
|
overflow-x: auto;
|
|
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
background: white;
|
|
table-layout: fixed;
|
|
}
|
|
|
|
thead {
|
|
background: linear-gradient(135deg, #fef6f0, #ffffff);
|
|
border-bottom: 2px solid #ffe4d6;
|
|
}
|
|
|
|
th {
|
|
padding: 18px 15px;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: #2d5a3d;
|
|
font-size: 16px;
|
|
border-bottom: 1px solid #ffe4d6;
|
|
}
|
|
|
|
th:nth-child(1) { width: 15%; } /* 姓名 */
|
|
th:nth-child(2) { width: 20%; } /* 测评时间 */
|
|
th:nth-child(3) { width: 10%; } /* 分数 */
|
|
th:nth-child(4) { width: 15%; } /* 年级 */
|
|
th:nth-child(5) { width: 25%; } /* 学校 */
|
|
th:nth-child(6) { width: 15%; } /* 操作 */
|
|
|
|
td {
|
|
padding: 16px 15px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
font-size: 15px;
|
|
color: #333;
|
|
word-wrap: break-word;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
tbody tr {
|
|
transition: all 0.3s ease;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
tbody tr:hover {
|
|
background: linear-gradient(135deg, #fff8f3, #ffffff);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 8px rgba(255, 126, 95, 0.1);
|
|
}
|
|
|
|
tbody tr:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.name-cell {
|
|
font-weight: 500;
|
|
color: #2d5a3d;
|
|
}
|
|
|
|
.time-cell {
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.subject-cell {
|
|
display: inline-block;
|
|
padding: 6px 12px;
|
|
background: linear-gradient(135deg, #ffe4d6, #fff);
|
|
border: 1px solid #ff7e5f;
|
|
border-radius: 20px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: #ff7e5f;
|
|
}
|
|
|
|
.action-cell {
|
|
text-align: center;
|
|
}
|
|
|
|
.view-btn {
|
|
display: inline-block;
|
|
padding: 8px 16px;
|
|
background: linear-gradient(135deg, #ff7e5f, #feb47b);
|
|
color: white;
|
|
text-decoration: none;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
transition: all 0.3s ease;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.view-btn:hover {
|
|
background: linear-gradient(135deg, #ff6b52, #fe9b5b);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 3px 10px rgba(255, 126, 95, 0.3);
|
|
}
|
|
|
|
.submit-btn {
|
|
display: inline-block;
|
|
padding: 12px 24px;
|
|
background: linear-gradient(135deg, #4CAF50, #66BB6A);
|
|
color: white;
|
|
text-decoration: none;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
transition: all 0.3s ease;
|
|
border: none;
|
|
cursor: pointer;
|
|
box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
|
|
}
|
|
|
|
.submit-btn:hover {
|
|
background: linear-gradient(135deg, #45a049, #5cb85c);
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
|
|
}
|
|
|
|
.pagination-container {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 20px;
|
|
background: #f9f9f9;
|
|
border-top: 1px solid #e0e0e0;
|
|
flex-wrap: wrap;
|
|
gap: 15px;
|
|
}
|
|
|
|
.pagination-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
}
|
|
|
|
.pagination-info {
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.page-size-selector {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.page-size-selector label {
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.page-size-select {
|
|
padding: 6px 8px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
background: white;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.pagination-controls {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
}
|
|
|
|
.page-info {
|
|
color: #666;
|
|
font-size: 14px;
|
|
margin-left: 10px;
|
|
}
|
|
|
|
.pagination-btn {
|
|
padding: 8px 12px;
|
|
background: white;
|
|
border: 1px solid #ddd;
|
|
color: #666;
|
|
text-decoration: none;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
min-width: 36px;
|
|
}
|
|
|
|
.pagination-btn:hover:not(.disabled) {
|
|
background: linear-gradient(135deg, #ff7e5f, #feb47b);
|
|
color: white;
|
|
border-color: #ff7e5f;
|
|
}
|
|
|
|
.pagination-btn.active {
|
|
background: linear-gradient(135deg, #ff7e5f, #feb47b);
|
|
color: white;
|
|
border-color: #ff7e5f;
|
|
}
|
|
|
|
.pagination-btn.disabled {
|
|
background: #f5f5f5;
|
|
color: #ccc;
|
|
cursor: not-allowed;
|
|
border-color: #e0e0e0;
|
|
}
|
|
|
|
.pagination-ellipsis {
|
|
padding: 8px 4px;
|
|
color: #999;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: #666;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.error {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: #e74c3c;
|
|
font-size: 16px;
|
|
background: #fff9f7;
|
|
border-radius: 8px;
|
|
border-left: 4px solid #ff7e5f;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.empty {
|
|
text-align: center;
|
|
padding: 60px 20px;
|
|
color: #999;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 48px;
|
|
margin-bottom: 15px;
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.footer {
|
|
padding: 20px;
|
|
text-align: center;
|
|
color: #8b5a2b;
|
|
font-size: 14px;
|
|
background: #fef6f0;
|
|
border-top: 1px solid #ffe4d6;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
body {
|
|
padding: 0;
|
|
}
|
|
|
|
.header {
|
|
padding: 20px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 24px;
|
|
}
|
|
|
|
.content {
|
|
padding: 15px;
|
|
}
|
|
|
|
.table-container {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
table {
|
|
min-width: 500px;
|
|
}
|
|
|
|
th, td {
|
|
padding: 12px 10px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.subject-cell {
|
|
font-size: 12px;
|
|
padding: 4px 8px;
|
|
}
|
|
|
|
.view-btn {
|
|
padding: 6px 12px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.submit-btn {
|
|
padding: 10px 20px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.pagination-container {
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
padding: 15px;
|
|
}
|
|
|
|
.pagination-left {
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.pagination-controls {
|
|
flex-wrap: wrap;
|
|
gap: 3px;
|
|
}
|
|
|
|
.pagination-btn {
|
|
padding: 6px 10px;
|
|
font-size: 12px;
|
|
min-width: 32px;
|
|
}
|
|
|
|
.pagination-info, .page-info {
|
|
font-size: 12px;
|
|
}
|
|
|
|
.page-size-selector {
|
|
font-size: 12px;
|
|
}
|
|
|
|
.page-size-select {
|
|
padding: 4px 6px;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>📊 测评报告列表</h1>
|
|
<p>查看所有学员的学科能力测评报告</p>
|
|
<div style="text-align: center; margin-top: 20px;">
|
|
<button id="create-report-btn" class="submit-btn">✏️ 开始测评</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="table-container">
|
|
<div id="loading" class="loading">正在加载数据...</div>
|
|
<div id="error" class="error" style="display: none;"></div>
|
|
<div id="table-content" style="display: none;">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>姓名</th>
|
|
<th>测评时间</th>
|
|
<th>分数</th>
|
|
<th>年级</th>
|
|
<th>学校</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="report-list">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="empty" class="empty" style="display: none;">
|
|
<div class="empty-icon">📋</div>
|
|
<p>暂无测评报告数据</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="pagination-container">
|
|
<div class="pagination-left" id="pagination-left">
|
|
<div class="pagination-info">
|
|
<span>显示</span>
|
|
<select class="page-size-select">
|
|
<option value="5">5</option>
|
|
<option value="10" selected>10</option>
|
|
<option value="20">20</option>
|
|
<option value="50">50</option>
|
|
</select>
|
|
<span>条记录</span>
|
|
</div>
|
|
<div class="pagination-controls">
|
|
<!-- 分页按钮将由JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
<div class="page-info">
|
|
<!-- 页面信息将由JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
<p>© 2024 尚逸基石学科能力测评系统</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// 初始化报告列表管理器
|
|
new ReportListManager();
|
|
|
|
// 添加页面大小选择事件
|
|
const pageSizeSelect = document.querySelector('.page-size-select');
|
|
if (pageSizeSelect) {
|
|
pageSizeSelect.addEventListener('change', function() {
|
|
const pageSize = parseInt(this.value);
|
|
if (window.reportManager) {
|
|
window.reportManager.changePageSize(pageSize);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 创建新测评按钮事件
|
|
const createBtn = document.getElementById('create-report-btn');
|
|
if (createBtn) {
|
|
createBtn.addEventListener('click', function() {
|
|
window.location.href = '/survey.html';
|
|
});
|
|
}
|
|
});
|
|
|
|
// 全局变量,用于报告管理器实例
|
|
window.ReportListManager = class ReportListManager {
|
|
constructor() {
|
|
this.reports = [];
|
|
this.allReports = [];
|
|
this.currentPage = 1;
|
|
this.pageSize = 10;
|
|
this.totalPages = 1;
|
|
this.totalRecords = 0;
|
|
window.reportManager = this;
|
|
this.init();
|
|
}
|
|
|
|
async init() {
|
|
try {
|
|
await this.fetchReports();
|
|
this.render();
|
|
} catch (error) {
|
|
console.error('初始化失败:', error);
|
|
this.showError(`数据加载失败: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
async fetchReports() {
|
|
try {
|
|
document.getElementById('loading').style.display = 'block';
|
|
|
|
const response = await fetch(`/api/reports?page=${this.currentPage}&pageSize=${this.pageSize}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'content-type': 'application/json'
|
|
}
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`API请求失败: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
this.reports = data.reports || [];
|
|
this.totalRecords = data.total || 0;
|
|
this.totalPages = data.total_pages || 1;
|
|
this.currentPage = data.page || 1;
|
|
|
|
document.getElementById('loading').style.display = 'none';
|
|
|
|
if (this.reports.length === 0) {
|
|
document.getElementById('empty').style.display = 'block';
|
|
document.getElementById('table-content').style.display = 'none';
|
|
} else {
|
|
document.getElementById('empty').style.display = 'none';
|
|
document.getElementById('table-content').style.display = 'block';
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('获取报告失败:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
render() {
|
|
this.renderTable();
|
|
this.renderPagination();
|
|
}
|
|
|
|
renderTable() {
|
|
const tbody = document.getElementById('report-list');
|
|
tbody.innerHTML = '';
|
|
|
|
this.reports.forEach((report, index) => {
|
|
const row = document.createElement('tr');
|
|
|
|
// 解析时间戳并转换为东八区时间
|
|
const dateObj = new Date(report.generated_at);
|
|
// 加8小时转换为东八区时间
|
|
const east8Time = new Date(dateObj.getTime() + 8 * 60 * 60 * 1000);
|
|
|
|
// 格式化为 YYYY-MM-DD HH:MM
|
|
const year = east8Time.getFullYear();
|
|
const month = String(east8Time.getMonth() + 1).padStart(2, '0');
|
|
const day = String(east8Time.getDate()).padStart(2, '0');
|
|
const hours = String(east8Time.getHours()).padStart(2, '0');
|
|
const minutes = String(east8Time.getMinutes()).padStart(2, '0');
|
|
|
|
const date = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
|
|
row.innerHTML = `
|
|
<td class="name-cell">${report.name}</td>
|
|
<td class="time-cell">${date}</td>
|
|
<td class="score-cell">${report.total_score}分</td>
|
|
<td class="grade-cell">${report.grade}</td>
|
|
<td class="school-cell">${report.school}</td>
|
|
<td class="action-cell">
|
|
<a href="/public/report.html?id=${report.id}" class="view-btn">查看报告</a>
|
|
</td>
|
|
`;
|
|
|
|
tbody.appendChild(row);
|
|
});
|
|
}
|
|
|
|
renderPagination() {
|
|
const pagination = document.getElementById('pagination-left');
|
|
const pageInfo = document.querySelector('.page-info');
|
|
const controls = document.querySelector('.pagination-controls');
|
|
|
|
if (!pageInfo || !controls) return;
|
|
|
|
pageInfo.textContent = `第 ${this.currentPage} 页,共 ${this.totalPages} 页`;
|
|
|
|
const pageSizeSelect = document.querySelector('.page-size-select');
|
|
if (pageSizeSelect) {
|
|
pageSizeSelect.value = this.pageSize;
|
|
}
|
|
|
|
controls.innerHTML = '';
|
|
|
|
const prevBtn = document.createElement('button');
|
|
prevBtn.className = 'pagination-btn';
|
|
prevBtn.textContent = '上一页';
|
|
prevBtn.disabled = this.currentPage === 1;
|
|
prevBtn.onclick = () => this.goToPage(this.currentPage - 1);
|
|
controls.appendChild(prevBtn);
|
|
|
|
const startPage = Math.max(1, this.currentPage - 2);
|
|
const endPage = Math.min(this.totalPages, this.currentPage + 2);
|
|
|
|
if (startPage > 1) {
|
|
this.addPageButton(controls, 1);
|
|
if (startPage > 2) {
|
|
const ellipsis = document.createElement('span');
|
|
ellipsis.className = 'pagination-ellipsis';
|
|
ellipsis.textContent = '...';
|
|
controls.appendChild(ellipsis);
|
|
}
|
|
}
|
|
|
|
for (let i = startPage; i <= endPage; i++) {
|
|
this.addPageButton(controls, i);
|
|
}
|
|
|
|
if (endPage < this.totalPages) {
|
|
if (endPage < this.totalPages - 1) {
|
|
const ellipsis = document.createElement('span');
|
|
ellipsis.className = 'pagination-ellipsis';
|
|
ellipsis.textContent = '...';
|
|
controls.appendChild(ellipsis);
|
|
}
|
|
this.addPageButton(controls, this.totalPages);
|
|
}
|
|
|
|
const nextBtn = document.createElement('button');
|
|
nextBtn.className = 'pagination-btn';
|
|
nextBtn.textContent = '下一页';
|
|
nextBtn.disabled = this.currentPage === this.totalPages;
|
|
nextBtn.onclick = () => this.goToPage(this.currentPage + 1);
|
|
controls.appendChild(nextBtn);
|
|
}
|
|
|
|
addPageButton(container, pageNum) {
|
|
const btn = document.createElement('button');
|
|
btn.className = `pagination-btn ${pageNum === this.currentPage ? 'active' : ''}`;
|
|
btn.textContent = pageNum;
|
|
btn.onclick = () => this.goToPage(pageNum);
|
|
container.appendChild(btn);
|
|
}
|
|
|
|
async goToPage(page) {
|
|
if (page < 1 || page > this.totalPages || page === this.currentPage) {
|
|
return;
|
|
}
|
|
|
|
this.currentPage = page;
|
|
await this.fetchReports();
|
|
this.render();
|
|
}
|
|
|
|
async changePageSize(pageSize) {
|
|
if (pageSize === this.pageSize) {
|
|
return;
|
|
}
|
|
|
|
this.pageSize = pageSize;
|
|
this.currentPage = 1;
|
|
await this.fetchReports();
|
|
this.render();
|
|
}
|
|
|
|
showError(message) {
|
|
const errorDiv = document.getElementById('error');
|
|
errorDiv.textContent = message;
|
|
errorDiv.style.display = 'block';
|
|
|
|
setTimeout(() => {
|
|
errorDiv.style.display = 'none';
|
|
}, 5000);
|
|
}
|
|
};
|
|
</script>
|
|
<script src="report-list.js"></script>
|
|
</body>
|
|
</html> |