コード例 #1
0
        /// <summary>Sends a reminder email.</summary>
        public void SendReminderEmail()
        {
            if (EmailChanges)
            {
                List <SlkUser> users = new List <SlkUser>();

                foreach (LearnerAssignmentProperties learnerAssignment in keyedResults.Values)
                {
                    if (learnerAssignment.Status != null)
                    {
                        switch (learnerAssignment.Status.Value)
                        {
                        case LearnerAssignmentState.NotStarted:
                        case LearnerAssignmentState.Active:
                            users.Add(learnerAssignment.User);
                            break;
                        }
                    }
                }

                if (users.Count > 0)
                {
                    using (AssignmentEmailer emailer = new AssignmentEmailer(this, Store.Settings.EmailSettings, SPSiteGuid, SPWebGuid))
                    {
                        emailer.SendReminderEmail(users);
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>Sends and email when a learner submits an assignment.</summary>
 /// <param name="name">The name of the learner.</param>
 public void SendSubmitEmail(string name)
 {
     if (EmailOnSubmit)
     {
         using (AssignmentEmailer emailer = new AssignmentEmailer(this, Store.Settings.EmailSettings, SPSiteGuid, SPWebGuid))
         {
             emailer.SendSubmitEmail(name);
         }
     }
 }
コード例 #3
0
        /// <summary>Deletes the assignment.</summary>
        public void Delete(SPWeb web)
        {
            Store.DeleteAssignment(Id);

            if (EmailChanges)
            {
                using (AssignmentEmailer emailer = new AssignmentEmailer(this, Store.Settings.EmailSettings, web))
                {
                    emailer.SendCancelEmail(Learners);
                }
            }

            //Delete corresponding assignment folder from the drop box if exists
            if (IsNonELearning)
            {
                DropBoxManager dropBoxManager = new DropBoxManager(this);
                dropBoxManager.DeleteAssignmentFolder();
            }
        }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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);
                    }
                }
            }
        }
コード例 #6
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;
 }