From 4c6222210ebff0f6fae1f70e7017f0803b0f5461 Mon Sep 17 00:00:00 2001
From: Christoph Thelen <christoph.thelen@mni.thm.de>
Date: Wed, 6 Feb 2013 13:07:21 +0100
Subject: [PATCH] Fixed missing question badges

---
 src/main/java/de/thm/arsnova/dao/CouchDBDao.java           | 4 ++--
 src/main/java/de/thm/arsnova/dao/IDatabaseDao.java         | 2 +-
 src/main/java/de/thm/arsnova/services/QuestionService.java | 3 ++-
 src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java      | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
index bb480de4b..ef96970be 100644
--- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
+++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java
@@ -260,10 +260,10 @@ public class CouchDBDao implements IDatabaseDao {
 	}
 
 	@Override
-	public final int getSkillQuestionCount(final String sessionkey) {
+	public final int getSkillQuestionCount(final Session session) {
 		try {
 			View view = new View("skill_question/count_by_session");
-			view.setKey(URLEncoder.encode("\"" + sessionkey + "\"", "UTF-8"));
+			view.setKey(URLEncoder.encode("\"" + session.get_id() + "\"", "UTF-8"));
 			ViewResults results = this.getDatabase().view(view);
 
 			if (results.getJSONArray("rows").optJSONObject(0) == null) {
diff --git a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java
index 673ca9883..574891cb6 100644
--- a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java
+++ b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java
@@ -57,7 +57,7 @@ public interface IDatabaseDao {
 
 	List<Question> getSkillQuestions(String session);
 
-	int getSkillQuestionCount(String sessionkey);
+	int getSkillQuestionCount(Session session);
 
 	LoggedIn registerAsOnlineUser(User u, Session s);
 
diff --git a/src/main/java/de/thm/arsnova/services/QuestionService.java b/src/main/java/de/thm/arsnova/services/QuestionService.java
index d1f42986e..9f82ac39b 100644
--- a/src/main/java/de/thm/arsnova/services/QuestionService.java
+++ b/src/main/java/de/thm/arsnova/services/QuestionService.java
@@ -63,7 +63,8 @@ public class QuestionService implements IQuestionService {
 	@Override
 	@Authenticated
 	public int getSkillQuestionCount(String sessionkey) {
-		return databaseDao.getSkillQuestionCount(sessionkey);
+		Session session = this.databaseDao.getSessionFromKeyword(sessionkey);
+		return databaseDao.getSkillQuestionCount(session);
 	}
 
 	@Override
diff --git a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
index fd0b45520..f653c5e89 100644
--- a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
+++ b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java
@@ -214,8 +214,8 @@ public class StubDatabaseDao implements IDatabaseDao {
 	}
 
 	@Override
-	public int getSkillQuestionCount(String sessionkey) {
-		return stubQuestions.get(sessionkey).size();
+	public int getSkillQuestionCount(Session session) {
+		return stubQuestions.get(session.getKeyword()).size();
 	}
 
 	@Override
-- 
GitLab