def build_for_focusroom(cls, focusroom, student): assert student.userinfo.school.schoolprofile.focus # first check if you can calculate an average focusroom_graded_assignments = get_focusroom_graded_assignments( focusroom) if focusroom_graded_assignments.count() == 0: return None # element cannot exist with no data remedial_assignment_pks = [ ] # the list of assignments for remedials which included the current student for graded_assignment in focusroom_graded_assignments: if student in graded_assignment.content_object.students.all(): remedial_assignment_pks.append(graded_assignment.pk) if len(remedial_assignment_pks) == 0: return None # current student has never been in a remedial for this focusroom focusroom_average = get_fraction_label( focusroom_graded_assignments.aggregate( Avg('average'))['average__avg']) submissions = Submission.objects.filter( assignment__pk__in=remedial_assignment_pks, student=student) if submissions.count() == 0: raise InvalidStateError( 'No submissions found for student in remedials belonging to focusroom with graded assignments' ) student_average = get_fraction_label( submissions.aggregate(Avg('marks'))['marks__avg']) return cls(student_average, focusroom_average, get_focusroom_label(focusroom.subjectRoom.subject.name))
def get_assignment_target_label(assignment): if assignment.content_type == ContentType.objects.get_for_model(SubjectRoom): return get_subjectroom_label(assignment.get_subjectroom()) elif assignment.content_type == ContentType.objects.get_for_model(Remedial): return get_focusroom_label(get_subjectroom_label(assignment.get_subjectroom())) else: raise InvalidContentTypeError(assignment.content_type)
def get_contained_room_labels(self): rooms = [] for subjectroom in self.get_contained_subjectrooms(): rooms.append(subjectroom.subject.name) if self.focus: rooms.append(get_focusroom_label(subjectroom.subject.name)) return rooms
def for_focusroom(cls, student, focusroom): submissions = [] assert student.userinfo.school.schoolprofile.focus for graded_assignment in get_focusroom_graded_assignments(focusroom): if student in graded_assignment.content_object.students.all(): submissions.append( Submission.objects.get(student=student, assignment=graded_assignment)) if len(submissions) == CHART_CORRECTED_ASSIGNMENTS_LIMIT: break return cls(get_focusroom_label(focusroom.subjectRoom.subject.name), focusroom.subjectRoom.teacher, submissions)
def __init__(self, assignment): if assignment.content_type == ContentType.objects.get_for_model( SubjectRoom): self.target = Link(self.get_subjectroom_label(assignment), UrlNames.SUBJECT_ID.name, (assignment.get_subjectroom()).pk) elif assignment.content_type == ContentType.objects.get_for_model( Remedial): self.target = Link( get_focusroom_label(self.get_subjectroom_label(assignment)), UrlNames.FOCUS_ID.name, assignment.content_object.focusRoom.pk) else: raise InvalidContentTypeError(assignment.content_type) self.due = get_datetime_label(assignment.due)
def for_focusroom(cls, focusroom): return cls( get_focusroom_label(get_subjectroom_label(focusroom.subjectRoom)), focusroom.subjectRoom.teacher, get_focusroom_graded_assignments(focusroom))
def __init__(self, focusroom): self.focusroom_id = focusroom.pk self.focusroom_label = get_focusroom_label( get_subjectroom_label(focusroom.subjectRoom)) self.subjectteacher_label = get_user_label( focusroom.subjectRoom.teacher)
def __init__(self, focusroom, average): super(ClassroomsTableFocusroomRow, self).__init__( Link(get_focusroom_label(focusroom.subjectRoom.subject.name), UrlNames.FOCUS_ID.name, focusroom.pk), focusroom.subjectRoom.teacher, average)