基于SSM實(shí)現(xiàn)的評(píng)教系統(tǒng)
?項(xiàng)目編號(hào):BS-GX-014
數(shù)據(jù)庫(kù):mysql
開(kāi)發(fā)工具:IDEA / ECLIPSE
開(kāi)發(fā)技術(shù):SSM 框架
本系統(tǒng)基于SSM框架實(shí)現(xiàn)。主要包含三個(gè)角色,管理員,老師,學(xué)生。管理員主要管理學(xué)生,老師,課程。學(xué)生可以進(jìn)行選課,選完課后可以對(duì)任課老師評(píng)價(jià)。老師可以查看自己的評(píng)價(jià)信息。
部分展示功能如下:
? ?管理員角色:
? ? ? ?









學(xué)生角色:




老師角色:



本項(xiàng)目功能完整,運(yùn)行無(wú)誤,適合做畢業(yè)設(shè)計(jì)使用,如有需要,請(qǐng)聯(lián)系作者。
部分核心代碼:
package one.controller;import java.util.List;
import javax.annotation.Resource;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import one.domain.Admin;import one.domain.Curriculum;import one.domain.Evaluate;import one.domain.PageBean;import one.domain.Student;import one.domain.Teacher;import one.service.AdminService;import one.service.CurriculumService;import one.service.ManyTableService;import one.service.StudentService;import one.service.TeacherService;import one.vo.Details;import one.vo.ManyTable;import one.vo.Tea_Curri;public class AdminController {
private ManyTableService mts;
private StudentService stus;
private TeacherService teas;
private AdminService adms;
private CurriculumService curs;
public String seetea(Model model) throws Exception{
List<Tea_Curri> listtea_curri = mts.gettea_curri();
model.addAttribute("listtea_curri", listtea_curri); return "admin/seetea.jsp";
}
public String seedetails(int cid,Model model) throws Exception{
List<Details> listdetails = mts.getdetails(cid); int sum=0; int flag=0; for(Details det:listdetails){ if(det.getEscore()==null){ continue;
}
sum+=det.getEscore();
flag++;
} if(flag==0){ return ?"pjnotfinish.jsp";
} double avg=sum/flag; int b=(int) (avg/10);
String grade; switch(b){ case 10:grade="非常優(yōu)秀";break; case 9:grade="優(yōu)秀";break; case 8:grade="良好";break; case 7:grade="中等";break; case 6:grade="及格";break; default:grade="不合格";
}
model.addAttribute("grade", grade);
model.addAttribute("avg", avg);
model.addAttribute("listdetails", listdetails); return "admin/details.jsp";
}
public String viewstu(Model model,int currPage) throws Exception{ int pageSize=5; int count = stus.getcount(); int totalPage=(int) Math.ceil((count*1.0/pageSize)); if(currPage<=0){
currPage=1;
} if(currPage>=totalPage){
currPage=totalPage;
}
PageBean<Student> pb = stus.getfenyestu(currPage, pageSize);// List<Student> listallstu = stus.getallstu();
List<Student> liststu = pb.getList();
model.addAttribute("pb", pb);
model.addAttribute("liststu", liststu); return "admin/viewstu.jsp";
}
public String viewtea(Model model,int currPage) throws Exception{ int pageSize=5; int count = teas.getcount(); int totalPage=(int) Math.ceil((count*1.0/pageSize)); if(currPage<=0){
currPage=1;
} if(currPage>=totalPage){
currPage=totalPage;
}
PageBean<Teacher> pb = teas.getfenyetea(currPage, pageSize);// List<Teacher> listalltea = teas.getalltea();
List<Teacher> listtea = pb.getList();
model.addAttribute("pb", pb);
model.addAttribute("listtea",listtea); return "admin/viewtea.jsp";
}
public String viewtea(Student stu,Model model) throws Exception{ Student getstu = stus.getstu(stu.getSid()); if(getstu==null){
stus.insertstu(stu);
model.addAttribute("succ", "添加成功");
}else{
model.addAttribute("err", "已存在該編號(hào)的學(xué)生");
} return "admin/addstu.jsp";
}
public String viewtea(Teacher tea,Model model) throws Exception{ Teacher gettea = teas.gettea(tea.getTid()); if(gettea==null){
teas.inserttea(tea);
model.addAttribute("succ", "添加成功");
}else{
model.addAttribute("err", "已存在該編號(hào)的教師");
} return "admin/addtea.jsp";
}
//點(diǎn)擊查看課程
public String viewcurri(Model model,int currPage) throws Exception{ int pageSize=10; int count = curs.getcount(); int totalPage=(int) Math.ceil((count*1.0/pageSize)); if(currPage<=0){
currPage=1;
} if(currPage>=totalPage){
currPage=totalPage;
}
PageBean<Curriculum> pb = curs.getfenyecur(currPage, pageSize);
List<Curriculum> listcur = pb.getList();
model.addAttribute("pb", pb);
model.addAttribute("listcur",listcur); return "admin/viewcurri.jsp";
}
//修改密碼,點(diǎn)擊提交
public String uppwd(String oldpwd,String newpwd,HttpServletRequest request,Model model)throws Exception{ HttpSession session = request.getSession();
Admin adm=(Admin) session.getAttribute("adm"); if(adm.getApassword().equals(oldpwd)){
adm.setApassword(newpwd);
adms.uppwd(adm);
}else{
model.addAttribute("pwderr","你的原始密碼有誤"); return "admin/updatepwd.jsp";
} return "admin/uppwdsuccess.jsp";
}
//點(diǎn)擊添加課程功能
public String addcurri(Model model) throws Exception{
List<Teacher> listalltea = teas.getalltea();
model.addAttribute("listtea",listalltea); return "admin/addcurri.jsp";
}
//填寫課程信息后,點(diǎn)擊提交
public String submitcurri(Curriculum cur,Model model) throws Exception{ Curriculum curri = curs.getbyid(cur.getCid()); if(curri==null){
curs.addcur(cur);
model.addAttribute("succ", "添加成功");
}else{
model.addAttribute("err", "該編號(hào)的課程已存在");
}
List<Teacher> listalltea = teas.getalltea();
model.addAttribute("listtea",listalltea); return "admin/addcurri.jsp";
}
//點(diǎn)擊學(xué)生選課
public String stuselectcur(Model model,int currPage)throws Exception{ int pageSize=10; int count = stus.getcount(); int totalPage=(int) Math.ceil((count*1.0/pageSize)); if(currPage<=0){
currPage=1;
} if(currPage>=totalPage){
currPage=totalPage;
}
PageBean<Student> pb = stus.getfenyestu(currPage, pageSize);// List<Student> listallstu = stus.getallstu();
List<Student> liststu = pb.getList();
model.addAttribute("pb", pb);
model.addAttribute("liststu", liststu); return "admin/stuselectcur.jsp";
}
//點(diǎn)擊教師任課
public String teaselectcur(Model model,int currPage)throws Exception{ int pageSize=10; int count = teas.getcount(); int totalPage=(int) Math.ceil((count*1.0/pageSize)); if(currPage<=0){
currPage=1;
} if(currPage>=totalPage){
currPage=totalPage;
}
PageBean<Teacher> pb = teas.getfenyetea(currPage, pageSize);
List<Teacher> listalltea = pb.getList();
model.addAttribute("pb", pb);
model.addAttribute("listtea",listalltea); return "admin/teaselectcur.jsp";
}
//點(diǎn)擊選課詳情
public String selectcurdetails(Model model,String ssid,String sname)throws Exception{
List<ManyTable> liststu_curbystuid = mts.getstu_curbystuid(ssid); if(liststu_curbystuid.size()==0){
model.addAttribute("sname", sname); return "admin/noselectcur.jsp";
}
model.addAttribute("liststu_curbystuid", liststu_curbystuid);
model.addAttribute("sname", sname); return "admin/stucurdetails.jsp";
}
//點(diǎn)擊教師任課詳情
public String teacurdetails(Model model,String tid,String tname)throws Exception{
List<Curriculum> listcurbytid = curs.getcurbytid(tid); if(listcurbytid.size()==0){
model.addAttribute("tname", tname); return "admin/teanocur.jsp";
}
model.addAttribute("listcurbytid", listcurbytid);
model.addAttribute("tname", tname);
model.addAttribute("tid", tid); return "admin/teacurdetails.jsp";
}
//修改學(xué)生信息
public String updatestu(Student stu,Model model)throws Exception{
stus.updatestu(stu);
List<Student> listallstu = stus.getallstu();
model.addAttribute("liststu", listallstu); return "/viewstu?currPage=1";
}
//修改教師信息
public String updatetea(Teacher tea,Model model)throws Exception{
teas.updatetea(tea);
List<Teacher> listalltea = teas.getalltea();
model.addAttribute("listtea",listalltea); return "/viewtea?currPage=1";
}
//刪除學(xué)生
public String ?delstu(HttpServletRequest request)throws Exception{ String sid = request.getParameter("sid");
stus.delstu(sid); return "/viewstu?currPage=1";
}
//刪除老師
public String deltea(String tid)throws Exception{
teas.deltea(tid); return "/viewtea?currPage=1";
}
//刪除課程
public String deletecurriculumbyid(int cid)throws Exception{
curs.deletecur(cid); return "/viewcurri?currPage=1";
}
//點(diǎn)擊修改課程
public String updatecurr(Model model)throws Exception{
List<Teacher> listalltea = teas.getalltea();
model.addAttribute("listtea",listalltea); return "admin/updatecurr.jsp";
}
//課程里點(diǎn)擊確認(rèn)修改
public String querenxiugai(Model model,Curriculum curr){
curs.querenxiugai(curr); return "viewcurri?currPage=1";
}
//按姓名查詢學(xué)生
public String nameselect(String name,Model model)throws Exception{
List<Student> liststu = stus.findbyname(name); if(liststu.size()==0){ return "admin/NewFile1.jsp";
}
model.addAttribute("liststu", liststu); return "admin/NewFile2.jsp";
}
//按姓名查詢老師
public String tnameselect(String name,Model model)throws Exception{
List<Teacher> listtea = teas.findteabyname(name); if(listtea.size()==0){ return "admin/NewFile3.jsp";
}
model.addAttribute("listtea", listtea); return "admin/NewFile4.jsp";
}
}
package one.controller;import java.util.Date;import java.util.List;import javax.annotation.Resource;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import one.domain.Curriculum;import one.domain.Evaluate;import one.domain.Student;import one.domain.Studentandcurriculum;import one.service.CurriculumService;import one.service.EvaluateService;import one.service.ManyTableService;import one.service.StudentService;import one.vo.ManyTable;public class StudentController {
private StudentService stus;
private CurriculumService curs;
private EvaluateService evaService; //修改密碼,點(diǎn)擊提交
public String uppwd(String oldpwd,String newpwd,HttpServletRequest request,Model model)throws Exception{ HttpSession session = request.getSession();
Student stu=(Student) session.getAttribute("stu"); if(stu.getSpassword().equals(oldpwd)){
stu.setSpassword(newpwd);
stus.uppwd(stu);
}else{
model.addAttribute("pwderr","你的原始密碼有誤"); return "student/updatepwd.jsp";
} return "student/uppwdsuccess.jsp";
}
//學(xué)生點(diǎn)擊進(jìn)行評(píng)教
public String allpj(HttpServletRequest request,Model model) throws Exception{ HttpSession session = request.getSession(); Student stu = (Student) session.getAttribute("stu");
List<ManyTable> listpj = ?mts.getall(stu.getSid()); if(listpj.size()==0){ return "student/nocurr.jsp";
}else{
model.addAttribute("listpj", listpj); return "student/allpingjiao.jsp";
}
}
private ManyTableService mts;
private EvaluateService evas;
//學(xué)生提交評(píng)教
public String subpj(HttpServletRequest request,int eid,String advise,Model model)throws Exception{ int ?a = Integer.parseInt(request.getParameter("1")); int ?b = Integer.parseInt(request.getParameter("2")); int ?c = Integer.parseInt(request.getParameter("3")); int ?d = Integer.parseInt(request.getParameter("4")); int ?e = Integer.parseInt(request.getParameter("5")); int ?f = Integer.parseInt(request.getParameter("6")); int ?g = Integer.parseInt(request.getParameter("7")); int ?h = Integer.parseInt(request.getParameter("8")); int ?i = Integer.parseInt(request.getParameter("9")); int ?j = Integer.parseInt(request.getParameter("10")); int sum=a+b+c+d+e+f+g+h+i+j; if(advise==""){
advise=null;
}
Date date=new Date();
Evaluate eva=new Evaluate();
eva.setEid(eid);
eva.setEscore(sum);
eva.setEcomment(advise);
eva.setEdate(date);
evas.uppj(eva); HttpSession session = request.getSession(); Student stu = (Student) session.getAttribute("stu");
List<ManyTable> listpj = ?mts.getall(stu.getSid());
model.addAttribute("listpj", listpj); return "student/allpingjiao.jsp";
}
//點(diǎn)擊添加選課
public String addmycur(Model model)throws Exception{
List<Curriculum> listallcur = curs.getallcur();
model.addAttribute("listallcur", listallcur); return "student/addmycur.jsp";
}
public String stuaddcur(HttpSession session,Model model,int scid ) throws Exception{ Student stu = (Student) session.getAttribute("stu");
Studentandcurriculum stucur=new Studentandcurriculum();
stucur.setScid(scid);
System.out.println(stu.getSid());
stucur.setSsid(stu.getSid()); Studentandcurriculum myselect = stus.findmyselect(stucur); if(myselect==null){
stus.stuaddcur(stucur);
Evaluate eva=new Evaluate();
eva.setEsid(stucur.getSsid());
eva.setEcid(stucur.getScid());
evaService.addstuselect(eva);
model.addAttribute("succ", "添加選課成功!");
}else{
model.addAttribute("err", "你已經(jīng)選了該課程!");
}
List<Curriculum> listallcur = curs.getallcur();
model.addAttribute("listallcur", listallcur); return "student/addmycur.jsp";
}
}