def as_context(self, student=None): participants_count, max_participants = self.saturation_level sub_name = self.subject.name context = { 'title': sub_name, 'course_id': self.id, 'course': self, 'backurl': reverse('subject', args=[sub_name]), 'participants_count': participants_count, 'max_participants': max_participants, 'course_is_active': self.active, 'course_is_visible': self.visible, } if student: student = get_user_information(student) context['position_in_queue'] = self.position_in_queue(student) context['is_subbed'] = student.course_set.filter( id=self.id).exists() if self.can_modify(student): context['can_modify'] = True context['is_teacher'] = self.is_teacher(student) context['students'] = self.participants.all() return context
def unenroll(self, student): student = get_user_information(student) if self._is_participant(student): self.participants.remove(student) else: raise self.IsNotEnrolled
def position_in_queue(self, student): queue = list(self.get_queue()) if len(queue) == 0: return 0 users = [p.participant for p in queue] user = get_user_information(student) if not user in users: return 0 return users.index(user) + 1
def enroll(self, student): student = get_user_information(student) if self._is_participant(student): raise self.IsEnrolled elif not self.active: raise self.IsInactive elif self.saturated: raise self.IsFull elif self.is_archived(): raise self.IsArchived else: self.participants.add(student)
def enroll(self, student): student = get_user_information(student) if self._is_participant(student): raise self.IsEnrolled elif self.student_only and not student.is_student(): raise self.IsNoStudent elif self.student_only and student.is_pending_student(): raise self.IsNoVerifiedStudent elif not self.active: raise self.IsInactive elif self.saturated: raise self.IsFull else: self.participants.add(student)
def enroll(self, student): student = get_user_information(student) if self._is_participant(student): raise self.IsEnrolled elif self.student_only and not student.is_student(): raise self.IsNoStudent elif self.student_only and student.is_pending_student(): raise self.IsNoVerifiedStudent elif not self.active: raise self.IsInactive elif self.saturated: raise self.IsFull elif self.is_archived(): raise self.IsArchived else: self.participants.add(student)
def enroll(self, student): student = get_user_information(student) if self._is_participant(student): raise self.IsEnrolled elif not self.active: raise self.IsInactive elif self.is_archived(): raise self.IsArchived else: if (self.participants.count()): ticket_number = Participation.objects.filter( course=self).reverse()[0].ticket_number + 1 else: ticket_number = 1 Participation.objects.create(participant=student, course=self, ticket_number=ticket_number)
def as_context(self, student=None): participants_count, max_participants = self.saturation_level sub_name = self.subject.name context = { 'title': sub_name, 'course_id': self.id, 'course': self, 'backurl': reverse('subject', args=[sub_name]), 'participants_count': participants_count, 'max_participants': max_participants, 'course_is_active': self.active, } if student: student = get_user_information(student) context['is_subbed'] = student.course_set.filter(id=self.id).exists() context['is_verified_student'] = student.is_verified_student() if self.is_teacher(student): context['is_teacher'] = True context['students'] = self.participants.all() return context
def is_participant(self, student): return self._is_participant( get_user_information(student)) and not self.is_archived()
def _is_participant(self, student): student = get_user_information(student) return student in self.participants.all()
def is_participant(self, student): return self._is_participant(get_user_information(student))