From e931adb3c50e55e5b6af89d411bf9a7be950f69a Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Tue, 17 Sep 2013 22:28:51 -0700 Subject: Fixing question 4 to skip 4a in some cases. For this fix I am moving Question and Answer from the backend into a new model package. Question is now used in SurveyPageResource instead of the Map. Eventually I should encode/decode the model from the json directly. I am adding support to the Question model to find the next question based on the answer to the current question. If the answer has a specific nextQuestion field, that is used. Otherwise the question's nextQuestion field is used. This is to facilitate skipping irrelevant questions. --- .../p4square/grow/backend/resources/Question.java | 72 ---------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/com/p4square/grow/backend/resources/Question.java (limited to 'src/com/p4square/grow/backend/resources/Question.java') diff --git a/src/com/p4square/grow/backend/resources/Question.java b/src/com/p4square/grow/backend/resources/Question.java deleted file mode 100644 index e90ca77..0000000 --- a/src/com/p4square/grow/backend/resources/Question.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2013 Jesse Morgan - */ - -package com.p4square.grow.backend.resources; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Model of an assessment question. - * - * @author Jesse Morgan - */ -class Question { - public static enum QuestionType { - TEXT, IMAGE, SLIDER, QUAD, CIRCLE; - } - - private final String mQuestionId; - private final QuestionType mType; - private final String mQuestionText; - private Map mAnswers; - - private final String mPreviousQuestionId; - private final String mNextQuestionId; - - public Question(final Map map) { - mQuestionId = (String) map.get("id"); - mType = QuestionType.valueOf(((String) map.get("type")).toUpperCase()); - - mQuestionText = (String) map.get("text"); - - mPreviousQuestionId = (String) map.get("previousQuestion"); - mNextQuestionId = (String) map.get("nextQuestion"); - - mAnswers = new HashMap(); - for (Map.Entry answer : - ((Map) map.get("answers")).entrySet()) { - - final String id = answer.getKey(); - final Map answerMap = (Map) answer.getValue(); - final Answer answerObj = new Answer(id, answerMap); - mAnswers.put(id, answerObj); - } - } - - public String getId() { - return mQuestionId; - } - - public QuestionType getType() { - return mType; - } - - public String getText() { - return mQuestionText; - } - - public String getPrevious() { - return mPreviousQuestionId; - } - - public String getNext() { - return mNextQuestionId; - } - - public Map getAnswers() { - return Collections.unmodifiableMap(mAnswers); - } -} -- cgit v1.2.3