diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-08-21 22:35:32 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-08-21 22:35:32 -0700 |
commit | 9b33aaf27cd8f73402ee9967c6b0fd76a90f8ebe (patch) | |
tree | 2f97ddb022299309d6e96f6e25bc2506295fda63 | |
parent | 883cfedc17921273cb6098de3a2c52f2a092aadc (diff) |
Adding images, creating circle questions and misc. fixes.
25 files changed, 67 insertions, 22 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> diff --git a/web/images/2-a1-hover.jpg b/web/images/2-a1-hover.jpg Binary files differnew file mode 100644 index 0000000..8101265 --- /dev/null +++ b/web/images/2-a1-hover.jpg diff --git a/web/images/2-a1.jpg b/web/images/2-a1.jpg Binary files differnew file mode 100644 index 0000000..d87ea14 --- /dev/null +++ b/web/images/2-a1.jpg diff --git a/web/images/2-a2-hover.jpg b/web/images/2-a2-hover.jpg Binary files differnew file mode 100644 index 0000000..40c1bd7 --- /dev/null +++ b/web/images/2-a2-hover.jpg diff --git a/web/images/2-a2.jpg b/web/images/2-a2.jpg Binary files differnew file mode 100644 index 0000000..e03669c --- /dev/null +++ b/web/images/2-a2.jpg diff --git a/web/images/2-a3-hover.jpg b/web/images/2-a3-hover.jpg Binary files differnew file mode 100644 index 0000000..3e1ba81 --- /dev/null +++ b/web/images/2-a3-hover.jpg diff --git a/web/images/2-a3.jpg b/web/images/2-a3.jpg Binary files differnew file mode 100644 index 0000000..fb7098a --- /dev/null +++ b/web/images/2-a3.jpg diff --git a/web/images/2-a4-hover.jpg b/web/images/2-a4-hover.jpg Binary files differnew file mode 100644 index 0000000..6afd429 --- /dev/null +++ b/web/images/2-a4-hover.jpg diff --git a/web/images/2-a4.jpg b/web/images/2-a4.jpg Binary files differnew file mode 100644 index 0000000..7280d49 --- /dev/null +++ b/web/images/2-a4.jpg diff --git a/web/images/2-a5-hover.jpg b/web/images/2-a5-hover.jpg Binary files differnew file mode 100644 index 0000000..8cd1f9d --- /dev/null +++ b/web/images/2-a5-hover.jpg diff --git a/web/images/2-a5.jpg b/web/images/2-a5.jpg Binary files differnew file mode 100644 index 0000000..465c199 --- /dev/null +++ b/web/images/2-a5.jpg diff --git a/web/images/2-a6-hover.jpg b/web/images/2-a6-hover.jpg Binary files differnew file mode 100644 index 0000000..1fe87bd --- /dev/null +++ b/web/images/2-a6-hover.jpg diff --git a/web/images/2-a6.jpg b/web/images/2-a6.jpg Binary files differnew file mode 100644 index 0000000..df26868 --- /dev/null +++ b/web/images/2-a6.jpg diff --git a/web/images/8-a1-hover.jpg b/web/images/8-a1-hover.jpg Binary files differindex 8aa82f1..cfa7077 100644 --- a/web/images/8-a1-hover.jpg +++ b/web/images/8-a1-hover.jpg diff --git a/web/images/8-a1.jpg b/web/images/8-a1.jpg Binary files differindex bdf77aa..e249a3c 100644 --- a/web/images/8-a1.jpg +++ b/web/images/8-a1.jpg diff --git a/web/images/8-a2-hover.jpg b/web/images/8-a2-hover.jpg Binary files differindex e7d298a..77af9cc 100644 --- a/web/images/8-a2-hover.jpg +++ b/web/images/8-a2-hover.jpg diff --git a/web/images/8-a2.jpg b/web/images/8-a2.jpg Binary files differindex af6f4c4..287353d 100644 --- a/web/images/8-a2.jpg +++ b/web/images/8-a2.jpg diff --git a/web/images/8-a3-hover.jpg b/web/images/8-a3-hover.jpg Binary files differindex bf3abed..6d3b50c 100644 --- a/web/images/8-a3-hover.jpg +++ b/web/images/8-a3-hover.jpg diff --git a/web/images/8-a3.jpg b/web/images/8-a3.jpg Binary files differindex c67dd57..eab7d7a 100644 --- a/web/images/8-a3.jpg +++ b/web/images/8-a3.jpg diff --git a/web/scripts/growth.js b/web/scripts/growth.js index 5bc30d4..9aae3aa 100644 --- a/web/scripts/growth.js +++ b/web/scripts/growth.js @@ -1,10 +1,10 @@ $(document).ready(function() { $('.slider').draggable({ - axis:"x", - containment:"parent", + axis:"x", + containment:"parent", cursor:"pointer", - stop: function (event, ui) { + stop: function (event, ui) { var range = $(ui.helper).parent().width() - 46; var value = (ui.position.left + range / 2) / range; $("#answerField").val(value); @@ -12,9 +12,9 @@ $(document).ready(function() }); $('.quad .selector').draggable({ - containment:"parent", + containment:"parent", cursor:"pointer", - stop: function (event, ui) { + stop: function (event, ui) { updateQuadAnswer(ui.position.left, ui.position.top); }, drag: function (event, ui) { @@ -35,7 +35,7 @@ $(document).ready(function() updateQuadAnswer(e.offsetX - 10, e.offsetY - 10); } }); - + var previousAnswer = $("#answerField").val(); if (!isNaN(previousAnswer)) { var range = $('.sliderQuestion .sliderbar').width() - 46; @@ -101,20 +101,20 @@ function selectAnswer(element) function previousQuestion() { $("#direction").val("previous"); - sendAnswer(); + sendAnswer(false); } function nextQuestion() { $("#direction").val("next"); - sendAnswer(); + sendAnswer(true); } -function sendAnswer() +function sendAnswer(required) { var selectedAnswer = $("#answerField").val(); - - if (selectedAnswer == '') { + + if (required && selectedAnswer == '') { notice('Please select an answer before moving to the next question'); return; } @@ -149,7 +149,7 @@ function playVideo(videoId) notice("We could not find a video format that will work with your browser. Please try another browser or contact us."); }).error(function(jqXHR, error) { - notice('Could not load video due to ' + error + '. If the problem persists, please contact us.'); + notice('Could not load video due to ' + error + '. If the problem persists, please contact us.'); }); } @@ -175,14 +175,14 @@ function reportVideoComplete(data) $('#chapterprogress .progresslabel').html(percent); closeVideo(); - + $.ajax({ type: "POST", url: location.href + "/videos/" + videoId + ".json", dataType: "json", data: {'completed':'true'} }).error(function(jqXHR, error) { - notice('Could not record video completiton due to ' + error + '. If the problem persists, please contact us.'); + notice('Could not record video completiton due to ' + error + '. If the problem persists, please contact us.'); }); if (completed == total) { diff --git a/web/style.css b/web/style.css index 026ca7c..09cb5be 100644 --- a/web/style.css +++ b/web/style.css @@ -419,6 +419,19 @@ footer a:hover { text-align: left; } +.quadQuestion .above span, .quadQuestion .below span { + display: inline-block; + width: 40%; +} + +.quadQuestion .above span { + vertical-align: bottom; +} + +.quadQuestion .below span { + vertical-align: top; +} + .quad { background: url('/images/quad.png') center center no-repeat; width: 273px; |