Example #1
0
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)
Example #2
0
    def teacher_endpoint(self):
        # form to create assignment from assignmentquestionslist
        form = AssignmentForm(self.user, self.override, self.request.POST)
        if form.is_valid():
            assignmentQuestionsList = form.cleaned_data['question_set']
            subjectRoom = form.cleaned_data['subjectroom']
            assigned = form.cleaned_data['assigned']
            due = form.cleaned_data['due']
            # check if same aql has been assigned in this subjectroom before, if yes increase number
            number = Assignment.get_new_assignment_number(
                assignmentQuestionsList, subjectRoom)
            new_assignment = Assignment.objects.create(
                assignmentQuestionsList=assignmentQuestionsList,
                content_object=subjectRoom,
                assigned=assigned,
                due=due,
                number=number)
            return redirect_with_success_toast(
                self.request,
                'Assignment %s for SubjectRoom %s was assigned successfully.' %
                (new_assignment.get_title(),
                 get_subjectroom_label(new_assignment.get_subjectroom())))

        else:
            return render(
                self.request, self.template,
                AuthenticatedVM(self.user,
                                AssignmentBody(form,
                                               self.override)).as_context())
Example #3
0
    def __init__(self, subjectroom):
        standards = []

        for standard in Standard.objects.filter(
                number__lte=subjectroom.classRoom.standard.number).order_by(
                    '-number'):
            chapters = []

            school_filter = Q(school=subjectroom.classRoom.school) | Q(
                school=HWCentralRepo.refs.SCHOOL)
            standard_subject_filter = Q(subject=subjectroom.subject) & Q(
                standard=standard)

            aql_query = school_filter & standard_subject_filter

            for chapter_id in AssignmentQuestionsList.objects.filter(
                    aql_query).values_list("chapter", flat=True).distinct():
                chapter = Chapter.objects.get(pk=chapter_id)
                aqls = AssignmentQuestionsList.objects.filter(
                    aql_query, chapter=chapter).order_by('number')
                aqls = [AqlSelectElem(aql) for aql in aqls]
                chapters.append(SelectElem(chapter.name, chapter.pk, aqls))

            if len(chapters) > 0:
                standards.append(
                    SelectElem(standard.number, standard.pk, chapters))

        super(TeacherSubjectRoomSelectOverrideElem,
              self).__init__(get_subjectroom_label(subjectroom),
                             subjectroom.pk, standards)
Example #4
0
 def __init__(self, user):
     super(TeacherSettingsBody, self).__init__(user)
     self.subjectrooms = []
     for subjectroom in user.subjects_managed_set.all():
         self.subjectrooms.append(get_subjectroom_label(subjectroom))
     self.classrooms = []
     for classroom in user.classes_managed_set.all():
         self.classrooms.append(get_classroom_label(classroom))
Example #5
0
 def get_target_label(self):
     if self.content_type == ContentType.objects.get_for_model(User):
         return get_user_label(self.content_object)
     elif self.content_type == ContentType.objects.get_for_model(School):
         return self.content_object.name
     elif self.content_type == ContentType.objects.get_for_model(ClassRoom):
         return get_classroom_label(self.content_object)
     elif self.content_type == ContentType.objects.get_for_model(
             SubjectRoom):
         return get_subjectroom_label(self.content_object)
     else:
         raise InvalidContentTypeError(self.content_type)
Example #6
0
    def __init__(self):
        subjectrooms = self.get_subjectrooms()

        subjectroom_options = [UNSELECTED_OPTION]
        self.student_selects = []
        for subjectroom in subjectrooms:
            subjectroom_options.append((subjectroom.pk, get_subjectroom_label(subjectroom)))
            student_options = [(student.pk, get_user_label(student)) for student in subjectroom.students.all()]
            student_options.insert(0, (0, "Full Class"))
            student_select = Select({'id': 'student-select-' + str(subjectroom.pk)}, student_options)
            self.student_selects.append(student_select.render('student_subjectroom' + str(subjectroom.pk), 0))

        self.subjectroom_select = Select({'class': SELECT_CHOSEN_CLASS, 'id': 'subjectroom-select'},
                                         subjectroom_options).render('subjectroom', 0)
Example #7
0
 def __init__(self, classteacher, *args, **kwargs):
     super(ClassSubjectAnnouncementForm, self).__init__(*args, **kwargs)
     options_list = []
     for subjectroom in SubjectRoom.objects.filter(teacher=classteacher):
         options_list.append(
             (ClassSubjectAnnouncementForm.CLASSROOM_ID_PREFIX +
              str(subjectroom.pk), get_subjectroom_label(subjectroom)))
     for classroom in ClassRoom.objects.filter(classTeacher=classteacher):
         options_list.append(
             (ClassSubjectAnnouncementForm.SUBJECTROOM_ID_PREFIX +
              str(classroom.pk), get_classroom_label(classroom)))
     self.fields['target'] = forms.ChoiceField(
         choices=options_list,
         widget=ChosenNoSearchSelect,
         help_text=ANNOUNCEMENT_TARGET_HELP_TEXT)
Example #8
0
 def __init__(self, subjectroom):
     self.subjectroom_id = subjectroom.pk
     self.subjectroom_label = get_subjectroom_label(subjectroom)
     self.subjectteacher_label = get_user_label(subjectroom.teacher)
Example #9
0
 def for_focusroom(cls, focusroom):
     return cls(
         get_focusroom_label(get_subjectroom_label(focusroom.subjectRoom)),
         focusroom.subjectRoom.teacher,
         get_focusroom_graded_assignments(focusroom))
Example #10
0
 def for_subjectroom(cls, subjectroom):
     return cls(get_subjectroom_label(subjectroom), subjectroom.teacher,
                get_subjectroom_graded_assignments(subjectroom))
Example #11
0
 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)
Example #12
0
 def get_subjectroom_label(self, assignment):
     return get_subjectroom_label(assignment.get_subjectroom())