data entry and evaluation working, without storage of results
This commit is contained in:
parent
abbe1a39ff
commit
a123fa71e3
5 changed files with 120 additions and 27 deletions
|
@ -52,7 +52,7 @@ class Questionnaire(AdapterBase, Questionnaire):
|
||||||
def questions(self):
|
def questions(self):
|
||||||
for qug in self.questionGroups:
|
for qug in self.questionGroups:
|
||||||
for qu in qug.questions:
|
for qu in qug.questions:
|
||||||
qu.questionnaire = self
|
#qu.questionnaire = self
|
||||||
yield qu
|
yield qu
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +65,13 @@ class QuestionGroup(AdapterBase, QuestionGroup):
|
||||||
'questionnaire', 'questions', 'feedbackItems',)
|
'questionnaire', 'questions', 'feedbackItems',)
|
||||||
_noexportAttributes = _adapterAttributes
|
_noexportAttributes = _adapterAttributes
|
||||||
|
|
||||||
|
@property
|
||||||
|
def questionnaire(self):
|
||||||
|
for p in self.context.getParents():
|
||||||
|
ap = adapted(p)
|
||||||
|
if IQuestionnaire.providedBy(ap):
|
||||||
|
return ap
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def subobjects(self):
|
def subobjects(self):
|
||||||
return [adapted(c) for c in self.context.getChildren()]
|
return [adapted(c) for c in self.context.getChildren()]
|
||||||
|
@ -73,6 +80,10 @@ class QuestionGroup(AdapterBase, QuestionGroup):
|
||||||
def questions(self):
|
def questions(self):
|
||||||
return [obj for obj in self.subobjects if IQuestion.providedBy(obj)]
|
return [obj for obj in self.subobjects if IQuestion.providedBy(obj)]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def feedbackItems(self):
|
||||||
|
return [obj for obj in self.subobjects if IFeedbackItem.providedBy(obj)]
|
||||||
|
|
||||||
|
|
||||||
class Question(AdapterBase, Question):
|
class Question(AdapterBase, Question):
|
||||||
|
|
||||||
|
@ -87,6 +98,20 @@ class Question(AdapterBase, Question):
|
||||||
def text(self):
|
def text(self):
|
||||||
return self.context.description
|
return self.context.description
|
||||||
|
|
||||||
|
@property
|
||||||
|
def questionGroup(self):
|
||||||
|
for p in self.context.getParents():
|
||||||
|
ap = adapted(p)
|
||||||
|
if IQuestionGroup.providedBy(ap):
|
||||||
|
return ap
|
||||||
|
|
||||||
|
@property
|
||||||
|
def questionnaire(self):
|
||||||
|
return self.questionGroup.questionnaire
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.context)
|
||||||
|
|
||||||
|
|
||||||
class FeedbackItem(AdapterBase, FeedbackItem):
|
class FeedbackItem(AdapterBase, FeedbackItem):
|
||||||
|
|
||||||
|
@ -97,3 +122,7 @@ class FeedbackItem(AdapterBase, FeedbackItem):
|
||||||
'text',)
|
'text',)
|
||||||
_noexportAttributes = _adapterAttributes
|
_noexportAttributes = _adapterAttributes
|
||||||
|
|
||||||
|
@property
|
||||||
|
def text(self):
|
||||||
|
return self.context.description
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,9 @@ surveys and self-assessments.
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
|
from cybertools.knowledge.survey.questionnaire import Response
|
||||||
from loops.browser.concept import ConceptView
|
from loops.browser.concept import ConceptView
|
||||||
|
from loops.common import adapted
|
||||||
from loops.organize.party import getPersonForUser
|
from loops.organize.party import getPersonForUser
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,8 +35,33 @@ template = ViewPageTemplateFile('view_macros.pt')
|
||||||
class SurveyView(ConceptView):
|
class SurveyView(ConceptView):
|
||||||
|
|
||||||
tabview = 'index.html'
|
tabview = 'index.html'
|
||||||
|
data = None
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def macro(self):
|
def macro(self):
|
||||||
return template.macros['survey']
|
return template.macros['survey']
|
||||||
|
|
||||||
|
def results(self):
|
||||||
|
form = self.request.form
|
||||||
|
if 'submit' in form:
|
||||||
|
self.data = {}
|
||||||
|
response = Response(self.adapted, None)
|
||||||
|
for key, value in form.items():
|
||||||
|
if key.startswith('question_'):
|
||||||
|
uid = key[len('question_'):]
|
||||||
|
question = adapted(self.getObjectForUid(uid))
|
||||||
|
value = int(value)
|
||||||
|
self.data[uid] = value
|
||||||
|
response.values[question] = value
|
||||||
|
result = response.getGroupedResult()
|
||||||
|
return [dict(category=r[0].title, text=r[1].text) for r in result]
|
||||||
|
#return [{'category': 'foo', 'text': 'bar'}]
|
||||||
|
return []
|
||||||
|
|
||||||
|
def isChecked(self, question, value):
|
||||||
|
if self.data is not None:
|
||||||
|
setting = self.data.get(question.uid)
|
||||||
|
if setting is not None:
|
||||||
|
return value == setting
|
||||||
|
return value == 0
|
||||||
|
|
||||||
|
|
|
@ -2,33 +2,55 @@
|
||||||
<html i18n:domain="loops">
|
<html i18n:domain="loops">
|
||||||
|
|
||||||
|
|
||||||
<metal:block define-macro="survey">
|
<metal:block define-macro="survey"
|
||||||
|
tal:define="feedback item/results">
|
||||||
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
<metal:title use-macro="item/conceptMacros/concepttitle" />
|
||||||
<table>
|
<div tal:condition="feedback">
|
||||||
<tr>
|
<h3 i18n:translate="">Feedback</h3>
|
||||||
<th></th>
|
<table>
|
||||||
<th>
|
<tr>
|
||||||
<table>
|
<th i18n:translate="">Category</th>
|
||||||
<tr>
|
<th i18n:translate="">Response</th>
|
||||||
<td i18n:translate="">Does not apply</td>
|
</tr>
|
||||||
<td style="text-align: right"
|
<tr tal:repeat="fbitem feedback">
|
||||||
i18n:translate="">Fully applies</td>
|
<td tal:content="fbitem/category" />
|
||||||
</tr>
|
<td tal:content="fbitem/text" />
|
||||||
</table>
|
</tr>
|
||||||
</th>
|
</table>
|
||||||
</tr>
|
<br />
|
||||||
<tr tal:repeat="question item/adapted/questions">
|
</div>
|
||||||
<td tal:content="question/text" />
|
<h3 i18n:translate="">Questionnaire</h3>
|
||||||
<td style="white-space: nowrap">
|
<form method="post">
|
||||||
<span tal:repeat="value python:range(question.answerRange)">
|
<table>
|
||||||
<input type="radio"
|
<tr>
|
||||||
tal:attributes="name question/uid;
|
<th></th>
|
||||||
value value;
|
<th>
|
||||||
checked repeat/value/start" />
|
<table>
|
||||||
</span>
|
<tr>
|
||||||
</td>
|
<td i18n:translate="">Does not apply</td>
|
||||||
</tr>
|
<td style="text-align: right"
|
||||||
</table>
|
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 string:question_${question/uid};
|
||||||
|
value value;
|
||||||
|
checked python:item.isChecked(question, value)" />
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<input type="submit" name="submit" value="Evaluate Questionnaire"
|
||||||
|
i18n:attributes="value" />
|
||||||
|
</form>
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -184,12 +184,27 @@ msgstr "Negativbewertung"
|
||||||
msgid "Value inversion: High selection means low value."
|
msgid "Value inversion: High selection means low value."
|
||||||
msgstr "Invertierung der Bewertung: Hohe gewählte Stufe bedeutet niedriger Wert."
|
msgstr "Invertierung der Bewertung: Hohe gewählte Stufe bedeutet niedriger Wert."
|
||||||
|
|
||||||
|
msgid "Questionnaire"
|
||||||
|
msgstr "Fragebogen"
|
||||||
|
|
||||||
|
msgid "Feedback"
|
||||||
|
msgstr "Auswertung"
|
||||||
|
|
||||||
|
msgid "Category"
|
||||||
|
msgstr "Kategorie"
|
||||||
|
|
||||||
|
msgid "Response"
|
||||||
|
msgstr "Beurteilung"
|
||||||
|
|
||||||
msgid "Does not apply"
|
msgid "Does not apply"
|
||||||
msgstr "Trifft nicht zu"
|
msgstr "Trifft nicht zu"
|
||||||
|
|
||||||
msgid "Fully applies"
|
msgid "Fully applies"
|
||||||
msgstr "Trifft voll zu"
|
msgstr "Trifft voll zu"
|
||||||
|
|
||||||
|
msgid "Evaluate Questionnaire"
|
||||||
|
msgstr "Fragebogen auswerten"
|
||||||
|
|
||||||
# competence (qualification)
|
# competence (qualification)
|
||||||
|
|
||||||
msgid "Validity Period (Months)"
|
msgid "Validity Period (Months)"
|
||||||
|
|
Loading…
Add table
Reference in a new issue