end-user view for displaying the questionnaire
This commit is contained in:
parent
efea782af2
commit
abbe1a39ff
9 changed files with 123 additions and 7 deletions
|
@ -190,6 +190,8 @@ Survey
|
|||
>>> from loops.knowledge.tests import importSurvey
|
||||
>>> importSurvey(loopsRoot)
|
||||
|
||||
>>> from loops.knowledge.survey.browser import SurveyView
|
||||
|
||||
|
||||
Fin de partie
|
||||
=============
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# survey types
|
||||
type(u'questionnaire', u'Fragebogen', viewName=u'',
|
||||
type(u'questionnaire', u'Fragebogen', viewName=u'survey.html',
|
||||
typeInterface=u'loops.knowledge.survey.interfaces.IQuestionnaire',
|
||||
options=u'action.portlet:create_subtype,edit_concept')
|
||||
type(u'questiongroup', u'Fragengruppe', viewName=u'',
|
||||
|
|
|
@ -25,7 +25,7 @@ from zope.interface import implementer, implements
|
|||
|
||||
from cybertools.knowledge.survey.questionnaire import Questionnaire, \
|
||||
QuestionGroup, Question, FeedbackItem
|
||||
from loops.common import AdapterBase
|
||||
from loops.common import adapted, AdapterBase
|
||||
from loops.knowledge.survey.interfaces import IQuestionnaire, \
|
||||
IQuestionGroup, IQuestion, IFeedbackItem
|
||||
from loops.type import TypeInterfaceSourceList
|
||||
|
@ -44,6 +44,17 @@ class Questionnaire(AdapterBase, Questionnaire):
|
|||
'questionGroups', 'questions', 'responses',)
|
||||
_noexportAttributes = _adapterAttributes
|
||||
|
||||
@property
|
||||
def questionGroups(self):
|
||||
return [adapted(c) for c in self.context.getChildren()]
|
||||
|
||||
@property
|
||||
def questions(self):
|
||||
for qug in self.questionGroups:
|
||||
for qu in qug.questions:
|
||||
qu.questionnaire = self
|
||||
yield qu
|
||||
|
||||
|
||||
class QuestionGroup(AdapterBase, QuestionGroup):
|
||||
|
||||
|
@ -54,6 +65,14 @@ class QuestionGroup(AdapterBase, QuestionGroup):
|
|||
'questionnaire', 'questions', 'feedbackItems',)
|
||||
_noexportAttributes = _adapterAttributes
|
||||
|
||||
@property
|
||||
def subobjects(self):
|
||||
return [adapted(c) for c in self.context.getChildren()]
|
||||
|
||||
@property
|
||||
def questions(self):
|
||||
return [obj for obj in self.subobjects if IQuestion.providedBy(obj)]
|
||||
|
||||
|
||||
class Question(AdapterBase, Question):
|
||||
|
||||
|
@ -64,6 +83,10 @@ class Question(AdapterBase, Question):
|
|||
'text', 'questionnaire', 'answerRange', 'feedbackItems',)
|
||||
_noexportAttributes = _adapterAttributes
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self.context.description
|
||||
|
||||
|
||||
class FeedbackItem(AdapterBase, FeedbackItem):
|
||||
|
||||
|
|
40
knowledge/survey/browser.py
Normal file
40
knowledge/survey/browser.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Definition of view classes and other browser related stuff for
|
||||
surveys and self-assessments.
|
||||
"""
|
||||
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from loops.browser.concept import ConceptView
|
||||
from loops.organize.party import getPersonForUser
|
||||
|
||||
|
||||
template = ViewPageTemplateFile('view_macros.pt')
|
||||
|
||||
class SurveyView(ConceptView):
|
||||
|
||||
tabview = 'index.html'
|
||||
|
||||
@Lazy
|
||||
def macro(self):
|
||||
return template.macros['survey']
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
i18n_domain="loops">
|
||||
|
||||
<!-- concept classes -->
|
||||
|
||||
<zope:adapter
|
||||
factory="loops.knowledge.survey.base.Questionnaire"
|
||||
provides="loops.knowledge.survey.interfaces.IQuestionnaire" />
|
||||
|
@ -19,4 +21,14 @@
|
|||
factory="loops.knowledge.survey.base.FeedbackItem"
|
||||
provides="loops.knowledge.survey.interfaces.IFeedbackItem" />
|
||||
|
||||
<!-- views -->
|
||||
|
||||
<zope:adapter
|
||||
name="survey.html"
|
||||
for="loops.interfaces.IConcept
|
||||
zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
provides="zope.interface.Interface"
|
||||
factory="loops.knowledge.survey.browser.SurveyView"
|
||||
permission="zope.View" />
|
||||
|
||||
</configure>
|
||||
|
|
35
knowledge/survey/view_macros.pt
Normal file
35
knowledge/survey/view_macros.pt
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!-- ZPT macros for loops.knowledge.survey views -->
|
||||
<html i18n:domain="loops">
|
||||
|
||||
|
||||
<metal:block define-macro="survey">
|
||||
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>
|
||||
<table>
|
||||
<tr>
|
||||
<td i18n:translate="">Does not apply</td>
|
||||
<td style="text-align: right"
|
||||
i18n:translate="">Fully applies</td>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<tr tal:repeat="question item/adapted/questions">
|
||||
<td tal:content="question/text" />
|
||||
<td style="white-space: nowrap">
|
||||
<span tal:repeat="value python:range(question.answerRange)">
|
||||
<input type="radio"
|
||||
tal:attributes="name question/uid;
|
||||
value value;
|
||||
checked repeat/value/start" />
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</metal:block>
|
||||
|
||||
|
||||
</html>
|
Binary file not shown.
|
@ -3,7 +3,7 @@ msgstr ""
|
|||
|
||||
"Project-Id-Version: 0.13.0\n"
|
||||
"POT-Creation-Date: 2007-05-22 12:00 CET\n"
|
||||
"PO-Revision-Date: 2013-02-26 12:00 CET\n"
|
||||
"PO-Revision-Date: 2013-03-07 12:00 CET\n"
|
||||
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
|
||||
"Language-Team: loops developers <helmutm@cy55.de>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -184,6 +184,12 @@ msgstr "Negativbewertung"
|
|||
msgid "Value inversion: High selection means low value."
|
||||
msgstr "Invertierung der Bewertung: Hohe gewählte Stufe bedeutet niedriger Wert."
|
||||
|
||||
msgid "Does not apply"
|
||||
msgstr "Trifft nicht zu"
|
||||
|
||||
msgid "Fully applies"
|
||||
msgstr "Trifft voll zu"
|
||||
|
||||
# competence (qualification)
|
||||
|
||||
msgid "Validity Period (Months)"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,9 +17,7 @@
|
|||
#
|
||||
|
||||
"""
|
||||
View class(es) for change tracks.
|
||||
|
||||
$Id$
|
||||
View classes for tracks.
|
||||
"""
|
||||
|
||||
from zope import component
|
||||
|
|
Loading…
Add table
Reference in a new issue