v0.6测试
This commit is contained in:
@@ -20,7 +20,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
||||
$page_title = '操行分管理';
|
||||
$role = $_SESSION['role'] ?? '';
|
||||
|
||||
if (!in_array($role, ['班主任', '班长'])) {
|
||||
if (!in_array($role, ['班主任', '班长', '劳动委员'])) {
|
||||
header('Location: /admin/dashboard.php');
|
||||
exit();
|
||||
}
|
||||
@@ -112,7 +112,11 @@ loadStudents();
|
||||
<div class="form-group">
|
||||
<label>分数变动</label>
|
||||
<input type="number" id="pointsChange" required placeholder="正数为加分,负数为扣分">
|
||||
<small><?php echo $role === '班长' ? '班长单次±5分以内' : '班主任无限制'; ?></small>
|
||||
<small><?php
|
||||
if ($role === '班长') echo '班长单次±5分以内';
|
||||
elseif ($role === '劳动委员') echo '劳动委员仅限±1分';
|
||||
else echo '班主任无限制';
|
||||
?></small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>原因</label>
|
||||
|
||||
@@ -58,7 +58,7 @@ async function loadDashboard() {
|
||||
}
|
||||
|
||||
let quickActions = '';
|
||||
if ('<?php echo $role; ?>' === '班主任' || '<?php echo $role; ?>' === '班长') {
|
||||
if ('<?php echo $role; ?>' === '班主任' || '<?php echo $role; ?>' === '班长' || '<?php echo $role; ?>' === '劳动委员') {
|
||||
quickActions += '<button class="btn btn-primary" onclick="location.href=\'/admin/conduct.php\'">操行分管理</button>';
|
||||
}
|
||||
if ('<?php echo $role; ?>' === '班主任') {
|
||||
|
||||
@@ -66,8 +66,8 @@ include __DIR__ . '/../includes/header.php';
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentHistoryPage = 1;
|
||||
let totalHistoryPages = 1;
|
||||
var currentHistoryPage = 1;
|
||||
var totalHistoryPages = 1;
|
||||
|
||||
async function loadStudentsForSelect() {
|
||||
const res = await apiGet('/api/admin/students');
|
||||
@@ -86,12 +86,14 @@ async function loadHistory(page = 1) {
|
||||
const endDate = document.getElementById('historyEndDate').value;
|
||||
const studentId = document.getElementById('historyStudentId').value;
|
||||
|
||||
const res = await apiGet('/api/admin/conduct/history', {
|
||||
const params = {
|
||||
page, page_size: 20,
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
student_id: studentId
|
||||
});
|
||||
end_date: endDate
|
||||
};
|
||||
if (studentId) params.student_id = studentId;
|
||||
|
||||
const res = await apiGet('/api/admin/conduct/history', params);
|
||||
|
||||
if (res && res.success) {
|
||||
let html = '';
|
||||
|
||||
@@ -172,7 +172,6 @@ function handleSubmitPoints() {
|
||||
submitBatchPoints();
|
||||
}
|
||||
|
||||
loadStudents();
|
||||
loadStudents();
|
||||
</script>
|
||||
<script src="/assets/js/admin.js"></script>
|
||||
|
||||
@@ -112,8 +112,8 @@ include __DIR__ . '/../includes/header.php';
|
||||
|
||||
<script>
|
||||
const userRole = '<?php echo $role; ?>';
|
||||
let currentPage = 1;
|
||||
let totalPages = 1;
|
||||
var currentPage = 1;
|
||||
var totalPages = 1;
|
||||
|
||||
async function loadStudents(page = 1) {
|
||||
currentPage = page;
|
||||
|
||||
@@ -101,9 +101,17 @@ $_SESSION['real_name'] = $data['real_name'] ?? '';
|
||||
$_SESSION['role'] = $data['role'] ?? '';
|
||||
$_SESSION['login_time'] = time();
|
||||
|
||||
// 如果是学生,额外设置 student_id(与 user_id 相同)
|
||||
// 如果是学生,额外设置 student_id
|
||||
if ($data['user_type'] === 'student') {
|
||||
$_SESSION['student_id'] = $data['user_id'];
|
||||
if (empty($data['student_id'])) {
|
||||
http_response_code(400);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '学生类型必须提供 student_id'
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$_SESSION['student_id'] = $data['student_id'];
|
||||
}
|
||||
|
||||
// 保存 Session
|
||||
|
||||
@@ -58,7 +58,7 @@ define('JWT_STORAGE_KEY', $config['JWT_STORAGE_KEY']);
|
||||
define('USER_STORAGE_KEY', $config['USER_STORAGE_KEY']);
|
||||
define('SITE_NAME', $config['SITE_NAME']);
|
||||
define('SESSION_TIMEOUT', (int)$config['SESSION_TIMEOUT']);
|
||||
define('ICP_ENABLED', $config['ICP_ENABLED'] === 'false');
|
||||
define('ICP_ENABLED', $config['ICP_ENABLED'] !== 'false');
|
||||
define('ICP_NUMBER', $config['ICP_NUMBER'] ?? '');
|
||||
|
||||
// 扣分规则配置(有默认值,不强制要求在.env中配置)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="nav">
|
||||
<a href="/admin/dashboard.php" class="nav-item<?php echo $current_page === 'dashboard' ? ' active' : ''; ?>">首页</a>
|
||||
<a href="/admin/students.php" class="nav-item<?php echo $current_page === 'students' ? ' active' : ''; ?>">学生管理</a>
|
||||
<?php if ($role === '班主任' || $role === '班长'): ?>
|
||||
<?php if ($role === '班主任' || $role === '班长' || $role === '劳动委员'): ?>
|
||||
<a href="/admin/conduct.php" class="nav-item<?php echo $current_page === 'conduct' ? ' active' : ''; ?>">操行分管理</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($role === '班主任' || $role === '学习委员'): ?>
|
||||
|
||||
@@ -98,7 +98,8 @@ if (isset($_SESSION['user_id']) && isset($_SESSION['user_type'])) {
|
||||
user_type: userData.user_type,
|
||||
username: userData.username,
|
||||
real_name: userData.real_name,
|
||||
role: userData.role || ''
|
||||
role: userData.role || '',
|
||||
student_id: userData.student_id || null
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ include __DIR__ . '/../includes/header.php';
|
||||
|
||||
<div class="nav">
|
||||
<a href="/parent/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/parent/homework.php" class="nav-item">作业情况</a>
|
||||
<a href="/parent/attendance.php" class="nav-item active">考勤记录</a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ include __DIR__ . '/../includes/header.php';
|
||||
|
||||
<div class="nav">
|
||||
<a href="/student/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/student/conduct.php" class="nav-item">操行分</a>
|
||||
<a href="/student/conduct_history.php" class="nav-item">操行分</a>
|
||||
<a href="/student/homework.php" class="nav-item">作业</a>
|
||||
<a href="/student/attendance.php" class="nav-item active">考勤</a>
|
||||
<a href="/student/password.php" class="nav-item">修改密码</a>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'student') {
|
||||
header('Location: /index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
// 重定向到学生端首页的操行分标签
|
||||
header('Location: /student/dashboard.php');
|
||||
exit();
|
||||
|
||||
@@ -241,7 +241,12 @@ $student_id = $_SESSION['student_id'];
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE_URL = '<?php echo API_BASE_URL; ?>';
|
||||
window.API_BASE_URL = '<?php echo API_BASE_URL; ?>';
|
||||
window.JWT_STORAGE_KEY = '<?php echo JWT_STORAGE_KEY; ?>';
|
||||
window.USER_STORAGE_KEY = '<?php echo USER_STORAGE_KEY; ?>';
|
||||
</script>
|
||||
<script src="/assets/js/common.js"></script>
|
||||
<script>
|
||||
const STUDENT_ID = <?php echo $student_id; ?>;
|
||||
|
||||
let conductPage = 1;
|
||||
@@ -392,7 +397,7 @@ $student_id = $_SESSION['student_id'];
|
||||
res.data.homework.forEach(hw => {
|
||||
html += `
|
||||
<tr>
|
||||
<td>${hw.subject}</td>
|
||||
<td>${hw.subject_name}</td>
|
||||
<td>${hw.title}</td>
|
||||
<td>${hw.deadline}</td>
|
||||
<td>${getStatusBadge(hw.status, 'homework')}</td>
|
||||
@@ -508,6 +513,5 @@ $student_id = $_SESSION['student_id'];
|
||||
loadDashboard();
|
||||
checkForceChangePassword();
|
||||
</script>
|
||||
<script src="/assets/js/common.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -24,7 +24,7 @@ include __DIR__ . '/../includes/header.php';
|
||||
|
||||
<div class="nav">
|
||||
<a href="/student/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/student/conduct.php" class="nav-item">操行分</a>
|
||||
<a href="/student/conduct_history.php" class="nav-item">操行分</a>
|
||||
<a href="/student/homework.php" class="nav-item active">作业</a>
|
||||
<a href="/student/attendance.php" class="nav-item">考勤</a>
|
||||
<a href="/student/password.php" class="nav-item">修改密码</a>
|
||||
@@ -53,7 +53,7 @@ async function loadHomework() {
|
||||
let html = '';
|
||||
res.data.homework.forEach(hw => {
|
||||
html += `<tr>
|
||||
<td>${escapeHtml(hw.subject)}</td>
|
||||
<td>${escapeHtml(hw.subject_name)}</td>
|
||||
<td>${escapeHtml(hw.title)}</td>
|
||||
<td>${hw.deadline}</td>
|
||||
<td>${getStatusBadge(hw.status, 'homework')}</td>
|
||||
|
||||
@@ -23,7 +23,7 @@ include __DIR__ . '/../includes/header.php';
|
||||
|
||||
<div class="nav">
|
||||
<a href="/student/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/student/conduct.php" class="nav-item">操行分</a>
|
||||
<a href="/student/conduct_history.php" class="nav-item">操行分</a>
|
||||
<a href="/student/homework.php" class="nav-item">作业</a>
|
||||
<a href="/student/attendance.php" class="nav-item">考勤</a>
|
||||
<a href="/student/password.php" class="nav-item active">修改密码</a>
|
||||
|
||||
Reference in New Issue
Block a user