hehai
mzh820631607 4 years ago
parent f621b5ffb2
commit fa8aa0a999
  1. 8
      src/main/java/com/msdw/tms/controller/ClassTeachingController.java
  2. 20
      src/main/java/com/msdw/tms/service/impl/EvaluationRecordServiceImpl.java
  3. 2
      src/main/resources/mapper/tms/ClassTeachingDao.xml
  4. 4
      src/main/resources/mapper/tms/ExperimentalStudentDao.xml
  5. 4
      src/main/resources/mapper/tms/UserInfoDao.xml

@ -71,7 +71,7 @@ public class ClassTeachingController implements ClassTeachingApi {
*/ */
@Override @Override
@GetMapping("/checkInvitationCode") @GetMapping("/checkInvitationCode")
public R check(@RequestParam Integer userId,@RequestParam Integer projectId){ public R check(@RequestParam Integer userId,@RequestParam("id") Integer projectId){
List o = experimentalStudentService.queryIsCode(userId,projectId); List o = experimentalStudentService.queryIsCode(userId,projectId);
if (o.size()>0){ if (o.size()>0){
return R.ok(); return R.ok();
@ -91,6 +91,7 @@ public class ClassTeachingController implements ClassTeachingApi {
public R joinPractice(@RequestBody ExperimentalTeachingEntity entity1){ public R joinPractice(@RequestBody ExperimentalTeachingEntity entity1){
//获取参数 //获取参数
Integer projectId = entity1.getProjectId(); Integer projectId = entity1.getProjectId();
Integer id = entity1.getId();
Integer invitationCode = entity1.getInvitationCode(); Integer invitationCode = entity1.getInvitationCode();
Integer userId = entity1.getUserId(); Integer userId = entity1.getUserId();
//用于接受参数 //用于接受参数
@ -100,11 +101,12 @@ public class ClassTeachingController implements ClassTeachingApi {
//if (isCode==0) //if (isCode==0)
if (invitationCode!=null){ if (invitationCode!=null){
entity.setProjectId(projectId); entity.setId(id);
// entity.setProjectId(projectId);
ExperimentalTeachingEntity result= classTeachingService.queryInvitationcode(entity);//邀请码唯一 ExperimentalTeachingEntity result= classTeachingService.queryInvitationcode(entity);//邀请码唯一
Integer code = result.getInvitationCode(); Integer code = result.getInvitationCode();
if (invitationCode.equals(code)==true){ if (invitationCode.equals(code)==true){
ExperimentalStudentEntity student = studentEntity.setUserId(userId).setProjectId(projectId); ExperimentalStudentEntity student = studentEntity.setUserId(userId).setProjectId(id);
experimentalStudentService.saveCode(student); experimentalStudentService.saveCode(student);
return R.ok(); return R.ok();
}else{ }else{

@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -318,6 +319,7 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
String userAnswer) { String userAnswer) {
//1、根据当前传递的evaluationRecordId和currentQuestionSortNo查询当前试题 //1、根据当前传递的evaluationRecordId和currentQuestionSortNo查询当前试题
EvaluationQuestionVO evaluationQuestionVO = evaluationQuestionDao.selectByInfo(evaluationRecordId, currentQuestionSortNo); EvaluationQuestionVO evaluationQuestionVO = evaluationQuestionDao.selectByInfo(evaluationRecordId, currentQuestionSortNo);
if (evaluationQuestionVO == null) { if (evaluationQuestionVO == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM); ExceptionCast.cast(CommonCode.INVALID_PARAM);
} }
@ -325,6 +327,19 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
Integer questionPoints = evaluationQuestionVO.getQuestionPoints(); Integer questionPoints = evaluationQuestionVO.getQuestionPoints();
//正确答案 //正确答案
String answer = evaluationQuestionVO.getAnswer(); String answer = evaluationQuestionVO.getAnswer();
String userString = "";
String answerString = "";
char[] arr = userAnswer.toCharArray();
Arrays.sort(arr);
for (char a : arr){
userString = userString + String.valueOf(a);
}
char[] array = answer.toCharArray();
Arrays.sort(array);
for (char b : array){
answerString = answerString + String.valueOf(b);
}
//修改当前试题状态 //修改当前试题状态
//记录用户的答案 //记录用户的答案
//判断当前试题正误 //判断当前试题正误
@ -333,13 +348,14 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
evaluationQuestion.setId(evaluationQuestionVO.getId()); evaluationQuestion.setId(evaluationQuestionVO.getId());
evaluationQuestion.setUserAnswer(userAnswer); evaluationQuestion.setUserAnswer(userAnswer);
//如果用户答案为空,则设置状态为未作,设为错,得分设为0 //如果用户答案为空,则设置状态为未作,设为错,得分设为0
if (StringUtils.isEmpty(userAnswer)) { // if (StringUtils.isEmpty(userAnswer)) {
if (StringUtils.isEmpty(userString)) {
evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.NOT_MADE.getType()); evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.NOT_MADE.getType());
evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType()); evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType());
evaluationQuestion.setQuestionScore(0); evaluationQuestion.setQuestionScore(0);
} else { } else {
evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.MADE.getType()); evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.MADE.getType());
if (!answer.equals(userAnswer)) { if (!answerString.equals(userString)) {
evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType()); evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType());
evaluationQuestion.setQuestionScore(0); evaluationQuestion.setQuestionScore(0);
} else { } else {

@ -3,7 +3,7 @@
<mapper namespace="com.msdw.tms.dao.ClassTeachingDao"> <mapper namespace="com.msdw.tms.dao.ClassTeachingDao">
<select id="queryInvitationCode" resultType="com.msdw.tms.entity.ExperimentalTeachingEntity"> <select id="queryInvitationCode" resultType="com.msdw.tms.entity.ExperimentalTeachingEntity">
select invitation_code from tms_experimental_teaching where project_id = #{projectId} select invitation_code from tms_experimental_teaching where id = #{id}
</select> </select>
<select id="getByClassRecord" resultType="com.msdw.tms.entity.ExperimentalTeachingEntity"> <select id="getByClassRecord" resultType="com.msdw.tms.entity.ExperimentalTeachingEntity">

@ -3,10 +3,10 @@
<mapper namespace="com.msdw.tms.dao.ExperimentalStudentDao"> <mapper namespace="com.msdw.tms.dao.ExperimentalStudentDao">
<select id="queryIsCode" resultType="Map"> <select id="queryIsCode" resultType="Map">
SELECT userId FROM tms_experimental_student WHERE userId = #{userId} AND projectId = #{projectId} SELECT userId FROM tms_experimental_student WHERE userId = #{userId} AND id = #{projectId}
</select> </select>
<insert id="saveCode" parameterType="com.msdw.tms.entity.ExperimentalStudentEntity"> <insert id="saveCode" parameterType="com.msdw.tms.entity.ExperimentalStudentEntity">
INSERT INTO tms_experimental_student(projectId,userId) VALUES (#{projectId},#{userId}) INSERT INTO tms_experimental_student(projectId,userId) VALUES (#{id},#{userId})
</insert> </insert>
</mapper> </mapper>

@ -49,8 +49,8 @@
schoolId = #{schoolId}, schoolId = #{schoolId},
</if> </if>
<if test="phone !=null"> <if test="phone !=null">
phone #{phone} phone = #{phone}
</if>> </if>
</set> </set>
WHERE userId = #{userId}; WHERE userId = #{userId};

Loading…
Cancel
Save