Compare commits

..

5 Commits

Author SHA1 Message Date
670788339
52cd846750 日志 2024-09-02 15:22:01 +08:00
670788339
89fb61b9d0 日志 2024-09-02 15:15:59 +08:00
670788339
e67b2db8df 日志 2024-09-02 14:46:58 +08:00
670788339
66225736e6 Keyword 日志 2024-09-02 12:02:07 +08:00
670788339
ee93a0c0dc Keyword null显示'' 2024-09-02 11:49:11 +08:00
15 changed files with 171 additions and 357 deletions

View File

@@ -12,10 +12,13 @@ import com.xboe.module.dict.entity.DictDto;
import com.xboe.module.exam.entity.ExamTest; import com.xboe.module.exam.entity.ExamTest;
import com.xboe.school.study.entity.StudyCourse; import com.xboe.school.study.entity.StudyCourse;
import com.xboe.system.user.dao.UserDao; import com.xboe.system.user.dao.UserDao;
import com.xboe.system.user.entity.User;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;

View File

@@ -9,7 +9,6 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,7 +28,6 @@ import com.xboe.module.course.service.ICourseFileService;
*/ */
@RestController @RestController
@RequestMapping(value = "/xboe/m/course/cware") @RequestMapping(value = "/xboe/m/course/cware")
@Slf4j
public class CourseWareApi extends ApiBaseController { public class CourseWareApi extends ApiBaseController {
private String cookieName = "PLAYSIGN_TIME"; private String cookieName = "PLAYSIGN_TIME";
@@ -133,8 +131,6 @@ public class CourseWareApi extends ApiBaseController {
// 第一个/前端是时间 // 第一个/前端是时间
int index = signStr.indexOf("/"); int index = signStr.indexOf("/");
if (index <= 0) { if (index <= 0) {
log.info("解密后的字符串:"+signStr);
log.info("解密后的字符串的时间拼接:"+index);
return badRequest("验证错误"); return badRequest("验证错误");
} }
@@ -142,13 +138,9 @@ public class CourseWareApi extends ApiBaseController {
String cfid = signStr.substring(index+1);// 文件路径 String cfid = signStr.substring(index+1);// 文件路径
if (!time.equals(cookieTime)) { if (!time.equals(cookieTime)) {
log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
log.info("解密后的字符串的时间拼接:"+signStr);
return badRequest("验证错误"); return badRequest("验证错误");
} }
if(StringUtils.isBlank(cfid) || cfid.length()<10) { if(StringUtils.isBlank(cfid) || cfid.length()<10) {
log.info("查看时间文件路径:"+cfid);
log.info("解密后的字符串的时间拼接:"+signStr);
return badRequest("验证错误"); return badRequest("验证错误");
} }

View File

@@ -83,13 +83,8 @@ public class CourseContent extends BaseEntity {
* */ * */
@Column(name = "duration") @Column(name = "duration")
private Integer duration; private Integer duration;
/**
* 视频播放进度
* */
@Column(name = "progress_video")
private Float progressVideo;
/**用于学习时的状态显示,非存储字段*/ /**用于学习时的状态显示,非存储字段*/
@Transient @Transient
private Integer status; private Integer status;

View File

@@ -82,7 +82,4 @@ public interface ICourseContentService{
* @return * @return
*/ */
CourseAssess getAssess(String ccid); CourseAssess getAssess(String ccid);
void updateProcessVideo(String contentId, String courseId, Float processVideo);
} }

View File

@@ -1,7 +1,5 @@
package com.xboe.module.course.service.impl; package com.xboe.module.course.service.impl;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -143,17 +141,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
return assess; return assess;
} }
@Override
@Transactional
public void updateProcessVideo(String id, String courseId, Float progressVideo) {
// 处理 processVideo 为 null 的情况
if (progressVideo == null) {
progressVideo = 0.00f;
}
String sql = "UPDATE boe_course_content SET progress_video = "+ progressVideo+" WHERE id = "+ id+" AND course_id = "+ courseId+" ";
ccDao.sqlUpdate(sql);
}
@Override @Override
@Transactional @Transactional
public void updateName(String id, String name) { public void updateName(String id, String name) {

View File

@@ -355,17 +355,17 @@ public class AloneExamApi extends ApiBaseController {
return badRequest("此考试无试卷内容,考试已经过期或试卷已被删除"); return badRequest("此考试无试卷内容,考试已经过期或试卷已被删除");
} }
try { try {
List<TestQuestionVo> qlist=this.randomQuestion(examTest, paperJson); List<TestQuestionVo> qlist=this.randomQuestion(examTest, paperJson);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
paperJson=objectMapper.writeValueAsString(qlist); paperJson=objectMapper.writeValueAsString(qlist);
} catch (XaskException e) { } catch (XaskException e) {
log.error("生成试卷错误",e); log.error("生成试卷错误",e);
return error("生成考试试卷错误",e.getMessage(),map); return error("生成考试试卷错误",e.getMessage(),map);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
log.error("生成试卷解析生成json错误",e); log.error("生成试卷解析生成json错误",e);
return error("生成考试试卷解析错误",e.getMessage(),map); return error("生成考试试卷解析错误",e.getMessage(),map);
} }
} }
map.put("paper", paperJson); map.put("paper", paperJson);
long end=System.currentTimeMillis(); long end=System.currentTimeMillis();
log.info("开始考试用时="+(end-start)+" ms"); log.info("开始考试用时="+(end-start)+" ms");

View File

@@ -166,258 +166,118 @@ public class ExamQuestionApi extends ApiBaseController {
return badRequest("请上传正确的试题文件"); return badRequest("请上传正确的试题文件");
} }
//获取表头 //获取表头
Row row ; Row row = sheetAt.getRow(1);
//从第二行开始获取数据 //从第二行开始获取数据
List<ExamQuestion> examQuestions1 = new ArrayList<>(); List<ExamQuestion> examQuestions1 = new ArrayList<>();
QuestionDto questionDto = new QuestionDto(); QuestionDto questionDto = new QuestionDto();
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)") && !sheetAt.getRow(1).getCell(0).getStringCellValue().equals("")){
row = sheetAt.getRow(1);
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
Row row1 = sheetAt.getRow(i); for (int i=2;i<sheetAt.getPhysicalNumberOfRows();i++) {
if(row1==null || row1.getCell(0)==null){ //获取每一行
break;
}
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
break;
}
ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
if(row1.getCell(1).getStringCellValue().equals("单选题")){
examQuestion.setType(1);
}
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
} else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}
Cell cell = row1.getCell(3);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue())); Row row1 = sheetAt.getRow(i);
if(row1==null || row1.getCell(0)==null){
//单选 break;
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){
examQuestion.setDefaultScore(null);
}else {
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=6;j<=12;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(5).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=6;j<=12;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-6]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
} }
}else { if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
row = sheetAt.getRow(2); break;
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) { }
//获取每一行 ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
Row row1 = sheetAt.getRow(i); if(row1.getCell(1).getStringCellValue().equals("单选题")){
if(row1==null || row1.getCell(0)==null){ examQuestion.setType(1);
break; }
} if(row1.getCell(1).getStringCellValue().equals("多选题")){
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){ examQuestion.setType(2);
break; }
} examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
ExamQuestion examQuestion = new ExamQuestion(); if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setTitle(row1.getCell(0).getStringCellValue()); examQuestion.setDifficulty(2f);
if(row1.getCell(1).getStringCellValue().equals("单选题")){ }
examQuestion.setType(1); if(row1.getCell(3).getStringCellValue().equals("")){
} examQuestion.setDifficulty(3f);
if(row1.getCell(1).getStringCellValue().equals("多选题")){ }
examQuestion.setType(2); if(row1.getCell(3).getStringCellValue().equals("")){
} examQuestion.setDifficulty(1f);
log.debug("row1.getCell(2) = " + row1.getCell(2)); }
if (row1.getCell(2)==null ||row1.getCell(2).getStringCellValue() == null || row1.getCell(2).getStringCellValue().equals("")){ Cell cell = row1.getCell(4);
examQuestion.setDifficulty(null); cell.setCellType(CellType.STRING);
}else{
if( row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
} else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}
}
Cell cell = row1.getCell(3);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue())); // examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选 //单选
if (!cell.getStringCellValue().contains(",")){ if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(5).getStringCellValue()); examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){ examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
examQuestion.setDefaultScore(null); Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
}else { cell1.setCellType(CellType.STRING);
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue())); examQuestion.setAnalysis(cell1.getStringCellValue());
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>(); List<ExamOption> examOptions = new ArrayList<>();
for (int j=6;j<=12;j++) { for (int j=7;j<=13;j++) {
if(row1.getCell(j)!=null) { if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption(); ExamOption examOption = new ExamOption();
// 截取表头 // 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4); String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(5).getStringCellValue().contains(substring)) { if (row1.getCell(6).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=6;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true); examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-6])); examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){ } else {
examOptions.add(examOption); examOption.setIsAnswer(false);
} }
if (examOption.getIsAnswer()) {
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
} }
} }
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
} }
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=7;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
} }
} }
//判断题 只存在试题表中 //判断题 只存在试题表中
@@ -440,30 +300,27 @@ public class ExamQuestionApi extends ApiBaseController {
ExamQuestion examQuestion1 = new ExamQuestion(); ExamQuestion examQuestion1 = new ExamQuestion();
examQuestion1.setTitle(row2.getCell(0).getStringCellValue()); examQuestion1.setTitle(row2.getCell(0).getStringCellValue());
examQuestion1.setType(3); examQuestion1.setType(3);
System.out.println("1+++++++"+row2.getCell(1)); examQuestion1.setKnowledge(row2.getCell(1).getStringCellValue());
if(row2.getCell(1).getStringCellValue().equals("")){ if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(2f); examQuestion1.setDifficulty(2f);
}else if(row2.getCell(1).getStringCellValue().equals("")){ }
if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(3f); examQuestion1.setDifficulty(3f);
} else if(row2.getCell(1).getStringCellValue().equals("")){ }
if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(1f); examQuestion1.setDifficulty(1f);
}else if(row2.getCell(1).getStringCellValue().equals("")){
examQuestion1.setDifficulty(null);
} }
Cell cell1 = row2.getCell(2); Cell cell1 = row2.getCell(3);
cell1.setCellType(CellType.STRING); cell1.setCellType(CellType.STRING);
if (row2.getCell(2).getStringCellValue().isEmpty()){ examQuestion1.setDefaultScore(Float.valueOf(cell1.getStringCellValue()));
examQuestion1.setDefaultScore(null);
}else { if(row2.getCell(4)!=null) {
examQuestion1.setDefaultScore(Float.valueOf(row2.getCell(2).getStringCellValue())); examQuestion1.setAnalysis(row2.getCell(4).getStringCellValue());
}
if(row2.getCell(3)!=null) {
examQuestion1.setAnalysis(row2.getCell(3).getStringCellValue());
}else { }else {
examQuestion1.setAnalysis(""); examQuestion1.setAnalysis("");
} }
String cvalue=row2.getCell(4).getStringCellValue(); String cvalue=row2.getCell(5).getStringCellValue();
examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false"); examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false");
if(examQuestion1!=null){ if(examQuestion1!=null){
examQuestions2.add(examQuestion1); examQuestions2.add(examQuestion1);

View File

@@ -28,7 +28,7 @@ public class ExamTest extends BaseEntity {
/** /**
* 考试名称 * 考试名称
* */ * */
@Column(name = "test_name",length = 50) @Column(name = "test_name",nullable = false,length = 50)
private String testName; private String testName;
/** /**
@@ -46,7 +46,7 @@ public class ExamTest extends BaseEntity {
/** /**
* 考试时长 分钟 * 考试时长 分钟
* */ * */
@Column(name = "test_duration") @Column(name = "test_duration",nullable = false)
private Integer testDuration; private Integer testDuration;
/** /**
* 显示解析 * 显示解析
@@ -107,13 +107,13 @@ public class ExamTest extends BaseEntity {
/** /**
* 考试的类型 * 考试的类型
* */ * */
@Column(name = "test_type") @Column(name = "test_type",nullable = false)
private Integer testType; private Integer testType;
/** /**
* 发布状态 ,是否已发布 * 发布状态 ,是否已发布
*/ */
@Column(name = "published",length = 1) @Column(name = "published",length = 1,nullable = false)
private Boolean published; private Boolean published;
/** /**
* 发布时间 * 发布时间
@@ -154,7 +154,7 @@ public class ExamTest extends BaseEntity {
/** /**
* 范围1表独立使用2表课程内部 * 范围1表独立使用2表课程内部
* */ * */
@Column(name = "range_type") @Column(name = "range_type",nullable = false)
private Integer rangeType; private Integer rangeType;
/** /**

View File

@@ -95,7 +95,7 @@ public class ExamTestServiceImpl implements IExamTestService {
@Override @Override
public Boolean has(String paperId) { public Boolean has(String paperId) {
ExamTest et=examTestDao.findOne(FieldFilters.eq("paperId", paperId),FieldFilters.eq("deleted", false)); ExamTest et=examTestDao.findOne(FieldFilters.eq("paperId", paperId));
//String etId= (String)examTestDao.findField("id", FieldFilters.eq("paperId", paperId)); //String etId= (String)examTestDao.findField("id", FieldFilters.eq("paperId", paperId));
if(et==null){ if(et==null){
return true; return true;

View File

@@ -11,7 +11,6 @@ import com.xboe.api.vo.*;
import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.entity.UserGroupItem; import com.xboe.module.usergroup.entity.UserGroupItem;
import com.xboe.module.usergroup.service.IUserGroupService; import com.xboe.module.usergroup.service.IUserGroupService;
import com.xboe.school.study.dao.StudyCourseDao;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -66,9 +65,7 @@ import javax.servlet.http.HttpServletRequest;
@RestController @RestController
@RequestMapping(value="/xboe/school/study/course") @RequestMapping(value="/xboe/school/study/course")
public class StudyCourseApi extends ApiBaseController{ public class StudyCourseApi extends ApiBaseController{
@Autowired @Autowired
IStudyCourseService service; IStudyCourseService service;
@@ -324,19 +321,8 @@ public class StudyCourseApi extends ApiBaseController{
if (StringUtils.isEmpty(token)) { if (StringUtils.isEmpty(token)) {
token = request.getHeader("token"); token = request.getHeader("token");
} }
//检查是否已存在 //检查是否已存在
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId()); StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
// 20240815 特训营结营考试 临时代码
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
// redisTemplate.opsForValue().set(item.getId(),item.getId());
// //设置过期时间为1天
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
// }else{
// return success("");
// }
if(item!=null) { if(item!=null) {
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况 //如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) { if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
@@ -421,14 +407,6 @@ public class StudyCourseApi extends ApiBaseController{
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId()); StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) { if(item!=null) {
//如果记录存在但是进度不到100未完成情况就更新进度一期不会有这种情况 //如果记录存在但是进度不到100未完成情况就更新进度一期不会有这种情况
// 20240815 特训营结营考试 临时代码
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
// redisTemplate.opsForValue().set(item.getId(),item.getId());
// //设置过期时间为1天
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
// }else{
// return success("");
// }
if(item.getProgress()<100) { if(item.getProgress()<100) {
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token); studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
} }
@@ -534,14 +512,6 @@ public class StudyCourseApi extends ApiBaseController{
token = request.getHeader("token"); token = request.getHeader("token");
} }
try { try {
// 20240815 特训营结营考试 临时代码
// if(itemId != null && redisTemplate.opsForValue().get(itemId)==null){
// redisTemplate.opsForValue().set(itemId,itemId);
// //设置过期时间为1天
// redisTemplate.expire(itemId, 60, TimeUnit.SECONDS);
// }else{
// return success(true);
// }
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token); studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token); List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
log.info("在线课学习记录"+allUserList); log.info("在线课学习记录"+allUserList);
@@ -559,7 +529,7 @@ public class StudyCourseApi extends ApiBaseController{
* @return * @return
*/ */
@PostMapping("/study-video-time") @PostMapping("/study-video-time")
public JsonResponse<Boolean> study(String itemId,Integer videoTime,String contentId , String courseId,Float progressVideo){ public JsonResponse<Boolean> study(String studyId,String itemId,Integer videoTime){
if(StringUtils.isBlank(itemId)){ if(StringUtils.isBlank(itemId)){
return error("参数错误"); return error("参数错误");
@@ -569,10 +539,7 @@ public class StudyCourseApi extends ApiBaseController{
} }
//检查是否已存在 //检查是否已存在
try { try {
studyService.updateLastTime(itemId,videoTime, getCurrent().getAccountId()); studyService.updateLastTime(itemId,videoTime,getCurrent().getAccountId());
if (contentId != null && courseId != null && progressVideo != null){
contentService.updateProcessVideo(contentId, courseId, progressVideo);
}
return success(true); return success(true);
}catch(Exception e) { }catch(Exception e) {
log.error("记录最后学习时间错误",e); log.error("记录最后学习时间错误",e);
@@ -723,10 +690,9 @@ public class StudyCourseApi extends ApiBaseController{
return error("查询失败",e.getMessage()); return error("查询失败",e.getMessage());
} }
} }
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){ public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
if(StringUtils.isBlank(studyId)){ if(StringUtils.isBlank(studyId)){
return error("无学习信息"); return error("无学习信息");
} }

View File

@@ -7,7 +7,6 @@ import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.xboe.api.ThirdApi; import com.xboe.api.ThirdApi;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.entity.StudyCourse; import com.xboe.school.study.entity.StudyCourse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -33,8 +32,6 @@ import javax.servlet.http.HttpServletRequest;
@RestController @RestController
@RequestMapping(value="/xboe/school/study/exam") @RequestMapping(value="/xboe/school/study/exam")
public class StudyExamApi extends ApiBaseController{ public class StudyExamApi extends ApiBaseController{
@Autowired
StudyCourseDao scDao;
@Autowired @Autowired
IStudyExamService sexamService; IStudyExamService sexamService;

View File

@@ -44,7 +44,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
LocalDateTime ldt=LocalDateTime.now(); LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(assess.getStudyId()); sci.setStudyId(assess.getStudyId());
sci.setContentId(assess.getContentId()); sci.setContentId(assess.getContentId());
sci.setContentName("评估"); //sci.setContentName(homework.getContentName());
sci.setCourseId(assess.getCourseId()); sci.setCourseId(assess.getCourseId());
//sci.setCsectionId(homework.getCsectionId()); //sci.setCsectionId(homework.getCsectionId());
sci.setProgress(100);//直接设置为学习完成 sci.setProgress(100);//直接设置为学习完成

View File

@@ -82,7 +82,7 @@ public class StudyExamServiceImpl implements IStudyExamService{
LocalDateTime ldt=LocalDateTime.now(); LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(exam.getStudyId()); sci.setStudyId(exam.getStudyId());
sci.setContentId(exam.getContentId()); sci.setContentId(exam.getContentId());
sci.setContentName("考试"); //sci.setContentName(homework.getContentName());
sci.setCourseId(exam.getCourseId()); sci.setCourseId(exam.getCourseId());
//sci.setCsectionId(homework.getCsectionId()); //sci.setCsectionId(homework.getCsectionId());
sci.setProgress(prog);//直接设置为学习完成 sci.setProgress(prog);//直接设置为学习完成

View File

@@ -46,7 +46,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
LocalDateTime ldt=LocalDateTime.now(); LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(homework.getStudyId()); sci.setStudyId(homework.getStudyId());
sci.setContentId(homework.getContentId()); sci.setContentId(homework.getContentId());
sci.setContentName(homework.getHwName()); //sci.setContentName(homework.getContentName());
sci.setCourseId(homework.getCourseId()); sci.setCourseId(homework.getCourseId());
//sci.setCsectionId(homework.getCsectionId()); //sci.setCsectionId(homework.getCsectionId());
sci.setProgress(100);//直接设置为学习完成 sci.setProgress(100);//直接设置为学习完成
@@ -67,7 +67,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
//只是保留一条作业记录,不再保存多条记录了 //只是保留一条作业记录,不再保存多条记录了
//dao.save(homework); //dao.save(homework);
//设置id。然后进行悠 //设置id。然后进行悠
homework.setId(homework.getStudyItemId()); homework.setId(obj.toString());
dao.update(homework); dao.update(homework);
} }
} }

View File

@@ -98,12 +98,8 @@ public class StudyServiceImpl implements IStudyService{
//sci.setProgress(100);//直接设置为学习完成 //sci.setProgress(100);//直接设置为学习完成
sci.setLastTime(ldt); sci.setLastTime(ldt);
scItemDao.saveOrUpdate(sci); scItemDao.saveOrUpdate(sci);
if (sci.getId() != null){
dto.setStudyItemId(sci.getId()); dto.setStudyItemId(sci.getId());
}else {
log.info("学习记录插入失败"+sci.getId());
throw new IllegalArgumentException("学习记录插入失败");
}
//检查是否全部学习完成 //检查是否全部学习完成
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token); scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token);
@@ -186,7 +182,7 @@ public class StudyServiceImpl implements IStudyService{
if(StringUtils.isNotBlank(name)) { if(StringUtils.isNotBlank(name)) {
query.addFilter(FieldFilters.eq("aname", name)); query.addFilter(FieldFilters.eq("aname", name));
} }
int pageIndex2 = (pageIndex-1)*10; int pageIndex2 = pageIndex-1;
if(status!=null) { if(status!=null) {
if(status==3) { if(status==3) {
query.addFilter(FieldFilters.eq("status", 2)); query.addFilter(FieldFilters.eq("status", 2));
@@ -197,16 +193,16 @@ public class StudyServiceImpl implements IStudyService{
}else if (status == 1) { }else if (status == 1) {
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " + String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" + " left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
" where bsc.course_id = '"+courseId+"' and bsc.aname like '%"+name+"%' and bsc.id not in(" + " where bsc.course_id = '"+courseId+"' and bsc.id not in(" +
" select item.study_id from boe_study_course_item item " + " select item.study_id from boe_study_course_item item " +
" where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' and item.aname like '%"+name+"%' group by item.study_id" + " where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by item.study_id" +
" ) group by bsc.id limit "+ pageIndex2+","+ pageSize+";"; " ) group by bsc.id limit "+ pageIndex2+","+ pageSize+";";
String sql2 = "select count(*) as total from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " + String sql2 = "select count(*) as total from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" + " left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
" where bsc.course_id = '"+courseId+"' and bsc.aname like '%"+name+"%' and bsc.id not in(" + " where bsc.course_id = '"+courseId+"' and bsc.id not in(" +
" select item.study_id from boe_study_course_item item " + " select item.study_id from boe_study_course_item item " +
" where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' and item.aname like '%"+name+"%' group by item.study_id" + " where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by item.study_id" +
" ) group by bsc.id) as total"; " ) group by bsc.id) as total";
log.info("资源完成情况未开始sql"+sql); log.info("资源完成情况未开始sql"+sql);
List<Object[]> list = scDao.sqlFindList(sql); List<Object[]> list = scDao.sqlFindList(sql);
@@ -228,22 +224,46 @@ public class StudyServiceImpl implements IStudyService{
return pageList; return pageList;
} }
} }
// String sql = "select * from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.progress,item.status from boe_study_course bsc left join " +
// "boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
// "where bsc.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " +
// " UNION ALL " +
// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " +
// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " +
// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" +
// " select bsc.id from boe_study_course bsc " +
// " left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
// " where bsc.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by bsc.id" +
// " )group by bsc.id) a group by a.id limit "+ pageIndex+","+ pageSize+";";
// String sql2 = "select count(*) from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.progress,item.status from boe_study_course bsc left join " +
// "boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
// "where bsc.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " +
// " UNION ALL " +
// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " +
// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " +
// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" +
// " select bsc.id from boe_study_course bsc " +
// " left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
// " where bsc.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by bsc.id" +
// " )group by bsc.id) a group by a.id";
String sql = "select a.id, a.course_id, a.course_name, a.aname, " + String sql = "select a.id, a.course_id, a.course_name, a.aname, " +
"IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " + "IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "' and aname like '%"+name+"%') a " + "from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "') a " +
"left join " + "left join " +
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " + "from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
"where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' and item.aname like '%"+name+"%' group by bsc.id) b " + "where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' group by bsc.id) b " +
"on a.course_id = b.course_id and a.id = b.id " + "on a.course_id = b.course_id and a.id = b.id " +
"group by a.id limit "+ pageIndex2+","+ pageSize+";"; "group by a.id limit "+ pageIndex2+","+ pageSize+";";
String sql2 = "select count(*) as total from (select a.id, a.course_id, a.course_name, a.aname, " + String sql2 = "select count(*) as total from (select a.id, a.course_id, a.course_name, a.aname, " +
"IFNULL(b.finish_time, 0) as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " + "IFNULL(b.finish_time, 0) as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "' and aname like '%"+name+"%') a " + "from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "') a " +
"left join " + "left join " +
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " + "(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " + "from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
"where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' and item.aname like '%"+name+"%' group by bsc.id) b " + "where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' group by bsc.id) b " +
"on a.course_id = b.course_id and a.id = b.id " + "on a.course_id = b.course_id and a.id = b.id " +
"group by a.id) as total"; "group by a.id) as total";
log.info("资源完成情况全部sql"+sql); log.info("资源完成情况全部sql"+sql);