基于javaweb+mysql的ssh课程资源教学在线考试平台(java+ssh+mysql+jsp+tomcat)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSH课程资源教学在线考试平台(java+ssh+mysql+jsp+tomcat)
一、项目简述
功能包括: 管理员可以增删改查教材、教材商、入库教材、用户(用 户包括学生和教师)可以对教材商、教材进行。xcel的导入 导出操作。教师可以领取入库的教材,可以退还教材。学 生只能在对应的教师那里领取教材,并且可以退还教材、 查询自己已经领取的教材。并且对已领教材付款等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Struts+Spring+Hibernate + html+ css + JavaScript + JQuery + Ajax等等。
public String getFilename() throws IOException {
return encodeDownloadFilename(filename, ServletActionContext.getRequest().getHeader("User-Agent"));
}
public void setFilename(String filename) throws UnsupportedEncodingException {
filename = new String(filename.getBytes("iso-8859-1"), "utf-8");
this.filename = filename;
}
public String getContentType() {
return ServletActionContext.getServletContext().getMimeType(filename);
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
// *****************************
private HomeworkService homeworkService;
private CourseService courseService;
public void setHomeworkService(HomeworkService homeworkService) {
this.homeworkService = homeworkService;
}
public void setCourseService(CourseService courseService) {
this.courseService = courseService;
}
// **********上传文件*******************
public String upload() throws Exception {
InputStream is = new FileInputStream(file);
String uploadPath = ServletActionContext.getServletContext().getRealPath("/homeworks");
File toFile = new File(uploadPath, this.getFileFileName());
OutputStream os = new FileOutputStream(toFile);
byte[] buffer = new byte[1024];
int length = 0;
while (-1 != (length = is.read(buffer, 0, buffer.length))) {
os.write(buffer);
}
is.close();
os.close();
homework.setName(fileFileName);
homeworkService.saveHomework(homework);
return "upload";
}
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getIdentity() {
return identity;
}
public void setIdentity(String identity) {
this.identity = identity;
}
// *****************************
private AdminService adminService;
public void setAdminService(AdminService adminService) {
this.adminService = adminService;
}
private TeacherService teacherService;
public void setTeacherService(TeacherService teacherService) {
this.teacherService = teacherService;
}
private StudentService studentService;
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
public String login() {
if("student".equals(identity)) {//如果以学生身份登录
if(studentService.allowLogin(id, password)) {
Student student = studentService.findStudentById(id);
student.setStatus(2);
studentService.updateStudent(student);
//保存学生记录到session范围
ActionContext context=ActionContext.getContext();
context.getSession().put("student", student);
return "studentSuccess";
}else {
ActionContext.getContext().put("msg","账号或者密码不正确!");
return this.ERROR;
}
}
else if("teacher".equals(identity)){
if(teacherService.allowLogin(id, password)) {
Teacher teacher = teacherService.findTeacherById(id);
课程资源在线管理平台管理员端
</div>
</div>
<div id="wrapper">
<!--左侧导航开始-->
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="nav-close"><i class="fa fa-times-circle"></i>
</div>
<div class="sidebar-collapse">
<ul class="nav" id="side-menu">
<li class="nav-header">
<div class="dropdown profile-element">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="clear">
<span class="block m-t-xs" style="font-size:20px;">
<i class="fa fa-area-chart"></i>
<strong class="font-bold">菜单栏</strong>
</span>
</span>
</a>
</div>
<div class="logo-element">
菜单栏
</div>
</li>
<li>
<a class="J_menuItem" href="welcome.html">
<i class="fa fa-home"></i>
<span class="nav-label">主页</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-user"></i>
<span class="nav-label">用户管理</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="teacherAction_selectAll">查询所有教师</a>
</li>
<li>
<a class="J_menuItem" href="admin/addTeacher.jsp">添加教师</a>
</li>
<li>
List<Course> courses = courseService.findAllCourse();
ActionContext.getContext().put("courses", courses);
return "beforeAdd";
}
public String selectAllofMine() {
System.out.println(homework.getStudent().getSid());
List<Homework> homeworks = homeworkService.findHomeworkBySid(homework.getStudent().getSid());
ActionContext.getContext().put("homeworks", homeworks);
return "selectAllofMine";
}
}
package CourseWeb.Action;
public class StudentAction extends ActionSupport implements ModelDriven<Student>{
private static final long serialVersionUID=1L;
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
// **********用于读excel文件*******************
private File file;
private String fileFileName;
private String fileContentType;
@Repository
public class StudentDaoImpl implements StudentDao {
// 提供hibernate模板
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public Student findById(String sid) {
return this.hibernateTemplate.get(Student.class, sid);
}
public List<Student> findAll() {
return this.hibernateTemplate.find("from Student");
}
public void save(Student student) {
this.hibernateTemplate.save(student);
}
public void update(Student student) {
this.hibernateTemplate.update(student);
}
public void delete(Student student) {
this.hibernateTemplate.delete(student);
}
public List<Student> findInChat(String tid){
Configuration config=new Configuration().configure();
SessionFactory sessionFactory=config.buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction t = session.beginTransaction();
Query query=session.createSQLQuery("select * from student s where exists(select * from chat c where s.sid=c.sid and c.tid=?)").addEntity(Student.class);
query.setString(0, tid);
List<Student> students=query.list();
t.commit();
session.close();
sessionFactory.close();
return students;
Integer qid = new Integer(0);
Integer scores1 = new Integer(0);
String answer_r,answer_m;
MyAnswer myAnswer = new MyAnswer();
myAnswer.setEid(exam.getEid());
HttpServletRequest request = ServletActionContext.getRequest();
//处理单选题
Integer size1 = Integer.parseInt(request.getParameter("size1"));
for(int i=0;i<size1;i++){
qid=Integer.parseInt(request.getParameter("qids1"+i));
answer_m=request.getParameter("answers1"+i);
myAnswer.setQid(qid);
myAnswer.setAnswer(answer_m);
myAnswerService.saveMyAnswer(myAnswer);
answer_r=questionService.findQuestionById(qid).getAnswer();
if(answer_r.equals(answer_m)){
scores1+=qpService.findQPById(qid, pid).getScore();
}
}
//处理多选题
Integer size2 = Integer.parseInt(request.getParameter("size2"));
for(int i=0;i<size2;i++){
qid=Integer.parseInt(request.getParameter("qids2"+i));
String[] temp=request.getParameterValues("answers2"+i);
answer_m=temp[0];
for(int j=1;j<temp.length;j++)
answer_m=answer_m+", "+temp[j];
myAnswer.setQid(qid);
myAnswer.setAnswer(answer_m);
myAnswerService.saveMyAnswer(myAnswer);
answer_r=questionService.findQuestionById(qid).getAnswer();
if(answer_r.equals(answer_m)){
scores1+=qpService.findQPById(qid, pid).getScore();
}
for(int i=0;i<size3;i++){
qid=Integer.parseInt(request.getParameter("qids3"+i));
answer_m=request.getParameter("answers3"+i);
myAnswer.setQid(qid);
myAnswer.setAnswer(answer_m);
myAnswerService.saveMyAnswer(myAnswer);
answer_r=questionService.findQuestionById(qid).getAnswer();
if(answer_r.equals(answer_m)){
scores1+=qpService.findQPById(qid, pid).getScore();
}
}
//处理解答题
if(qids4.size()==0){
exam.setStatus(3);
exam.setScore2(0);
exam.setScore3(scores1);
}
else{
for(int i=0;i<qids4.size();i++){
qid = qids4.get(i);
answer_m = answers4.get(i);
myAnswer.setQid(qid);
myAnswer.setAnswer(answer_m);
myAnswerService.saveMyAnswer(myAnswer);
}
}
exam.setScore1(scores1);
examService.updateExam(exam);
ActionContext.getContext().put("scores1", scores1);
return "submitExam";
}
public String markPaper(){
Integer pid = this.paper.getPid();
/**
* 使用hibernate.cfg.xml
*/
//public class UserDaoImpl implements UserDao {
// // 提供hibernate模板
// private HibernateTemplate hibernateTemplate;
// public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
// this.hibernateTemplate = hibernateTemplate;
// }
// public User findById(Integer id) {
// return this.hibernateTemplate.get(User.class, id);
// }
// public List<User> findAll() {
// return this.hibernateTemplate.find("from User");
// }
// public void save(User user) {
// this.hibernateTemplate.save(user);
// }
// public void update(User user) {
// this.hibernateTemplate.update(user);
// }
// public void delete(User user) {
// this.hibernateTemplate.delete(user);
// }
//}
/**
* 不使用hibernate.cfg.xml
*/
// //继承 HibernateDaoSupport自动生成模板, 必须提供SessionFactory
// public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
// public User findById(Integer id) {
// return this.getHibernateTemplate().get(User.class, id);
// }
// public List<User> findAll() {
// return this.getHibernateTemplate().find("from User");
// }
// public void save(User user) {
// this.getHibernateTemplate().save(user);
// }
// public void update(User user) {
// this.getHibernateTemplate().update(user);
// }
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
// **********用于下载文件*******************
private String filename;
private String contentType;
public String getFilename() throws IOException {
return encodeDownloadFilename(filename, ServletActionContext.getRequest().getHeader("User-Agent"));
}
public void setFilename(String filename) throws UnsupportedEncodingException {
filename = new String(filename.getBytes("iso-8859-1"), "utf-8");
this.filename = filename;
}
public String getContentType() {
return ServletActionContext.getServletContext().getMimeType(filename);
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
// *****************************
private HomeworkService homeworkService;
private CourseService courseService;
public void setHomeworkService(HomeworkService homeworkService) {
this.homeworkService = homeworkService;
}
public void setCourseService(CourseService courseService) {
this.courseService = courseService;
}
// **********上传文件*******************
public String upload() throws Exception {
InputStream is = new FileInputStream(file);
String uploadPath = ServletActionContext.getServletContext().getRealPath("/homeworks");
File toFile = new File(uploadPath, this.getFileFileName());
OutputStream os = new FileOutputStream(toFile);
byte[] buffer = new byte[1024];
</li>
<li>
<a href="#">
<i class="fa fa-user"></i>
<span class="nav-label">用户管理</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="teacherAction_selectAll">查询所有教师</a>
</li>
<li>
<a class="J_menuItem" href="admin/addTeacher.jsp">添加教师</a>
</li>
<li>
<a class="J_menuItem" href="studentAction_selectAll">查询所有学生</a>
</li>
<li>
<a class="J_menuItem" href="admin/readStudent.jsp">导入学生信息</a>
</li>
<li>
<a class="J_menuItem" href="admin/addStudent.jsp">添加学生</a>
</li>
</ul>
</li>
<li>
<a href="#">
<i class="fa fa-book"></i>
<span class="nav-label">课程管理</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="courseAction_selectAll">查询所有课程</a>
</li>
<li>
<a class="J_menuItem" href="admin/addCourse.jsp">添加课程</a>
</li>
</ul>
</li>
<li>
<a href="#">
<i class="fa fa-edit"></i>
<span class="nav-label">试题管理</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="questionAction_selectAll">查询所有试题</a>
</li>
Student student = (Student)ActionContext.getContext().getSession().get("student");
List<Chat> chats = chatService.findChatByTS(teacher.getTid(), student.getSid());
ActionContext.getContext().put("teacher", teacher);
ActionContext.getContext().put("teachers", teachers);
ActionContext.getContext().put("chats", chats);
return "beforChat";
}
public String addChat() {
Teacher teacher = teacherService.findTeacherById(this.teacher.getTid());
Student student = (Student)ActionContext.getContext().getSession().get("student");
Chat chat = new Chat();
chat.setContent(content);
chat.setStudent(student);
chat.setTeacher(teacher);
chat.setDirection(1);
chat.setTime(new Date());
chatService.saveChat(chat);
if(teacher.getStatus()==1){
SystemMail.sendMail(teacher.getEmail(), teacher.getName(), student.getName(), 1);
}
List<Teacher> teachers = teacherService.findAllTeacher();
List<Chat> chats = chatService.findChatByTS(teacher.getTid(), student.getSid());
ActionContext.getContext().put("teacher", teacher);
ActionContext.getContext().put("teachers", teachers);
ActionContext.getContext().put("chats", chats);
return "beforChat";
}
}
package CourseWeb.Action;
Teacher teacher = teacherService.findTeacherById(this.teacher.getTid());
Student student = (Student)ActionContext.getContext().getSession().get("student");
Chat chat = new Chat();
chat.setContent(content);
chat.setStudent(student);
chat.setTeacher(teacher);
chat.setDirection(1);
chat.setTime(new Date());
chatService.saveChat(chat);
if(teacher.getStatus()==1){
SystemMail.sendMail(teacher.getEmail(), teacher.getName(), student.getName(), 1);
}
List<Teacher> teachers = teacherService.findAllTeacher();
List<Chat> chats = chatService.findChatByTS(teacher.getTid(), student.getSid());
ActionContext.getContext().put("teacher", teacher);
ActionContext.getContext().put("teachers", teachers);
ActionContext.getContext().put("chats", chats);
return "beforChat";
}
}
package CourseWeb.Action;
public class LoginAction extends ActionSupport{
private static final long serialVersionUID=1L;
private String id;
<input type="radio" name="answer" value="T" checked>正确
<input type="radio" name="answer" value="F" >错误
</td>
</tr>
</s:elseif>
<s:else>
<tr align="center">
<td>参考答案</td>
<td colspan="7"><textarea name="answer" class="form-control" rows=8>${requestScope.question.answer}</textarea></td>
</tr>
</s:else>
<tr align="center" class="success">
<td colspan="8">
<input type="hidden" name="qid" value="${requestScope.question.qid}">
<input type="hidden" name="type" value="${requestScope.question.type}">
<input type="submit" class="btn btn-success" name="update" value=" 修 改 ">
</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>添加试题</title>
<meta http-equiv="pragma" content="no-cache">
// *****************************
private PaperService paperService;
private QuestionService questionService;
private CourseService courseService;
private QPService qpService;
private ExamService examService;
private MyAnswerService myAnswerService;
public void setPaperService(PaperService paperService) {
this.paperService = paperService;
}
public void setQuestionService(QuestionService questionService) {
this.questionService = questionService;
}
public void setCourseService(CourseService courseService) {
this.courseService = courseService;
}
public void setQpService(QPService qpService) {
this.qpService = qpService;
}
public void setExamService(ExamService examService) {
this.examService = examService;
}
public void setMyAnswerService(MyAnswerService myAnswerService) {
this.myAnswerService = myAnswerService;
}
public String selectAll() {
List<Paper> papers = paperService.findAllPaper();
ActionContext.getContext().put("papers",papers);
return "selectAll";
}
public String beforeUpdate(){
Paper paper = paperService.findPaperById(this.paper.getPid());
ActionContext.getContext().put("paper", paper);
return "beforeUpdate";
}
public String update(){
this.paperService.updatePaper(paper);
return "success";
}
public String delete(){
paperService.deletePaper(paper);
List<Paper> papers = paperService.findAllPaper();
private MyAnswerService myAnswerService;
public void setPaperService(PaperService paperService) {
this.paperService = paperService;
}
public void setQuestionService(QuestionService questionService) {
this.questionService = questionService;
}
public void setCourseService(CourseService courseService) {
this.courseService = courseService;
}
public void setQpService(QPService qpService) {
this.qpService = qpService;
}
public void setExamService(ExamService examService) {
this.examService = examService;
}
public void setMyAnswerService(MyAnswerService myAnswerService) {
this.myAnswerService = myAnswerService;
}
public String selectAll() {
List<Paper> papers = paperService.findAllPaper();
ActionContext.getContext().put("papers",papers);
return "selectAll";
}
public String beforeUpdate(){
Paper paper = paperService.findPaperById(this.paper.getPid());
ActionContext.getContext().put("paper", paper);
return "beforeUpdate";
}
public String update(){
this.paperService.updatePaper(paper);
return "success";
}
public String delete(){
paperService.deletePaper(paper);
List<Paper> papers = paperService.findAllPaper();
ActionContext.getContext().put("papers", papers);
return "selectAll";
}
public String add(){
Course course = courseService.findCourseById(paper.getCourse().getCid());
paper.setName(paper.getYear()+paper.getTerm()+course.getName()+"课程"+paper.getType()+"试卷");
//System.out.println(paper.getCourse().getCid()+"名字"+paper.getCourse().getCid());
paper.setStatus(1);
// return this.getHibernateTemplate().get(User.class, id);
// }
// public List<User> findAll() {
// return this.getHibernateTemplate().find("from User");
// }
// public void save(User user) {
// this.getHibernateTemplate().save(user);
// }
// public void update(User user) {
// this.getHibernateTemplate().update(user);
// }
// public void delete(User user) {
// this.getHibernateTemplate().delete(user);
// }
// }
/**
* 使用注解方式
*/
@Repository
public class AdminDaoImpl implements AdminDao {
// 提供hibernate模板
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public Admin findById(String aid) {
return this.hibernateTemplate.get(Admin.class, aid);
}
public List<Admin> findAll() {
@Repository
public class ExamDaoImpl implements ExamDao {
// 提供hibernate模板
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public Exam findById(Integer cid) {
return this.hibernateTemplate.get(Exam.class, cid);
}
public List<Exam> findAll() {
return this.hibernateTemplate.find("from Exam where status=3");
}
public void save(Exam exam) {
this.hibernateTemplate.save(exam);
}
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
// **********用于读excel文件*******************
private Student student = new Student();
public Student getModel() {
return this.student;
}
// *****************************
private StudentService studentService;
private ChatService chatService;
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
public void setChatService(ChatService chatService) {
this.chatService = chatService;
}
public String selectAll() {
List<Student> students = studentService.findAllStudent();
ActionContext.getContext().put("students",students);
return "selectAll";
}
public String beforeUpdate(){
Student student = studentService.findStudentById(this.student.getSid());
ActionContext.getContext().put("student", student);
return "beforeUpdate";
}
public String update(){
@Repository
public class UserDaoImpl implements UserDao {
// 提供hibernate模板
private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public User findById(Integer id) {
return this.hibernateTemplate.get(User.class, id);
}
public List<User> findAll() {
return this.hibernateTemplate.find("from User");
}
public void save(User user) {
this.hibernateTemplate.save(user);
}
public void update(User user) {
this.hibernateTemplate.update(user);
}
public void delete(User user) {
this.hibernateTemplate.delete(user);
}
}
package CourseWeb.Test;
List<Question> qs_si_m = questionService.findQuestionByTD("single", "2",paper.getCourse().getCid());
List<Question> qs_si_d = questionService.findQuestionByTD("single", "3",paper.getCourse().getCid());
System.out.print("单选题"+qs_si_e.size()+";"+qs_si_m.size()+";"+qs_si_d.size());
if(si_e_n>qs_si_e.size()||si_m_n>qs_si_m.size()||si_d_n>qs_si_d.size()){
ActionContext.getContext().put("msg", "题库中没有足够的满足条件的单选题");
return "generateFalse";
}
List<Question> qs_m_e = questionService.findQuestionByTD("multiple", "1",paper.getCourse().getCid());
List<Question> qs_m_m = questionService.findQuestionByTD("multiple", "2",paper.getCourse().getCid());
List<Question> qs_m_d = questionService.findQuestionByTD("multiple", "3",paper.getCourse().getCid());
if(m_e_n>qs_m_e.size()||m_m_n>qs_m_m.size()||m_d_n>qs_m_d.size()){
ActionContext.getContext().put("msg", "题库中没有足够的满足条件的多选题");
return "generateFalse";
}
List<Question> qs_j_e = questionService.findQuestionByTD("judgment", "1",paper.getCourse().getCid());
List<Question> qs_j_m = questionService.findQuestionByTD("judgment", "2",paper.getCourse().getCid());
List<Question> qs_j_d = questionService.findQuestionByTD("judgment", "3",paper.getCourse().getCid());
System.out.print("判断题"+qs_j_e.size()+";"+qs_j_m.size()+";"+qs_j_d.size());
if(j_e_n>qs_j_e.size()||j_m_n>qs_j_m.size()||j_d_n>qs_j_d.size()){
ActionContext.getContext().put("msg", "题库中没有足够的满足条件的判断题");
List<Course> cs = (List<Course>)ActionContext.getContext().get("courses");
System.out.println("测试"+cs.size());
return "generateFalse";
}
List<Question> qs_su_e = questionService.findQuestionByTD("subject", "1",paper.getCourse().getCid());
List<Question> qs_su_m = questionService.findQuestionByTD("subject", "2",paper.getCourse().getCid());
List<Question> qs_su_d = questionService.findQuestionByTD("subject", "3",paper.getCourse().getCid());
if(su_e_n>qs_su_e.size()||su_m_n>qs_su_m.size()||su_d_n>qs_su_d.size()){
ActionContext.getContext().put("msg", "题库中没有足够的满足条件的解答题题");
return "generateFalse";
}
paper.setStatus(1);
Course course = courseService.findCourseById(paper.getCourse().getCid());
paper.setName(paper.getYear()+paper.getTerm()+course.getName()+"课程"+paper.getType()+"试卷");
paperService.savePaper(paper);
Integer pid=paper.getPid();
Integer[] single1=generateRandom(si_e_n,qs_si_e.size());
for(int i=0;i<si_e_n;i++){
qpService.saveQP(new QP(qs_si_e.get(single1[i]).getQid(),pid,si_e_s));
}
Integer[] single2=generateRandom(si_m_n,qs_si_m.size());
for(int i=0;i<si_m_n;i++){
qpService.saveQP(new QP(qs_si_m.get(single2[i]).getQid(),pid,si_m_s));
}
Integer[] single3=generateRandom(si_d_n,qs_si_d.size());
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
// **********用于读excel文件*******************
private Student student = new Student();
public Student getModel() {
return this.student;
}
// *****************************
private StudentService studentService;
private ChatService chatService;
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
public void setChatService(ChatService chatService) {
this.chatService = chatService;
}
public String selectAll() {
List<Student> students = studentService.findAllStudent();
ActionContext.getContext().put("students",students);
return "selectAll";
}
public String beforeUpdate(){
Student student = studentService.findStudentById(this.student.getSid());
ActionContext.getContext().put("student", student);
return "beforeUpdate";
}
public String update(){
this.studentService.updateStudent(student);
return "success";
}
public class ThemeAction extends ActionSupport implements ModelDriven<Theme>{
private static final long serialVersionUID=1L;
private Theme theme = new Theme();
Student student = new Student();
public Theme getModel() {
Theme theme = this.theme;
theme.setSender(student);
return this.theme;
}
// *****************************
private ThemeService themeService;
private ReplyService replyService;
public void setThemeService(ThemeService themeService) {
this.themeService = themeService;
}
public void setReplyService(ReplyService replyService) {
this.replyService = replyService;
}
public String selectAll() {
List<Theme> themes = themeService.findAllTheme();
ActionContext.getContext().put("themes",themes);
return "selectAll";
}
public String selectAllForA() {
List<Theme> themes = themeService.findAllTheme();
ActionContext.getContext().put("themes",themes);
return "selectAllForA";
}
public String adminDelete() {
themeService.deleteTheme(theme);
return this.selectAllForA();
}
public String update(){
this.themeService.updateTheme(theme);
return "success";
}
public String delete(){
}
public String showTheme(){
Theme theme = themeService.findThemeById(this.theme.getThid());
List<Reply> replys = replyService.findReplyByThid(this.theme.getThid());
ActionContext.getContext().put("theme1", theme);
ActionContext.getContext().put("replys", replys);
return "showTheme";
}
}
package CourseWeb.Action;
public class ReplyAction extends ActionSupport implements ModelDriven<Reply>{
private static final long serialVersionUID=1L;
private Theme theme;
public Theme getTheme() {
return theme;
}
public void setTheme(Theme theme) {
this.theme = theme;
}
private Reply reply = new Reply();
return false;
}
}
if(f.answer.value==""){
alert("答案不能为空!!");
f.answer.focus();
return false;
}
if(course.value==""){
alert("请选择所属课程!");
return false;
}
if(f.difficulty.value==""){
alert("请选择试题难度!");
return false;
}
return true;
}
function init(){
var type = "${requestScope.question.type}";
var typename = document.getElementById("typename");
switch(type){
case "single":
typename.innerHTML="单选题";
break;
case "multiple":
typename.innerHTML="多选题";
break;
case "judgment":
typename.innerHTML="判断题";
break;
default:
typename.innerHTML="解答题";
break;
}
}
</script>
</head>
<body onload="init();">
<form action="questionAction_update" method="post" role="form" onSubmit="return checkForm(this)">
<div style="width:1000;margin:20">
<table class="table table-striped table-bordered">
<thead>
<tr align="center">
<td colspan="8" class="success"><h3>更新试题信息</h3></td>
</tr>
</thead>
<tbody>
<tr align="center">
<td width=100>试题编号</td>
<td width=100>${requestScope.question.qid}</td>
sheet.addCell(new Number(1, i+1, exams.get(i).getScore1()));
sheet.addCell(new Number(2, i+1, exams.get(i).getScore2()));
sheet.addCell(new Number(3, i+1, exams.get(i).getScore3()));
}
book.write();
} catch (Exception e) {
System.out.println(e);
}finally{
if(book!=null){
try {
book.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
package CourseWeb.Action;
public class TeacherAction extends ActionSupport implements ModelDriven<Teacher>{
private static final long serialVersionUID=1L;
private String content;