Exemple #1
0
        /// <summary>Applies permissions to the learner folder and creates it if required.</summary>
        /// <param name="user">The learner to create the folder for.</param>
        /// <param name="learnerPermissions">The permissions to set.</param>
        /// <param name="instructorPermissions">The instructor permissions to set.</param>
        /// <param name="removeObserverPermissions">Whether to remove observer permissions or not.</param>
        void ApplyAssignmentPermission(SPUser user, SPRoleType learnerPermissions, SPRoleType instructorPermissions, bool removeObserverPermissions)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite spSite = new SPSite(assignmentProperties.SPSiteGuid))
                {
                    using (SPWeb spWeb = spSite.OpenWeb(assignmentProperties.SPWebGuid))
                    {
                        DropBox dropBox = new DropBox(store, spWeb);
                        AssignmentFolder assignmentFolder = dropBox.GetAssignmentFolder(assignmentProperties);

                        if (assignmentFolder != null)
                        {
                            // Get the learner sub folder
                            AssignmentFolder learnerSubFolder = assignmentFolder.FindLearnerFolder(user);

                            if (learnerSubFolder == null)
                            {
                                learnerSubFolder = assignmentFolder.CreateLearnerAssignmentFolder(user);
                            }

                            // Apply learner permissions
                            learnerSubFolder.RemovePermissions(user);
                            if (learnerPermissions != SPRoleType.None)
                            {
                                learnerSubFolder.ApplyPermission(user, learnerPermissions);
                            }

                            // Apply instructor permissions
                            foreach (SlkUser instructor in assignmentProperties.Instructors)
                            {
                                learnerSubFolder.RemovePermissions(instructor.SPUser);
                                learnerSubFolder.ApplyPermission(instructor.SPUser, instructorPermissions);
                            }

                            if (removeObserverPermissions)
                            {
                                learnerSubFolder.RemoveObserverPermission();
                            }
                        }
                    }
                }
            });
        }
Exemple #2
0
        void ApplySubmittedPermissions(AssignmentFolder learnerSubFolder)
        {
            // IF the assignment is auto return, the learner will still be able to view the drop box assignment files
            // otherwise, learner permissions will be removed from the learner's subfolder in the Drop Box document library
            if (assignmentProperties.AutoReturn == false)
            {
                learnerSubFolder.RemovePermissions(CurrentUser);
            }

            // Grant instructors contribute permission on learner subfolder
            foreach (SlkUser instructor in assignmentProperties.Instructors)
            {
                if (instructor.SPUser == null)
                {
                    throw new SafeToDisplayException(string.Format(culture.Culture, culture.Resources.DropBoxManagerUploadFilesNoInstructor, instructor.Name));
                }
                learnerSubFolder.RemovePermissions(instructor.SPUser);
                learnerSubFolder.ApplyPermission(instructor.SPUser, SPRoleType.Contributor);
            }
        }