summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-08-21 22:35:32 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-08-21 22:35:32 -0700
commit9b33aaf27cd8f73402ee9967c6b0fd76a90f8ebe (patch)
tree2f97ddb022299309d6e96f6e25bc2506295fda63 /src
parent883cfedc17921273cb6098de3a2c52f2a092aadc (diff)
Adding images, creating circle questions and misc. fixes.
Diffstat (limited to 'src')
-rw-r--r--src/com/p4square/grow/backend/resources/Question.java6
-rw-r--r--src/com/p4square/grow/backend/resources/SurveyResultsResource.java1
-rw-r--r--src/com/p4square/grow/frontend/SurveyPageResource.java17
-rw-r--r--src/templates/templates/question-circle.ftl21
-rw-r--r--src/templates/templates/survey.ftl3
5 files changed, 40 insertions, 8 deletions
diff --git a/src/com/p4square/grow/backend/resources/Question.java b/src/com/p4square/grow/backend/resources/Question.java
index c53883c..e90ca77 100644
--- a/src/com/p4square/grow/backend/resources/Question.java
+++ b/src/com/p4square/grow/backend/resources/Question.java
@@ -10,12 +10,12 @@ import java.util.Map;
/**
* Model of an assessment question.
- *
+ *
* @author Jesse Morgan <jesse@jesterpm.net>
*/
class Question {
public static enum QuestionType {
- TEXT, IMAGE, SLIDER, QUAD;
+ TEXT, IMAGE, SLIDER, QUAD, CIRCLE;
}
private final String mQuestionId;
@@ -45,7 +45,7 @@ class Question {
mAnswers.put(id, answerObj);
}
}
-
+
public String getId() {
return mQuestionId;
}
diff --git a/src/com/p4square/grow/backend/resources/SurveyResultsResource.java b/src/com/p4square/grow/backend/resources/SurveyResultsResource.java
index db7dad0..5e4a8bb 100644
--- a/src/com/p4square/grow/backend/resources/SurveyResultsResource.java
+++ b/src/com/p4square/grow/backend/resources/SurveyResultsResource.java
@@ -186,6 +186,7 @@ public class SurveyResultsResource extends ServerResource {
score.count++;
break;
+ case CIRCLE:
case QUAD:
scoreQuad(score, question, answerId);
break;
diff --git a/src/com/p4square/grow/frontend/SurveyPageResource.java b/src/com/p4square/grow/frontend/SurveyPageResource.java
index 8145c0d..351eade 100644
--- a/src/com/p4square/grow/frontend/SurveyPageResource.java
+++ b/src/com/p4square/grow/frontend/SurveyPageResource.java
@@ -116,11 +116,18 @@ public class SurveyPageResource extends FreeMarkerPageResource {
final Form form = new Form(entity);
final String answerId = form.getFirstValue("answer");
final String direction = form.getFirstValue("direction");
+ boolean justGoBack = false; // FIXME: Ugly hack
if (mQuestionId == null || answerId == null || answerId.length() == 0) {
- // Something is wrong.
- setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
- return null;
+ if ("previous".equals(direction)) {
+ // Just go back
+ justGoBack = true;
+
+ } else {
+ // Something is wrong.
+ setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
+ return null;
+ }
}
try {
@@ -138,7 +145,7 @@ public class SurveyPageResource extends FreeMarkerPageResource {
}
// Store answer
- {
+ if (!justGoBack) {
Map<String, String> answer = new HashMap<String, String>();
answer.put("answerId", answerId);
JsonResponse response = backendPut("/accounts/" + mUserId +
@@ -174,7 +181,7 @@ public class SurveyPageResource extends FreeMarkerPageResource {
nextPage += "/account/training/" + score;
}
}
-
+
} else {
nextPage += "/account/assessment/question/" + nextQuestionId;
}
diff --git a/src/templates/templates/question-circle.ftl b/src/templates/templates/question-circle.ftl
new file mode 100644
index 0000000..157833c
--- /dev/null
+++ b/src/templates/templates/question-circle.ftl
@@ -0,0 +1,21 @@
+<div class="quadQuestion question">
+ <div class="above">
+ <span class="left">${question.topleft}</span>
+ <span class="right">${question.topright}</span>
+ </div>
+ <div class="middle">
+ <div class="quad"><img src="${staticRoot}/images/quadselector.png" class="selector" /></div>
+ </div>
+ <div class="below">
+ <span class="left">${question.bottomleft}</span>
+ <span class="right">${question.bottomright}</span>
+ </div>
+</div>
+
+<h1>${question.question}</h1>
+<#if question.description??>
+<p>
+ ${question.description}
+</p>
+</#if>
+
diff --git a/src/templates/templates/survey.ftl b/src/templates/templates/survey.ftl
index da4e0b3..2885d7b 100644
--- a/src/templates/templates/survey.ftl
+++ b/src/templates/templates/survey.ftl
@@ -42,6 +42,9 @@
<#case "quad">
<#include "/templates/question-quad.ftl">
<#break>
+ <#case "circle">
+ <#include "/templates/question-circle.ftl">
+ <#break>
</#switch>
</article>
</form>