示例#1
0
文件: __init__.py 项目: 3dna/sdaps
def report(survey, filter, filename=None, papersize=None, small=0, suppress=None):
    assert isinstance(survey, model.survey.Survey)

    # compile clifilter
    filter = clifilter.clifilter(survey, filter)

    # First: calculate buddies

    # init buddies
    survey.questionnaire.calculate.init()

    # iterate over sheets
    survey.iterate(
        survey.questionnaire.calculate.read,
        lambda: survey.sheet.valid and not survey.sheet.empty and filter()
    )

    # do calculations
    survey.questionnaire.calculate.calculate()

    # Second: report buddies

    # init buddies
    survey.questionnaire.report.init(small, suppress)

    # iterate over sheets
    survey.iterate(
        survey.questionnaire.report.report,
        lambda: survey.sheet.valid and filter()
    )

    # create story
    story = template.story_title(
        survey,
        {
            _(u'Turned in Questionnaires'): survey.questionnaire.calculate.count,
        }
    )
    story.extend(survey.questionnaire.report.story())

    # create report(out of story)
    if filename is None:
        filename = survey.new_path('report_%i.pdf')
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    papersize = paper.get_reportlab_papersize(papersize)

    doc = template.DocTemplate(
        filename,
        _(u'sdaps report'),
        {
            'title': survey.title,
            'subject': subject,
        },
        papersize=papersize
    )
    doc.build(story)
示例#2
0
def cover(cmdline):
    from sdaps import template

    survey = model.survey.Survey.load(cmdline['project'])

    story = template.story_title(survey)
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    if cmdline['output']:
        filename = cmdline['output']
    else:
        filename = survey.new_path('cover_%i.pdf')

    doc = template.DocTemplate(
        filename,
        _(u'sdaps questionnaire'),
        {
            'title': survey.title,
            'subject': subject
        }
    )
    doc.build(story)
示例#3
0
def report(survey,
           filter,
           filename=None,
           papersize=None,
           small=0,
           suppress=None):
    assert isinstance(survey, model.survey.Survey)

    # compile clifilter
    filter = clifilter.clifilter(survey, filter)

    # First: calculate buddies

    # init buddies
    survey.questionnaire.calculate.init()

    # iterate over sheets
    survey.iterate(
        survey.questionnaire.calculate.read,
        lambda: survey.sheet.valid and not survey.sheet.empty and filter())

    # do calculations
    survey.questionnaire.calculate.calculate()

    # Second: report buddies

    # init buddies
    survey.questionnaire.report.init(small, suppress)

    # iterate over sheets
    survey.iterate(survey.questionnaire.report.report,
                   lambda: survey.sheet.valid and filter())

    # create story
    story = template.story_title(survey, {
        _(u'Turned in Questionnaires'):
        survey.questionnaire.calculate.count,
    })
    story.extend(survey.questionnaire.report.story())

    # create report(out of story)
    if filename is None:
        filename = survey.new_path('report_%i.pdf')
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    papersize = paper.get_reportlab_papersize(papersize)

    doc = template.DocTemplate(filename,
                               _(u'sdaps report'), {
                                   'title': survey.title,
                                   'subject': subject,
                               },
                               papersize=papersize)
    doc.build(story)
示例#4
0
def cover(survey, output=None):

    story = template.story_title(survey)
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    if output:
        filename = output
    else:
        filename = survey.new_path('cover_%i.pdf')

    doc = template.DocTemplate(filename, _(u'sdaps questionnaire'), {
        'title': survey.title,
        'subject': subject
    })
    doc.build(story)
示例#5
0
def cover(cmdline):
    from sdaps import template

    survey = model.survey.Survey.load(cmdline['project'])

    story = template.story_title(survey)
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    if cmdline['output']:
        filename = cmdline['output']
    else:
        filename = survey.new_path('cover_%i.pdf')

    doc = template.DocTemplate(filename, _(u'sdaps questionnaire'), {
        'title': survey.title,
        'subject': subject
    })
    doc.build(story)
示例#6
0
文件: __init__.py 项目: bgeneto/sdaps
def cover(survey, output=None):

    story = template.story_title(survey)
    subject = []
    for key, value in survey.info.iteritems():
        subject.append(u'%(key)s: %(value)s' % {'key': key, 'value': value})
    subject = u'\n'.join(subject)

    if output:
        filename = output
    else:
        filename = survey.new_path('cover_%i.pdf')

    doc = template.DocTemplate(
        filename,
        _(u'sdaps questionnaire'),
        {
            'title': survey.title,
            'subject': subject
        }
    )
    doc.build(story)