- def build_package(self, zippath, student, verbose):
- with open(zippath, 'w') as outf:
- zipf = zipfile.ZipFile(outf, 'w', zipfile.ZIP_STORED)
-
- for si, section in enumerate(Section.objects.all()):
- li = 1
- li_adv = 1
- for lesson in section.lesson_set.all():
- advanced = lesson.level.slug == "liceum"
- section_dir = "%d_%s%s" % (
- si + 1, section.slug,
- " (zaawansowane)" if advanced else "")
- if lesson.type == 'course':
- if advanced:
- ind = li_adv
- li_adv += 1
- else:
- ind = li
- li += 1
- prefix = "%s/%02d_%s/" % (
- section_dir, ind, lesson.slug,
- )
- elif lesson.type == 'synthetic':
- prefix = "%s/%s (synteza)/" % (
- section_dir, lesson.slug)
- elif lesson.type == 'project':
- prefix = "%s/%s (projekt)/" % (
- section_dir, lesson.slug)
- else:
- prefix = "%s/%s/" % (
- section_dir, lesson.slug)
- lesson.add_to_zip(zipf, student, prefix)
- zipf.close()
-