当前位置: 首页>>代码示例>>Python>>正文


Python Student.get_current方法代码示例

本文整理汇总了Python中students.models.Student.get_current方法的典型用法代码示例。如果您正苦于以下问题:Python Student.get_current方法的具体用法?Python Student.get_current怎么用?Python Student.get_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在students.models.Student的用法示例。


在下文中一共展示了Student.get_current方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_context_data

# 需要导入模块: from students.models import Student [as 别名]
# 或者: from students.models.Student import get_current [as 别名]
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     exam_rooms = ExamRoom.objects.filter(available=True)
     context['student_count'] = Student.get_current(want_exam=True).order_by('name', 'prename').count()
     context['free_places_1'] = sum([exam_room.capacity(1) for exam_room in exam_rooms])
     context['free_places_2'] = sum([exam_room.capacity(2) for exam_room in exam_rooms])
     return context
开发者ID:d120,项目名称:pyophase,代码行数:9,代码来源:dashboard_views.py

示例2: assign

# 需要导入模块: from students.models import Student [as 别名]
# 或者: from students.models.Student import get_current [as 别名]
    def assign(self):
        """
        Do the real assignment based on object properties
        """

        spacing = self.spacing
        capacity_string = 'capacity_{:d}_free'.format(spacing)
        order_by_string = "-{:s}".format(capacity_string)

        exam_rooms = ExamRoom.objects.filter(available=True).order_by(order_by_string)
        exam_students = Student.get_current(tutor_group__group_category=self.group_category, want_exam=True)
        exam_students = exam_students.order_by('name', 'prename')
        student_count = exam_students.count()

        if exam_rooms.count() == 0 or student_count == 0:
            return 0

        maximum_capacity = exam_rooms.aggregate(maximum_capacity=Sum(capacity_string)).get('maximum_capacity')

        # Set ratio so that all room gets equals percentage
        ratio = student_count / maximum_capacity

        # on minimal room mode and if the ratio is less then 90% the ratio is set to 90%
        # e.g. the first rooms get filled by 90%. The other rooms are not used
        if self.mode == 1 and ratio < 0.9:
            ratio = 0.9

        # returns each room as often as seats are available for the given ratio
        exam_room_list = chain.from_iterable(repeat(room, room.seats(spacing, ratio)) for room in exam_rooms)

        assign = partial(PersonToExamRoomAssignment, assignment=self)

        assignments = (assign(person=student, room=room) for student, room in zip(exam_students, exam_room_list))
        result = PersonToExamRoomAssignment.objects.bulk_create(assignments)

        return len(result)
开发者ID:d120,项目名称:pyophase,代码行数:38,代码来源:models.py


注:本文中的students.models.Student.get_current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。