学生成绩管理系统
1、简介
2、系统设计
3、数据库设计(sys_grade)
3.1、管理员表(sys_admin)
drop table sys_admin;
create table sys_admin
(
`admin_id` int primary key auto_increment not null comment '主键自增',
`admin_name` varchar(20) comment '管理员账号',
`admin_nick` varchar(20) comment '管理员昵称',
`admin_pwd` varchar(20) comment '管理员密码',
`admin_phone` varchar(20) comment '管理员电话'
);
insert into sys_admin(`admin_name`,`admin_nick`,`admin_pwd`,`admin_phone`) values
('admin', '系统管理员', 'admin', '13377254691'),
('ruanjia', 'Ruanjia管理员', 'ruanjia', '13377254692'),
('test', '测试管理员', '123456', '13377254693')
select * from sys_admin;
3.2、教师表(sys_teacher)
drop table sys_teacher;
create table sys_teacher
(
`teacher_id` int primary key auto_increment not null comment '主键(教师编号)',
`teacher_pwd` varchar(32) not null comment '教师密码',
`teacher_name` varchar(10) comment '教师名称',
`teacher_phone` varchar(11) comment '教师电话'
);
insert into sys_teacher(`teacher_name`, `teacher_p`,`teacher_phone`) values
('刘日辉', '123456', '13766876555'),
('欧文辉', '123456', '13766876556'),
('秦 玉', '123456', '13766876557')
select * from sys_teacher;
3.3、学生表(sys_student)
drop table sys_student;
create table sys_student
(
`student_id` int primary key auto_increment not null comment '主键',
`student_number` varchar(10) not null comment '学号',
`student_pwd` varchar(32) not null comment '密码',
`student_name` varchar(10) not null comment '学生姓名',
`professional_id` int not null comment '学生所属专业编号',
`class` int not null comment '学生班级',
`student_phone` varchar(11) not null comment '学生手机号码'
);
insert into sys_student(`student_number`, `student_name`, `professional_id`, `class`, `student_phone`)values
('2120180331', '蔡蔡一', 1, 1, '13377254691'),
('2120180332', '蔡蔡二', 1, 1, '13377254692'),
('2120180333', '蔡蔡三', 1, 1, '13377254693'),
('2120180334', '蔡蔡四', 1, 2, '13377254694'),
('2120180335', '蔡蔡五', 1, 3, '13377254695');
select * from sys_student;
3.4、院系表(sys_professional)
drop table sys_professional;
create table sys_professional
(
`professional_id` int primary key auto_increment not null comment '主键',
`professional_name` varchar(20) not null comment '院系\专业名称',
`pid` varchar(3) not null comment '值为 0 标识为院系,其他代表院系专业',
`professional_course` varchar(20) not null comment '院系\专业的课程'
);
insert into sys_professional(`professional_name`, `pid`, `professional_course`) values
('计算机应用技术', '1', 'xxx'),
('信息工程学院', '0', ''),
('教育学院', '0', ''),
('软甲工程学院', '0', ''),
('商学院', '0', ''),
('汽车工程学院', '0', '')
select * from sys_professional;
3.5、课程表(sys_course)
drop table sys_course;
create table sys_course
(
`course_id` int primary key auto_increment not null comment '主键',
`course_name` varchar(20) not null comment '课程名称'
);
insert into sys_course(`course_name`) values
('PHP程序设计基础教程'),
('计算机网络原理'),
('计算机组成原理'),
('C++入门基础教程'),
('Spring 5 核心原理'),
('Spring Cloud Alibaba 微服务原理与实战')
select * from sys_course;
3.6、任课表(sys_ct)
drop table sys_ct;
create table sys_ct
(
`ct_id` int primary key auto_increment not null comment '主键',
`ct_time` char(10) not null comment '任课时间(例如:202201)',
`course_id` int not null comment '课程编号',
`professional_id` int not null comment '专业编号',
`teacher_id` int not null comment '教师编号',
`ct_student_time` varchar(4) not null comment '学生哪一届(例如:18届)'
)
insert into sys_ct(`ct_time`, `course_id`, `professional_id`, `teacher_id`, `ct_student_time`) values
('20220527', 1, 6, 1, '18届')
select * from sys_ct;
3.7、任课申请表(sys_audit_course)
drop table sys_audit_course;
create table sys_audit_course
(
`audit_id` int primary key auto_increment not null comment '主键',
`is_audit` varchar(1) not null comment '审核状态:0未审核,1审核通过,2审核未通过',
`time` varchar(10) not null comment '任课时间',
`course_id` int not null comment '课程编号',
`professional_id` int not null comment '专业编号',
`teacher_id` int not null comment '教师编号',
`student_time` varchar(4) not null comment '那一届的学生',
`audit_time` datetime not null comment '申请审核的时间'
);
insert into
select * from sys_audit_course;
3.8、成绩表(sys_grade)
drop table sys_grade;
create table sys_grade
(
`grade_id` int primary key auto_increment not null comment '主键',
`ct_id` int not null comment '任课编号',
`student_n` int not null comment '学生编号',
`grade_value` int not null comment '成绩'
);
select * from sys_grade;
4、后台管理开发
4.1、需要使用的工具类
1、MySQL连接工具类
<!-- 数据库连接工具类 -->
<?php
class DBUtils
{
private static $host = "mysql:dbname=sys_grade;host=127.0.0.1:3308";
private static $username = "root";
private static $password = "";
public static function selectAll($sql)
{
$result = self::db_connect() -> query($sql);
$resAll = $result-> fetchAll();
$result = null;
return $resAll;
}
public static function insert($sql)
{
$result = self::db_connect() -> exec($sql);
$counts = $result;
$result = null;
return $counts;
}
public static function delete($sql)
{
$result = self::db_connect() -> exec($sql);
$counts = $result;
$result = null;
return $counts;
}
public static function update($sql)
{
$result = self::db_connect() -> exec($sql);
$counts = $result;
$result = null;
return $counts;
}
private static function db_connect()
{
return new pdo(self::$host,self::$username,self::$password);
}
}
2、StringUtils工具类
<?php
class StringUtils
{
private static $isEmpty = "";
private static $isNull = null;
public static function isEmpty(string $str)
{
return self::isBlank($str) || self::$isEmpty == $str ? true : false;
}
public static function isBlank($obj)
{
return self::$isNull == $obj ? true : false;
}
}
4.2、实体对象
1、管理员实体
<?php
class sysAdmin
{
private $adminId;
private $adminName;
private $adminNick;
private $adminPwd;
private $adminPhone;
public function __construct($adminId, $adminName, $adminNick, $adminPwd, $adminPhone)
{
$this->adminId = $adminId;
$this->adminName = $adminName;
$this->adminNick = $adminNick;
$this->adminPwd = $adminPwd;
$this->adminPhone = $adminPhone;
}
public function getAdminId()
{
return $this->adminId;
}
public function setAdminId($adminId): void
{
$this->adminId = $adminId;
}
public function getAdminName()
{
return $this->adminName;
}
public function setAdminName($adminName): void
{
$this->adminName = $adminName;
}
public function getAdminNick()
{
return $this->adminNick;
}
public function setAdminNick($adminNick): void
{
$this->adminNick = $adminNick;
}
public function getAdminPwd()
{
return $this->adminPwd;
}
public function setAdminPwd($adminPwd): void
{
$this->adminPwd = $adminPwd;
}
public function getAdminPhone()
{
return $this->adminPhone;
}
public function setAdminPhone($adminPhone): void
{
$this->adminPhone = $adminPhone;
}
public function toString()
{
return
[
"adminId" => $this->adminId,
"adminName" => $this->adminName,
"adminNick" => $this->adminNick,
"adminPwd" => $this->adminPwd,
"adminPhone" => $this->adminPhone,
];
}
}
2、教师实体
<?php
class SysTeacher
{
private $teacherId;
private $teacherName;
private $teacherPwd;
private $teacherPhone;
public function __construct($teacherId, $teacherName, $teacherPwd, $teacherPhone)
{
$this->teacherId = $teacherId;
$this->teacherName = $teacherName;
$this->teacherPwd = $teacherPwd;
$this->teacherPhone = $teacherPhone;
}
public function getTeacherId()
{
return $this->teacherId;
}
public function setTeacherId($teacherId): void
{
$this->teacherId = $teacherId;
}
public function getTeacherName()
{
return $this->teacherName;
}
public function setTeacherName($teacherName): void
{
$this->teacherName = $teacherName;
}
public function getTeacherPwd()
{
return $this->teacherPwd;
}
public function setTeacherPwd($teacherPwd): void
{
$this->teacherPwd = $teacherPwd;
}
public function getTeacherPhone()
{
return $this->teacherPhone;
}
public function setTeacherPhone($teacherPhone): void
{
$this->teacherPhone = $teacherPhone;
}
public function toString()
{
return
[
"teacherId" => $this->teacherId,
"teacherName" => $this->teacherName,
"teacherPwd" => $this->teacherPwd,
"teacherPhone" => $this->teacherPhone,
];
}
}
3、学生实体
<?php
class SysStudent
{
private $studentId;
private $studentNumber;
private $studentPwd;
private $studentName;
private $professionalId;
private $class;
private $studentPhone;
public function __construct($studentId, $studentNumber, $studentPwd, $studentName, $professionalId, $class, $studentPhone)
{
$this->studentId = $studentId;
$this->studentNumber = $studentNumber;
$this->studentPwd = $studentPwd;
$this->studentName = $studentName;
$this->professionalId = $professionalId;
$this->class = $class;
$this->studentPhone = $studentPhone;
}
public static function foreachStudent(array $data)
{
$user = [];
foreach ($data as $time => $chi)
{
$sysStudent = new SysStudent
(
$chi['student_id'],
$chi['student_number'],
$chi['student_pwd'],
$chi['student_name'],
$chi['professional_id'],
$chi['class'],
$chi['student_phone']
);
$sysStudent = $sysStudent -> toString();
array_push($user, $sysStudent);
}
return $user;
}
public function getStudentId()
{
return $this->studentId;
}
public function setStudentId($studentId): void
{
$this->studentId = $studentId;
}
public function getStudentNumber()
{
return $this->studentNumber;
}
public function setStudentNumber($studentNumber): void
{
$this->studentNumber = $studentNumber;
}
public function getStudentPwd()
{
return $this->studentPwd;
}
public function setStudentPwd($studentPwd): void
{
$this->studentPwd = $studentPwd;
}
public function getStudentName()
{
return $this->studentName;
}
public function setStudentName($studentName): void
{
$this->studentName = $studentName;
}
public function getProfessionalId()
{
return $this->professionalId;
}
public function setProfessionalId($professionalId): void
{
$this->professionalId = $professionalId;
}
public function getClass()
{
return $this->class;
}
public function setClass($class): void
{
$this->class = $class;
}
public function getStudentPhone()
{
return $this->studentPhone;
}
public function setStudentPhone($studentPhone): void
{
$this->studentPhone = $studentPhone;
}
public function toString()
{
return
[
"studentId" => $this->studentId,
"studentNumber" => $this->studentNumber,
"studentPwd" => $this->studentPwd,
"studentName" => $this->studentName,
"professionalId" => $this->professionalId,
"class" => $this->class,
"studentPhone" => $this->studentPhone,
];
}
}
4、院系实体
<?php
class SysProfessional
{
private $professionalId;
private $professionalName;
private $pid;
private $professionalCourse;
public function __construct($professionalId, $professionalName, $pid, $professionalCourse)
{
$this->professionalId = $professionalId;
$this->professionalName = $professionalName;
$this->pid = $pid;
$this->professionalCourse = $professionalCourse;
}
public function getProfessionalId()
{
return $this->professionalId;
}
public function setProfessionalId($professionalId): void
{
$this->professionalId = $professionalId;
}
public function getProfessionalName()
{
return $this->professionalName;
}
public function setProfessionalName($professionalName): void
{
$this->professionalName = $professionalName;
}
public function getPid()
{
return $this->pid;
}
public function setPid($pid): void
{
$this->pid = $pid;
}
public function getProfessionalCourse()
{
return $this->professionalCourse;
}
public function setProfessionalCourse($professionalCourse): void
{
$this->professionalCourse = $professionalCourse;
}
public function toString()
{
return
[
"professionalId" => $this->professionalId,
"professionalName" => $this->professionalName,
"pid" => $this->pid,
"professionalCourse" => $this->professionalCourse,
];
}
}
5、课程实体
<?php
class SysCourse
{
private $courseId;
private $courseName;
public function __construct($courseId, $courseName)
{
$this->courseId = $courseId;
$this->courseName = $courseName;
}
public function getCourseId()
{
return $this->courseId;
}
public function setCourseId($courseId): void
{
$this->courseId = $courseId;
}
public function getCourseName()
{
return $this->courseName;
}
public function setCourseName($courseName): void
{
$this->courseName = $courseName;
}
public function toString()
{
return
[
"courseId" => $this->courseId,
"courseName" => $this->courseName
];
}
}
6、任课实体
<?php
class SysCt
{
private $ctId;
private $ctTime;
private $courseId;
private $professionalId;
private $teacherId;
private $ctStudentTime;
public function __construct($ctId, $ctTime, $courseId, $professionalId, $teacherId, $ctStudentTime)
{
$this->ctId = $ctId;
$this->ctTime = $ctTime;
$this->courseId = $courseId;
$this->professionalId = $professionalId;
$this->teacherId = $teacherId;
$this->ctStudentTime = $ctStudentTime;
}
public function getCtId()
{
return $this->ctId;
}
public function setCtId($ctId): void
{
$this->ctId = $ctId;
}
public function getCtTime()
{
return $this->ctTime;
}
public function setCtTime($ctTime): void
{
$this->ctTime = $ctTime;
}
public function getCourseId()
{
return $this->courseId;
}
public function setCourseId($courseId): void
{
$this->courseId = $courseId;
}
public function getProfessionalId()
{
return $this->professionalId;
}
public function setProfessionalId($professionalId): void
{
$this->professionalId = $professionalId;
}
public function getTeacherId()
{
return $this->teacherId;
}
public function setTeacherId($teacherId): void
{
$this->teacherId = $teacherId;
}
public function getCtStudentTime()
{
return $this->ctStudentTime;
}
public function setCtStudentTime($ctStudentTime): void
{
$this->ctStudentTime = $ctStudentTime;
}
public function toString()
{
return
[
"ctId" => $this->ctId,
"ctTime" => $this->ctTime,
"courseId" => $this->courseId,
"professionalId" => $this->professionalId,
"teacherId" => $this->teacherId,
"ctStudentTime" => $this->ctStudentTime
];
}
}
7、任课申请实体
<?php
class SysAuditCourse
{
private $auditId;
private $isAudit;
private $time;
private $courseId;
private $professionalId;
private $teacherId;
private $studentTime;
private $auditTime;
public function __construct($auditId, $isAudit, $time, $courseId, $professionalId, $teacherId, $studentTime, $auditTime)
{
$this->auditId = $auditId;
$this->isAudit = $isAudit;
$this->time = $time;
$this->courseId = $courseId;
$this->professionalId = $professionalId;
$this->teacherId = $teacherId;
$this->studentTime = $studentTime;
$this->auditTime = $auditTime;
}
public function getAuditId()
{
return $this->auditId;
}
public function setAuditId($auditId): void
{
$this->auditId = $auditId;
}
public function getIsAudit()
{
return $this->isAudit;
}
public function setIsAudit($isAudit): void
{
$this->isAudit = $isAudit;
}
public function getTime()
{
return $this->time;
}
public function setTime($time): void
{
$this->time = $time;
}
public function getCourseId()
{
return $this->courseId;
}
public function setCourseId($courseId): void
{
$this->courseId = $courseId;
}
public function getProfessionalId()
{
return $this->professionalId;
}
public function setProfessionalId($professionalId): void
{
$this->professionalId = $professionalId;
}
public function getTeacherId()
{
return $this->teacherId;
}
public function setTeacherId($teacherId): void
{
$this->teacherId = $teacherId;
}
public function getStudentTime()
{
return $this->studentTime;
}
public function setStudentTime($studentTime): void
{
$this->studentTime = $studentTime;
}
public function getAuditTime()
{
return $this->auditTime;
}
public function setAuditTime($auditTime): void
{
$this->auditTime = $auditTime;
}
public function toString()
{
return
[
"auditId" => $this->auditId,
"isAudit" => $this->isAudit,
"time" => $this->time,
"courseId" => $this->courseId,
"professionalId" => $this->professionalId,
"teacherId" => $this->teacherId,
"studentTime" => $this->studentTime,
"auditTime" => $this->auditTime
];
}
}
8、成绩实体
<?php
class SysGrade
{
private $gradeId;
private $ctId;
private $studentId;
private $gradeValue;
public function __construct($gradeId, $ctId, $studentId, $gradeValue)
{
$this->gradeId = $gradeId;
$this->ctId = $ctId;
$this->studentId = $studentId;
$this->gradeValue = $gradeValue;
}
public function getGradeId()
{
return $this->gradeId;
}
public function setGradeId($gradeId): void
{
$this->gradeId = $gradeId;
}
public function getCtId()
{
return $this->ctId;
}
public function setCtId($ctId): void
{
$this->ctId = $ctId;
}
public function getStudentId()
{
return $this->studentId;
}
public function setStudentId($studentId): void
{
$this->studentId = $studentId;
}
public function getGradeValue()
{
return $this->gradeValue;
}
public function setGradeValue($gradeValue): void
{
$this->gradeValue = $gradeValue;
}
public function toString()
{
return
[
"gradeId" => $this->gradeId,
"ctId" => $this->ctId,
"studentId" => $this->studentId,
"gradeValue" => $this->gradeValue
];
}
}
9、系统菜单实体
4.3、功能开发
1、登录接口开发
<?php
require('../result/ResultInfo.php');
require('../utils/DBUtils.php');
require('../utils/StringUtils.php');
require('../entity/SysStudent.php');
require('../entity/SysMenu.php');
require('../entity/SysTeacher.php');
$username = $_POST['username'];
$password = $_POST['password'];
$code = $_POST['code'];
function login($username, $password, $code)
{
if (!StringUtils::isEmpty($username) && $code == "0")
{
$data = DBUtils::selectAll("select * from sys_student where student_number=$username limit 1");
if (!StringUtils::isBlank($data))
{
$user = sysstudent::foreachStudent($data);
$menus = sysmenu::getStudentMenuList();
if (!StringUtils::isEmpty($password) && $user[0]['studentPwd'] == $password)
{
echo ResultInfo::ok([
"userInfo" => $user,
"menus" => $menus
]);
} else
{
echo ResultInfo::error("密码错误!");
}
} else
{
echo ResultInfo::error("该学生【 $username 】不存在,请联系老师!");
}
}
else if (!StringUtils::isEmpty($username) && $code == "1")
{
$data = DBUtils::selectAll("select * from sys_teacher where teacher_id=$username");
if (!StringUtils::isBlank($data))
{
$user = systeacher::foreachTeacher($data);
$menus = sysmenu::getTeacherMenuList();
if (!StringUtils::isEmpty($password) && $user[0]['teacherPwd'] == $password)
{
echo ResultInfo::ok([
"userInfo" => $user,
"menus" => $menus
]);
} else
{
echo ResultInfo::error("密码错误!");
}
} else
{
echo ResultInfo::error("该教师【 $username 】不存在,请联系学校领导!");
}
}
else
{
echo ResultInfo::error("系统异常,请联系管理员!");
}
}
login($username,$password,$code);
5、前台管理开发
5.1、JS-JSON
JSON.stringify()
JSON.parse()