diff --git a/lms/djangoapps/ccx/tests/test_views.py b/lms/djangoapps/ccx/tests/test_views.py index cb215a82d9..cab99f89f7 100644 --- a/lms/djangoapps/ccx/tests/test_views.py +++ b/lms/djangoapps/ccx/tests/test_views.py @@ -156,7 +156,7 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase): cls.verticals = flatten([ [ ItemFactory.create( - due=due, parent=sequential, graded=True, format='Homework' + start=start, due=due, parent=sequential, graded=True, format='Homework', category=u'vertical' ) for _ in xrange(2) ] for sequential in cls.sequentials ]) @@ -363,6 +363,9 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase): unhide(schedule[0]) schedule[0]['start'] = u'2014-11-20 00:00' schedule[0]['children'][0]['due'] = u'2014-12-25 00:00' # what a jerk! + schedule[0]['children'][0]['children'][0]['start'] = u'2014-12-20 00:00' + schedule[0]['children'][0]['children'][0]['due'] = u'2014-12-25 00:00' + response = self.client.post( url, json.dumps(schedule), content_type='application/json' ) @@ -374,6 +377,13 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase): schedule[0]['children'][0]['due'], u'2014-12-25 00:00' ) + self.assertEqual( + schedule[0]['children'][0]['children'][0]['due'], u'2014-12-25 00:00' + ) + self.assertEqual( + schedule[0]['children'][0]['children'][0]['start'], u'2014-12-20 00:00' + ) + # Make sure start date set on course, follows start date of earliest # scheduled chapter ccx = CustomCourseForEdX.objects.get() diff --git a/lms/djangoapps/ccx/views.py b/lms/djangoapps/ccx/views.py index 0fdf8cb80d..56d43b07b6 100644 --- a/lms/djangoapps/ccx/views.py +++ b/lms/djangoapps/ccx/views.py @@ -258,6 +258,16 @@ def save_ccx(request, course, ccx=None): graded[block.format] = graded.get(block.format, 0) + 1 children = unit.get('children', None) + # For a vertical, override start and due dates of all its problems. + if unit.get('category', None) == u'vertical': + for component in block.get_children(): + # override start and due date of problem (Copy dates of vertical into problems) + if start: + override_field_for_ccx(ccx, component, 'start', start) + + if due: + override_field_for_ccx(ccx, component, 'due', due) + if children: override_fields(block, children, graded, earliest, ccx_ids_to_delete) return earliest, ccx_ids_to_delete