Ejemplo n.º 1
0
def atstudent_stats(session, students=[]):
    if students == []:
        students = get_session_students(session)
    nbstudents = 0
    nbchoices = 0
    nbokstudents = 0
    for student in students:
        nbstudents += 1
        schoice = False
        for at in session.atelier_set.all():
            for ats in student.atstudent_set.all():
                print student, ats.atelier.pk, at.pk
                if ats.atelier.pk == at.pk:
                    nbchoices += 1
                    schoice = True
                    break
        if schoice:
            nbokstudents += 1
    return {'nbstudents': nbstudents, 'nbokstudents': nbokstudents,
            'nbchoices': nbchoices}
Ejemplo n.º 2
0
def summary(request, sid):
    teacher = get_object_or_404(Teacher, user=request.user)
    session = get_object_or_404(Session, pk=sid, admins=teacher)
    students = get_session_students(session)
    for student in students:
        student.choices = []
        for at in session.atelier_set.all():
            found = False
            for ats in student.atstudent_set.all():
                print student, ats.atelier.pk, at.pk
                if ats.atelier.pk == at.pk:
                    student.choices.append(ats)
                    found = True
                    break
            if not found:
                student.choices.append({'atelier': at, 'student': student,
                                             'pk': '-1', 'score': '-'})
    return render(request, 'atstudent/teacher/summary.html',
                  {'students': students, 'session': session,
                   'teacher': teacher})