avoid leaking of attributes to subclasses: put in constructor instead of class
This commit is contained in:
parent
63163a00e7
commit
2dcd73f56f
2 changed files with 3 additions and 4 deletions
|
@ -31,8 +31,8 @@ class IQuestionnaire(Interface):
|
|||
""" A collection of questions for setting up a survey.
|
||||
"""
|
||||
|
||||
questions = Attribute('An ordered collection of questions.')
|
||||
questionGroups = Attribute('An ordered collection of question groups (optional).')
|
||||
questions = Attribute('An ordered collection of questions.')
|
||||
responses = Attribute('A set of responses.')
|
||||
defaultAnswerRange = Attribute('The number of answer options to select from. '
|
||||
'Default value used for questions that do not '
|
||||
|
|
|
@ -29,13 +29,12 @@ from cybertools.knowledge.survey.interfaces import IFeedbackItem, IResponse
|
|||
class Questionnaire(object):
|
||||
|
||||
implements(IQuestionnaire)
|
||||
|
||||
defaultAnswerRange = 5
|
||||
|
||||
def __init__(self):
|
||||
self.questionGroups = []
|
||||
self.questions = []
|
||||
self.responses = []
|
||||
self.defaultAnswerRange = 5
|
||||
|
||||
|
||||
class QuestionGroup(object):
|
||||
|
@ -53,12 +52,12 @@ class Question(object):
|
|||
implements(IQuestion)
|
||||
|
||||
_answerRange = None
|
||||
revertAnswerOptions = False
|
||||
|
||||
def __init__(self, questionnaire, text=u''):
|
||||
self.questionnaire = questionnaire
|
||||
self.feedbackItems = {}
|
||||
self.text = text
|
||||
self.revertAnswerOptions = False
|
||||
|
||||
def getAnswerRange(self):
|
||||
return self._answerRange or self.questionnaire.defaultAnswerRange
|
||||
|
|
Loading…
Add table
Reference in a new issue