這套基于Java在線考試系統(tǒng)是我的優(yōu)秀畢業(yè)設(shè)計(jì)作品,當(dāng)初是團(tuán)隊(duì)開(kāi)發(fā)出來(lái)的,花了兩個(gè)月時(shí)間。從系統(tǒng)設(shè)計(jì)到開(kāi)發(fā)成功都花了團(tuán)隊(duì)很多的心血。
在線考試系統(tǒng)實(shí)現(xiàn)了包含題庫(kù)編輯、抽題組卷、試題分析、在線考試等模塊的Web考試系統(tǒng)。在線考試系統(tǒng)一直以來(lái)就畢業(yè)設(shè)計(jì)的熱門選題,難度也算是比較高的畢設(shè)項(xiàng)目了。對(duì)學(xué)生的技術(shù)水平要求高,工作量也比較大。
在線考試系統(tǒng)已經(jīng)實(shí)現(xiàn)的主要功能有:
1、在線考試(包含限定時(shí)間設(shè)置),支持選擇題、填空題、判斷題三種題型,自動(dòng)判分
2、選擇題、填空題、判斷題及用戶信息的文本文件數(shù)據(jù)的Web導(dǎo)入
3、用戶注冊(cè)、登錄、修改密碼、基本信息管理
4、按照一定給分策略進(jìn)行抽題和組卷,支持“固定組卷” 和“隨機(jī)組卷”兩種方式
5、按照內(nèi)容、知識(shí)點(diǎn)、答案等搜索題庫(kù),題目及分?jǐn)?shù)的統(tǒng)計(jì)
6、章節(jié)知識(shí)點(diǎn)的分層和樹(shù)狀展示
7、管理廣播消息的推送、系統(tǒng)設(shè)置的修改
項(xiàng)目是基于Java+Tomca+Mysql開(kāi)發(fā)的,部署簡(jiǎn)單,代碼注釋詳細(xì)易懂。
下面看下在線考試系統(tǒng)數(shù)據(jù)庫(kù)表設(shè)計(jì)
登錄代碼
package cn.lynu.lyq.java_exam.actions;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import cn.lynu.lyq.java_exam.dao.StudentDao;
import cn.lynu.lyq.java_exam.entity.Student;
@Component("userLogin")
@Scope("prototype")
public class UserLoginAction extends ActionSupport {
private static final long serialVersionUID = 5090548832375142158L;
private final static Logger logger = LoggerFactory.getLogger(UserLoginAction.class);
private String registerNo;
private String password;
private String username;
@Resource
private StudentDao studentDao;
public String getRegisterNo() {
return registerNo;
}
public void setRegisterNo(String registerNo) {
this.registerNo = registerNo;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String execute() throws Exception {
logger.info("用戶登陸");
Student stu = studentDao.findByRegNoAndPassword(registerNo, password);
if(stu!=null){
username=stu.getName();
ActionContext ctx=ActionContext.getContext();
ctx.getSession().put("USER_INFO", stu);
}else{
this.addActionError("學(xué)號(hào)或密碼錯(cuò)誤,請(qǐng)重新輸入!");
}
return SUCCESS;
}
public String logout() throws Exception{
logger.info("用戶退出登陸");
ActionContext ctx=ActionContext.getContext();
ctx.getSession().remove("USER_INFO");
this.addActionMessage("退出登陸成功!");
return SUCCESS;
}
}
成績(jī)功能代碼
package cn.lynu.lyq.java_exam.actions;
import java.awt.Font;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.lang.ArrayUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.ui.TextAnchor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import cn.lynu.lyq.java_exam.common.ExamPhase;
import cn.lynu.lyq.java_exam.dao.ExamDao;
import cn.lynu.lyq.java_exam.dao.StudentDao;
import cn.lynu.lyq.java_exam.dao.StudentExamScoreDao;
import cn.lynu.lyq.java_exam.entity.Student;
import cn.lynu.lyq.java_exam.entity.StudentExamScore;
import cn.lynu.lyq.java_exam.misc.CustomColorBarRenderer;
@Component("scoresBarChart")
@Scope("prototype")
public class ScoresBarChartAction extends ActionSupport {
private static final long serialVersionUID = 2217462899746164125L;
private final static Logger logger = LoggerFactory.getLogger(ScoresBarChartAction.class);
private JFreeChart chart;
@Resource
private StudentDao studentDao;
@Resource
private ExamDao examDao;
@Resource
private StudentExamScoreDao studentExamScoreDao;
public JFreeChart getChart() {
return chart;
}
public void setChart(JFreeChart chart) {
this.chart = chart;
}
@Override
public String execute() throws Exception {
// double[][] data = new double[][] { { 90 , 80 , 77 , 85 } };
// String[] rowKeys = {""};
// String[] columnKeys = { "張三", "李四", "王二", "馬六" };
ActionContext ctx =ActionContext.getContext();
String classSearch=ctx.getParameters().get("classSearch").getValue();
String examNameSearch=ctx.getParameters().get("examNameSearch").getValue();
logger.debug("classSearch=["+classSearch+"]");
logger.debug("examNameSearch=["+examNameSearch+"]");
// Student theStudent =(Student)ctx.getSession().get("USER_INFO");
// List<Student> stuList = studentDao.findByGrade(theStudent.getGrade());
List<String> examNameList = examDao.findAllDistinctExamName();
if(!examNameSearch.equals("")){
examNameSearch=examNameList.get(Integer.parseInt(examNameSearch)-1);
}else{
examNameSearch=examNameList.get(0);
}
List<StudentExamScore> list1 = studentExamScoreDao.findByClassIdAndExamNameAndExamPhase(classSearch,examNameSearch,
ExamPhase.FINAL_SCORED.getChineseName());
List<String> stuNameList = new ArrayList<>();
List<Double> scoreList = new ArrayList<>();
for(StudentExamScore examScore:list1){
scoreList.add((double)examScore.getScore());
Student stu = studentDao.findById(examScore.getStudent().getId());
stuNameList.add(stu.getName());
}
String[] stuNameArray = (String[])stuNameList.toArray(new String[stuNameList.size()]);
Double[] integerScoreArray = (Double[])scoreList.toArray(new Double[scoreList.size()]);
double[] scoreArray = ArrayUtils.toPrimitive(integerScoreArray);
//排序
int[] index = new int[scoreArray.length];//原始下標(biāo)數(shù)組
for(int i=0; i<scoreArray.length; i++){
index[i] = i;
}
sortWithIndex(scoreArray,index);
//根據(jù)分?jǐn)?shù)排序,重新排列姓名數(shù)組
String[] stuNameArraySorted = new String[stuNameArray.length];
for(int i=0; i<stuNameArray.length; i++){
stuNameArraySorted[i] = stuNameArray[index[i]];
}
double[][] data = new double[][] { scoreArray };
String[] rowKeys = {""};
String[] columnKeys = stuNameArraySorted;
// logger.debug(">>>>>>>>>>學(xué)生名列表:"+Arrays.toString(stuNameArraySorted));
// logger.debug(">>>>>>>>>>學(xué)生名length:"+stuNameArraySorted.length);
// logger.debug(">>>>>>>>>>分?jǐn)?shù)列表:"+Arrays.toString(scoreArray));
// logger.debug(">>>>>>>>>>分?jǐn)?shù)length"+scoreArray.length);
CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
// 創(chuàng)建主題樣式
StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
// 設(shè)置標(biāo)題字體
standardChartTheme.setExtraLargeFont(new Font("SimHei", Font.BOLD, 20));
// 設(shè)置圖例的字體
standardChartTheme.setRegularFont(new Font("Microsoft YaHei", Font.PLAIN, 15));
// 設(shè)置軸向的字體
standardChartTheme.setLargeFont(new Font("Microsoft YaHei", Font.PLAIN, 15));
standardChartTheme.setSmallFont(new Font("Microsoft YaHei", Font.PLAIN, 12));
// 應(yīng)用主題樣式
ChartFactory.setChartTheme(standardChartTheme);
chart = ChartFactory.createBarChart3D("成績(jī)分布圖", "姓名", "成績(jī)", dataset, PlotOrientation.HORIZONTAL, false,
false, false);
CategoryPlot plot = chart.getCategoryPlot();// 獲得圖表區(qū)域?qū)ο? CustomColorBarRenderer renderer = new CustomColorBarRenderer();
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE4, TextAnchor.BASELINE_RIGHT));
renderer.setItemLabelAnchorOffset(25D);
renderer.setBaseItemLabelsVisible(true);
plot.setRenderer(renderer);
return SUCCESS;
}
/*
* 冒泡排序 并返回 排序?qū)?yīng)的原始下標(biāo)
*/
public void sortWithIndex(double[] array, int[] index){
// index = new int[array.length];//原始下標(biāo)數(shù)組
// for(int i=0; i<array.length; i++){
// index[i] = i;
// }
for(int i=0; i<array.length; i++){//冒泡輪次i
for(int j=0; j<array.length-i-1; j++){//參與比較的數(shù)組下標(biāo)j
if(array[j]<array[j+1]){
double tmp = array[j];
array[j] = array[j+1];
array[j+1] = tmp;
int tmp2 = index[j];
index[j] = index[j+1];
index[j+1] = tmp2;
}
}
}
}
}
需要可以加微信(LGY178888)了解下!