def set_due_date_extension(course, unit, student, due_date): """ Sets a due date extension. Raises DashboardError if the unit or extended due date is invalid. """ if due_date: # Check that the new due date is valid: with disable_overrides(): original_due_date = getattr(unit, 'due', None) if not original_due_date: raise DashboardError( _("Unit {0} has no due date to extend.").format(unit.location)) if due_date < original_due_date: raise DashboardError( _("An extended due date must be later than the original due date." )) override_field_for_user(student, unit, 'due', due_date) else: # We are deleting a due date extension. Check that it exists: if not get_override_for_user(student, unit, 'due'): raise DashboardError( _("No due date extension is set for that student and unit.")) clear_override_for_user(student, unit, 'due')
def test_transform(self, field): override_field_for_user(self.learner, self.block, field, expected_overrides.get(field)) # collect phase OverrideDataTransformer.collect(self.block_structure) # transform phase OverrideDataTransformer().transform( usage_info=self.course_usage_key, block_structure=self.block_structure, ) # verify overridden data assert get_override_for_user(self.learner, self.block, field) == expected_overrides.get(field)
def test_transform(self, field): override_field_for_user( self.learner, self.block, field, expected_overrides.get(field) ) # collect phase OverrideDataTransformer.collect(self.block_structure) # transform phase OverrideDataTransformer().transform( usage_info=self.course_usage_key, block_structure=self.block_structure, ) # verify overridden data assert get_override_for_user(self.learner, self.block, field) == expected_overrides.get(field)
def test_transform_all_fields(self): """Test overriding of all fields""" for field in REQUESTED_FIELDS: override_field_for_user(self.learner, self.block, field, expected_overrides.get(field)) # collect phase OverrideDataTransformer.collect(self.block_structure) # transform phase OverrideDataTransformer(self.learner).transform( usage_info=self.course_usage_key, block_structure=self.block_structure, ) # verify overridden data for field in REQUESTED_FIELDS: assert get_override_for_user( self.learner, self.block, field) == expected_overrides.get(field)
def test_transform_for_selected_learner(self, field): """ assert that data transformed for selected learner """ override_field_for_user(self.learner, self.block, field, expected_overrides.get(field)) # collect phase OverrideDataTransformer.collect(self.block_structure) # transform phase OverrideDataTransformer(self.learner).transform( usage_info=self.course_usage_key, block_structure=self.block_structure, ) # verify learner has overridden data assert get_override_for_user(self.learner, self.block, field) == expected_overrides.get(field) # other learner2 dont have overridden data assert get_override_for_user(self.learner2, self.block, field) is None
def test_transform_all_fields(self): """Test overriding of all fields""" for field in REQUESTED_FIELDS: override_field_for_user( self.learner, self.block, field, expected_overrides.get(field) ) # collect phase OverrideDataTransformer.collect(self.block_structure) # transform phase OverrideDataTransformer().transform( usage_info=self.course_usage_key, block_structure=self.block_structure, ) # verify overridden data for field in REQUESTED_FIELDS: assert get_override_for_user(self.learner, self.block, field) == expected_overrides.get(field)
def set_due_date_extension(course, unit, student, due_date): """ Sets a due date extension. Raises DashboardError if the unit or extended due date is invalid. """ if due_date: # Check that the new due date is valid: with disable_overrides(): original_due_date = getattr(unit, 'due', None) if not original_due_date: raise DashboardError(_("Unit {0} has no due date to extend.").format(unit.location)) if due_date < original_due_date: raise DashboardError(_("An extended due date must be later than the original due date.")) override_field_for_user(student, unit, 'due', due_date) else: # We are deleting a due date extension. Check that it exists: if not get_override_for_user(student, unit, 'due'): raise DashboardError(_("No due date extension is set for that student and unit.")) clear_override_for_user(student, unit, 'due')