diff --git a/src/main/java/de/thm/arsnova/controller/QuestionByLecturerController.java b/src/main/java/de/thm/arsnova/controller/QuestionByLecturerController.java index 23c0911a0d852b9b06df6907125cc7138ddbd552..b3ec0cd81d60f856d35eb6d04c1df7dccfd6256c 100644 --- a/src/main/java/de/thm/arsnova/controller/QuestionByLecturerController.java +++ b/src/main/java/de/thm/arsnova/controller/QuestionByLecturerController.java @@ -137,6 +137,20 @@ public class QuestionByLecturerController extends AbstractController { } this.questionService.update(question); } + + @RequestMapping(value = "/{questionId}/publishcorrectanswer", method = RequestMethod.POST) + @ResponseBody + public final void publishCorrectAnswer( + @PathVariable final String questionId, + @RequestParam(required = false) final Boolean showCorrectAnswer, + @RequestBody final Question question, + final HttpServletResponse response + ) { + if (showCorrectAnswer != null) { + question.setShowAnswer(showCorrectAnswer); + } + this.questionService.update(question); + } @RequestMapping( value = { "/list" }, diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index e9cea280a8744b640305190cab2070fc54a1a536..b74cfcd4ff2f4eee3d8224b01f9a36921422fc11 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -536,12 +536,12 @@ public class CouchDBDao implements IDatabaseDao { q.put("releasedFor", question.getReleasedFor()); q.put("possibleAnswers", question.getPossibleAnswers()); q.put("noCorrect", question.isNoCorrect()); + q.put("showStatistic", question.isShowStatistic()); + q.put("showAnswer", question.isShowAnswer()); try { database.saveDocument(q, null); - question.set_id(q.getId()); question.set_rev(q.getRev()); - return question; } catch (IOException e) { LOGGER.error("Could not save question {}", question); @@ -560,6 +560,7 @@ public class CouchDBDao implements IDatabaseDao { q.put("possibleAnswers", question.getPossibleAnswers()); q.put("noCorrect", question.isNoCorrect()); q.put("showStatistic", question.isShowStatistic()); + q.put("showAnswer", question.isShowAnswer()); this.database.saveDocument(q); question.set_rev(q.getRev()); diff --git a/src/main/java/de/thm/arsnova/entities/Question.java b/src/main/java/de/thm/arsnova/entities/Question.java index 3ce3ae862fd9689d2396c0753bb40a056ac7dfd4..cb50a5ad8e06623e1f673e11975d315ceed0f998 100644 --- a/src/main/java/de/thm/arsnova/entities/Question.java +++ b/src/main/java/de/thm/arsnova/entities/Question.java @@ -37,6 +37,7 @@ public class Question { private int number; private int duration; private boolean showStatistic; // sic + private boolean showAnswer; private String _id; private String _rev; @@ -160,6 +161,14 @@ public class Question { this.showStatistic = showStatistic; } + public boolean isShowAnswer() { + return showAnswer; + } + + public void setShowAnswer(boolean showAnswer) { + this.showAnswer = showAnswer; + } + public final String get_id() { return _id; }