改动表结构,修改sql

beetlsql3-dev
Mlxa0324 2 years ago
parent d2faa36b91
commit 6e9688d2b2

@ -12,7 +12,9 @@ import static com.ibeetl.admin.core.util.servlet.ServletUtils.getRequest;
/**
* <p>
*
*
* {@link CorePlatformService }
*
* </p>
*
* @author mlx

@ -25,5 +25,4 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper<TeacherOpenC
List<TeacherOpenCourseQuestionLog> getByIds(String ids);
List<TeacherOpenCourseQuestionLog> getValuesByQuery(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery);
Integer doCount(TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery);
}

@ -107,67 +107,30 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity{
@FetchSql("select count(1) from resources_question_snapshot t " +
"where t.question_status = 1 " +
"and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
private int questionCount;
// 平均答对数量
@FetchSql("SELECT " +
" tz.sum_temp / IFNULL( tz.student_count, 1 ) " +
"FROM " +
" ( " +
" SELECT " +
" sum( CASE WHEN t.question_answer = CONCAT( ta.teacher_open_course_question_log_answer, ',' ) THEN 1 ELSE 0 END ) AS sum_temp, " +
" count( " +
" DISTINCT ( ta.student_id )) AS student_count " +
" FROM " +
" resources_question_snapshot t " +
" INNER JOIN teacher_open_course_question_log ta ON ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id " +
" AND ta.resources_question_snapshot_id = t.resources_question_snapshot_id " +
" WHERE " +
" t.question_status = 1 " +
" AND ta.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId#) tz ")
@FetchSql("select sum(t.student_score > 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
private Integer avgSuccessCount;
// 平均答错数量
@FetchSql("SELECT " +
" tz.sum_temp / IFNULL( tz.student_count, 1 ) " +
"FROM " +
" ( " +
" SELECT " +
" sum( CASE WHEN t.question_answer <> CONCAT( ta.teacher_open_course_question_log_answer, ',' ) THEN 1 ELSE 0 END ) AS sum_temp, " +
" count( " +
" DISTINCT ( ta.student_id )) AS student_count " +
" FROM " +
" resources_question_snapshot t " +
" INNER JOIN teacher_open_course_question_log ta ON ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id " +
" AND ta.resources_question_snapshot_id = t.resources_question_snapshot_id " +
" WHERE " +
" t.question_status = 1 " +
" AND ta.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId#) tz ")
@FetchSql("select sum(t.student_score = 0) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
private Integer avgErrorCount;
// 平均正确率 100最大
private float avgSuccessRate;
// 平均得分
@FetchSql("SELECT " +
" tz.sum_temp / IFNULL( tz.student_count, 1 ) " +
"FROM " +
" ( " +
" SELECT " +
" sum( CASE WHEN t.question_answer <> CONCAT( ta.teacher_open_course_question_log_answer, ',' ) THEN t.question_score ELSE 0 END ) AS sum_temp, " +
" count( " +
" DISTINCT ( ta.student_id )) AS student_count " +
" FROM " +
" resources_question_snapshot t " +
" INNER JOIN teacher_open_course_question_log ta ON ta.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id " +
" AND ta.resources_question_snapshot_id = t.resources_question_snapshot_id " +
" WHERE " +
" t.question_status = 1 " +
" AND ta.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId#) tz ")
@FetchSql("select sum(t.student_score) / if(count(DISTINCT(t.student_id)) =0, 1, count(DISTINCT(t.student_id))) \n" +
"from teacher_open_course_question_log t \n" +
"where t.teacher_open_course_question_log_status = 1 " +
" AND t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# ")
private float avgScore;
// 关联的班级列表

@ -1,8 +1,10 @@
package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ReUtil;
import cn.jlw.util.EnumUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
@ -31,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@ -220,6 +223,7 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
/**
*
*
*
* @param questionLogMap <ID, []> {"10086": ["D", "A", "B", "A"]}
* @param questionSettingId ID
@ -233,12 +237,15 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 查询符合条件的日志表
String questionSnapshotIds = join(questionLogMap.keySet().toArray(), ",");
TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery = new TeacherOpenCourseQuestionLogQuery();
teacherOpenCourseQuestionLogQuery.setResourcesQuestionSnapshotIdPlural(questionSnapshotIds);
teacherOpenCourseQuestionLogQuery.setTeacherOpenCourseQuestionLogStatus(1);
teacherOpenCourseQuestionLogQuery.setStudentId(student.getStudentId());
teacherOpenCourseQuestionLogQuery.setTeacherOpenCourseQuestionSettingId(questionSettingId);
List<TeacherOpenCourseQuestionLog> valuesByQuery = teacherOpenCourseQuestionLogDao.getValuesByQuery(teacherOpenCourseQuestionLogQuery);
// 查询条件
TeacherOpenCourseQuestionLogQuery questionLogQuery = TeacherOpenCourseQuestionLogQuery.builder()
.resourcesQuestionSnapshotIdPlural(questionSnapshotIds)
.teacherOpenCourseQuestionLogStatus(1)
.studentId(student.getStudentId())
.teacherOpenCourseQuestionSettingId(questionSettingId)
.build();
List<TeacherOpenCourseQuestionLog> valuesByQuery = teacherOpenCourseQuestionLogDao.getValuesByQuery(questionLogQuery);
Assert.notEmpty(valuesByQuery, "未查询到题目!");
// 处理答案和分数
@ -255,8 +262,10 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
}
// 是否是正确答案
Boolean isTrue = (questionLog.getQuestionAnswer() + ",").equals(answersText);
questionLog.setStudentScore(isTrue ? questionLog.getQuestionScore() : BigDecimal.valueOf(0));
Boolean isCorrectAnswer = questionLog.getQuestionAnswer().equalsIgnoreCase(answersText);
// 计算该题目学生的得分情况
questionLog.setStudentScore(isCorrectAnswer ? questionLog.getQuestionScore() : BigDecimal.valueOf(0));
});
updateBatch(valuesByQuery);
@ -294,9 +303,9 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
Integer teacherOpenCourseQuestionSettingSettingDoCount = hwSetting.getTeacherOpenCourseQuestionSettingDoCount();
Assert.isTrue(teacherOpenCourseQuestionSettingSettingDoCount > 1, "作答次数设置有误,请联系管理员!");
// 数据库查询该学生已经做过的次数
TeacherOpenCourseQuestionLogQuery teacherOpenCourseQuestionLogQuery = new TeacherOpenCourseQuestionLogQuery();
teacherOpenCourseQuestionLogQuery.setStudentId(student.getStudentId());
Integer doCount = teacherOpenCourseQuestionLogDao.doCount(teacherOpenCourseQuestionLogQuery);
TeacherOpenCourseQuestionLog teacherOpenCourseQuestionLog = new TeacherOpenCourseQuestionLog();
teacherOpenCourseQuestionLog.setStudentId(student.getStudentId());
long doCount = teacherOpenCourseQuestionLogDao.templateCount(teacherOpenCourseQuestionLog);
// 断言判断最大作答次数
Assert.isTrue(doCount < teacherOpenCourseQuestionSettingSettingDoCount, "已超过最大作答次数!");
}
@ -325,22 +334,48 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService<Teacher
// 单题选项排序处理
resourcesQuestionSnapshots.forEach(value -> {
shuffleOrderOptions(value, "questionAnswer","questionOption", true);
// 屏蔽答案
});
// 做题日志关联学生, 初步提交日志信息,不包含学生提交的答案和得分情况
preSubmitStudentQuestionLog(student.getStudentId(), teacherOpenCourseQuestionSettingId, resourcesQuestionSnapshots);
// 屏蔽答案
resourcesQuestionSnapshots.forEach(value -> {
value.setQuestionAnswer(null);
});
}
List<TeacherOpenCourseQuestionLog> logs = BeanUtil.copyToList(resourcesQuestionSnapshots, TeacherOpenCourseQuestionLog.class);
return resourcesQuestionSnapshots;
}
/**
* ID
*
* @param studentId
*/
public void preSubmitStudentQuestionLog(@NotBlank(message = "学生ID不能为空") final Long studentId,
@NotBlank(message = "题目配置ID不能为空") final Long teacherOpenCourseQuestionSettingId,
@NotEmpty(message = "题目快照列表不能为空!") List<ResourcesQuestionSnapshot> resourcesQuestionSnapshots) {
if (CollectionUtil.isEmpty(resourcesQuestionSnapshots)) {
return;
}
// 断言
Assert.notBlank(resourcesQuestionSnapshots.get(0).getQuestionAnswer(), "题目快照选项不能为空!");
List<TeacherOpenCourseQuestionLog> teacherOpenCourseQuestionLogs = BeanUtil.copyToList(resourcesQuestionSnapshots, TeacherOpenCourseQuestionLog.class);
// 设计个单表,后面进行修改操作
logs.forEach(logPo -> {
logPo.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSettingId);
logPo.setTeacherOpenCourseQuestionLogStatus(1);
logPo.setStudentId(student.getStudentId());
logPo.setTeacherOpenCourseQuestionLogAddTime(new Date());
teacherOpenCourseQuestionLogs.forEach(questionLog -> {
// 题目的答案,如果最后一位是逗号,则删除掉
String questionAnswer = ReUtil.replaceAll(questionLog.getQuestionAnswer(), "\\,$", "");
questionLog.setTeacherOpenCourseQuestionSettingId(teacherOpenCourseQuestionSettingId);
questionLog.setTeacherOpenCourseQuestionLogStatus(1);
questionLog.setStudentId(studentId);
questionLog.setTeacherOpenCourseQuestionLogAddTime(new Date());
questionLog.setQuestionAnswer(questionAnswer);
});
insertBatch(logs);
return resourcesQuestionSnapshots;
insertBatch(teacherOpenCourseQuestionLogs);
}
/**

@ -194,6 +194,20 @@ public class TeacherOpenCourseQuestionLogController {
return JsonResult.success();
}
/**
* -
* @param teacherOpenCourseQuestionSettingId ID
* @param fromTypeEnum
* @return
*/
@PostMapping(MODEL + "/questionDetail.json")
@Function("teacherOpenCourseQuestionLog.query")
public JsonResult questionDetail(Long teacherOpenCourseQuestionSettingId,
ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum, @SCoreUser CoreUser coreUser) {
Assert.isTrue(coreUser.isStudent(), "非学生身份,无法获取题目!");
return JsonResult.success(teacherOpenCourseQuestionLogService.questionDetail(teacherOpenCourseQuestionSettingId, fromTypeEnum));
}
/**
* -
*
@ -239,18 +253,4 @@ public class TeacherOpenCourseQuestionLogController {
return JsonResult.success(teacherOpenCourseQuestionLogService.questionAnalysis(questionSnapshotIds));
}
/**
* -
* @param teacherOpenCourseQuestionSettingId ID
* @param fromTypeEnum
* @return
*/
@PostMapping(MODEL + "/questionDetail.json")
@Function("teacherOpenCourseQuestionLog.query")
public JsonResult questionDetail(Long teacherOpenCourseQuestionSettingId,
ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum, @SCoreUser CoreUser coreUser) {
Assert.isTrue(coreUser.isStudent(), "非学生身份,无法获取题目!");
return JsonResult.success(teacherOpenCourseQuestionLogService.questionDetail(teacherOpenCourseQuestionSettingId, fromTypeEnum));
}
}

