public AbstractCourse CreateCourse(string courseName)
        {
            AbstractCourse abstractCourse = GetCourse(courseName);

            abstractCourse.CreateCourseMaterial();
            abstractCourse.CreateCourseSchedule();
            return(abstractCourse);
        }
示例#2
0
        public AbstractCourse CreateCourse(string scheduleType)
        {
            AbstractCourse course = this.GetCourse(scheduleType);

            course.CreateCourseMaterial();
            course.CreateSchedule();
            return(course);
        }
        public ICourse CreateCourse(DeveloperPlatform developerPlatform)
        {
            AbstractCourse course = this.GetCourse(developerPlatform);

            if (course != null)
            {
                course.CreateCourseMaterial();
                course.CreateSchedule();
            }
            return(course);
        }
示例#4
0
        private static void ShowDay1()
        {
            var            args   = new string[] { "k" };
            AbstractCourse course = null;

            if (string.Equals("N", args[0]))
            {
                course = new NetCourse();
            }
            else
            {
                course = new JavaCourse();
            }

            Console.WriteLine(course.CreateCourseMaterial());
            Console.WriteLine(course.CreateSchedule());
        }
示例#5
0
        /// <summary>
        /// Returns tags for either a course or a community, if one exists for the notification. Otherwise, empty string.
        ///
        /// </summary>
        /// <param name="c">The abstract course</param>
        /// <returns>Tag with leading space (" CptS 314") if course or community exists, "" if not.</returns>
        private string GetCourseTags(AbstractCourse c)
        {
            string tag = "";

            if (c != null)
            {
                if (c is Course)
                {
                    tag = (c as Course).Prefix + " " + (c as Course).Number;
                }
                else if (c is Community)
                {
                    tag = (c as Community).Nickname;
                }
            }

            return(tag);
        }
        /// <summary>
        /// Returns tags for either a course or a community as well as a tag for a notification, if one exists for the notification. Otherwise, empty string.
        ///
        /// </summary>
        /// <param name="c" , "n">The abstract course Notification param</param>
        /// <returns>Tag with leading space (" CptS 314") if course or community exists, "" if not.</returns>
        private string getCourseNotificationTag(AbstractCourse c, Notification n)
        {
            string tag = "";

            if (c != null || n != null)
            {
                if (c is Course)
                {
                    tag = "[" + (c as Course).Prefix + " " + (c as Course).Number + "]" + "[" + n.ItemType + "]";
                }
                else if (c is Community)
                {
                    tag = "[" + (c as Community).Nickname + "]" + "[" + n.ItemType + "]";
                }
            }

            return(tag);
        }
示例#7
0
        public static void Main(string[] args)
        {
            String         selection = Console.ReadLine();
            AbstractCourse course    = CourseFactory.CreateCourse(selection);

            course.DisplayCourseDetails(); String courseName = Console.ReadLine();
            var            offlineCourseFactory = new OnlineCourseFactory();
            AbstractCourse abstractCourse       = offlineCourseFactory.CreateCourse(courseName);

            abstractCourse.DisplayCourseDetails();


            courseName = Console.ReadLine();
            var onlineCourseFactory = new OnlineCourseFactory();

            abstractCourse = onlineCourseFactory.CreateCourse(courseName);
            abstractCourse.DisplayCourseDetails();


            Console.ReadKey();
        }
示例#8
0
    public static DateTime UTCToCourse(this DateTime date, int?courseID)
    {
        using (var db = new OSBLEContext())
        {
            int offsetVal = -8;

            if (courseID != null)
            {
                //get Abstract Course
                AbstractCourse abstractCourse = db.AbstractCourses.Find(courseID);
                //check if it's a course or community
                if (abstractCourse is Course)
                {
                    Course course = (Course)abstractCourse;
                    offsetVal = course.TimeZoneOffset;
                }
            }

            TimeZoneInfo tzInfo = GetTimeZone(offsetVal);

            DateTime utcKind = DateTime.SpecifyKind(date, DateTimeKind.Utc);
            return(TimeZoneInfo.ConvertTimeFromUtc(utcKind, tzInfo));
        }
    }
示例#9
0
        /// <summary>
        /// Returns a list of course documents wrapped in a DirectoryListing object
        /// </summary>
        /// <param name="course"></param>
        /// <param name="includeParentLink"></param>
        /// <returns></returns>
        public static DirectoryListing GetCourseDocumentsFileList(AbstractCourse course, bool includeParentLink = true)
        {
            string path = Models.FileSystem.Directories.GetCourseDocs(course.ID).GetPath();

            return(BuildFileList(path, includeParentLink));
        }
