diff --git a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java index 07f17995a9d96dc555b0a8c19554097ace260f32..758d94865594d22f13ccdbae5da912517a386ec8 100644 --- a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java +++ b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java @@ -121,6 +121,18 @@ public class LecturerQuestionController extends AbstractController { } } + @RequestMapping(value = "/sort", method = RequestMethod.POST) + public void publishQuestion( + @PathVariable final String questionId, + @RequestParam(required = false) final Boolean publish, + @RequestBody final Question question + ) { + if (publish != null) { + question.setActive(publish); + } + questionService.update(question); + } + @RequestMapping(value = "/{questionId}/publishstatistics", method = RequestMethod.POST) public void publishStatistics( @PathVariable final String questionId, diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index 671e69db205e4cd01d44fc9272a5508800a3dfc0..0ec989191d2b4b7c018a29a69fee5b146e2cb698 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -1381,14 +1381,24 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware @Cacheable("lecturequestions") @Override public List<Question> getLectureQuestionsForUsers(final Session session) { - String viewName = "skill_question/lecture_question_by_session_for_all"; - return getQuestions(new NovaView(viewName), session); + String viewName = "question_sort/lecture_question_by_session_sorted_for_all"; + List<Question> result = getQuestions(new NovaView(viewName), session); + if(result == null) { + String viewName = "skill_question/lecture_question_by_session_for_all"; + result = getQuestions(new NovaView(viewName), session); + } + return result; } @Override public List<Question> getLectureQuestionsForTeachers(final Session session) { - String viewName = "skill_question/lecture_question_by_session"; - return getQuestions(new NovaView(viewName), session); + String viewName = "question_sort/lecture_question_by_session_sorted"; + List<Question> result = getQuestions(new NovaView(viewName), session); + if (result == null) { + String viewName = "skill_question/lecture_question_by_session"; + result = getQuestions(new NovaView(viewName), session); + } + return result; } @Cacheable("flashcardquestions") @@ -1407,14 +1417,24 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware @Cacheable("preparationquestions") @Override public List<Question> getPreparationQuestionsForUsers(final Session session) { - String viewName = "skill_question/preparation_question_by_session_for_all"; - return getQuestions(new NovaView(viewName), session); + String viewName = "question_sort/preparation_question_by_session_sorted_for_all"; + List<Question> result = getQuestions(new NovaView(viewName), session); + if (result == null) { + String viewName = "skill_question/preparation_question_by_session_for_all"; + result = getQuestions(new NovaView(viewName), session); + } + return result; } @Override public List<Question> getPreparationQuestionsForTeachers(final Session session) { - String viewName = "skill_question/preparation_question_by_session"; - return getQuestions(new NovaView(viewName), session); + String viewName = "question_sort/preparation_question_by_session_sorted"; + List<Question> result = getQuestions(new NovaView(viewName), session); + if (result == null) { + String viewName = "skill_question/preparation_question_by_session"; + result = getQuestions(new NovaView(viewName), session); + } + return result; } private List<Question> getQuestions(final NovaView view, final Session session) { @@ -1909,4 +1929,23 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware info.setNumUnredInterposed(unreadInterposed); return info; } + + @OVerride + String getSaveOrderId(Session session) { + String view = "question_sort/get_id"; + } + + @Override + String saveQuestionSort(Session session, final String[] sortOrder) { + final Document a = new Document(); + a.put("type", "question_sort"); + a.put("sessionId", session.getSessionId()); + a.put("sortOrder", sortOrder); + try { + database.saveDocument(a); + } catch (final IOException e) { + return null; + } + return sortOrder; + } } diff --git a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java index c60e1e296d6c7305367e6a3bbab2197aa65a7415..eb38f6fab366af5f425c67d482ef0423e56d9b22 100644 --- a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java +++ b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java @@ -196,4 +196,8 @@ public interface IDatabaseDao { SessionInfo importSession(User user, ImportExportSession importSession); Statistics getStatistics(); + + String getSaveOrderId(Session session); + + String saveQuestionSort(Session session, final String[] sortOrder); } diff --git a/src/main/java/de/thm/arsnova/entities/Session.java b/src/main/java/de/thm/arsnova/entities/Session.java index 7a5cca22dacb3eff02459faf04016bf4f28d41ef..a5df967d538ae09f94848b2ec42ac740cfd16eab 100644 --- a/src/main/java/de/thm/arsnova/entities/Session.java +++ b/src/main/java/de/thm/arsnova/entities/Session.java @@ -49,9 +49,6 @@ public class Session implements Serializable { private String ppFaculty; private String ppLevel; private String sessionType; - - private boolean sortPreparationQuestions; - private boolean sortLectureQuestions; private String _id; private String _rev; @@ -291,22 +288,6 @@ public class Session implements Serializable { public void setSessionType(final String sessionType) { this.sessionType = sessionType; } - - public boolean getSortPreparationQuestions() { - return sortIndexPreparation; - } - - public void setSortPreparationQuestions(final boolean SortPreparationQuestions) { - this.sortIndexPreparation = sortIndexPreparation; - } - - public boolean getSortPreparationQuestions() { - return sortIndexPreparation; - } - - public void setSortLectureQuestions(final boolean SortLectureQuestions) { - this.sortIndexLecture = sortIndexLecture; - } @Override public String toString() {