|
@@ -8,7 +8,7 @@ import nju.seec.helper.dto.groups.Modify;
|
|
|
import nju.seec.helper.dto.quiz.QuizDTO;
|
|
import nju.seec.helper.dto.quiz.QuizDTO;
|
|
|
import nju.seec.helper.dto.quiz.QuizStudentAnswerDTO;
|
|
import nju.seec.helper.dto.quiz.QuizStudentAnswerDTO;
|
|
|
import nju.seec.helper.enums.QuizState;
|
|
import nju.seec.helper.enums.QuizState;
|
|
|
-import nju.seec.helper.enums.UserType;
|
|
|
|
|
|
|
+import nju.seec.helper.enums.UserRole;
|
|
|
import nju.seec.helper.service.QuizService;
|
|
import nju.seec.helper.service.QuizService;
|
|
|
import nju.seec.helper.service.QuizStudentAnswerService;
|
|
import nju.seec.helper.service.QuizStudentAnswerService;
|
|
|
import nju.seec.helper.vo.quiz.QuizStudentAnswerStatisticVO;
|
|
import nju.seec.helper.vo.quiz.QuizStudentAnswerStatisticVO;
|
|
@@ -41,13 +41,13 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 基于课件获取测试列表
|
|
* 基于课件获取测试列表
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER, UserType.STUDENT}, message = "获得测试列表")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "获得测试列表")
|
|
|
@GetMapping("/slide/{slideId}")
|
|
@GetMapping("/slide/{slideId}")
|
|
|
public PageResponse<QuizVO> getQuizzesBySlide(LoginUser user,
|
|
public PageResponse<QuizVO> getQuizzesBySlide(LoginUser user,
|
|
|
@PathVariable Long slideId,
|
|
@PathVariable Long slideId,
|
|
|
@RequestParam(required = false, defaultValue = "") String key,
|
|
@RequestParam(required = false, defaultValue = "") String key,
|
|
|
@PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
|
|
@PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
|
|
|
- switch (user.getType()) {
|
|
|
|
|
|
|
+ switch (user.getRole()) {
|
|
|
case TEACHER:
|
|
case TEACHER:
|
|
|
return PageResponse.of(quizService.teacherGetQuizzesBySlide(user, slideId, key, pageable));
|
|
return PageResponse.of(quizService.teacherGetQuizzesBySlide(user, slideId, key, pageable));
|
|
|
case STUDENT:
|
|
case STUDENT:
|
|
@@ -60,13 +60,13 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 基于状态获取测试列表
|
|
* 基于状态获取测试列表
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER, UserType.STUDENT}, message = "获取测试列表")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER, UserRole.STUDENT}, message = "获取测试列表")
|
|
|
@GetMapping("/state")
|
|
@GetMapping("/state")
|
|
|
public PageResponse<QuizVO> getQuizzesByState(LoginUser user,
|
|
public PageResponse<QuizVO> getQuizzesByState(LoginUser user,
|
|
|
QuizState state,
|
|
QuizState state,
|
|
|
@RequestParam(required = false, defaultValue = "") String key,
|
|
@RequestParam(required = false, defaultValue = "") String key,
|
|
|
@PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
|
|
@PageableDefault(Integer.MAX_VALUE) Pageable pageable) {
|
|
|
- switch (user.getType()) {
|
|
|
|
|
|
|
+ switch (user.getRole()) {
|
|
|
case TEACHER:
|
|
case TEACHER:
|
|
|
return PageResponse.of(quizService.teacherGetQuizzesByState(user, state, key, pageable));
|
|
return PageResponse.of(quizService.teacherGetQuizzesByState(user, state, key, pageable));
|
|
|
case STUDENT:
|
|
case STUDENT:
|
|
@@ -79,7 +79,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 获得某一测试的详细内容
|
|
* 获得某一测试的详细内容
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.STUDENT, UserType.TEACHER}, message = "获得测试")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.STUDENT, UserRole.TEACHER}, message = "获得测试")
|
|
|
@GetMapping("/{quizId}")
|
|
@GetMapping("/{quizId}")
|
|
|
public QuizVO getOneQuiz(LoginUser user, @PathVariable("quizId") Long quizId) {
|
|
public QuizVO getOneQuiz(LoginUser user, @PathVariable("quizId") Long quizId) {
|
|
|
return quizService.getOneQuiz(user, quizId);
|
|
return quizService.getOneQuiz(user, quizId);
|
|
@@ -88,7 +88,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 创建测试
|
|
* 创建测试
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER}, message = "创建测试")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER}, message = "创建测试")
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public QuizVO createQuiz(LoginUser user, @Validated(Create.class) @RequestBody QuizDTO quizDTO) {
|
|
public QuizVO createQuiz(LoginUser user, @Validated(Create.class) @RequestBody QuizDTO quizDTO) {
|
|
|
return quizService.createQuiz(user, quizDTO);
|
|
return quizService.createQuiz(user, quizDTO);
|
|
@@ -97,7 +97,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 修改测试 (仅限未开始时可以修改)
|
|
* 修改测试 (仅限未开始时可以修改)
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER}, message = "修改测试")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER}, message = "修改测试")
|
|
|
@PutMapping("/{quizId}")
|
|
@PutMapping("/{quizId}")
|
|
|
public QuizVO updateQuiz(LoginUser user, @PathVariable Long quizId, @Validated(Modify.class) @RequestBody QuizDTO quizDTO) {
|
|
public QuizVO updateQuiz(LoginUser user, @PathVariable Long quizId, @Validated(Modify.class) @RequestBody QuizDTO quizDTO) {
|
|
|
return quizService.modifyQuiz(user, quizId, quizDTO);
|
|
return quizService.modifyQuiz(user, quizId, quizDTO);
|
|
@@ -106,7 +106,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 删除测试 (伪删除)
|
|
* 删除测试 (伪删除)
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER}, message = "删除测试")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER}, message = "删除测试")
|
|
|
@DeleteMapping("/{quizId}")
|
|
@DeleteMapping("/{quizId}")
|
|
|
public void deleteQuiz(LoginUser user, @PathVariable("quizId") String quizId) {
|
|
public void deleteQuiz(LoginUser user, @PathVariable("quizId") String quizId) {
|
|
|
quizService.deleteQuiz(user, Long.valueOf(quizId));
|
|
quizService.deleteQuiz(user, Long.valueOf(quizId));
|
|
@@ -115,7 +115,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 提交作答
|
|
* 提交作答
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.STUDENT}, message = "提交作答")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.STUDENT}, message = "提交作答")
|
|
|
@PostMapping("/{quizId}/student-answer")
|
|
@PostMapping("/{quizId}/student-answer")
|
|
|
public QuizStudentAnswerVO submitQuizStudentAnswer(LoginUser user, @PathVariable Long quizId, @Validated @RequestBody QuizStudentAnswerDTO quizStudentAnswerDTO) {
|
|
public QuizStudentAnswerVO submitQuizStudentAnswer(LoginUser user, @PathVariable Long quizId, @Validated @RequestBody QuizStudentAnswerDTO quizStudentAnswerDTO) {
|
|
|
return quizStudentAnswerService.submitQuizStudentAnswer(user, quizId, quizStudentAnswerDTO);
|
|
return quizStudentAnswerService.submitQuizStudentAnswer(user, quizId, quizStudentAnswerDTO);
|
|
@@ -124,7 +124,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 获取测试作答列表
|
|
* 获取测试作答列表
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER}, message = "获取学生作答")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER}, message = "获取学生作答")
|
|
|
@GetMapping("/{quizId}/student-answers")
|
|
@GetMapping("/{quizId}/student-answers")
|
|
|
public PageResponse<QuizStudentAnswerVO> getQuizStudentAnswers(LoginUser user,
|
|
public PageResponse<QuizStudentAnswerVO> getQuizStudentAnswers(LoginUser user,
|
|
|
@PathVariable Long quizId,
|
|
@PathVariable Long quizId,
|
|
@@ -136,7 +136,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 学生获取某一测试自己的作答
|
|
* 学生获取某一测试自己的作答
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.STUDENT}, message = "获取作答")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.STUDENT}, message = "获取作答")
|
|
|
@GetMapping("/{quizId}/student-answer")
|
|
@GetMapping("/{quizId}/student-answer")
|
|
|
public QuizStudentAnswerVO getOneQuizStudentAnswer(LoginUser user, @PathVariable Long quizId) {
|
|
public QuizStudentAnswerVO getOneQuizStudentAnswer(LoginUser user, @PathVariable Long quizId) {
|
|
|
return quizStudentAnswerService.getQuizStudentAnswer(user, quizId);
|
|
return quizStudentAnswerService.getQuizStudentAnswer(user, quizId);
|
|
@@ -145,7 +145,7 @@ public class QuizController {
|
|
|
/**
|
|
/**
|
|
|
* 获取测试作答提交的统计信息
|
|
* 获取测试作答提交的统计信息
|
|
|
*/
|
|
*/
|
|
|
- @Auth(roles = {UserType.TEACHER}, message = "获取测试统计消息")
|
|
|
|
|
|
|
+ @Auth(roles = {UserRole.TEACHER}, message = "获取测试统计消息")
|
|
|
@GetMapping("/{quizId}/statistic")
|
|
@GetMapping("/{quizId}/statistic")
|
|
|
public QuizStudentAnswerStatisticVO getQuizStatistic(LoginUser user, @PathVariable Long quizId) {
|
|
public QuizStudentAnswerStatisticVO getQuizStatistic(LoginUser user, @PathVariable Long quizId) {
|
|
|
return quizStudentAnswerService.getQuizStudentAnswerStatistic(user, quizId);
|
|
return quizStudentAnswerService.getQuizStudentAnswerStatistic(user, quizId);
|