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)
|
||||
#inst = person.getParents([pred])
|
||||
inst = self.institution
|
||||
instUid = self.getUidForObject(inst)
|
||||
if inst:
|
||||
for c in inst.getChildren([pred]):
|
||||
uid = self.getUidForObject(c)
|
||||
data = respManager.load(uid)
|
||||
data = respManager.load(uid, instUid)
|
||||
if data:
|
||||
resp = Response(self.adapted, None)
|
||||
for qu in self.adapted.questions:
|
||||
|
@ -177,6 +178,9 @@ class SurveyView(InstitutionMixin, ConceptView):
|
|||
respManager = Responses(self.context)
|
||||
respManager.personId = (self.request.form.get('person') or
|
||||
respManager.getPersonId())
|
||||
if self.adapted.teamBasedEvaluation and self.institution:
|
||||
respManager.institutionId = self.getUidForObject(
|
||||
baseObject(self.institution))
|
||||
data = {}
|
||||
response = Response(self.adapted, None)
|
||||
for key, value in form.items():
|
||||
|
@ -257,6 +261,9 @@ class SurveyView(InstitutionMixin, ConceptView):
|
|||
respManager = Responses(self.context)
|
||||
respManager.personId = (self.request.form.get('person') or
|
||||
respManager.getPersonId())
|
||||
if self.adapted.teamBasedEvaluation and self.institution:
|
||||
respManager.institutionId = self.getUidForObject(
|
||||
baseObject(self.institution))
|
||||
self.data = respManager.load()
|
||||
|
||||
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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -34,19 +34,31 @@ class Responses(BaseRecordManager):
|
|||
implements(IResponses)
|
||||
|
||||
storageName = 'survey_responses'
|
||||
personId = None
|
||||
institutionId = None
|
||||
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
def save(self, data):
|
||||
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)
|
||||
|
||||
def load(self, personId=None):
|
||||
def load(self, personId=None, institutionId=None):
|
||||
if personId is None:
|
||||
personId = self.personId
|
||||
if institutionId is None:
|
||||
institutionId = self.institutionId
|
||||
if 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:
|
||||
return tracks[0].data
|
||||
|
|
|
@ -66,7 +66,15 @@ class BaseTrackView(TrackView):
|
|||
obj = util.getObjectForUid(uid)
|
||||
if obj is not None:
|
||||
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
|
||||
def authentication(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue