版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、四川交通職業(yè)技術(shù)學(xué)院信息工程系項(xiàng)目設(shè)計(jì)文檔題 目:學(xué)生在線考試系統(tǒng)班 級(jí) 軟件13-1 學(xué) 號(hào) 20131645、20132907、20132185、20132266 姓 名 姜維川、鄭雨云、侯鑒航、鄧凱 任課教師 吉朝明 二O一五 年 6 月目錄1 需求描述32 系統(tǒng)功能描述32.1 系統(tǒng)功能圖32.2 系統(tǒng)主流程圖33 數(shù)據(jù)庫(kù)設(shè)計(jì)54 界面原型設(shè)計(jì)55 類設(shè)計(jì)66 關(guān)鍵代碼88 項(xiàng)目總結(jié)249程序錯(cuò)誤報(bào)告2510參考文獻(xiàn)25學(xué)生在線考試系統(tǒng)文檔1 需求描述該系統(tǒng)主要是由前臺(tái)學(xué)生端和后臺(tái)教師端兩部分組成。前臺(tái)學(xué)生端即是學(xué)生通過(guò)在線考試后得到分?jǐn)?shù),后臺(tái)教師端即是對(duì)試卷和學(xué)生的信息進(jìn)行管理。2
2、系統(tǒng)功能描述2.1 系統(tǒng)功能圖系統(tǒng)功能圖如圖1所示。圖1 系統(tǒng)功能圖2.2 系統(tǒng)主流程圖系統(tǒng)主流程圖如圖2所示。圖2 系統(tǒng)主流程圖3 數(shù)據(jù)庫(kù)設(shè)計(jì)本系統(tǒng)選擇Mysql數(shù)據(jù)庫(kù),建立名為testsystem.mdb的數(shù)據(jù)庫(kù),涉及到主要的數(shù)據(jù)庫(kù)表設(shè)計(jì)如表1-表2-表3所示。表1 test字段名字段類型可否為空說(shuō)明idINT(10)Not null主鍵testidINT(10)Not nullsidINT(10)NULLcontenttextNot nullgradeINT(10)Not nullansweridINT(10)Not null表2 answer字段名字段類型可否為空說(shuō)明idINT(10)
3、Not null主鍵tidINT(10)Not nullcontenttextNot null表3 student字段名字段類型可否為空說(shuō)明idINT(10)Not null主鍵uidINT(10)Not nullnamevarchar(30)Not nullprofessionalIdINT(10)Not nulldepartmentINT(10)Not nullxhINT(10)Not nullsexvarchar(30)Not nulltikeIdINT(10)Not nullageINT(10)Not null4 界面原型設(shè)計(jì)1. 前臺(tái)首頁(yè)2. 后臺(tái)首頁(yè)5 類設(shè)計(jì)本系統(tǒng)設(shè)計(jì)了actio
4、n、Aspect、dao、filter、model、service六個(gè)類,具體說(shuō)明及相關(guān)類代碼如下:(1) action類action+TestAction( )+userAction( )(2) Aspect類Aspect+LogAspect( )(3)dao類dao+AnswerDao( )+DepartMentDao( )+GradeDao( )+ProfessionalDao( )+SubjectDao( )+TestDao( )+UserDao( )(4)filter類filter+MyFilter( )(5) model類model+Answer( )+Department( )+
5、Grade( )+GradeJSon( )+Loganderror( )+Professional( )+Student( )+StudentJson( )+Subject( )+Test( )+Users( )(6) service類Service+AnswerManage( )+DepartmentManage( )+Factory( )+GradeManage( )+ProfessionalManage( )+SubjectManage( )+TestManage( )+UserManagerImp( )6 關(guān)鍵代碼(1)獲取及更新題目答案package com.test.dao;imp
6、ort java.util.List;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry;import org.hibernate.service.ServiceRegistryBuilder;import com.test.mode
7、l.Answer;import com.test.model.Department;public class AnswerDaoImp implements AnswerDaoprivate SessionFactory sessionFactory;private Session sess;private Transaction transaction;private void createsession()sess=sessionFactory.openSession();transaction=sess.beginTransaction();private void destory()m
8、it();sess.close();sessionFactory.close();public AnswerDaoImp() Configuration configuration=new Configuration();configuration.configure();ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(configuration.getProperties().buildServiceRegistry();SessionFactory sessionFactory=confi
9、guration.buildSessionFactory(serviceRegistry);/為當(dāng)前的sessionFactory賦值this.sessionFactory=sessionFactory;Overridepublic List<Answer> getanswers() Session session=sessionFactory.openSession();Query query=session.createQuery("from Answer");List<Answer> answers=query.list();session.c
10、lose();return answers;Overridepublic List<Answer> getAnswersBytid(int tid) Session session=sessionFactory.openSession();Query query=session.createQuery("from Answer where test.id="+tid);List<Answer> answers=query.list();session.close();return answers;Overridepublic Answer getAn
11、swerById(int id) Session session=sessionFactory.openSession();Query query=session.createQuery("from Answer d where d.id="+id);List<Answer> answers=query.list();if(answers.size()>0)session.close();return answers.get(0);return null;Overridepublic boolean saveanswer(Answer answer) tr
12、y createsession();sess.save(answer);mit();destory();return true; catch (Exception e) / TODO: handle exceptionreturn false;Overridepublic boolean updateanswer(Answer answer) try createsession();sess.update(answer);destory();return true; catch (Exception e) / TODO: handle exceptionreturn false;Overrid
13、epublic boolean deleteanswer(Answer answer) createsession();String sql="delete from Answer where id="+answer.getId();Query query=sess.createQuery(sql);if(query.executeUpdate()!=0)destory();return true;return false;(2)測(cè)試package com.test.dao;import java.util.ArrayList;import java.util.HashSe
14、t;import java.util.List;import java.util.Set;import net.sf.json.JSONArray;import net.sf.json.JSONObject;import org.aspectj.weaver.ast.And;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuratio
15、n;import org.hibernate.service.ServiceRegistry;import org.hibernate.service.ServiceRegistryBuilder;import com.test.model.Answer;import com.test.model.Subject;import com.test.model.Test;import com.test.service.Factory;public class TestDaoImp implements TestDaoprivate SessionFactory sessionFactory;pri
16、vate Session sess;private Transaction transaction;private void createsession()sess=sessionFactory.openSession();transaction=sess.beginTransaction();private void destory()mit();sess.close();sessionFactory.close();public TestDaoImp() Configuration configuration=new Configuration();configuration.config
17、ure();ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(configuration.getProperties().buildServiceRegistry();SessionFactory sessionFactory=configuration.buildSessionFactory(serviceRegistry);/為當(dāng)前的sessionFactory賦值this.sessionFactory=sessionFactory;Overridepublic List<Test&g
18、t; getTestBySid(int sid) Session session=sessionFactory.openSession();Query query;if(sid=-1)query=session.createQuery("from Test");else query=session.createQuery("from Test where subject.id="+sid);List<Test> tests=query.list();session.close();return tests;Overridepublic JSO
19、NArray getTestBySidJson(int sid)Session session=sessionFactory.openSession();Query query;if(sid=-1)query=session.createQuery("from Test");else query=session.createQuery("from Test where subject.id="+sid);List<Test> tests=query.list();JSONObject jsonObject;List<Test> a
20、lltest=new ArrayList<Test>();for (Test test : tests) Set<Answer> answers = new HashSet();/List<Answer> listanswers=Factory.getAnswerManage().getAnswersBytid(test.getId();Set<Answer> currentanswer=test.getAnswers();for (Answer answer : currentanswer) answer.setTest(null);answe
21、rs.add(answer);test.setAnswers(answers);test.setSubject(null);alltest.add(test);JSONArray jsonArray=new JSONArray().fromObject(tests);session.close();return jsonArray;Overridepublic List<Test> getTest() / TODO Auto-generated method stubreturn null;Overridepublic boolean saveTest(Test test) / T
22、ODO Auto-generated method stubreturn false;Overridepublic boolean updateTest(Test test) / TODO Auto-generated method stubreturn false;Overridepublic boolean deleteTest(Test test) / TODO Auto-generated method stubreturn false;(3) 用戶操作package com.test.dao;import java.util.ArrayList;import java.util.Li
23、st;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry;import org.hibernate.service.ServiceRegistryBuilder;import com.test.model.Department;imp
24、ort com.test.model.Professional;import com.test.model.Student;import com.test.model.StudentJson;import com.test.model.Users;import com.test.service.Factory;public class UserDaoImp implements UserDaoprivate SessionFactory sessionFactory;private Session sess;private Transaction transaction;private voi
25、d createsession()sess=sessionFactory.openSession();transaction=sess.beginTransaction();private void destory()mit();sess.close();sessionFactory.close();public UserDaoImp()Configuration configuration=new Configuration();configuration.configure();ServiceRegistry serviceRegistry=new ServiceRegistryBuild
26、er().applySettings(configuration.getProperties().buildServiceRegistry();SessionFactory sessionFactory=configuration.buildSessionFactory(serviceRegistry);/為當(dāng)前的sessionFactory賦值this.sessionFactory=sessionFactory;Overridepublic boolean select_user(Users user) System.out.println("開始執(zhí)行查找用戶操作");C
27、onfiguration configuration=new Configuration();configuration.configure();ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(configuration.getProperties().buildServiceRegistry();SessionFactory sessionFactory=configuration.buildSessionFactory(serviceRegistry);Session session=se
28、ssionFactory.openSession();/Transaction transaction=session.beginTransaction();String sql=" from Users as u where u.loginId='"+user.getLoginId()+"' and u.loginPwd='"+user.getLoginPwd()+"' and u.role='"+user.getRole()+"'"System.out.print
29、ln(sql);Query query=session.createQuery(sql);List<Users> alluser=query.list();/System.out.println(alluser);if(alluser.size()>0)System.out.println("找到有用戶");session.close();return true;elseSystem.out.println("沒有找到有用戶");return false;Overridepublic Student select_studentByUi
30、d(int uid) System.out.println("開始根據(jù)用戶的Id查找學(xué)生了");Session session=sessionFactory.openSession();String hsql="from Student as s where s.uid="+uid;System.out.println(hsql);Query query=session.createQuery(hsql);Student student=null;List<Student> students=query.list();session.clos
31、e();if(students.size()>0)student=students.get(0);return student;elsereturn student;Overridepublic Users getUserByLoginId(String LoginId) Session session=sessionFactory.openSession();String sql=" from Users as u where u.loginId='"+LoginId+"'"System.out.println(sql);Quer
32、y query=session.createQuery(sql);List<Users> alluser=query.list();if(alluser.size()>0)System.out.println("找到有用戶");session.close();return alluser.get(0);elsereturn null;Overridepublic boolean updateStudent(Student student) try createsession();sess.update(student);destory();return t
33、rue; catch (Exception e) / TODO: handle exceptionreturn false;Overridepublic int saveUsers(Users user) int uid=-1;try createsession();sess.save(user);uid=user.getId();destory();return uid; catch (Exception e) / TODO: handle exceptionreturn uid;Overridepublic int saveStudent(Student student) int id=-
34、1;try createsession();sess.save(student);id=student.getId();destory();return id; catch (Exception e) / TODO: handle exceptionreturn id;Overridepublic List<Student> getAllStudents() Session session=sessionFactory.openSession();String sql=" from Student"System.out.println(sql);Query qu
35、ery=session.createQuery(sql);List<Student> alluser=query.list();if(alluser.size()>0)System.out.println("找到有學(xué)生");session.close();return alluser;elsereturn null;Overridepublic List<StudentJson> getAllstudentJson() createsession();String sql=" from Student"System.out.
36、println(sql);Query query=sess.createQuery(sql);List<Student> alluser=query.list();List<StudentJson> studentJsons=new ArrayList<StudentJson>();if(alluser.size()>0)for(Student student:alluser)StudentJson studentJson=new StudentJson();studentJson.setAge(student.getAge().toString();
37、Department department=Factory.getDepartmentManage().getDepartMentById(student.getDepartment();Professional professional=Factory.getProfessionalManage().getProFeProfessionalById(student.getProfessionalId();studentJson.setDepartment(department.getDname();studentJson.setId(student.getId();studentJson.s
38、etName(student.getName();studentJson.setProfessional(professional.getPname();studentJson.setSex(student.getSex();studentJson.setXh(student.getXh();studentJsons.add(studentJson);destory();return studentJsons;elsereturn null;(4) 獲取分?jǐn)?shù)package com.test.dao;import java.util.ArrayList;import java.util.List
39、;import net.sf.json.JSONArray;import net.sf.json.JsonConfig;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry;import org.hibernate.service.Se
40、rviceRegistryBuilder;import com.test.model.Grade;import com.test.model.GradeJSon;import com.test.model.Professional;import com.test.model.Student;import com.test.model.Subject;import com.test.service.Factory;public class GradeDaoImp implements GradeDaoprivate SessionFactory sessionFactory;private Se
41、ssion sess;private Transaction transaction;private void createsession()sess=sessionFactory.openSession();transaction=sess.beginTransaction();private void destory()mit();sess.close();sessionFactory.close();public GradeDaoImp() Configuration configuration=new Configuration();configuration.configure();
42、ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(configuration.getProperties().buildServiceRegistry();SessionFactory sessionFactory=configuration.buildSessionFactory(serviceRegistry);/為當(dāng)前的sessionFactory賦值this.sessionFactory=sessionFactory;Overridepublic Grade getGradeByid(i
43、nt id) Session session=sessionFactory.openSession();Query query=session.createQuery("from Grade g where g.id="+id);List<Grade> grades=query.list();if(grades.size()>0)session.close();return grades.get(0);return null;Overridepublic List<Grade> getGradeByUid(int uid) System.out
44、.println("開始根據(jù)用戶的id來(lái)查找了"+uid);createsession();Query query;if(uid=-1)query=sess.createQuery("from Grade");else query=sess.createQuery("from Grade where student.uid="+uid);List<Grade> grades=query.list();for (Grade grade : grades) System.out.println(grade.getId();Sy
45、stem.out.println(grade.getSubject().getName();System.out.println(grade.getStudent().getUid();destory();return grades;Overridepublic boolean saveGrade(Grade grade) try createsession();sess.save(grade);destory();return true; catch (Exception e) System.out.println(e.getMessage();return false;Overridepu
46、blic boolean deleteGradeByid(int id) createsession();String sql="delete from Grade where id="+id;Query query=sess.createQuery(sql);if(query.executeUpdate()!=0)destory();return true;return false;Overridepublic boolean updateSubject(Grade grade) try createsession();sess.update(grade);destory
47、();return true; catch (Exception e) / TODO: handle exceptionreturn false;Overridepublic List<Grade> getGradeBySid(int sid) Session session=sessionFactory.openSession();Query query;if(sid=-1)query=session.createQuery("from Grade");else query=session.createQuery("from Grade where subject.id="+sid);List<Grade> grades=query.list();session.close();return grades;Overridepublic List<GradeJSon> getAllGradeJSON() Session session=sessionFactory.openSession();Query query=session.createQuery("from Grade");List<Grade> gr
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 高支模施工流程標(biāo)準(zhǔn)化方案
- 礦山工程混凝土拌合站物流方案
- Patulin-Standard-生命科學(xué)試劑-MCE
- Oxeladin-citrate-Standard-生命科學(xué)試劑-MCE
- 電力線路改遷應(yīng)急預(yù)案方案
- 2024學(xué)校維修工程合同書模板
- 2024銀行貸款合同范本
- 華中師范大學(xué)《科學(xué)社會(huì)主義》2021-2022學(xué)年第一學(xué)期期末試卷
- 華中師范大學(xué)《行政管理學(xué)》2022-2023學(xué)年第一學(xué)期期末試卷
- 非營(yíng)利組織宣傳品印刷管理方案
- 古希臘文明智慧樹知到期末考試答案章節(jié)答案2024年復(fù)旦大學(xué)
- excel自動(dòng)生產(chǎn)排程(至柔Ⅱ) 最新版
- 湖北某創(chuàng)省優(yōu)質(zhì)安全文明工地實(shí)施方案(楚天杯)_secret
- 案例分折----奇瑞信息化
- 九陽(yáng)真經(jīng)原文
- 企業(yè)有價(jià)證券管理制度
- 機(jī)關(guān)工作人員考勤表Excel模板
- 日照市重點(diǎn)支柱產(chǎn)業(yè)情況
- 兒童過(guò)敏性休克ppt課件
- 安全生產(chǎn)文明施工措施費(fèi)用明細(xì)報(bào)表范文
- 腹腔鏡設(shè)備的使用和保養(yǎng)PPT課件
評(píng)論
0/150
提交評(píng)論