예제 #1
0
    def test_extract_dates_from_course_custom_and_default_pls_one_subsection_graded(self):
        """
        A section with a subsection that has relative_weeks_due and
        a subsection without relative_weeks_due that has graded content.
        Default PLS should apply for the subsection without relative_weeks_due that has graded content.
        If custom PLS is not set, the subsection will fall back to the default
        PLS logic of evenly spaced sections.
        """
        with self.store.bulk_operations(self.course.id):
            sequential1 = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=2)
            vertical1 = ItemFactory.create(category='vertical', parent=sequential1)
            problem1 = ItemFactory.create(category='problem', parent=vertical1)

            chapter2 = ItemFactory.create(category='chapter', parent=self.course)
            sequential2 = ItemFactory.create(category='sequential', parent=chapter2, graded=True)
            vertical2 = ItemFactory.create(category='vertical', parent=sequential2)
            problem2 = ItemFactory.create(category='problem', parent=vertical2)

            expected_dates = [
                (self.course.location, {}),
                (self.chapter.location, {'due': timedelta(days=14)}),
                (sequential1.location, {'due': timedelta(days=14)}),
                (vertical1.location, {'due': timedelta(days=14)}),
                (problem1.location, {'due': timedelta(days=14)}),
                (chapter2.location, {'due': timedelta(days=42)}),
                (sequential2.location, {'due': timedelta(days=42)}),
                (vertical2.location, {'due': timedelta(days=42)}),
                (problem2.location, {'due': timedelta(days=42)})
            ]
        course = self.store.get_item(self.course.location)
        with patch.object(utils, 'get_expected_duration', return_value=timedelta(weeks=6)):
            self.assertCountEqual(extract_dates_from_course(course), expected_dates)
예제 #2
0
 def test_extract_dates_from_course_all_subsections(self):
     """
     With relative_weeks_due on all subsections. All subsections should
     have their corresponding due dates.
     """
     with self.store.bulk_operations(self.course.id):
         sequential1 = ItemFactory.create(category='sequential',
                                          parent=self.chapter,
                                          relative_weeks_due=3)
         sequential2 = ItemFactory.create(category='sequential',
                                          parent=self.chapter,
                                          relative_weeks_due=4)
         sequential3 = ItemFactory.create(category='sequential',
                                          parent=self.chapter,
                                          relative_weeks_due=5)
         expected_dates = [(self.course.location, {}),
                           (self.chapter.location, {
                               'due': timedelta(days=35)
                           }),
                           (sequential1.location, {
                               'due': timedelta(days=21)
                           }),
                           (sequential2.location, {
                               'due': timedelta(days=28)
                           }),
                           (sequential3.location, {
                               'due': timedelta(days=35)
                           })]
     course = self.store.get_item(self.course.location)
     self.assertCountEqual(extract_dates_from_course(course),
                           expected_dates)
예제 #3
0
 def test_extract_dates_from_course_custom_and_default_pls_one_subsection(
         self):
     """
     relative_weeks_due in one of the subsections. Only one of them should have a set due date.
     The other subsections do not have due dates because they are not graded
     and default PLS do not assign due dates to non graded assignments.
     If custom PLS is not set, the subsection will fall back to the default
     PLS logic of evenly spaced sections.
     """
     with self.store.bulk_operations(self.course.id):
         sequential = ItemFactory.create(category='sequential',
                                         parent=self.chapter,
                                         relative_weeks_due=3)
         ItemFactory.create(category='sequential', parent=self.chapter)
         ItemFactory.create(category='sequential', parent=self.chapter)
         expected_dates = [(self.course.location, {}),
                           (self.chapter.location, {
                               'due': timedelta(days=28)
                           }),
                           (sequential.location, {
                               'due': timedelta(days=21)
                           })]
     course = self.store.get_item(self.course.location)
     self.assertCountEqual(extract_dates_from_course(course),
                           expected_dates)
예제 #4
0
 def test_extract_dates_from_course_inheritance(self):
     """
     extract_dates_from_course should return a list of (block item location, field metadata dictionary)
     and the blocks should inherit the dates from those above in the hiearchy
     (ex. If a subsection is assigned a due date, its children should also have the same due date)
     """
     with self.store.bulk_operations(self.course.id):
         sequential = ItemFactory.create(category='sequential',
                                         parent=self.chapter,
                                         relative_weeks_due=3)
         vertical = ItemFactory.create(category='vertical',
                                       parent=sequential)
         problem = ItemFactory.create(category='problem', parent=vertical)
         expected_dates = [(self.course.location, {}),
                           (self.chapter.location, {
                               'due': timedelta(days=21)
                           }),
                           (sequential.location, {
                               'due': timedelta(days=21)
                           }),
                           (vertical.location, {
                               'due': timedelta(days=21)
                           }),
                           (problem.location, {
                               'due': timedelta(days=21)
                           })]
     course = self.store.get_item(self.course.location)
     self.assertCountEqual(extract_dates_from_course(course),
                           expected_dates)
예제 #5
0
 def test_extract_dates_from_course_no_subsections(self):
     """
     Without relative_weeks_due on all subsections. None of the subsections should
     have due dates.
     """
     with self.store.bulk_operations(self.course.id):
         for _ in range(3):
             ItemFactory.create(category='sequential', parent=self.chapter)
         expected_dates = [(self.course.location, {})]
     course = self.store.get_item(self.course.location)
     self.assertCountEqual(extract_dates_from_course(course), expected_dates)
예제 #6
0
    def test_extract_dates_from_course_custom_and_default_pls_multiple_subsections_graded(self):
        """
        A section with a subsection that has relative_weeks_due and multiple sections without
        relative_weeks_due that has graded content. Default PLS should apply for the subsections
        without relative_weeks_due that has graded content.
        If custom PLS is not set, the subsection will fall back to the default
        PLS logic of evenly spaced sections.
        """
        with self.store.bulk_operations(self.course.id):
            sequential1 = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=4)
            vertical1 = ItemFactory.create(category='vertical', parent=sequential1)
            problem1 = ItemFactory.create(category='problem', parent=vertical1)

            expected_dates = [
                (self.course.location, {}),
                (self.chapter.location, {'due': timedelta(days=28)}),
                (sequential1.location, {'due': timedelta(days=28)}),
                (vertical1.location, {'due': timedelta(days=28)}),
                (problem1.location, {'due': timedelta(days=28)})
            ]

            for i in range(3):
                chapter = ItemFactory.create(category='chapter', parent=self.course)
                sequential = ItemFactory.create(category='sequential', parent=chapter, graded=True)
                vertical = ItemFactory.create(category='vertical', parent=sequential)
                problem = ItemFactory.create(category='problem', parent=vertical)
                num_days = i * 14 + 28
                expected_dates.extend([
                    (chapter.location, {'due': timedelta(days=num_days)}),
                    (sequential.location, {'due': timedelta(days=num_days)}),
                    (vertical.location, {'due': timedelta(days=num_days)}),
                    (problem.location, {'due': timedelta(days=num_days)}),
                ])
        course = self.store.get_item(self.course.location)
        with patch.object(utils, 'get_expected_duration', return_value=timedelta(weeks=8)):
            self.assertCountEqual(extract_dates_from_course(course), expected_dates)