feat: 多班级版班级管理系统 v2.0

技术栈:Go (Gin + GORM) + PHP + MySQL 5.7 + Redis

主要功能:
- 多班级完全隔离(class_id 贯穿全系统)
- 后端 Go Gin(端口 56789),Nginx 反代
- 超级管理员独立登录(env 配置,默认账密 admin/Admin123)
- bcrypt 密码加密(无 PASSWORD_SALT)
- 科任老师/课代表新角色
- 课代表作业管理页面
- 排行榜分项排行(操行分/考勤/作业)
- 角色加减分上下限由班主任配置
- 家长改密功能(可开关)
- 班级角色按需开关
- 宿舍号格式:南0-000
- 周度/月度重置功能
- MySQL 5.7 兼容
- 43 轮代码审查 + 全部修复

开发者: Canglan
版权归属: Sea Network Technology Studio
许可证: Apache License 2.0
This commit is contained in:
2026-06-22 10:21:52 +08:00
commit 16059ad3bf
135 changed files with 19933 additions and 0 deletions

View File

@@ -0,0 +1,264 @@
<?php
/**
* 多班级版班级管理系统 - 学期管理页面
*
* 开发者: Canglan
* 联系方式: admin@sea-studio.top
* 版权归属: Sea Network Technology Studio
* 许可证: Apache License 2.0
*
* 版权所有 © Sea Network Technology Studio
*/
require_once __DIR__ . '/../config.php';
if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_type'], ['admin', 'super_admin'])) {
header('Location: /index.php');
exit();
}
$role = $_SESSION['role'] ?? '';
if ($role !== '班主任') {
header('Location: /admin/dashboard.php');
exit();
}
$page_title = '学期管理';
include __DIR__ . '/../includes/header.php';
?>
<?php include __DIR__ . '/../includes/nav.php'; ?>
<div class="container">
<!-- 周期重置 -->
<div class="card">
<h3>周期重置</h3>
<p class="text-muted" style="margin-bottom:15px;">手动触发当前班级的周/月操行分重置(重置前会自动创建分数快照)</p>
<div class="action-bar">
<button class="btn btn-warning" onclick="confirmPeriodReset('weekly')">执行本周重置</button>
<button class="btn btn-warning" onclick="confirmPeriodReset('monthly')">执行本月重置</button>
<button class="btn btn-secondary" onclick="showPeriodArchives('weekly')">查看周归档</button>
<button class="btn btn-secondary" onclick="showPeriodArchives('monthly')">查看月归档</button>
</div>
</div>
<div class="card">
<div class="action-bar">
<button class="btn btn-primary" onclick="showCreateSemesterModal()">创建新学期</button>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th>学期名称</th>
<th>开始日期</th>
<th>结束日期</th>
<th>当前周数</th>
<th>状态</th>
<th>记录数</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody id="semesterList"></tbody>
</table>
</div>
</div>
</div>
<!-- 创建学期模态框 -->
<div id="createSemesterModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>创建新学期</h3>
<button class="modal-close" onclick="closeModal('createSemesterModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitCreateSemester()">
<div class="form-group">
<label>学期名称 <span style="color:red;">*</span></label>
<input type="text" id="semesterName" required placeholder="如2025春季学期" maxlength="100">
</div>
<div style="margin-bottom: 8px;">
<button type="button" class="btn btn-sm btn-outline" style="margin-right: 6px;" onclick="fillSemesterDates('upper')">上学期9月-次年2月</button>
<button type="button" class="btn btn-sm btn-outline" onclick="fillSemesterDates('lower')">下学期3月-7月</button>
</div>
<div class="form-group">
<label>开始日期</label>
<input type="date" id="semesterStartDate">
</div>
<div class="form-group">
<label>结束日期 <small style="color: #999;">(可选)</small></label>
<input type="date" id="semesterEndDate" placeholder="可选,不确定可不填">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">创建学期</button>
<button type="button" class="btn" onclick="closeModal('createSemesterModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 编辑学期模态框 -->
<div id="editSemesterModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>编辑学期</h3>
<button class="modal-close" onclick="closeModal('editSemesterModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitEditSemester()">
<input type="hidden" id="editSemesterId">
<div class="form-group">
<label>学期名称 <span style="color:red;">*</span></label>
<input type="text" id="editSemesterName" required placeholder="如2025春季学期" maxlength="100">
</div>
<div class="form-group">
<label>开始日期</label>
<input type="date" id="editSemesterStartDate">
</div>
<div class="form-group">
<label>结束日期 <small style="color: #999;">(可选)</small></label>
<input type="date" id="editSemesterEndDate">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">保存修改</button>
<button type="button" class="btn btn-danger" onclick="deleteSemester()">删除学期</button>
<button type="button" class="btn" onclick="closeModal('editSemesterModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 关联数据确认模态框 -->
<div id="associateConfirmModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>关联数据到学期</h3>
<button class="modal-close" onclick="closeModal('associateConfirmModal')">&times;</button>
</div>
<div class="form-group">
<p id="associateConfirmText" style="margin: 10px 0;"></p>
<p style="color: #666; font-size: 14px;">将把该日期范围内所有未分配学期的操行分记录和考勤记录关联到此学期。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="confirmAssociate()">确认关联</button>
<button type="button" class="btn" onclick="closeModal('associateConfirmModal')">取消</button>
</div>
</div>
</div>
<!-- 归档确认模态框 -->
<div id="archiveConfirmModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>确认归档学期</h3>
<button class="modal-close" onclick="closeModal('archiveConfirmModal')">&times;</button>
</div>
<div class="form-group">
<p id="archiveConfirmText" style="margin: 10px 0;"></p>
<p style="color: #666; font-size: 14px;">归档会创建所有学生当前操行分的数据快照,原始数据不受影响。</p>
<div style="margin-top: 10px;">
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px;">
<input type="checkbox" id="archiveResetScores">
归档后重置所有学生操行分为初始值60分
</label>
</div>
<p style="color: #e74c3c; font-size: 13px; margin-top: 6px;">注意:归档前需确保学期已设置开始日期,否则无法归档。归档后该学期数据将变为只读,不可撤销。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="confirmArchive()">确认归档</button>
<button type="button" class="btn" onclick="closeModal('archiveConfirmModal')">取消</button>
</div>
</div>
</div>
<!-- 归档数据查看模态框 -->
<div id="archiveDataModal" class="modal">
<div class="modal-content" style="max-width: 700px;">
<div class="modal-header">
<h3 id="archiveDataTitle">归档数据</h3>
<button class="modal-close" onclick="closeModal('archiveDataModal')">&times;</button>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th colspan="2" style="text-align:center; border-bottom: none;">基本信息</th>
<th rowspan="2" style="vertical-align: middle;">姓名</th>
<th rowspan="2" style="vertical-align: middle;">操行分</th>
<th colspan="4" style="text-align:center; border-bottom: none;">考勤统计</th>
<th colspan="3" style="text-align:center; border-bottom: none;">作业统计</th>
</tr>
<tr>
<th>排名</th>
<th>学号</th>
<th>出勤</th>
<th>缺勤</th>
<th>迟到</th>
<th>请假</th>
<th>已交</th>
<th>未交</th>
<th>迟交</th>
</tr>
</thead>
<tbody id="archiveDataList"></tbody>
</table>
</div>
<div class="pagination" id="archivePagination"></div>
<div class="modal-footer">
<button type="button" class="btn" onclick="closeModal('archiveDataModal')">关闭</button>
</div>
</div>
</div>
<!-- 周期重置确认模态框 -->
<div id="periodResetModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>确认周期重置</h3>
<button class="modal-close" onclick="closeModal('periodResetModal')">&times;</button>
</div>
<div class="form-group">
<p id="periodResetText" style="margin: 10px 0;"></p>
<p style="color: #e74c3c; font-size: 13px; margin-top: 6px;">注意:重置前会自动保存当前操行分快照,重置后所有学生操行分将恢复为初始值。此操作不可撤销。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" onclick="executePeriodReset()">确认重置</button>
<button type="button" class="btn" onclick="closeModal('periodResetModal')">取消</button>
</div>
</div>
</div>
<!-- 周期归档数据查看模态框 -->
<div id="periodArchivesModal" class="modal">
<div class="modal-content" style="max-width: 600px;">
<div class="modal-header">
<h3 id="periodArchivesTitle">周期归档数据</h3>
<button class="modal-close" onclick="closeModal('periodArchivesModal')">&times;</button>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th>周期标签</th>
<th>排名</th>
<th>学号</th>
<th>姓名</th>
<th>操行分</th>
<th>触发方式</th>
<th>归档时间</th>
</tr>
</thead>
<tbody id="periodArchivesList"></tbody>
</table>
</div>
<div class="pagination" id="periodArchivePagination"></div>
<div class="modal-footer">
<button type="button" class="btn" onclick="closeModal('periodArchivesModal')">关闭</button>
</div>
</div>
</div>
<script src="/assets/js/modules/modal-utils.js"></script>
<script src="/assets/js/semesters.js"></script>
<?php include __DIR__ . '/../includes/footer.php'; ?>