void SaveNewAssignment(SPWeb web, SlkRole slkRole) { // Security checks: If assigning as an instructor, fails if user isn't an instructor on // the web (implemented by calling EnsureInstructor). Fails if the user doesn't have access to the package/file if (web == null) { throw new ArgumentNullException("web"); } if (PackageFormat == null && Location == null) { throw new InvalidOperationException(SlkCulture.GetResources().InvalidNewAssignment); } SPSiteGuid = web.Site.ID; SPWebGuid = web.ID; VerifyRole(web, slkRole); Id = Store.CreateAssignment(this); if (isSelfAssigned == false) { //Update the MRU list Store.AddToUserWebList(web); } if (IsNonELearning) { DropBoxManager dropBoxMgr = new DropBoxManager(this); Microsoft.SharePoint.Utilities.SPUtility.ValidateFormDigest(); dropBoxMgr.CreateAssignmentFolder(); } if (EmailChanges) { using (AssignmentEmailer emailer = new AssignmentEmailer(this, Store.Settings.EmailSettings, web)) { emailer.SendNewEmail(Learners); } } }
void UpdateAssignment(SPWeb web) { AssignmentProperties oldProperties = Store.LoadAssignmentProperties(Id, SlkRole.Instructor); CopyInvariantProperties(oldProperties); bool corePropertiesChanged = false; if (Title != oldProperties.Title || StartDate != oldProperties.StartDate || DueDate != oldProperties.DueDate || PointsPossible != oldProperties.PointsPossible || Description != oldProperties.Description || AutoReturn != oldProperties.AutoReturn || ShowAnswersToLearners != oldProperties.ShowAnswersToLearners || EmailChanges != oldProperties.EmailChanges) { corePropertiesChanged = true; } SlkUserCollectionChanges instructorChanges = new SlkUserCollectionChanges(oldProperties.Instructors, Instructors); SlkUserCollectionChanges learnerChanges = new SlkUserCollectionChanges(oldProperties.Learners, Learners); if (corePropertiesChanged || instructorChanges.HasChanges || learnerChanges.HasChanges) { Store.UpdateAssignment(this, corePropertiesChanged, instructorChanges, learnerChanges); if (IsNonELearning) { // Update the assignment folder in the Drop Box DropBoxManager dropBoxMgr = new DropBoxManager(this); dropBoxMgr.UpdateAssignment(oldProperties); } if (EmailChanges) { using (AssignmentEmailer emailer = new AssignmentEmailer(this, Store.Settings.EmailSettings, web)) { emailer.SendNewEmail(learnerChanges.Additions); emailer.SendCancelEmail(learnerChanges.Removals); } } } }