add person-based questionnaire
control team- and person-based questionnaires via questionnaireType; person-based questionnaire: refer to (answer questions for) other person.
This commit is contained in:
parent
5b2b28da19
commit
5f8ed47165
5 changed files with 39 additions and 5 deletions
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -41,9 +41,18 @@ class Questionnaire(AdapterBase, Questionnaire):
|
||||||
|
|
||||||
_contextAttributes = list(IQuestionnaire)
|
_contextAttributes = list(IQuestionnaire)
|
||||||
_adapterAttributes = AdapterBase._adapterAttributes + (
|
_adapterAttributes = AdapterBase._adapterAttributes + (
|
||||||
|
'teamBasedEvaluation',
|
||||||
'questionGroups', 'questions', 'responses',)
|
'questionGroups', 'questions', 'responses',)
|
||||||
_noexportAttributes = _adapterAttributes
|
_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
|
@property
|
||||||
def questionGroups(self):
|
def questionGroups(self):
|
||||||
return self.getQuestionGroups()
|
return self.getQuestionGroups()
|
||||||
|
|
|
@ -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
|
# 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
|
# 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:
|
if self.adapted.teamBasedEvaluation and self.institution:
|
||||||
respManager.institutionId = self.getUidForObject(
|
respManager.institutionId = self.getUidForObject(
|
||||||
baseObject(self.institution))
|
baseObject(self.institution))
|
||||||
|
if self.adapted.questionnaireType == 'person':
|
||||||
|
respManager.referrerId = respManager.getPersonId()
|
||||||
if self.adapted.questionnaireType == 'pref_selection':
|
if self.adapted.questionnaireType == 'pref_selection':
|
||||||
return self.prefsResults(respManager, form, action)
|
return self.prefsResults(respManager, form, action)
|
||||||
data = {}
|
data = {}
|
||||||
|
@ -378,6 +380,8 @@ class SurveyView(InstitutionMixin, ConceptView):
|
||||||
if self.adapted.teamBasedEvaluation and self.institution:
|
if self.adapted.teamBasedEvaluation and self.institution:
|
||||||
respManager.institutionId = self.getUidForObject(
|
respManager.institutionId = self.getUidForObject(
|
||||||
baseObject(self.institution))
|
baseObject(self.institution))
|
||||||
|
if self.adapted.questionnaireType == 'person':
|
||||||
|
respManager.referrerId = respManager.getPersonId()
|
||||||
self.data = respManager.load()
|
self.data = respManager.load()
|
||||||
|
|
||||||
def getValues(self, question):
|
def getValues(self, question):
|
||||||
|
|
|
@ -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
|
# 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
|
# 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.'),
|
description=_(u'Select the type of the questionnaire.'),
|
||||||
source=KeywordVocabulary((
|
source=KeywordVocabulary((
|
||||||
('standard', _(u'Standard Questionnaire')),
|
('standard', _(u'Standard Questionnaire')),
|
||||||
|
('person', _(u'Person-related Questionnaire')),
|
||||||
|
('team', _(u'Team-related Questionnaire')),
|
||||||
('pref_selection', _(u'Preference Selection')),
|
('pref_selection', _(u'Preference Selection')),
|
||||||
)),
|
)),
|
||||||
default='standard',
|
default='standard',
|
||||||
|
@ -84,6 +86,8 @@ class IQuestionnaire(IConceptSchema, interfaces.IQuestionnaire):
|
||||||
default=False,
|
default=False,
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
#teamBasedEvaluation = Attribute('Team-based Evaluation')
|
||||||
|
|
||||||
feedbackColumns = Records(
|
feedbackColumns = Records(
|
||||||
title=_(u'Feedback Columns'),
|
title=_(u'Feedback Columns'),
|
||||||
description=_(u'Column definitions for the results table '
|
description=_(u'Column definitions for the results table '
|
||||||
|
|
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,6 +36,7 @@ class Responses(BaseRecordManager):
|
||||||
storageName = 'survey_responses'
|
storageName = 'survey_responses'
|
||||||
personId = None
|
personId = None
|
||||||
institutionId = None
|
institutionId = None
|
||||||
|
referrerId = None
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
@ -45,18 +46,24 @@ class Responses(BaseRecordManager):
|
||||||
id = self.personId
|
id = self.personId
|
||||||
if self.institutionId:
|
if self.institutionId:
|
||||||
id += '.' + self.institutionId
|
id += '.' + self.institutionId
|
||||||
|
if self.referrerId:
|
||||||
|
id += '.' + self.referrerId
|
||||||
self.storage.saveUserTrack(self.uid, 0, id, data,
|
self.storage.saveUserTrack(self.uid, 0, id, data,
|
||||||
update=True, overwrite=True)
|
update=True, overwrite=True)
|
||||||
|
|
||||||
def load(self, personId=None, institutionId=None):
|
def load(self, personId=None, referrerId=None, institutionId=None):
|
||||||
if personId is None:
|
if personId is None:
|
||||||
personId = self.personId
|
personId = self.personId
|
||||||
|
if referrerId is None:
|
||||||
|
referrerId = self.referrerId
|
||||||
if institutionId is None:
|
if institutionId is None:
|
||||||
institutionId = self.institutionId
|
institutionId = self.institutionId
|
||||||
if personId:
|
if personId:
|
||||||
id = personId
|
id = personId
|
||||||
if institutionId:
|
if institutionId:
|
||||||
id += '.' + institutionId
|
id += '.' + institutionId
|
||||||
|
if referrerId:
|
||||||
|
id += '.' + referrerId
|
||||||
tracks = self.storage.getUserTracks(self.uid, 0, id)
|
tracks = self.storage.getUserTracks(self.uid, 0, id)
|
||||||
if not tracks: # then try without institution
|
if not tracks: # then try without institution
|
||||||
tracks = self.storage.getUserTracks(self.uid, 0, personId)
|
tracks = self.storage.getUserTracks(self.uid, 0, personId)
|
||||||
|
|
|
@ -104,6 +104,16 @@
|
||||||
</metal:block>
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:block define-macro="quest_person">
|
||||||
|
<metal:block use-macro="item/template/macros/quest_standard" />
|
||||||
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:block define-macro="quest_team">
|
||||||
|
<metal:block use-macro="item/template/macros/quest_standard" />
|
||||||
|
</metal:block>
|
||||||
|
|
||||||
|
|
||||||
<metal:block define-macro="quest_pref_selection">
|
<metal:block define-macro="quest_pref_selection">
|
||||||
<h3 i18n:translate="">Questionnaire</h3>
|
<h3 i18n:translate="">Questionnaire</h3>
|
||||||
<div class="error"
|
<div class="error"
|
||||||
|
|
Loading…
Add table
Reference in a new issue