Esempio n. 1
0
    def build_for_subjectroom(cls, subjectroom, student):
        # first check if you can calculate an average

        subjectroom_graded_assignments = get_subjectroom_graded_assignments(
            subjectroom)
        if subjectroom_graded_assignments.count() == 0:
            return None  # element cannot exist with no data

        subjectroom_average = get_fraction_label(
            subjectroom_graded_assignments.aggregate(
                Avg('average'))['average__avg'])

        # need to evaluate the graded assignments query beforehand because as on 11/15 LIMIT is not supported for IN subquery
        graded_assignment_pks = list(
            subjectroom_graded_assignments.values_list('pk', flat=True))
        submissions = Submission.objects.filter(
            assignment__pk__in=graded_assignment_pks, student=student)
        if submissions.count() == 0:
            raise InvalidStateError(
                'No submissions found for student belonging to subjectroom with graded assignments'
            )

        student_average = get_fraction_label(
            submissions.aggregate(Avg('marks'))['marks__avg'])

        return cls(student_average, subjectroom_average,
                   subjectroom.subject.name)
Esempio n. 2
0
    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))
Esempio n. 3
0
 def __init__(self, submission):
     super(PerformanceBreakdownElement,
           self).__init__(submission.assignment)
     self.subjectroom_average = get_fraction_label(
         submission.assignment.average)
     self.student_score = get_fraction_label(submission.marks)
     self.student_completion = get_fraction_label(submission.completion)
     self.submission_id = submission.pk
Esempio n. 4
0
 def __init__(self, graded_assignment):
     super(RoomPerformanceBreakdownElement,
           self).__init__(graded_assignment)
     self.subjectroom_average = get_fraction_label(
         graded_assignment.average)
     self.standard_average = get_fraction_label(
         get_standard_average(graded_assignment))
     self.subjectroom_completion = get_fraction_label(
         graded_assignment.completion)
Esempio n. 5
0
 def __init__(self, submission):
     super(OpenPerformanceBreakdownElement,
           self).__init__(submission.assignment)
     self.student_score = get_fraction_label(submission.marks)
     self.student_completion = get_fraction_label(submission.completion)
     self.submission_id = submission.pk
     self.subjectroom_average = get_fraction_label(
         calculate_open_aql_average(
             submission.assignment.assignmentQuestionsList))
Esempio n. 6
0
    def build_for_open(cls, subjectroom, student):
        utils = OpenStudentUtils(student)

        student_average = utils.get_average(subjectroom)
        if student_average is None:
            return None

        return cls(
            get_fraction_label(student_average),
            get_fraction_label(utils.get_subjectroom_average(subjectroom)),
            subjectroom.subject.name)
Esempio n. 7
0
 def __init__(self, submission, include_student_header):
     assert is_assignment_corrected(submission.assignment)
     self.marks = get_fraction_label(submission.marks)
     if include_student_header:
         self.student = get_user_label(submission.student)
     else:
         self.student = None
Esempio n. 8
0
 def __init__(self, submission):
     self.score = get_fraction_label(submission.marks)
Esempio n. 9
0
 def __init__(self, student, completion):
     self.full_name = get_user_label(student)
     self.completion = get_fraction_label(completion)
Esempio n. 10
0
 def __init__(self, submission):
     self.full_name = get_user_label(submission.student)
     self.score = get_fraction_label(submission.marks)
     self.submission_id = submission.pk
Esempio n. 11
0
 def __init__(self, submission):
     self.completion = get_fraction_label(submission.completion)
     self.timestamp = get_datetime_label(submission.timestamp)