/// <summary>Gets the result for a learner.</summary> /// <param name="learner">The learner to get the result for.</param> public LearnerAssignmentProperties ResultForLearner(SlkUser learner) { LearnerAssignmentProperties result = null; userResults.TryGetValue(learner.UserId.GetKey(), out result); return(result); }
/// <summary>Sends an email when an assignment is returned.</summary> /// <param name="learner">The learner being returned.</param> /// <param name="learnerAssignment">The learner assignment properties.</param> public void SendReturnEmail(SlkUser learner, LearnerAssignmentProperties learnerAssignment) { if (properties.EmailChanges) { emailSender.SendReturnEmail(learner, learnerAssignment); } }
/// <summary>Sends an email when an assignment is returned.</summary> /// <param name="learner">The learner being returned.</param> /// <param name="learnerAssignment">The learner assignment properties.</param> public void SendReturnEmail(SlkUser learner, LearnerAssignmentProperties learnerAssignment) { this.learnerAssignment = learnerAssignment; SendEmail(learner, ReturnSubjectText(), ReturnBodyText()); }
/// <summary>Function to update the DropBox document library after the current assignment being edited</summary> /// <param name="oldAssignmentProperties">The old assignment properties</param> public void UpdateAssignment(AssignmentProperties oldAssignmentProperties) { SPSecurity.RunWithElevatedPrivileges(delegate { using (SPSite spSite = new SPSite(assignmentProperties.SPSiteGuid)) { using (SPWeb spWeb = spSite.OpenWeb(assignmentProperties.SPWebGuid)) { using (new AllowUnsafeUpdates(spWeb)) { DropBox dropBox = new DropBox(store, spWeb); string oldAssignmentFolderName = DropBox.GenerateFolderName(oldAssignmentProperties); string newAssignmentFolderName = DropBox.GenerateFolderName(assignmentProperties); // If assignment title has been changed, create a new assignment folder and move old assignment folder contents to it if (string.Compare(oldAssignmentFolderName, newAssignmentFolderName, true, CultureInfo.InvariantCulture) != 0) { dropBox.ChangeFolderName(oldAssignmentFolderName, newAssignmentFolderName); } // Get new assignment folder, or the old one if the title has not been changed // in both cases, the value of the current assignment folder name will be stored in newAssignmentFolderName AssignmentFolder assignmentFolder = dropBox.GetAssignmentFolder(assignmentProperties); if (assignmentFolder != null) { assignmentFolder.RemoveAllPermissions(); // Grant assignment instructors Read permission on the assignment folder ApplyInstructorsReadAccessPermissions(assignmentFolder, spWeb, dropBox); // Delete subfolders of the learners who have been removed from the assignment DeleteRemovedLearnerFolders(assignmentFolder, oldAssignmentProperties); foreach (SlkUser learner in assignmentProperties.Learners) { // Grant assignment learners Read permission on the assignment folder and drop box assignmentFolder.ApplyPermission(learner.SPUser, SPRoleType.Reader); AssignmentFolder.ApplySharePointPermission(spWeb, dropBox.DropBoxList, learner.SPUser, SPRoleType.Reader); AssignmentFolder learnerSubFolder = assignmentFolder.FindLearnerFolder(learner.SPUser); LearnerAssignmentProperties result = assignmentProperties.ResultForLearner(learner); if (learnerSubFolder == null) { // Create a new subfolder for this learner learnerSubFolder = assignmentFolder.CreateLearnerAssignmentFolder(learner.SPUser); } if (result != null) { AssignUpdatePermissions(learnerSubFolder, learner.SPUser, result.Status); } } } } } } }); }