diff --git a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java index 9a63ae7177d02f1814c74d575b265f7db8bd297f..06ed93309ff3a80fce19765dfbdfe543cec951cc 100644 --- a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java +++ b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java @@ -35,6 +35,11 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wordnik.swagger.annotations.ApiResponse; +import com.wordnik.swagger.annotations.ApiResponses; + import de.thm.arsnova.PaginationListDecorator; import de.thm.arsnova.entities.Answer; import de.thm.arsnova.entities.Question; @@ -51,13 +56,21 @@ import de.thm.arsnova.web.Pagination; */ @RestController @RequestMapping("/lecturerquestion") +@Api(value = "/lecturerquestion", description = "Operations for Lecture Questions") public class LecturerQuestionController extends PaginationController { public static final Logger LOGGER = LoggerFactory.getLogger(LecturerQuestionController.class); @Autowired private IQuestionService questionService; - + + @ApiOperation(value = "Get question with provided question Id", + nickname = "getQuestion", + notes = "getQuestion(@PathVariable final String questionId)" + ) + @ApiResponses(value = { + @ApiResponse(code = 404, message = "Not Found - The requested resource could not be found but may be available again in the future.") + }) @RequestMapping(value = "/{questionId}", method = RequestMethod.GET) public Question getQuestion(@PathVariable final String questionId) { final Question question = questionService.getQuestion(questionId); @@ -68,6 +81,13 @@ public class LecturerQuestionController extends PaginationController { throw new NotFoundException(); } + @ApiOperation(value = "Post provided question", + nickname = "postQuestion", + notes = "postQuestion(@RequestBody final Question question)" + ) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error") + }) @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Question postQuestion(@RequestBody final Question question) { @@ -77,6 +97,13 @@ public class LecturerQuestionController extends PaginationController { throw new BadRequestException(); } + @ApiOperation(value = "Update the question, identified by provided id, with the provided question in the Request Body", + nickname = "updateQuestion", + notes = "updateQuestion(@PathVariable final String questionId,@RequestBody final Question question)" + ) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error") + }) @RequestMapping(value = "/{questionId}", method = RequestMethod.PUT) public Question updateQuestion( @PathVariable final String questionId, @@ -89,6 +116,11 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Start new Pi Round on question, identified by provided id, with an optional time", + nickname = "startPiRound", + notes = "startPiRound(@PathVariable final String questionId," + + "@RequestParam(value = \"time\", defaultValue = \"0\", required = false) final int time)" + ) @RequestMapping(value = "/{questionId}/questionimage", method = RequestMethod.GET) public String getQuestionImage( @PathVariable final String questionId, @@ -116,6 +148,10 @@ public class LecturerQuestionController extends PaginationController { } @RequestMapping(value = "/{questionId}/canceldelayedpiround", method = RequestMethod.POST) + @ApiOperation(value = "Cancel Pi Round on question, identified by provided id", + nickname = "cancelPiRound", + notes = "cancelPiRound(@PathVariable final String questionId)" + ) public void cancelPiRound( @PathVariable final String questionId ) { @@ -123,12 +159,21 @@ public class LecturerQuestionController extends PaginationController { } @RequestMapping(value = "/{questionId}/resetpiroundstate", method = RequestMethod.POST) + @ApiOperation(value = "Reset Pi Round on question, identified by provided id", + nickname = "resetPiQuestion", + notes = "resetPiQuestion(@PathVariable final String questionId)" + ) public void resetPiQuestion( @PathVariable final String questionId ) { questionService.resetPiRoundState(questionId); } + @ApiOperation(value = "Set voting admission on question, identified by provided id", + nickname = "setVotingAdmission", + notes = "setVotingAdmission(@PathVariable final String questionId," + + "@RequestParam(value = \"disable\", defaultValue = \"false\", required = false) final Boolean disableVote)" + ) @RequestMapping(value = "/{questionId}/disablevote", method = RequestMethod.POST) public void setVotingAdmission( @PathVariable final String questionId, @@ -143,6 +188,14 @@ public class LecturerQuestionController extends PaginationController { questionService.setVotingAdmission(questionId, disable); } + @ApiOperation(value = "Set voting admission for all questions", + nickname = "setVotingAdmissionForAllQuestions", + notes = "setVotingAdmissionForAllQuestions(" + + "@RequestParam final String sessionkey," + + "@RequestParam(value = \"disable\", defaultValue = \"false\", required = false) final Boolean disableVote," + + "@RequestParam(value = \"lecturequestionsonly\", defaultValue = \"false\", required = false) final boolean lectureQuestionsOnly," + + "@RequestParam(value = \"preparationquestionsonly\", defaultValue = \"false\", required = false) final boolean preparationQuestionsOnly)" + ) @RequestMapping(value = "/disablevote", method = RequestMethod.POST) public void setVotingAdmissionForAllQuestions( @RequestParam final String sessionkey, @@ -168,6 +221,13 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Publish a question, identified by provided id and question in Request Body.", + nickname = "publishQuestion", + notes = "publishQuestion(" + + "@PathVariable final String questionId," + + "@RequestParam(required = false) final Boolean publish," + + "@RequestBody final Question question)" + ) @RequestMapping(value = "/{questionId}/publish", method = RequestMethod.POST) public void publishQuestion( @PathVariable final String questionId, @@ -180,6 +240,14 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Publish all questions", + nickname = "publishAllQuestions", + notes = "publishAllQuestions(" + + "@RequestParam final String sessionkey," + + "@RequestParam(required = false) final Boolean publish," + + "@RequestParam(value = \"lecturequestionsonly\", defaultValue = \"false\", required = false) final boolean lectureQuestionsOnly," + + "@RequestParam(value = \"preparationquestionsonly\", defaultValue = \"false\", required = false) final boolean preparationQuestionsOnly)" + ) @RequestMapping(value = "/publish", method = RequestMethod.POST) public void publishAllQuestions( @RequestParam final String sessionkey, @@ -205,6 +273,13 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Publish statistics from question with provided id", + nickname = "publishStatistics", + notes = "publishStatistics(" + + "@PathVariable final String questionId," + + "@RequestParam(required = false) final Boolean showStatistics," + + "@RequestBody final Question question)" + ) @RequestMapping(value = "/{questionId}/publishstatistics", method = RequestMethod.POST) public void publishStatistics( @PathVariable final String questionId, @@ -217,6 +292,13 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Publish correct answer from question with provided id", + nickname = "publishCorrectAnswer", + notes = "publishCorrectAnswer(" + + "@PathVariable final String questionId," + + "@RequestParam(required = false) final Boolean showCorrectAnswer," + + "@RequestBody final Question question)" + ) @RequestMapping(value = "/{questionId}/publishcorrectanswer", method = RequestMethod.POST) public void publishCorrectAnswer( @PathVariable final String questionId, @@ -229,6 +311,15 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Get skill questions", + nickname = "getSkillQuestions", + notes = "getSkillQuestions(" + + "@RequestParam final String sessionkey," + + "@RequestParam(value = \"lecturequestionsonly\", defaultValue = \"false\") final boolean lectureQuestionsOnly," + + "@RequestParam(value = \"flashcardsonly\", defaultValue = \"false\") final boolean flashcardsOnly," + + "@RequestParam(value = \"preparationquestionsonly\", defaultValue = \"false\") final boolean preparationQuestionsOnly," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/", method = RequestMethod.GET) @Pagination public List<Question> getSkillQuestions( @@ -259,6 +350,15 @@ public class LecturerQuestionController extends PaginationController { return new PaginationListDecorator<Question>(questions, offset, limit); } + @ApiOperation(value = "Delete skill questions", + nickname = "deleteSkillQuestions", + notes = "deleteSkillQuestions(" + + "@RequestParam final String sessionkey," + + "@RequestParam(value = \"lecturequestionsonly\", defaultValue = \"false\") final boolean lectureQuestionsOnly," + + "@RequestParam(value = \"flashcardsonly\", defaultValue = \"false\") final boolean flashcardsOnly," + + "@RequestParam(value = \"preparationquestionsonly\", defaultValue = \"false\") final boolean preparationQuestionsOnly," + + "final HttpServletResponse response)" + ) @RequestMapping(value = { "/" }, method = RequestMethod.DELETE) public void deleteSkillQuestions( @RequestParam final String sessionkey, @@ -297,6 +397,11 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Delete answers and questions", + nickname = "deleteAnswersAndQuestion", + notes = "deleteAnswersAndQuestion(" + + "@PathVariable final String questionId)" + ) @RequestMapping(value = "/{questionId}", method = RequestMethod.DELETE) public void deleteAnswersAndQuestion( @PathVariable final String questionId @@ -373,6 +478,14 @@ public class LecturerQuestionController extends PaginationController { * @throws ForbiddenException * if not logged in */ + @ApiOperation(value = "Get answers for a question, identified by provided question ID", + nickname = "getAnswers", + notes = "getAnswers(" + + "@PathVariable final String questionId," + + "@RequestParam(value = \"piround\", required = false) final Integer piRound," + + "@RequestParam(value = \"all\", required = false, defaultValue = \"false\") final Boolean allAnswers," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.GET) public List<Answer> getAnswers( @PathVariable final String questionId, @@ -399,6 +512,13 @@ public class LecturerQuestionController extends PaginationController { return answers; } + @ApiOperation(value = "Save answer, provided in the Request Body, for a question, identified by provided question ID", + nickname = "saveAnswer", + notes = "saveAnswer(" + + "@PathVariable final String questionId," + + "@RequestBody final de.thm.arsnova.entities.transport.Answer answer," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.POST) public Answer saveAnswer( @PathVariable final String questionId, @@ -408,6 +528,14 @@ public class LecturerQuestionController extends PaginationController { return questionService.saveAnswer(questionId, answer); } + @ApiOperation(value = "Update answer, provided in Request Body, identified by question ID and answer ID", + nickname = "updateAnswer", + notes = "updateAnswer(" + + "@PathVariable final String questionId," + + "@PathVariable final String answerId," + + "@RequestBody final Answer answer," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/{answerId}", method = RequestMethod.PUT) public Answer updateAnswer( @PathVariable final String questionId, @@ -418,6 +546,13 @@ public class LecturerQuestionController extends PaginationController { return questionService.updateAnswer(answer); } + @ApiOperation(value = "Get Image, identified by question ID and answer ID", + nickname = "getImage", + notes = "getImage(" + + "@PathVariable final String questionId," + + "@PathVariable final String answerId," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/{answerId}/image", method = RequestMethod.GET) public String getImage( @PathVariable final String questionId, @@ -428,6 +563,13 @@ public class LecturerQuestionController extends PaginationController { return questionService.getImage(questionId, answerId); } + @ApiOperation(value = "Delete answer, identified by question ID and answer ID", + nickname = "deleteAnswer", + notes = "deleteAnswer(" + + "@PathVariable final String questionId," + + "@PathVariable final String answerId," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/{answerId}", method = RequestMethod.DELETE) public void deleteAnswer( @PathVariable final String questionId, @@ -437,6 +579,12 @@ public class LecturerQuestionController extends PaginationController { questionService.deleteAnswer(questionId, answerId); } + @ApiOperation(value = "Delete answers from a question, identified by question ID", + nickname = "deleteAnswers", + notes = "deleteAnswers(" + + "@PathVariable final String questionId," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.DELETE) public void deleteAnswers( @PathVariable final String questionId, @@ -445,6 +593,14 @@ public class LecturerQuestionController extends PaginationController { questionService.deleteAnswers(questionId); } + @ApiOperation(value = "Delete all answers and questions from a session, identified by sessionkey", + nickname = "deleteAllQuestionsAnswers", + notes = "deleteAllQuestionsAnswers(" + + "@RequestParam final String sessionkey," + + "@RequestParam(value = \"lecturequestionsonly\", defaultValue = \"false\") final boolean lectureQuestionsOnly," + + "@RequestParam(value = \"preparationquestionsonly\", defaultValue = \"false\") final boolean preparationQuestionsOnly," + + "final HttpServletResponse response)" + ) @RequestMapping(value = "/answers", method = RequestMethod.DELETE) public void deleteAllQuestionsAnswers( @RequestParam final String sessionkey, @@ -480,6 +636,10 @@ public class LecturerQuestionController extends PaginationController { return questionService.getAnswerCount(questionId); } + @ApiOperation(value = "Get the amount of answers for a question, identified by the question ID", + nickname = "getAllAnswerCount", + notes = "getAllAnswerCount(@PathVariable final String questionId)" + ) @RequestMapping(value = "/{questionId}/allroundanswercount", method = RequestMethod.GET) public List<Integer> getAllAnswerCount(@PathVariable final String questionId) { return Arrays.asList( @@ -488,11 +648,19 @@ public class LecturerQuestionController extends PaginationController { ); } + @ApiOperation(value = "Get the total amount of answers by a question, identified by the question ID", + nickname = "getTotalAnswerCountByQuestion", + notes = "getTotalAnswerCountByQuestion(@PathVariable final String questionId)" + ) @RequestMapping(value = "/{questionId}/totalanswercount", method = RequestMethod.GET) public int getTotalAnswerCountByQuestion(@PathVariable final String questionId) { return questionService.getTotalAnswerCountByQuestion(questionId); } + @ApiOperation(value = "Get the amount of answers and abstention answers by a question, identified by the question ID", + nickname = "getAnswerAndAbstentionCount", + notes = "getAnswerAndAbstentionCount(@PathVariable final String questionId)" + ) @RequestMapping(value = "/{questionId}/answerandabstentioncount", method = RequestMethod.GET) public List<Integer> getAnswerAndAbstentionCount(@PathVariable final String questionId) { List<Integer> list = Arrays.asList( @@ -503,6 +671,10 @@ public class LecturerQuestionController extends PaginationController { return list; } + @ApiOperation(value = "Get all Freetext answers by a question, identified by the question ID", + nickname = "getFreetextAnswers", + notes = "getFreetextAnswers(@PathVariable final String questionId)" + ) @RequestMapping(value = "/{questionId}/freetextanswer/", method = RequestMethod.GET) @Pagination public List<Answer> getFreetextAnswers(@PathVariable final String questionId) { @@ -531,11 +703,22 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Set the sort order of the subjects from a session, identified by the sessionkey", + nickname = "setSubjectSortOrder", + notes = "setSubjectSortOrder(" + + "@RequestParam(required = true) final String sessionkey," + + "@RequestParam(required = true) final String sorttype," + + "@RequestParam(required = true) final String ispreparation," + + "@RequestBody String[] sortOrder)" + ) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error") + }) @RequestMapping(value = "/subjectsort", method = RequestMethod.POST) public void setSubjectSortOrder( @RequestParam(required = true) final String sessionkey, - @RequestParam(required = true) final String sorttype, - @RequestParam(required = true) final String ispreparation, + @RequestParam(required = true) final String sorttype, + @RequestParam(required = true) final String ispreparation, @RequestBody String[] sortOrder ) { try { @@ -544,7 +727,13 @@ public class LecturerQuestionController extends PaginationController { throw new BadRequestException(); } } - + + @ApiOperation(value = "Get the sort order of the subjects from a session, identified by the sessionkey", + nickname = "getSubjectSortType", + notes = "getSubjectSortType(" + + "@RequestParam(required = true) final String sessionkey," + + "@RequestParam(required = true) final String ispreparation)" + ) @RequestMapping(value = "/subjectsort", method = RequestMethod.GET) public String getSubjectSortType( @RequestParam(required = true) final String sessionkey, @@ -553,6 +742,18 @@ public class LecturerQuestionController extends PaginationController { return questionService.getSubjectSortType(sessionkey, ispreparation); } + @ApiOperation(value = "Set the sort order of the questions from a subject in a session, identified by the sessionkey", + nickname = "setQuestionSortOrder", + notes = "setQuestionSortOrder(" + + "@RequestParam(required = true) final String sessionkey," + + "@RequestParam(required = true) final String subject," + + "@RequestParam(required = true) final String sorttype," + + "@RequestParam(required = true) final String ispreparation," + + "@RequestBody String[] sortOrder)" + ) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error") + }) @RequestMapping(value = "/questionsort", method = RequestMethod.POST) public void setQuestionSortOrder( @RequestParam(required = true) final String sessionkey, @@ -568,6 +769,16 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Get the sort order of the questions from a subject in a session, identified by the sessionkey", + nickname = "getQuestionSortType", + notes = "getQuestionSortType(" + + "@RequestParam(required = true) final String sessionkey," + + "@RequestParam(required = true) final String subject," + + "@RequestParam(required = true, defaultValue = \"false\") final boolean ispreparation)" + ) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content - successfully processed the request") + }) @RequestMapping(value = "/questionsort", method = RequestMethod.GET) public String getQuestionSortType( @RequestParam(required = true) final String sessionkey,