Merge branch 'master' of git://github.com/pegpe/seantis-questionnaire into pegpe
commit
10d475ea31
|
@ -92,5 +92,7 @@ LANGUAGES = (
|
||||||
('de', 'Deutsch'),
|
('de', 'Deutsch'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REPLACEMENTSTRING = u'subst_with_ans_'
|
||||||
|
|
||||||
try: from local_settings import *
|
try: from local_settings import *
|
||||||
except: pass
|
except: pass
|
||||||
|
|
|
@ -164,7 +164,9 @@ class RunInfo(models.Model):
|
||||||
if key in cookies:
|
if key in cookies:
|
||||||
del cookies[key]
|
del cookies[key]
|
||||||
else:
|
else:
|
||||||
cookies[key] = str(value)
|
if type(value) == 'int':
|
||||||
|
value=str(value)
|
||||||
|
cookies[key] = value
|
||||||
cstr = json.dumps(cookies)
|
cstr = json.dumps(cookies)
|
||||||
if len(cstr) > 512: # XXX - hard coded to match cookie length above
|
if len(cstr) > 512: # XXX - hard coded to match cookie length above
|
||||||
raise Exception("Cannot set cookie. No more space in cookie jar!")
|
raise Exception("Cannot set cookie. No more space in cookie jar!")
|
||||||
|
|
|
@ -315,6 +315,10 @@ def show_questionnaire(request, runinfo, errors={}):
|
||||||
jstriggers = []
|
jstriggers = []
|
||||||
qvalues = {}
|
qvalues = {}
|
||||||
alignment=4
|
alignment=4
|
||||||
|
# initialize qvalues
|
||||||
|
for k,v in runinfo.get_cookiedict().items():
|
||||||
|
qvalues[k] = v
|
||||||
|
|
||||||
for question in questions:
|
for question in questions:
|
||||||
Type = question.get_type()
|
Type = question.get_type()
|
||||||
_qnum, _qalpha = split_numal(question.number)
|
_qnum, _qalpha = split_numal(question.number)
|
||||||
|
@ -329,6 +333,15 @@ def show_questionnaire(request, runinfo, errors={}):
|
||||||
'qalpha_class' : _qalpha and (ord(_qalpha[-1]) % 2 \
|
'qalpha_class' : _qalpha and (ord(_qalpha[-1]) % 2 \
|
||||||
and ' alodd' or ' aleven') or '',
|
and ' alodd' or ' aleven') or '',
|
||||||
}
|
}
|
||||||
|
#If the question has a magic string surrounded by spaces that refers to an answer to a previous question, fetch the answer and replace the magic string
|
||||||
|
#To be able to fetch the cookie with the answer it has to be stored using additional checks
|
||||||
|
#At the moment it only works for english.
|
||||||
|
replacementtext=settings.REPLACEMENTSTRING
|
||||||
|
questionnumberpos=question.text.find(replacementtext)
|
||||||
|
if questionnumberpos <> -1:
|
||||||
|
questionnumber=question.text_en[questionnumberpos:].split(' ')[0].replace(replacementtext,'')
|
||||||
|
if questionnumber in qvalues.keys():
|
||||||
|
question.text_en=question.text_en.replace(replacementtext+questionnumber,qvalues[questionnumber])
|
||||||
|
|
||||||
if not question.newline():
|
if not question.newline():
|
||||||
alignment = max(alignment, calc_alignment(question.text))
|
alignment = max(alignment, calc_alignment(question.text))
|
||||||
|
@ -363,9 +376,6 @@ def show_questionnaire(request, runinfo, errors={}):
|
||||||
if runinfo.questionset.sortid != 0:
|
if runinfo.questionset.sortid != 0:
|
||||||
progress = get_progress(runinfo.questionset.sortid / float(total))
|
progress = get_progress(runinfo.questionset.sortid / float(total))
|
||||||
|
|
||||||
# initialize qvalues
|
|
||||||
for k,v in runinfo.get_cookiedict().items():
|
|
||||||
qvalues[k] = v
|
|
||||||
if request.POST:
|
if request.POST:
|
||||||
for k,v in request.POST.items():
|
for k,v in request.POST.items():
|
||||||
if k.startswith("question_"):
|
if k.startswith("question_"):
|
||||||
|
@ -557,6 +567,8 @@ def answer_export(questionnaire, answers=None):
|
||||||
subject = answer.subject
|
subject = answer.subject
|
||||||
row = [""] * len(headings)
|
row = [""] * len(headings)
|
||||||
ans = answer.split_answer()
|
ans = answer.split_answer()
|
||||||
|
if type(ans) == int:
|
||||||
|
ans = str(ans)
|
||||||
for choice in ans:
|
for choice in ans:
|
||||||
col = None
|
col = None
|
||||||
if type(choice) == list:
|
if type(choice) == list:
|
||||||
|
|
Loading…
Reference in New Issue