コード例 #1
0
def _make_row(
    student: Student, subjects: [Subject], from_date: date, to_date: date
) -> tStudentRow:
    avg_marks = []
    for subj in subjects:
        # avg_marks.append(for_subj_mark_student(subj, student.id, from_date, to_date))
        avg_marks.append(avg_mark_student(subj, student.id, from_date, to_date))
    return tStudentRow(
        student=student,
        avg_marks=avg_marks,
        attendance=get_attendance_stats(
            StudentAttendance.objects.filter(
                student=student,
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
        total_reprimands=len(
            Penalty.objects.filter(
                student=student,
                type="reprimand",
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
        total_promotions=len(
            Penalty.objects.filter(
                student=student,
                type="promotion",
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
    )
コード例 #2
0
ファイル: squad.py プロジェクト: ivan339339/djour
def _make_row(student: Student, subjects: [Subject]) -> tStudentRow:
    return tStudentRow(
        student=student,
        avg_marks=[avg_mark_student(subj, student.id) for subj in subjects],
        attendance=get_attendance_stats(
            StudentAttendance.objects.filter(student=student)),
    )
コード例 #3
0
def _make_subtotal(students, subjects, from_date: date, to_date: date):
    avg_marks = []
    for subj in subjects:
        # avg_marks.append(for_subj_marks_group(students, subj, from_date, to_date))
        avg_marks.append(avg_marks_group(students, subj, from_date, to_date))
    return tStudentRow(
        # student=student,
        avg_marks=avg_marks,
        attendance=get_attendance_stats(
            StudentAttendance.objects.filter(
                student_id__in=students_to_ids(students),
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
        total_reprimands=len(
            Penalty.objects.filter(
                student_id__in=students_to_ids(students),
                type="reprimand",
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
        total_promotions=len(
            Penalty.objects.filter(
                student_id__in=students_to_ids(students),
                type="promotion",
                attendance__date__gte=from_date,
                attendance__date__lte=to_date,
            )
        ),
    )
コード例 #4
0
ファイル: squad.py プロジェクト: ivan339339/djour
def _make_squad_total(students, subjects):
    return tStudentRow(
        avg_marks=[avg_marks_group(students, subj) for subj in subjects],
        attendance=get_attendance_stats(
            StudentAttendance.objects.filter(
                student_id__in=students_to_ids(students))),
    )
コード例 #5
0
ファイル: students.py プロジェクト: evseevbl/djour
def student(request, student_id):
    st: Student = Student.objects.filter(id=student_id).first()
    all_subjects = Subject.objects.filter(timetable__squad__code=st.squad)
    avgs = []
    for subj in all_subjects:
        avgs.append(
            tAvg(
                short=subj.short,
                avg=avg_mark_student(
                    subj, student_id, date.today() - timedelta(weeks=300), date.today()
                ),
                # exams=
            )
        )
        # todo оценки с учётом пропусков
        # avgs.append(tAvg(
        #     short=subj.short + ' (с пропусками)',
        #     avg=get_avg_for_subject(subj, student_id, absent_zero=True)
        # ))

    atts = StudentAttendance.objects.filter(student=st)

    info = PersonalInfo.objects.filter(student=st).first()

    all_attendances = Attendance.objects.filter(squad=st.squad)

    penalties = Penalty.objects.filter(student=st)

    penalty_choices = {
        Penalty.REPRIMAND: "Взысканий",
        Penalty.PROMOTION: "Поощрений",
    }
    penalties_got_map = {
        penalty_choices[Penalty.PROMOTION]: 0,
        penalty_choices[Penalty.REPRIMAND]: 0,
    }

    for penalty in penalties:
        penalties_got_map[penalty_choices[penalty.type]] += 1

    penalty_stats = []
    for key, value in penalties_got_map.items():
        penalty_stats.append(tCount(label=key, count=value))

    duties = Duty.objects.filter(student=st)

    events = Event.objects.filter(eventparticipant__student=st).order_by("-date")

    return render(
        request,
        "journal/student.html",
        with_context(
            {
                "student": st,
                "avg_marks": avgs,
                "attendance_stats": get_attendance_stats(atts),
                "info": info,
                "penalties": penalties,
                "penalty_options": _get_options(Penalty.CHOICES),
                "penalty_stats": penalty_stats,
                "all_attendances": all_attendances,
                "duty_options": _get_options(Duty.CHOICES),
                "duty_stats": _get_avg_duty_marks(st),
                "duties": duties,
                "all_exams": _get_exam_marks(st),
                "stud_events": events,
                "available_events": Event.objects.exclude(id__in=events).order_by(
                    "-date"
                ),
                "all_events": Event.objects.all().order_by("-date"),
            }
        ),
    )