store response data of team-based surveys under person + institution key
This commit is contained in:
parent
328c1fbaaf
commit
57aee009b6
3 changed files with 33 additions and 6 deletions
|
@ -141,10 +141,11 @@ class SurveyView(InstitutionMixin, ConceptView):
|
||||||
#person = self.getObjectForUid(personId)
|
#person = self.getObjectForUid(personId)
|
||||||
#inst = person.getParents([pred])
|
#inst = person.getParents([pred])
|
||||||
inst = self.institution
|
inst = self.institution
|
||||||
|
instUid = self.getUidForObject(inst)
|
||||||
if inst:
|
if inst:
|
||||||
for c in inst.getChildren([pred]):
|
for c in inst.getChildren([pred]):
|
||||||
uid = self.getUidForObject(c)
|
uid = self.getUidForObject(c)
|
||||||
data = respManager.load(uid)
|
data = respManager.load(uid, instUid)
|
||||||
if data:
|
if data:
|
||||||
resp = Response(self.adapted, None)
|
resp = Response(self.adapted, None)
|
||||||
for qu in self.adapted.questions:
|
for qu in self.adapted.questions:
|
||||||
|
@ -177,6 +178,9 @@ class SurveyView(InstitutionMixin, ConceptView):
|
||||||
respManager = Responses(self.context)
|
respManager = Responses(self.context)
|
||||||
respManager.personId = (self.request.form.get('person') or
|
respManager.personId = (self.request.form.get('person') or
|
||||||
respManager.getPersonId())
|
respManager.getPersonId())
|
||||||
|
if self.adapted.teamBasedEvaluation and self.institution:
|
||||||
|
respManager.institutionId = self.getUidForObject(
|
||||||
|
baseObject(self.institution))
|
||||||
data = {}
|
data = {}
|
||||||
response = Response(self.adapted, None)
|
response = Response(self.adapted, None)
|
||||||
for key, value in form.items():
|
for key, value in form.items():
|
||||||
|
@ -257,6 +261,9 @@ class SurveyView(InstitutionMixin, ConceptView):
|
||||||
respManager = Responses(self.context)
|
respManager = Responses(self.context)
|
||||||
respManager.personId = (self.request.form.get('person') or
|
respManager.personId = (self.request.form.get('person') or
|
||||||
respManager.getPersonId())
|
respManager.getPersonId())
|
||||||
|
if self.adapted.teamBasedEvaluation and self.institution:
|
||||||
|
respManager.institutionId = self.getUidForObject(
|
||||||
|
baseObject(self.institution))
|
||||||
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) 2015 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
|
||||||
|
@ -34,20 +34,32 @@ class Responses(BaseRecordManager):
|
||||||
implements(IResponses)
|
implements(IResponses)
|
||||||
|
|
||||||
storageName = 'survey_responses'
|
storageName = 'survey_responses'
|
||||||
|
personId = None
|
||||||
|
institutionId = None
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
def save(self, data):
|
def save(self, data):
|
||||||
if self.personId:
|
if self.personId:
|
||||||
self.storage.saveUserTrack(self.uid, 0, self.personId, data,
|
id = self.personId
|
||||||
|
if self.institutionId:
|
||||||
|
id += '.' + self.institutionId
|
||||||
|
self.storage.saveUserTrack(self.uid, 0, id, data,
|
||||||
update=True, overwrite=True)
|
update=True, overwrite=True)
|
||||||
|
|
||||||
def load(self, personId=None):
|
def load(self, personId=None, institutionId=None):
|
||||||
if personId is None:
|
if personId is None:
|
||||||
personId = self.personId
|
personId = self.personId
|
||||||
|
if institutionId is None:
|
||||||
|
institutionId = self.institutionId
|
||||||
if personId:
|
if personId:
|
||||||
tracks = self.storage.getUserTracks(self.uid, 0, personId)
|
id = personId
|
||||||
|
if institutionId:
|
||||||
|
id += '.' + institutionId
|
||||||
|
tracks = self.storage.getUserTracks(self.uid, 0, id)
|
||||||
|
if not tracks: # then try without institution
|
||||||
|
tracks = self.storage.getUserTracks(self.uid, 0, personId)
|
||||||
if tracks:
|
if tracks:
|
||||||
return tracks[0].data
|
return tracks[0].data
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -66,7 +66,15 @@ class BaseTrackView(TrackView):
|
||||||
obj = util.getObjectForUid(uid)
|
obj = util.getObjectForUid(uid)
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
return obj
|
return obj
|
||||||
return uid
|
result = []
|
||||||
|
for id in uid.split('.'):
|
||||||
|
if id.isdigit():
|
||||||
|
obj = util.getObjectForUid(id)
|
||||||
|
if obj is not None:
|
||||||
|
result.append(obj.title)
|
||||||
|
continue
|
||||||
|
result.append(id)
|
||||||
|
return ' / '.join(result)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def authentication(self):
|
def authentication(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue