diff --git a/knowledge/survey/browser.py b/knowledge/survey/browser.py
index 8d6207e..502429b 100644
--- a/knowledge/survey/browser.py
+++ b/knowledge/survey/browser.py
@@ -47,6 +47,8 @@ class SurveyView(ConceptView):
batchSize = 12
teamData = None
+ template = template
+
@Lazy
def macro(self):
self.registerDojo()
@@ -137,6 +139,8 @@ class SurveyView(ConceptView):
if data:
resp = Response(self.adapted, None)
for qu in self.adapted.questions:
+ if qu.questionType != 'value_selection':
+ continue
if qu.uid in data:
resp.values[qu] = data[qu.uid]
qgAvailable = True
@@ -231,13 +235,16 @@ class SurveyView(ConceptView):
text = u'%s
(%s)' % (text, info)
return text
- def getValues(self, question):
- setting = None
+ def loadData(self):
if self.data is None:
respManager = Responses(self.context)
respManager.personId = (self.request.form.get('person') or
respManager.getPersonId())
self.data = respManager.load()
+
+ def getValues(self, question):
+ setting = None
+ self.loadData()
if self.data:
setting = self.data.get(question.uid)
if setting is None:
@@ -250,6 +257,11 @@ class SurveyView(ConceptView):
title=opt['description']))
return result
+ def getTextValue(self, question):
+ self.loadData()
+ if self.data:
+ return self.data.get(question.uid)
+
def getCssClass(self, question):
cls = ''
if self.errors and self.data.get(question.uid) is None:
diff --git a/knowledge/survey/interfaces.py b/knowledge/survey/interfaces.py
index a6b3300..f6d0b5d 100644
--- a/knowledge/survey/interfaces.py
+++ b/knowledge/survey/interfaces.py
@@ -26,7 +26,7 @@ from zope import interface, component, schema
from cybertools.composer.schema.grid.interfaces import Records
from cybertools.knowledge.survey import interfaces
from loops.interfaces import IConceptSchema, ILoopsAdapter
-from loops.util import _
+from loops.util import _, KeywordVocabulary
class IQuestionnaire(IConceptSchema, interfaces.IQuestionnaire):
@@ -108,6 +108,16 @@ class IQuestion(IConceptSchema, interfaces.IQuestion):
""" A single question within a questionnaire.
"""
+ questionType = schema.Choice(
+ title=_(u'Question Type'),
+ description=_(u'Select the type of the question.'),
+ source=KeywordVocabulary((
+ ('value_selection', _(u'Value Selection')),
+ ('text', _(u'Text')),
+ )),
+ default='value_selection',
+ required=True)
+
required = schema.Bool(
title=_(u'Required'),
description=_(u'Question must be answered.'),
diff --git a/knowledge/survey/view_macros.pt b/knowledge/survey/view_macros.pt
index 2c4efed..29454a9 100644
--- a/knowledge/survey/view_macros.pt
+++ b/knowledge/survey/view_macros.pt
@@ -93,19 +93,10 @@
tal:content="opt/label|string:" />
-
- |
-
-
- |
-
+
+
+
@@ -119,4 +110,34 @@
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+ |
+ |
+
+
+
+