diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index 82176db0839f980b9c77c3583d7b743a5966cf20..2fcaf7846c2018bf259b7ca1d61af8fdd05ee348 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -519,7 +519,7 @@ public class CouchDBDao implements IDatabaseDao { } @Override - public final Document saveQuestion(final Session session, final Question question) { + public final Question saveQuestion(final Session session, final Question question) { Document q = new Document(); q.put("type", "skill_question"); q.put("questionType", question.getQuestionType()); @@ -534,7 +534,11 @@ public class CouchDBDao implements IDatabaseDao { q.put("noCorrect", question.isNoCorrect()); try { database.saveDocument(q, null); - return q; + + question.set_id(q.getId()); + question.set_rev(q.getRev()); + + return question; } catch (IOException e) { LOGGER.error("Could not save question {}", question); } diff --git a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java index 78e7aa900893484e9a59862e2f2683690bc7143a..b8837942e505cef3556d2607520afdbc05046b37 100644 --- a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java +++ b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java @@ -50,7 +50,7 @@ public interface IDatabaseDao { boolean sessionKeyAvailable(String keyword); - Document saveQuestion(Session session, Question question); + Question saveQuestion(Session session, Question question); boolean saveQuestion(Session session, InterposedQuestion question); diff --git a/src/main/java/de/thm/arsnova/services/QuestionService.java b/src/main/java/de/thm/arsnova/services/QuestionService.java index 2351a4ff75e0ff7f9b83bfabe48d210099a7fe5a..3bc18f7c9f74d3fee42384c609a251af278a92b5 100644 --- a/src/main/java/de/thm/arsnova/services/QuestionService.java +++ b/src/main/java/de/thm/arsnova/services/QuestionService.java @@ -69,12 +69,8 @@ public class QuestionService implements IQuestionService { @Override @Authenticated public Question saveQuestion(Question question) { - Session session = this.databaseDao.getSessionFromKeyword(question.getSession()); - - Document d = this.databaseDao.saveQuestion(session, question); - question.set_id(d.getId()); - question.set_rev(d.getRev()); - return question; + Session session = this.databaseDao.getSessionFromKeyword(question.getSession()); + return this.databaseDao.saveQuestion(session, question); } @Override