當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。