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 @@ + + + + + + + + + + + + + +
+ + + + + + + diff --git a/locales/de/LC_MESSAGES/loops.mo b/locales/de/LC_MESSAGES/loops.mo index a83eb06..3166e4b 100644 Binary files a/locales/de/LC_MESSAGES/loops.mo and b/locales/de/LC_MESSAGES/loops.mo differ diff --git a/locales/de/LC_MESSAGES/loops.po b/locales/de/LC_MESSAGES/loops.po index 6eb5b10..7ded724 100644 --- a/locales/de/LC_MESSAGES/loops.po +++ b/locales/de/LC_MESSAGES/loops.po @@ -225,6 +225,15 @@ msgstr "Mindestanzahl an Antworten" msgid "Minumum number of questions that have to be answered. Empty means all questions have to be answered." msgstr "Anzahl der Fragen, die mindestens beantwortet werden müssen. Keine Angabe: Es müssen alle Fragen beantwortet werden." +msgid "Question Type" +msgstr "Fragentyp" + +msgid "Select the type of the question." +msgstr "Bitte den Typ der Frage auswählen." + +msgid "Value Selection" +msgstr "Auswahl Bewertung" + msgid "Required" msgstr "Pflichtfrage"