Skip to content

Commit

Permalink
student exam
Browse files Browse the repository at this point in the history
  • Loading branch information
Allenyep committed May 19, 2018
1 parent 9760c13 commit 79578f3
Show file tree
Hide file tree
Showing 86 changed files with 1,898 additions and 5,463 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ target

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# .idea
.idea
3 changes: 3 additions & 0 deletions code/GDES/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

589 changes: 374 additions & 215 deletions code/GDES/.idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public interface UserMapper {

/**
* 根据用户名查询权限信息
* @param userName
* @param idU
* @return
*/
//todo
//
Set<String> selectPermissionByUserName(String idU);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gdes.GDES.model;

import java.util.List;

public class Questions {
private String idQ;

Expand All @@ -23,6 +25,18 @@ public class Questions {

private String deleteornotQ;

//手动添加,试题选项
//TODO:试题选项,查询试题列表时控制选择题查询对应选项
private List<Questionsoption> questionsO;

public List<Questionsoption> getQuestionsO() {
return questionsO;
}

public void setQuestionsO(List<Questionsoption> questionsO) {
this.questionsO = questionsO;
}

public String getIdQ() {
return idQ;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.gdes.GDES.service;

import com.gdes.GDES.model.Historytestpaper;

import java.util.List;

/**
* 历史试题
* Created by Allen on 2018/5/19.
*/
public interface HistorytestpaperService {
/**
* 根据学生主键查询历史列表
* @param idS
* @return
*/
public List<Historytestpaper> queryByStudentid(String idS);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

public interface KnowledgepointService {
//TODO:知识点添加修改删除
//知识点添加修改删除

/**
* 查询所有知识点
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public interface QuestionsService {

//TODO:根据试题编号,课程,题目类型,知识点查询试题
//根据试题编号,课程,题目类型,知识点查询试题

/**
* 查询所有知识点
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.gdes.GDES.service;


import com.gdes.GDES.model.Questionsoption;

import java.util.List;

/**
* 试题选项--针对选择题
* Created by Allen on 2018/5/16.
*/

public interface QuestionsoptionService {
/**
* 根据试题编号查询试题选项
* @param idQ
* @return
* @throws Exception
*/
public List<Questionsoption> queryByidQ(String idQ)throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.gdes.GDES.service.impl;

import com.gdes.GDES.dao.HistorytestpaperMapper;
import com.gdes.GDES.model.Historytestpaper;
import com.gdes.GDES.model.HistorytestpaperExample;
import com.gdes.GDES.service.HistorytestpaperService;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
* 历史试卷
* Created by Allen on 2018/5/19.
*/
@Repository
public class HistorytestpaperServiceImpl implements HistorytestpaperService {
@Resource
private HistorytestpaperMapper htpm;

public List<Historytestpaper> queryByStudentid(String idS) {
HistorytestpaperExample htpe=new HistorytestpaperExample();
HistorytestpaperExample.Criteria criteria=htpe.createCriteria();

criteria.andIdSEqualTo(idS);

return htpm.selectByExample(htpe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<Questions> queryQuestionBySytle(String styleQ) throws Exception {

public List<Questions> queryQuestionByKnowpoint(String idKp) throws Exception {
//方法2
//TODO:数据库级联操作转换为服务操作
//数据库级联操作转换为服务操作
QuestionspointExample qpe=new QuestionspointExample();
QuestionspointExample.Criteria criteria=qpe.createCriteria();
criteria.andIdKpEqualTo(Integer.valueOf(idKp));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.gdes.GDES.service.impl;


import com.gdes.GDES.dao.QuestionsoptionMapper;
import com.gdes.GDES.model.Questionsoption;
import com.gdes.GDES.model.QuestionsoptionExample;
import com.gdes.GDES.model.Questionspoint;
import com.gdes.GDES.service.QuestionsoptionService;
import com.gdes.GDES.service.QuestionspointService;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
* 试题类型
* Created by Allen on 2018/5/16.
*/
@Repository
public class QuestionsoptionServiceImpl implements QuestionsoptionService{

@Resource
private QuestionsoptionMapper qpm;

public List<Questionsoption> queryByidQ(String idQ) throws Exception {
QuestionsoptionExample qoe=new QuestionsoptionExample();
QuestionsoptionExample.Criteria criteria=qoe.createCriteria();
criteria.andIdQEqualTo(idQ);

return qpm.selectByExample(qoe);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.gdes.GDES.controller;

import com.gdes.GDES.model.Historytestpaper;
import com.gdes.GDES.model.Questions;
import com.gdes.GDES.service.HistorytestpaperService;
import com.gdes.GDES.service.QuestionsService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* 学生控制器
* Created by Allen on 2018/5/19.
*/
@Controller
@RequestMapping("/student/")
public class StudentController {
@Resource
private HistorytestpaperService htps;

@Resource
private QuestionsService qs;

//学生发送做题请求
//练习测评,从题库中选取未做过的试题进行计算,时间不写入
//TODO:考虑选择知识点进行测评
@RequestMapping(value = "examlianxi")
private String examlianxi(String idS, Model model)throws Exception{
//TODO:练习测评出题算法
List<Questions> qlist=qs.queryAllQusetion();
List<Questions> reslist=new ArrayList<>();
List<Historytestpaper> htplist=htps.queryByStudentid(idS);
for(Historytestpaper htp:htplist){
for(Questions q:qlist){
if(!htp.getIdQ().equals(q.getIdQ())){
//未做过的试题
reslist.add(q);
}
}
}
//从reslist当中随机选择5道
if(reslist.size()<5){
reslist.addAll(qlist.subList(0,5));
}
List<Questions> res=new ArrayList<>();
for(int i=0;i<5;i++){
int rand= (int)(Math.random()*reslist.size());
res.add(reslist.get(rand));
reslist.remove(rand);
}

model.addAttribute("examlist",res);


return "/student/addtest";
}

//正式测评,从题库中随机选取试题进行计算,计入时间
//随机:获取题目长度,然后抽取5道试题
@RequestMapping("examzhengshi")
private String examzhengshi(String idS,Model model){


return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import com.gdes.GDES.model.Questions;
import com.gdes.GDES.model.Questionsoption;
import com.gdes.GDES.model.Questionspoint;
import com.gdes.GDES.service.KnowledgepointService;
import com.gdes.GDES.service.QuestionsService;
import com.gdes.GDES.service.QuestionspointService;
import com.gdes.GDES.service.TeacherService;
import com.gdes.GDES.model.utils.UUid;
import com.gdes.GDES.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -33,7 +31,8 @@ public class TeacherController {
@Resource
private QuestionspointService qps;

//TODO:试题选项服务层
@Resource
private QuestionsoptionService qos;


/*==================*/
Expand Down Expand Up @@ -117,17 +116,18 @@ public String knowpoint(String message, Model model)throws Exception{
public String shitidetail(String idQ,Model model)throws Exception{
Questions q=qs.queryByPrimary(idQ);
model.addAttribute("que",q);
//TODO:是否是选择题,读取选择题选项
//是否是选择题,读取选择题选项
if(q.getStyleQ().equals("1")){
List<Questionsoption> questionsoptions;
List<Questionsoption> questionsoptions=qos.queryByidQ(q.getIdQ());
model.addAttribute("oplist",questionsoptions);
}

List<Questionspoint> qs= qps.queryByQuestionId(idQ);
List<Knowledgepoint> Allkplist=kps.queryAllKnowledgepoint();
List<Knowledgepoint> reslist=new ArrayList<>();
for(Questionspoint qp:qs){
for(Knowledgepoint kp:Allkplist){
if(qp.getIdKp()==kp.getIdKp()){
if(qp.getIdKp().equals(kp.getIdKp())){
reslist.add(kp);
}
}
Expand All @@ -139,9 +139,51 @@ public String shitidetail(String idQ,Model model)throws Exception{
}

//更新试题页面,试题内容,试题答案,试题知识点
//TODO:选择题
//TODO:选择题,添加知识点,修改试题选项,修改知识点
@RequestMapping("updateshiti")
public String updateshiti(){
public String updateshiti(String contextQ,String answerQ,
String scoreQ,String idQ,Model model)throws Exception{
Questions q=new Questions();
q.setContextQ(contextQ);
q.setAnswerQ(answerQ);
q.setScoreQ(scoreQ);
q.setIdQ(idQ);

String str=qs.updateQuestion(q);
model.addAttribute("message",str);
return shitidetail(idQ,model);
}

//添加试题,填空,大题
@RequestMapping("addshiti1")
public String addshiti1(String contextQ,String answerQ,
String scoreQ,Model model)throws Exception{
Questions q=new Questions();
q.setIdQ(UUid.getUUID());
q.setContextQ(contextQ);
q.setAnswerQ(answerQ);
q.setScoreQ(scoreQ);
if(answerQ.length()>10){
q.setStyleQ("4");
}else{
q.setStyleQ("2");
}

//TODO:课程,教师
q.setIdT("1");
q.setIdC("2");

String str=qs.addQuestion(q);
model.addAttribute("message",str);
System.out.println(str);

return knowpoint(str,model);
}

//添加选择,多选单选
@RequestMapping("addshiti2")
public String addshiti2()throws Exception{

return null;
}
}
Loading

0 comments on commit 79578f3

Please sign in to comment.