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