Exemplo n.º 1
0
def manage_class(request, onlineclass):
    if request.method == "POST":
        form = DeadlineForm(request.POST)
        if form.is_valid():
            chapter = form.cleaned_data['chapter']
            date = form.cleaned_data['date']
            time = form.cleaned_data['time']
            deadline = Deadline(chapter=chapter,
                                deadline=date + ' ' + time + ':59')
            deadline.save()
            onlineclass = OnlineClass.objects.get(id=onlineclass)
            deadline.onlineclass.add(onlineclass)
            deadline.save()
            return redirect('manage_class', onlineclass=onlineclass.id)
    else:
        form = DeadlineForm()
    onlineclass = OnlineClass.objects.get(id=onlineclass)
    if onlineclass in Professor.objects.get(
            user=request.user).prof_class.all():
        professors = Professor.objects.all().values_list('user')
        students = User.objects.filter(
            userprofile__user_class=onlineclass).exclude(
                pk__in=professors).order_by(
                    Lower('first_name').asc(),
                    Lower('last_name').asc())
        students_list = []
        for student in students:
            students_list.append({
                'student':
                student,
                'predict':
                predict_drop_out(student.id, onlineclass)
            })
        deadlines = Deadline.objects.filter(onlineclass=onlineclass)
        chapters = []
        for deadline in deadlines:
            chapter = Chapter.objects.get(deadline=deadline)
            chapters.append({'chapter': chapter, 'deadline': deadline})
        return render(
            request, 'questions/show_class.html', {
                'title': onlineclass.name,
                'students_list': students_list,
                'chapters': chapters,
                'onlineclass': onlineclass,
                'form': form
            })
    else:
        raise PermissionDenied()
Exemplo n.º 2
0
writer.writerow([
    'turma', 'aluno', 'previsao', 'exercicios_resolvidos_8_9', 'aula_2',
    'aula_2_on_time', 'aula_3', 'aula_3_on_time', 'aula_4', 'aula_4_on_time',
    'aula_3_on_time', 'aula_4', 'aula_4_on_time', 'aula_5_on_time', 'aula_5',
    'aula_6_on_time', 'aula_6_on_time', 'aula_7', 'aula_7_on_time'
])

for id in classes:
    onlineclass = OnlineClass.objects.get(pk=id)
    professors = Professor.objects.all().values_list('user')
    students = User.objects.filter(
        userprofile__user_class=onlineclass).exclude(pk__in=professors)

    i = 1
    for student in students:
        predict = predict_drop_out(student.id, onlineclass, date)

        try:
            if predict < 7:
                on_time_exercises = count_on_time_exercises(
                    student, [17, 19], onlineclass)

                aula_2 = count_exercises(student, [20], onlineclass)
                aula_3 = count_exercises(student, [12], onlineclass)
                aula_4 = count_exercises(student, [13], onlineclass)
                aula_5 = count_exercises(student, [25], onlineclass)
                aula_6 = count_exercises(student, [26], onlineclass)
                aula_7 = count_exercises(student, [16], onlineclass)

                on_time_2 = count_on_time_exercises(student, [20], onlineclass)
                on_time_3 = count_on_time_exercises(student, [12], onlineclass)