28 lines
846 B
Python
28 lines
846 B
Python
import csv
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from assignments.helpers import write_assignments_to_csv, write_submissions_to_csv
|
|
from assignments.models import Assignment, StudentSubmission
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = """
|
|
Export assignments with submissions
|
|
"""
|
|
|
|
def handle(self, *args, **options):
|
|
ids = [171, 112, 113, 114, 272, 246, 250, 348, 598]
|
|
|
|
assignments = Assignment.objects.filter(id__in=ids)
|
|
|
|
with open('./export-assignments.csv', 'w') as f:
|
|
writer = csv.writer(f)
|
|
write_assignments_to_csv(writer, assignments)
|
|
|
|
submissions = StudentSubmission.objects.filter(assignment__id__in=ids)
|
|
|
|
with open('./export-submissions.csv', 'w') as f:
|
|
writer = csv.writer(f)
|
|
write_submissions_to_csv(writer, submissions)
|