highlight missing questions; show team size

This commit is contained in:
Helmut Merz 2014-06-04 08:57:34 +02:00
parent 95a510c759
commit ed996977f9
4 changed files with 47 additions and 21 deletions

View file

@ -45,6 +45,7 @@ class SurveyView(ConceptView):
data = None
errors = None
minBatchSize = 10
teamData = None
@Lazy
def macro(self):
@ -170,8 +171,8 @@ class SurveyView(ConceptView):
score=int(round(r['score'] * 100)), rank=r['rank'])
for r in values]
if self.showTeamResults:
teamData = self.getTeamData(respManager)
teamValues = response.getTeamResult(values, teamData)
self.teamData = self.getTeamData(respManager)
teamValues = response.getTeamResult(values, self.teamData)
for idx, r in enumerate(teamValues):
result[idx]['average'] = int(round(r['average'] * 100))
result[idx]['teamRank'] = r['rank']
@ -182,7 +183,8 @@ class SurveyView(ConceptView):
values = response.values
for qu in self.adapted.questions:
if qu.required and qu not in values:
errors.append('Please answer the obligatory questions.')
errors.append(dict(uid=qu.uid,
text='Please answer the obligatory questions.'))
break
qugroups = {}
for qugroup in self.adapted.questionGroups:
@ -194,7 +196,12 @@ class SurveyView(ConceptView):
if minAnswers in (u'', None):
minAnswers = len(qugroup.questions)
if count < minAnswers:
errors.append('Please answer the minimum number of questions.')
if self.adapted.noGrouping:
errors.append(dict(uid=qugroup.uid,
text='Please answer the highlighted questions.'))
else:
errors.append(dict(uid=qugroup.uid,
text='Please answer the minimum number of questions.'))
break
return errors
@ -229,6 +236,12 @@ class SurveyView(ConceptView):
title=opt['description']))
return result
def getCssClass(self, question):
cls = ''
if self.errors and self.data.get(question.uid) is None:
cls = 'error '
return cls + 'vpad'
class SurveyCsvExport(NodeView):

View file

@ -37,9 +37,15 @@
</tal:cols>
</tr>
</table>
<p tal:define="teamData item/teamData"
tal:condition="teamData">
<b><span i18n:translate="">Team Size</span>:
<span tal:content="python:len(teamData)" /></b><br />&nbsp;
</p>
<div class="button" id="show_questionnaire">
<a href="" onclick="back(); return false"
i18n:translate="">
<a href="" xxonclick="back(); return false"
i18n:translate=""
tal:attributes="href view/virtualTargetUrl">
Back to Questionnaire</a>
<br />
</div>
@ -56,7 +62,7 @@
tal:condition="errors">
<div tal:repeat="error errors">
<span i18n:translate=""
tal:content="error" />
tal:content="error/text" />
</div>
</div>
<form method="post">
@ -79,20 +85,21 @@
i18n:translate=""
tal:content="opt/label" />
</tr>
<tr class="vpad"
tal:repeat="question group/questions">
<td tal:content="question/text" />
<td style="white-space: nowrap; text-align: center"
tal:repeat="value python:item.getValues(question)">
<input type="radio"
i18n:attributes="title"
tal:attributes="
name string:question_${question/uid};
value value/value;
checked value/checked;
title value/title" />
</td>
</tr>
<tal:question repeat="question group/questions">
<tr tal:attributes="class python:item.getCssClass(question)">
<td tal:content="question/text" />
<td style="white-space: nowrap; text-align: center"
tal:repeat="value python:item.getValues(question)">
<input type="radio"
i18n:attributes="title"
tal:attributes="
name string:question_${question/uid};
value value/value;
checked value/checked;
title value/title" />
</td>
</tr>
</tal:question>
</tal:group>
</table>
<input type="submit" name="submit" value="Evaluate Questionnaire"

Binary file not shown.

View file

@ -277,6 +277,9 @@ msgstr "Bitte beantworten Sie die Pflichtfragen."
msgid "Please answer the minimum number of questions."
msgstr "Bitte beantworten Sie die angegebene Mindestanzahl an Fragen je Fragengruppe."
msgid "Please answer the highlighted questions."
msgstr "Bitte beantworten Sie die markierten Fragen."
msgid "Obligatory question, must be answered"
msgstr "Pflichtfrage, muss beantwortet werden"
@ -292,6 +295,9 @@ msgstr "Rang"
msgid "Team Rank"
msgstr "Rang Team"
msgid "Team Size"
msgstr "Anzahl der vom Team ausgefüllten Fragebögen"
# competence (qualification)
msgid "Validity Period (Months)"