diff --git a/knowledge/survey/browser.py b/knowledge/survey/browser.py index 04a46d1..205ad5b 100644 --- a/knowledge/survey/browser.py +++ b/knowledge/survey/browser.py @@ -44,6 +44,7 @@ class SurveyView(ConceptView): data = None errors = None + minBatchSize = 10 @Lazy def macro(self): @@ -55,6 +56,26 @@ class SurveyView(ConceptView): if self.editable: return 'index.html' + @Lazy + def groups(self): + result = [] + if self.adapted.noGrouping: + questions = list(self.adapted.questions) + questions.sort(key=lambda x: x.title) + size = len(questions) + nb = size / self.minBatchSize + rem = size % self.minBatchSize + bs = self.minBatchSize + ((rem + self.minBatchSize) / nb) + for idx in range(0, size, bs): + result.append(dict(title=u'Question', infoText=None, + questions=questions[idx:idx+bs])) + else: + for group in self.adapted.questionGroups: + result.append(dict(title=group.title, + infoText=self.getInfoText(group), + questions=group.questions)) + return result + @Lazy def answerOptions(self): opts = self.adapted.answerOptions diff --git a/knowledge/survey/view_macros.pt b/knowledge/survey/view_macros.pt index 8f5ec42..cd14558 100644 --- a/knowledge/survey/view_macros.pt +++ b/knowledge/survey/view_macros.pt @@ -61,11 +61,14 @@