Merge pull request #10619 from mitocw/fix/aq/dates_of_problems
Overridden start and due dates of problems to control due date of a unit from ccx schedule
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user