From 5f8ed471656e7799ec3091f19cab3f28e3b763d4 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 7 Apr 2016 08:24:27 +0200 Subject: [PATCH] add person-based questionnaire control team- and person-based questionnaires via questionnaireType; person-based questionnaire: refer to (answer questions for) other person. --- knowledge/survey/base.py | 11 ++++++++++- knowledge/survey/browser.py | 6 +++++- knowledge/survey/interfaces.py | 6 +++++- knowledge/survey/response.py | 11 +++++++++-- knowledge/survey/view_macros.pt | 10 ++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/knowledge/survey/base.py b/knowledge/survey/base.py index 3d0bc28..708aeb4 100644 --- a/knowledge/survey/base.py +++ b/knowledge/survey/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2015 Helmut Merz helmutm@cy55.de +# Copyright (c) 2016 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 @@ -41,9 +41,18 @@ class Questionnaire(AdapterBase, Questionnaire): _contextAttributes = list(IQuestionnaire) _adapterAttributes = AdapterBase._adapterAttributes + ( + 'teamBasedEvaluation', 'questionGroups', 'questions', 'responses',) _noexportAttributes = _adapterAttributes + def getTeamBasedEvaluation(self): + return (self.questionnaireType == 'team' or + getattr(self.context, '_teamBasedEvaluation', False)) + def setTeamBasedEvaluation(self, value): + if not value and getattr(self.context, '_teamBasedEvaluation', False): + self.context._teamBasedEvaluation = False + teamBasedEvaluation = property(getTeamBasedEvaluation, setTeamBasedEvaluation) + @property def questionGroups(self): return self.getQuestionGroups() diff --git a/knowledge/survey/browser.py b/knowledge/survey/browser.py index bf2f6cd..c39e778 100644 --- a/knowledge/survey/browser.py +++ b/knowledge/survey/browser.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2015 Helmut Merz helmutm@cy55.de +# Copyright (c) 2016 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 @@ -228,6 +228,8 @@ class SurveyView(InstitutionMixin, ConceptView): if self.adapted.teamBasedEvaluation and self.institution: respManager.institutionId = self.getUidForObject( baseObject(self.institution)) + if self.adapted.questionnaireType == 'person': + respManager.referrerId = respManager.getPersonId() if self.adapted.questionnaireType == 'pref_selection': return self.prefsResults(respManager, form, action) data = {} @@ -378,6 +380,8 @@ class SurveyView(InstitutionMixin, ConceptView): if self.adapted.teamBasedEvaluation and self.institution: respManager.institutionId = self.getUidForObject( baseObject(self.institution)) + if self.adapted.questionnaireType == 'person': + respManager.referrerId = respManager.getPersonId() self.data = respManager.load() def getValues(self, question): diff --git a/knowledge/survey/interfaces.py b/knowledge/survey/interfaces.py index 500c60f..1916cd5 100644 --- a/knowledge/survey/interfaces.py +++ b/knowledge/survey/interfaces.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013 Helmut Merz helmutm@cy55.de +# Copyright (c) 2016 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 @@ -45,6 +45,8 @@ class IQuestionnaire(IConceptSchema, interfaces.IQuestionnaire): description=_(u'Select the type of the questionnaire.'), source=KeywordVocabulary(( ('standard', _(u'Standard Questionnaire')), + ('person', _(u'Person-related Questionnaire')), + ('team', _(u'Team-related Questionnaire')), ('pref_selection', _(u'Preference Selection')), )), default='standard', @@ -84,6 +86,8 @@ class IQuestionnaire(IConceptSchema, interfaces.IQuestionnaire): default=False, required=False) + #teamBasedEvaluation = Attribute('Team-based Evaluation') + feedbackColumns = Records( title=_(u'Feedback Columns'), description=_(u'Column definitions for the results table ' diff --git a/knowledge/survey/response.py b/knowledge/survey/response.py index 8ba293c..77e5b6f 100644 --- a/knowledge/survey/response.py +++ b/knowledge/survey/response.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2015 Helmut Merz helmutm@cy55.de +# Copyright (c) 2016 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 @@ -36,6 +36,7 @@ class Responses(BaseRecordManager): storageName = 'survey_responses' personId = None institutionId = None + referrerId = None def __init__(self, context): self.context = context @@ -45,18 +46,24 @@ class Responses(BaseRecordManager): id = self.personId if self.institutionId: id += '.' + self.institutionId + if self.referrerId: + id += '.' + self.referrerId self.storage.saveUserTrack(self.uid, 0, id, data, update=True, overwrite=True) - def load(self, personId=None, institutionId=None): + def load(self, personId=None, referrerId=None, institutionId=None): if personId is None: personId = self.personId + if referrerId is None: + referrerId = self.referrerId if institutionId is None: institutionId = self.institutionId if personId: id = personId if institutionId: id += '.' + institutionId + if referrerId: + id += '.' + referrerId tracks = self.storage.getUserTracks(self.uid, 0, id) if not tracks: # then try without institution tracks = self.storage.getUserTracks(self.uid, 0, personId) diff --git a/knowledge/survey/view_macros.pt b/knowledge/survey/view_macros.pt index 6a0b7ac..94eda84 100644 --- a/knowledge/survey/view_macros.pt +++ b/knowledge/survey/view_macros.pt @@ -104,6 +104,16 @@ + + + + + + + + + +

Questionnaire