Skip to content
Snippets Groups Projects
Commit ead69b77 authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Questions are sorted and returned in full

parent a1becf0a
Branches
Tags
No related merge requests found
......@@ -218,17 +218,15 @@ public class CouchDBDao implements IDatabaseDao {
try {
if (session.getCreator().equals(user.getUsername())) {
view = new View("skill_question/by_session_sorted_by_subject_and_text");
view.setStartKey("[" + URLEncoder.encode("\"" + session.get_id() + "\"", "UTF-8") + "]");
view.setEndKey("[" + URLEncoder.encode("\"" + session.get_id() + "\",{}", "UTF-8") + "]");
} else {
if (user.getType().equals(User.THM)) {
view = new View("skill_question/by_session_for_thm");
view = new View("skill_question/by_session_for_thm_full");
} else {
view = new View("skill_question/by_session_for_all");
view = new View("skill_question/by_session_for_all_full");
}
view.setKey(URLEncoder.encode("\"" + session.get_id() + "\"", "UTF-8"));
}
view.setStartKey("[" + URLEncoder.encode("\"" + session.get_id() + "\"", "UTF-8") + "]");
view.setEndKey("[" + URLEncoder.encode("\"" + session.get_id() + "\",{}", "UTF-8") + "]");
ViewResults questions = this.getDatabase().view(view);
if (questions == null || questions.isEmpty()) {
......@@ -968,10 +966,10 @@ public class CouchDBDao implements IDatabaseDao {
"[" + URLEncoder.encode("\"" + user.getUsername() + "\",\"" + s.get_id() + "\"", "UTF-8") + "]"
);
ViewResults results = this.getDatabase().view(view);
List<Answer> answers = new ArrayList<Answer>();
if (results.getResults().isEmpty()) {
throw new NotFoundException();
return answers;
}
List<Answer> answers = new ArrayList<Answer>();
for (Document d : results.getResults()) {
Answer a = (Answer) JSONObject.toBean(d.getJSONObject().getJSONObject("value"), Answer.class);
a.set_id(d.getId());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment