diff --git a/src/main/java/de/thm/arsnova/services/IQuestionService.java b/src/main/java/de/thm/arsnova/services/IQuestionService.java index 633478fd05377f74204b4f9c6e4f1287af036ea7..43137b1ff48456d6b5495ee54ca2c8d5afc9c232 100644 --- a/src/main/java/de/thm/arsnova/services/IQuestionService.java +++ b/src/main/java/de/thm/arsnova/services/IQuestionService.java @@ -20,6 +20,7 @@ package de.thm.arsnova.services; import java.util.List; +import java.util.AbstractMap.SimpleEntry; import de.thm.arsnova.entities.Answer; import de.thm.arsnova.entities.InterposedQuestion; @@ -91,6 +92,8 @@ public interface IQuestionService { int getFlashcardCount(String sessionkey); int getPreparationQuestionCount(String sessionkey); + + SimpleEntry<String,Integer> getAnswerCountByQuestion(String questionid); int countLectureQuestionAnswers(String sessionkey); @@ -123,5 +126,4 @@ public interface IQuestionService { void deleteAllPreparationAnswers(String sessionkey); void deleteAllLectureAnswers(String sessionkey); - } diff --git a/src/main/java/de/thm/arsnova/services/QuestionService.java b/src/main/java/de/thm/arsnova/services/QuestionService.java index 9484450063b0acec0519561ea9acffa7bfcbfd38..407162723cf02dc40e0e6a25cbb8ae796c5339ad 100644 --- a/src/main/java/de/thm/arsnova/services/QuestionService.java +++ b/src/main/java/de/thm/arsnova/services/QuestionService.java @@ -19,10 +19,12 @@ package de.thm.arsnova.services; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.AbstractMap.SimpleEntry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -220,7 +222,6 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis databaseDao.deleteAnswers(question); } - @Override @PreAuthorize("isAuthenticated()") public List<String> getUnAnsweredQuestionIds(final String sessionKey) { @@ -501,6 +502,13 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis public int getPreparationQuestionCount(final String sessionkey) { return databaseDao.getPreparationQuestionCount(getSession(sessionkey)); } + + @Override + @PreAuthorize("isAuthenticated()") + public SimpleEntry<String,Integer> getAnswerCountByQuestion(final String questionid) { + final int questioncount = getAnswerCount(questionid); + return new AbstractMap.SimpleEntry<String, Integer>(questionid, questioncount); + } @Override @PreAuthorize("isAuthenticated()") diff --git a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java index b7dbfd3c364bec9593f153efa5bdd74e2489535f..5507524ac74cf2feda787f8dfaf873fe4ebec805 100644 --- a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java +++ b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java @@ -403,6 +403,7 @@ public class ARSnovaSocketIOServer implements ApplicationListener<NovaEvent>, No public void visit(NewAnswerEvent event) { final String sessionKey = event.getSession().getKeyword(); this.reportAnswersToLecturerQuestionAvailable(event.getSession(), new Question(event.getQuestion())); + broadcastInSession(sessionKey, "countQuestionAnswersByQuestion", questionService.getAnswerCountByQuestion(event.getQuestion().get_id())); broadcastInSession(sessionKey, "countLectureQuestionAnswers", questionService.countLectureQuestionAnswersInternal(sessionKey)); broadcastInSession(sessionKey, "countPreparationQuestionAnswers", questionService.countPreparationQuestionAnswersInternal(sessionKey)); sendToUser(event.getUser(), "unansweredLecturerQuestions", questionService.getUnAnsweredLectureQuestionIds(sessionKey, event.getUser()));