Beispiel #1
0
        internal static string AssignmentViewName(AssignmentProperties properties)
        {
            string title = MakeTitleSafe(properties.Title.Trim());

            return(string.Format(CultureInfo.InvariantCulture, "{0} {1}", GetDateOnly(properties.StartDate), title));
        }
Beispiel #2
0
 /// <summary>Function searches for the assignment folder.</summary>
 /// <returns>The folder object</returns>
 public AssignmentFolder GetAssignmentFolder(AssignmentProperties properties)
 {
     return(GetAssignmentFolder(GenerateFolderName(properties), properties));
 }
Beispiel #3
0
        /// <summary>Generates the name for a assignment folder.</summary>
        internal static string GenerateFolderName(AssignmentProperties properties)
        {
            string title = MakeTitleSafe(properties.Title.Trim());

            return(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", GetDateOnly(properties.StartDate), title, properties.Id.GetKey()));
        }
Beispiel #4
0
 /// <summary>Initializes a new instance of <see cref="AssignmentEmailer"/>.</summary>
 /// <param name="assignment">The assignment the emails are for.</param>
 /// <param name="settings">The email settings to use.</param>
 /// <param name="web">The SPWeb for the assignment.</param>
 /// <param name="emailSender">The <see cref="IEmailSender"/> to use.</param>
 public AssignmentEmailer(AssignmentProperties assignment, EmailSettings settings, SPWeb web, IEmailSender emailSender) : this(assignment, settings)
 {
     this.web = web;
     InitializeEmailSender(emailSender);
 }
Beispiel #5
0
 /// <summary>Initializes a new instance of <see cref="AssignmentEmailer"/>.</summary>
 /// <param name="assignment">The assignment the emails are for.</param>
 /// <param name="settings">The email settings to use.</param>
 public AssignmentEmailer(AssignmentProperties assignment, EmailSettings settings)
 {
     this.settings   = settings;
     this.assignment = assignment;
 }
Beispiel #6
0
 /// <summary>Initializes a new instance of <see cref="AssignmentEmailer"/>.</summary>
 /// <param name="assignment">The assignment the emails are for.</param>
 /// <param name="settings">The email settings to use.</param>
 /// <param name="siteId">The id of the site.</param>
 /// <param name="webId">The id of the web.</param>
 public AssignmentEmailer(AssignmentProperties assignment, EmailSettings settings, Guid siteId, Guid webId) : this(assignment, settings, siteId, webId, null)
 {
 }
Beispiel #7
0
 /// <summary>Initializes a new instance of <see cref="AssignmentEmailer"/>.</summary>
 /// <param name="assignment">The assignment the emails are for.</param>
 /// <param name="settings">The email settings to use.</param>
 /// <param name="web">The SPWeb for the assignment.</param>
 public AssignmentEmailer(AssignmentProperties assignment, EmailSettings settings, SPWeb web) : this(assignment, settings, web, null)
 {
 }
Beispiel #8
0
 /// <summary>Initializes a new instance of <see cref="AssignmentEmailer"/>.</summary>
 /// <param name="assignment">The assignment the emails are for.</param>
 /// <param name="settings">The email settings to use.</param>
 /// <param name="siteId">The id of the site.</param>
 /// <param name="webId">The id of the web.</param>
 /// <param name="emailSender">The <see cref="IEmailSender"/> to use.</param>
 public AssignmentEmailer(AssignmentProperties assignment, EmailSettings settings, Guid siteId, Guid webId, IEmailSender emailSender) : this(assignment, settings)
 {
     site = new SPSite(siteId);
     web  = site.OpenWeb(webId);
     InitializeEmailSender(emailSender);
 }
Beispiel #9
0
        /// <summary>Initializes an instance of this class.</summary>
        /// <param name="learnerAssignmentId">The identifier of the learner assignment represented by this object.</param>
        /// <param name="assignment">The assignment the result is for.</param>
        public LearnerAssignmentProperties(LearnerAssignmentItemIdentifier learnerAssignmentId, AssignmentProperties assignment)
        {
            if (learnerAssignmentId == null)
            {
                throw new ArgumentNullException("learnerAssignmentId");
            }

            LearnerAssignmentId = learnerAssignmentId;
            Assignment          = assignment;
        }
Beispiel #10
0
        /// <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);
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Beispiel #11
0
 /// <summary>Initializes a new instance of <see cref="AssignmentSaver"/>.</summary>
 /// <param name="store">The <see cref="ISlkStore"/> to use.</param>
 /// <param name="properties">The <see cref="AssignmentProperties"/> to save.</param>
 public AssignmentSaver(ISlkStore store, AssignmentProperties properties) : this(properties)
 {
     this.store = store;
     CurrentJob = store.CreateCurrentJob();
 }
Beispiel #12
0
 /// <summary>Initializes a new instance of <see cref="AssignmentSaver"/>.</summary>
 /// <param name="properties">The <see cref="AssignmentProperties"/> to save.</param>
 public AssignmentSaver(AssignmentProperties properties)
 {
     this.properties         = properties;
     emailSender             = new AssignmentEmailer(properties, properties.Store.Settings.EmailSettings, properties.SPSiteGuid, properties.SPWebGuid);
     emailSender.CacheEmails = true;
 }