def _all_grades_output(response, course):
    activities = all_activities_filter(offering=course)
    students = Member.objects.filter(offering=course, role="STUD").select_related('person')

    # get grade data into a format we can work with
    labtut = course.labtut
    grades = {}
    for a in activities:
        grades[a.slug] = {}
        if hasattr(a, 'numericgrade_set'):
            gs = a.numericgrade_set.all().select_related('member', 'member__person')
        else:
            gs = a.lettergrade_set.all().select_related('member', 'member__person')
        for g in gs:
            grades[a.slug][g.member.person.userid] = g