@ -4,7 +4,11 @@ import cn.jlw.validate.ValidateConfig;
import com.ibeetl.admin.core.annotation.Query;
import com.ibeetl.admin.core.web.query.PageParam;
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionLog;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@ -14,6 +18,10 @@ import java.util.Date;
*
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class TeacherOpenCourseQuestionLogQuery extends PageParam {
@NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
@Query(name = "学生做题日志ID", display = false)

@ -55,7 +55,7 @@ public class BaseTest {
*
* @throws Exception
*/
public void putStudentLoginInfoToEnv() throws Exception {
public String[] putStudentLoginInfoToEnv() throws Exception {
// 随机取一个学生的登录信息
List<Student> studentList = studentDao.execute(
"select org_id, user_id " +
@ -67,8 +67,13 @@ public class BaseTest {
// 学生ID
Student student = CollectionUtils.firstElement(studentList);
// 换学生身份登录系统
TestEnvUtil.setProperty("user.id", student.getUserId().toString());
TestEnvUtil.setProperty("user.orgId", student.getOrgId().toString());
String userId = student.getUserId().toString();
String orgId = student.getOrgId().toString();
TestEnvUtil.setProperty("user.id", userId);
TestEnvUtil.setProperty("user.orgId", orgId);
return new String[] { userId, orgId };
}
public void putLoginInfoToEnv(final String userId, final String orgId) throws Exception {
@ -88,7 +93,7 @@ public class BaseTest {
*
* @throws Exception
*/
public void putTeacherLoginInfoToEnv() throws Exception {
public String[] putTeacherLoginInfoToEnv() throws Exception {
// 随机取一个学生的登录信息
List<Teacher> teacherList = teacherDao.execute(
"select org_id, user_id " +
@ -100,9 +105,14 @@ public class BaseTest {
Assert.assertTrue("教师表表为空,程序中断!", ObjectUtil.isNotEmpty(teacherList));
// 学生ID
Teacher teacher = CollectionUtils.firstElement(teacherList);
// 换学生身份登录系统
TestEnvUtil.setProperty("user.id", teacher.getUserId().toString());
TestEnvUtil.setProperty("user.orgId", teacher.getOrgId().toString());
// 换教师身份登录系统
String userId = teacher.getUserId().toString();
String orgId = teacher.getOrgId().toString();
TestEnvUtil.setProperty("user.id", userId);
TestEnvUtil.setProperty("user.orgId", orgId);
return new String[] { userId, orgId };
}
/**

@ -9,6 +9,7 @@ import com.ibeetl.jlw.dao.StudentDao;
import com.ibeetl.jlw.dao.TeacherOpenCourseQuestionSettingDao;
import com.ibeetl.jlw.entity.ResourcesQuestionSnapshot;
import com.ibeetl.jlw.entity.TeacherOpenCourseQuestionSetting;
import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum;
import org.junit.Assert;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@ -22,9 +23,11 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static cn.hutool.json.JSONUtil.toJsonStr;
import static com.ibeetl.admin.test.util.test.RandomUtils.randomSet;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.join;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.util.CollectionUtils.firstElement;
class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
@ -38,6 +41,53 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
@Resource
TeacherOpenCourseQuestionSettingDao teacherOpenCourseQuestionSettingDao;
private static ResourcesQuestionSnapshotFromTypeEnum fromTypeEnum;
private static Long teacherOpenCourseQuestionSettingId;
// [用户ID组织ID]
private static String[] loginInfo;
@Test
@Order(1)
public void questionDetail() throws Exception {
try {
// 获取一个状态正常的作业ID
TeacherOpenCourseQuestionSetting entity = new TeacherOpenCourseQuestionSetting();
entity.setTeacherOpenCourseQuestionSettingStatus(1);
List<TeacherOpenCourseQuestionSetting> homeworkList = teacherOpenCourseQuestionSettingDao.template(entity);
// 断言
Assert.assertTrue(ObjectUtil.isNotEmpty(homeworkList));
// 开课作业ID
teacherOpenCourseQuestionSettingId = RandomUtil.randomEle(homeworkList).getTeacherOpenCourseQuestionSettingId();
fromTypeEnum = firstElement(randomSet(ResourcesQuestionSnapshotFromTypeEnum.class));
// 随机取一个学生的登录信息
loginInfo = putStudentLoginInfoToEnv();
//构造请求参数
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionDetail.json")
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
.param("teacherOpenCourseQuestionSettingId", String.valueOf(teacherOpenCourseQuestionSettingId))
.param("fromTypeEnum", fromTypeEnum.name());
//发送请求,验证返回结果
String result = mvc.perform(rb)
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0"))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}catch (Exception e) {
throw e;
}finally {
clearEnvLoginInfo();
}
}
/**
*
*
@ -45,6 +95,7 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
* fromType
*/
@Test
@Order(2)
void addQuestionLog() throws Exception {
try {
// 通过查询数据库来random实体类属性
@ -54,9 +105,11 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
" from resources_question_snapshot t\n" +
" where t.question_status = 1\n" +
"\tand teacher_open_course_question_setting_id = \n" +
"\t\t(select teacher_open_course_question_setting_id from resources_question_snapshot ORDER BY RAND() limit 1) \n" +
"\t\t(select teacher_open_course_question_setting_id from teacher_open_course_question_log ORDER BY RAND() limit 1) \n" +
" order by RAND()");
Assert.assertTrue("题目快照列表不能为空!", ObjectUtil.isNotEmpty(questionSnapshots));
// 题目快照ID和答案
Map<Long, TreeSet<String>> answerRandomMap = new ConcurrentHashMap<>();
@ -86,12 +139,12 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
});
// 随机取一个学生的登录信息
putStudentLoginInfoToEnv();
putLoginInfoToEnv(loginInfo[0], loginInfo[1]);
//构造请求参数
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/addQuestionLog.json")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.param("questionSettingId", questionSnapshots.get(0).getTeacherOpenCourseQuestionSettingId().toString())
.param("questionSettingId", teacherOpenCourseQuestionSettingId.toString())
.content(toJsonStr(answerRandomMap));
//发送请求,验证返回结果
String result = mvc.perform(rb)
@ -108,69 +161,44 @@ class TeacherOpenCourseQuestionLogControllerTest extends BaseTest {
}
}
@Test
@Order(2)
public void questionDetail() throws Exception {
// 获取一个状态正常的作业ID
TeacherOpenCourseQuestionSetting entity = new TeacherOpenCourseQuestionSetting();
entity.setTeacherOpenCourseQuestionSettingStatus(1);
List<TeacherOpenCourseQuestionSetting> homeworkList = teacherOpenCourseQuestionSettingDao.template(entity);
// 断言
Assert.assertTrue(ObjectUtil.isNotEmpty(homeworkList));
// 开课作业ID
Long teacherOpenCourseQuestionSettingId = RandomUtil.randomEle(homeworkList).getTeacherOpenCourseQuestionSettingId();
//构造请求参数
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionDetail.json")
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
.param("resourcesQuestionSnapshotFromId", String.valueOf(teacherOpenCourseQuestionSettingId));
//发送请求,验证返回结果
String result = mvc.perform(rb)
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0"))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
@Order(3)
public void questionAnalysis() throws Exception {
// 随机取一个学生的登录信息
List<ResourcesQuestionSnapshot> questionSnapshots = resourcesQuestionSnapshotDao.execute(
"select t.*\n" +
" from resources_question_snapshot t\n" +
" where t.question_status = 1\n" +
"\tand teacher_open_course_question_setting_id = \n" +
try {
// 随机取一个学生的登录信息
List<ResourcesQuestionSnapshot> questionSnapshots = resourcesQuestionSnapshotDao.execute(
"select t.*\n" +
" from resources_question_snapshot t\n" +
" where t.question_status = 1\n" +
"\tand teacher_open_course_question_setting_id = \n" +
"\t\t(select teacher_open_course_question_setting_id from resources_question_snapshot ORDER BY RAND() limit 1) \n" +
" order by RAND()");
// 断言
Assert.assertTrue(ObjectUtil.isNotEmpty(questionSnapshots));
// 开课作业ID
List<Long> questionSnapshotIds = RandomUtil.randomEleList(questionSnapshots, 10)
.stream().map(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId).collect(toList());
" order by RAND()");
// 断言
Assert.assertTrue(ObjectUtil.isNotEmpty(questionSnapshots));
putStudentLoginInfoToEnv();
// 开课作业ID
List<Long> questionSnapshotIds = RandomUtil.randomEleList(questionSnapshots, 10)
.stream().map(ResourcesQuestionSnapshot::getResourcesQuestionSnapshotId).collect(toList());
//构造请求参数
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionAnalysis.json")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(JSONUtil.toJsonStr(questionSnapshotIds));
putLoginInfoToEnv(loginInfo[0], loginInfo[1]);
//发送请求,验证返回结果
String result = mvc.perform(rb)
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0"))
.andReturn().getResponse().getContentAsString();
//构造请求参数
RequestBuilder rb = MockMvcRequestBuilders.post(MODEL + "/questionAnalysis.json")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(JSONUtil.toJsonStr(questionSnapshotIds));
System.out.println(result);
//发送请求,验证返回结果
String result = mvc.perform(rb)
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.code").value("0"))
.andReturn().getResponse().getContentAsString();
clearEnvLoginInfo();
System.out.println(result);
}catch (Exception e) {
throw e;
}finally {
// 清除登录信息
clearEnvLoginInfo();
}
}
}

@ -161,6 +161,7 @@ class TeacherOpenCourseQuestionSettingControllerTest extends BaseTest {
TeacherOpenCourseQuestionSettingQuery teacherOpenCourseQuestionSettingQuery = randomPojo(TeacherOpenCourseQuestionSettingQuery.class
// 处理plural 结尾的属性
, BeanUtil::ignoreFieldsHandler, (e) -> {
e.setDefault();
// 随机取一个开课ID
e.setTeacherOpenCourseId(RandomUtil.randomEle(openCourseList).getTeacherOpenCourseId());
e.setTeacherOpenCourseQuestionSettingType(typeEnum);
@ -173,11 +174,6 @@ class TeacherOpenCourseQuestionSettingControllerTest extends BaseTest {
e.setResourcesQuestionIdPlural(resourcesQuestionIds);
// 设置关联ID
e.setTeacherOpenCourseQuestionSettingId(e.getTeacherOpenCourseQuestionSettingId());
e.setTeacherOpenCourseQuestionSettingDoCount(1);
e.setTeacherOpenCourseQuestionSettingEndShowQa(1);
e.setTeacherOpenCourseQuestionSettingEndShowTrueFalse(1);
e.setTeacherOpenCourseQuestionSettingOptionNoOrder(1);
e.setTeacherOpenCourseQuestionSettingQuestionNoOrder(1);
e.setTeacherOpenCourseQuestionSettingSchoolClassIds(schoolClassIds);
});

Loading…
Cancel
Save