示例#10
0
        public ActionResult NewReply(DashboardReply dr)
        {
            if (ModelState.IsValid)
            {
                dr.CourseUser = ActiveCourseUser;
                dr.Posted     = DateTime.UtcNow;

                int replyTo = 0;
                if (Request.Form["reply_to"] != null)
                {
                    replyTo = Convert.ToInt32(Request.Form["reply_to"]);
                }

                int latestReply = 0;
                if (Request.Form["latest_reply"] != null)
                {
                    latestReply = Convert.ToInt32(Request.Form["latest_reply"]);
                }

                DashboardPost replyToPost = db.DashboardPosts.Find(replyTo);
                if (replyToPost != null)
                { // Does the post we're replying to exist?
                    // Are we a member of the course we're replying to?
                    CourseUser cu = (from c in currentCourses
                                     where c.AbstractCourseID == replyToPost.CourseUser.AbstractCourseID
                                     select c).FirstOrDefault();

                    AbstractCourse ac = null;
                    if (cu != null)
                    {
                        ac = cu.AbstractCourse;
                    }
                    if ((cu != null) && (cu.AbstractRole.CanGrade || ((ac != null) && (ac.AllowDashboardPosts))))
                    {
                        replyToPost.Replies.Add(dr);
                        db.SaveChanges();

                        //construct the subject & body
                        string             subject   = "";
                        string             body      = "";
                        List <MailAddress> addresses = new List <MailAddress>();

                        ViewBag.dp = replyToPost;
                        List <DashboardReply> replys = replyToPost.Replies.Where(r => r.ID > latestReply).ToList();

                        //slightly different messages depending on course type
                        if (ac is Course && (ac as Course).AllowDashboardReplies)
                        {
                            Course course = (Course)ac;
                            subject = "[" + course.Prefix + " " + course.Number + "] Reply from " + CurrentUser.FirstName + " " + CurrentUser.LastName;
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following reply to the Dashboard post " + replyToPost.DisplayTitle + " at " + dr.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        else if (ac is Community)
                        {
                            Community community = ac as Community;
                            subject = "[" + community.Nickname + "] Reply from " + CurrentUser.FirstName + " " + CurrentUser.LastName;
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following reply to the Dashboard post " + replyToPost.DisplayTitle + " at " + dr.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        else
                        {
                            //this should never execute, but just in case...
                            subject = "OSBLE Activity Post";
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following message at " + dr.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        body += "<br /><br />";
                        body += dr.Content.Replace("\n", "<br />");
                        body += string.Format("<br /><br /><a href=\"http://plus.osble.org/Home/Course?courseId={0}&postId={1}\">View and reply to post in OSBLE</a>",
                                              dr.CourseUser.AbstractCourseID,
                                              dr.ID
                                              );

                        //List<CoursesUsers> courseUsers = db.CoursesUsers.Where(c => (c.AbstractCourseID == ac.ID && c.UserProfile.EmailAllActivityPosts)).ToList();
                        List <CourseUser> courseUsers = (from c in db.CourseUsers
                                                         where c.AbstractCourseID == ac.ID &&
                                                         c.UserProfile.EmailAllActivityPosts &&
                                                         c.UserProfileID != CurrentUser.ID
                                                         select c).ToList();

                        foreach (CourseUser member in courseUsers)
                        {
                            if (member.UserProfile.UserName != null) // Ignore pending users
                            {
                                addresses.Add(new MailAddress(member.UserProfile.UserName, member.UserProfile.FirstName + " " + member.UserProfile.LastName));
                            }
                        }

                        //Send the message
                        Email.Send(subject, body, addresses);

                        foreach (DashboardReply r in replys)
                        {
                            SetupPostDisplay(r);
                        }

                        replys.Clear();
                        replys.Add(dr);
                        ViewBag.DashboardReplies = replys;

                        // Post notification to other thread participants
                        using (NotificationController nc = new NotificationController())
                        {
                            nc.SendDashboardNotification(dr.Parent, dr.CourseUser);
                        }
                    }
                    else
                    {
                        Response.StatusCode = 403;
                    }
                }
                else
                {
                    Response.StatusCode = 403;
                }
            }

            return(View("_SubDashboardReply"));
        }
示例#11
0
        public ActionResult NewPost(DashboardPost dp)
        {
            dp.CourseUser = ActiveCourseUser;
            dp.Posted     = DateTime.UtcNow;

            List <CourseUser> coursesToPost = new List <CourseUser>();

            bool sendEmail = Convert.ToBoolean(Request.Form["send_email"]);

            if (Request.Form["post_active"] != null)
            { // Post to active course only.
                coursesToPost.Add(ActiveCourseUser);
            }
            else if (Request.Form["post_all"] != null)
            { // Post to all courses.
                coursesToPost = currentCourses.Where(cu => cu.AbstractCourse is Course && cu.AbstractRole.CanModify && !cu.Hidden).ToList();
            }

            foreach (CourseUser cu in coursesToPost)
            {
                AbstractCourse c = cu.AbstractCourse;
                if (cu.AbstractRole.CanGrade || ((c != null) && (c.AllowDashboardPosts)))
                {
                    DashboardPost newDp = new DashboardPost
                    {
                        Content    = dp.Content,
                        Posted     = dp.Posted,
                        CourseUser = dp.CourseUser
                    };

                    if (ModelState.IsValid)
                    {
                        db.DashboardPosts.Add(newDp);
                        db.SaveChanges();

                        //construct the subject & body
                        string             subject   = "";
                        string             body      = "";
                        List <MailAddress> addresses = new List <MailAddress>();


                        //slightly different messages depending on course type
                        if (c is Course)
                        {
                            Course course = c as Course;
                            subject = "[" + course.Prefix + " " + course.Number + "] New Activity Post from " + CurrentUser.FirstName + " " + CurrentUser.LastName;
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following message to the class at " + dp.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        else if (c is Community)
                        {
                            Community community = c as Community;
                            subject = "[" + community.Nickname + "] New Activity Post from " + CurrentUser.FirstName + " " + CurrentUser.LastName;
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following message to the community at " + dp.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        else
                        {
                            //this should never execute, but just in case...
                            subject = "OSBLE Activity Post";
                            body    = CurrentUser.FirstName + " " + CurrentUser.LastName + " sent the following message at " + dp.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":";
                        }
                        body += "<br /><br />";
                        body += dp.Content.Replace("\n", "<br />");
                        body += string.Format("<br /><br /><a href=\"http://plus.osble.org/Home/Course?courseId={0}&postId={1}\">View and reply to post in OSBLE</a>",
                                              newDp.CourseUser.AbstractCourseID,
                                              newDp.ID
                                              );

                        List <CourseUser> courseUser = db.CourseUsers.Where(couseuser => couseuser.AbstractCourseID == c.ID).ToList();

                        //Who gets this email?  If the instructor desires, we send to everyone
                        if (c != null && sendEmail && cu.AbstractRole.CanModify)
                        {
                            foreach (CourseUser member in courseUser)
                            {
                                if (member.UserProfile.UserName != null) // Ignore pending users
                                {
                                    addresses.Add(new MailAddress(member.UserProfile.UserName, member.UserProfile.FirstName + " " + member.UserProfile.LastName));
                                }
                            }
                        }
                        //If the instructor didn't want to send to everyone, only send to those
                        //that want to receive everything
                        else
                        {
                            foreach (CourseUser member in courseUser)
                            {
                                if (member.UserProfile.UserName != null && member.UserProfile.EmailAllActivityPosts) // Ignore pending users
                                {
                                    addresses.Add(new MailAddress(member.UserProfile.UserName, member.UserProfile.FirstName + " " + member.UserProfile.LastName));
                                }
                            }
                        }

                        //Send the message
                        Email.Send(subject, body, addresses);
                    }
                }
            }

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#12
0
        /// <summary>
        /// Sends an email notification to a user.
        /// Does not run in debug mode.
        /// </summary>
        /// <param name="n">Notification to be emailed</param>
        private void emailNotification(Notification n)
        {
            try
            {
                SmtpClient mailClient = new SmtpClient();
                mailClient.UseDefaultCredentials = true;
                //this line causes a break if the course user is not part of any courses
                if (n.Sender == null)
                {
                    n.Sender = db.CourseUsers.Find(ActiveCourseUser.ID);
                }

                UserProfile sender    = db.UserProfiles.Find(n.Sender.UserProfileID);
                UserProfile recipient = db.UserProfiles.Find(n.Recipient.UserProfileID);

                //Abstract course can represent a course or a community
                AbstractCourse course = db.AbstractCourses.Where(b => b.ID == n.CourseID).FirstOrDefault();
                string[]       temp;
                //checking to see if there is no data besides abstractCourseID
                if (n.Data != null && n.Data != "IsAnonymous")
                {
                    temp = n.Data.Split(';');
                }
                else
                {
                    temp = new string[0];
                }

                int id;

                if (temp.Length == 1) //data not being used by other mail method, send from selected course
                {
                    id     = Convert.ToInt16(temp[0]);
                    course = db.AbstractCourses.Where(b => b.ID == id).FirstOrDefault();
                }

                string subject = "";
                if (getCourseNotificationTag(course, n) != "")
                {
                    subject = getCourseNotificationTag(course, n); // Email subject prefix
                }

                string body = "";

                string action = "";

                switch (n.ItemType)
                {
                case Notification.Types.Mail:
                    Mail m = db.Mails.Find(n.ItemID);
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    action = "reply to this message";
                    //yc: m.posted needs to have a converetd time

                    body  = sender.FirstName + " " + sender.LastName + " sent this message at " + m.Posted.UTCToCourse(ActiveCourseUser.AbstractCourseID).ToString() + ":\n\n";
                    body += "Subject: " + m.Subject + "\n\n";
                    body += m.Message;

                    break;

                case Notification.Types.EventApproval:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = sender.FirstName + " " + sender.LastName + " has requested your approval of an event posting.";

                    action = "approve/reject this event.";

                    break;

                case Notification.Types.Dashboard:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = sender.FirstName + " " + sender.LastName + " has posted to an activity feed thread in which you have participated.";

                    action = "view this activity feed thread.";

                    break;

                case Notification.Types.FileSubmitted:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = n.Data;     //sender.FirstName + " " + sender.LastName + " has submitted an assignment."; //Can we get name of assignment?

                    action = "view this assignment submission.";

                    break;

                case Notification.Types.RubricEvaluationCompleted:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = sender.FirstName + " " + sender.LastName + " has published a rubric for your assignment.";     //Can we get name of assignment?

                    action = "view this assignment submission.";

                    break;

                case "CriticalReview":
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = sender.FirstName + " " + sender.LastName + " has published a critical review for your assignment.";     //Can we get name of assignment?

                    action = "view this assignment submission.";

                    break;

                case Notification.Types.InlineReviewCompleted:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = n.Data;     //sender.FirstName + " " + sender.LastName + " has submitted an assignment."; //Can we get name of assignment?

                    action = "view this assignment submission.";

                    break;

                case Notification.Types.TeamEvaluationDiscrepancy:
                    subject += " - " + sender.FirstName + " " + sender.LastName;

                    body = sender.FirstName + " " + sender.LastName + " has submitted a Team Evaluation that has raised a discrepancy flag.";     //Can we get name of assignment?

                    action = "view team evaluation discrepancy.";

                    break;

                case Notification.Types.JoinCourseApproval:
                    subject += " - " + sender.FirstName + " " + sender.LastName;
                    if (course != null)
                    {
                        body = sender.FirstName + " " + sender.LastName + " has submitted a request to join " + course.Name;
                    }

                    action = "view the request to join.";

                    break;

                case Notification.Types.JoinCommunityApproval:
                    subject += " - " + sender.FirstName + " " + sender.LastName;
                    if (course != null)
                    {
                        body = sender.FirstName + " " + sender.LastName + " has submitted a request to join " + course.Name;
                    }

                    action = "view the request to join.";

                    break;

                case Notification.Types.UserTag:
                    if (n.Data != null && n.Data == "IsAnonymous")
                    {
                        subject += " - An anonymous user tagged you in a post!";
                        if (course != null)
                        {
                            body   = "An anonymous user has tagged you in a post or comment in " + course.Name;
                            action = "view the post or comment.";
                        }
                    }
                    else
                    {
                        subject += " - " + sender.FirstName + " " + sender.LastName + " tagged you in a post!";
                        if (course != null)
                        {
                            body   = sender.FirstName + " " + sender.LastName + " has tagged you in a post or comment in " + course.Name;
                            action = "view the post or comment.";
                        }
                    }
                    break;

                default:
                    subject += "No Email set up for this type of notification";

                    body = "No Email set up for this type of notification of type: " + n.ItemType;
                    break;
                }

                body += "\n\n---\nDo not reply to this email.\n";
                string str = getDispatchURL(n.ID);
                body += string.Format("<br /><br /><a href=\"{0}\">Click this link to {1}</a>", str, action);

                MailAddress        to         = new MailAddress(recipient.UserName, recipient.DisplayName((int)CourseRole.CourseRoles.Instructor));
                List <MailAddress> recipients = new List <MailAddress>();
                recipients.Add(to);
                Email.Send(subject, body, recipients);
            }
            catch (Exception e)
            {
                throw new Exception("emailNotification(Notification n) failed: " + e.Message, e);
            }
        }