コード例 #1
0
        //
        // GET: /Grading/Home/
        public ActionResult Index(int? sessionID)
        {
            // all courses ever
            List<Course> coursesAsFacilitator = null;
            List<Course> sessionCourses = null;
            Session session = null;

            if (sessionID.HasValue) {
                // get all courses
                coursesAsFacilitator = Didache.Courses.GetUsersCourses(CourseUserRole.Faciliator);
                coursesAsFacilitator.AddRange(Didache.Courses.GetUsersCourses(CourseUserRole.Faculty));
                sessionCourses = coursesAsFacilitator.Where(c => c.SessionID == sessionID.Value).ToList();

                session = new DidacheDb().Sessions.Find(sessionID.Value);

            } else {

                // just active courses
                coursesAsFacilitator = Didache.Courses.GetUsersRunningCourses(CourseUserRole.Faciliator);
                coursesAsFacilitator.AddRange(Didache.Courses.GetUsersRunningCourses(CourseUserRole.Faculty));

                sessionCourses = coursesAsFacilitator;

            }

            ViewBag.Session = session;
            ViewBag.Sessions = Sessions.GetSessions();
            ViewBag.CoursesAsFacilitator = coursesAsFacilitator;

            return View(sessionCourses);
        }
コード例 #2
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            Task task = db.Tasks.Find(taskID);
            UserTaskData data = db.UserTasks.SingleOrDefault(d => d.TaskID == taskID && d.UserID == userID);

            // CREATE POST
            InteractionThread thread = new InteractionThread();
            thread.UserID = userID;
            thread.TotalReplies = 0;
            thread.Subject = "Assignment: " + task.Name;
            thread.TaskID = taskID;
            thread.ThreadDate = DateTime.Now;
            db.InteractionThreads.Add(thread);
            db.SaveChanges();

            InteractionPost post = new InteractionPost();
            post.IsApproved = true;
            post.PostContent = request["usercomment"];
            post.PostContentFormatted = Interactions.FormatPost(request["usercomment"]);
            post.PostDate = DateTime.Now;
            post.ReplyToPostID = 0;
            post.ThreadID = thread.ThreadID;
            post.UserID = userID;
            post.Subject = "RE: Assignment: " + task.Name;
            post.TaskID = taskID;
            db.InteractionPosts.Add(post);
            db.SaveChanges();

            return new TaskTypeResult() { Success = true, UrlHash = "thread-" + thread.ThreadID };
        }
コード例 #3
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            StudentFile studentFile = null;

            // save file
            if (request.Files.Count > 0) {
                HttpPostedFileBase file = request.Files[0];

                studentFile = CourseFiles.SaveStudentFile(userID, data, file);
            }

            if (studentFile == null) {
                return new TaskTypeResult() { Success = false, Message = "No file" };
            } else {

                data.StudentSubmitDate = DateTime.Now;
                data.StudentFileID = studentFile.FileID;
                data.TaskCompletionStatus = TaskCompletionStatus.Completed;

                db.SaveChanges();

                return new TaskTypeResult() { Success = true };
            }
        }
コード例 #4
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            Task task = db.Tasks.Find(taskID);
            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            // find the related task to send this post to
            int interactionTaskID = task.RelatedTaskID;

            // nasty lookup
            if (interactionTaskID == 0) {
                List<Task> possibleMatches = db.Tasks
                                                    .Where(t => t.UnitID == task.UnitID && t.TaskTypeName == "CommentOnClassmatesFile")
                                                    .OrderBy(t => t.SortOrder)
                                                    .ToList();

                if (possibleMatches.Count > 0) {
                    interactionTaskID = possibleMatches[0].TaskID;
                }

            }

            // CREATE POST
            InteractionThread thread = new InteractionThread();
            thread.UserID = userID;
            thread.TotalReplies = 0;
            thread.Subject = "Assignment: " + task.Name;
            thread.TaskID = interactionTaskID;
            thread.ThreadDate = DateTime.Now;
            db.InteractionThreads.Add(thread);
            db.SaveChanges();

            InteractionPost post = new InteractionPost();
            post.IsApproved = true;
            post.PostContent = request["usercomment"];
            post.PostContentFormatted = Interactions.FormatPost(request["usercomment"]);
            post.PostDate = DateTime.Now;
            post.ReplyToPostID = 0;
            post.ThreadID = thread.ThreadID;
            post.UserID = userID;
            post.Subject = "RE: Assignment: " + task.Name;
            post.TaskID = interactionTaskID;
            db.InteractionPosts.Add(post);
            db.SaveChanges();

            // facilty and facilitators
            if (data != null) {
                data.PostID = post.PostID;
                data.StudentSubmitDate = DateTime.Now;
                data.TaskCompletionStatus = TaskCompletionStatus.Completed;

                db.SaveChanges();
            }

            return new TaskTypeResult() { Success = true, UrlHash = "thread-" + thread.ThreadID };
        }
コード例 #5
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            // handle post, create reply

            return new TaskTypeResult() { Success = true };
        }
コード例 #6
0
ファイル: Survey.cs プロジェクト: dallasseminary/Didache
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            // save completion status!
            data.TaskCompletionStatus = TaskCompletionStatus.Completed;
            db.SaveChanges();

            return new TaskTypeResult () { Success = true };
        }
コード例 #7
0
        public ActionResult Edit(DiscussionGroup model, HttpPostedFileBase groupimage)
        {
            DidacheDb db = new DidacheDb();

            try {
                // store the old email so we can know if it's changed
                DiscussionGroup group = db.DiscussionGroups.Find(model.GroupID);

                UpdateModel(group);

                db.SaveChanges();

                // do image

                // double check for image type
                if (groupimage != null && groupimage.ContentLength > 0 && System.Text.RegularExpressions.Regex.IsMatch(groupimage.FileName, "(jpeg|jpg|jpe)$", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) {

                    // save it to new path
                    string groupOriginalPath = Server.MapPath("~/images/groups/" + model.GroupID + "-original.jpg");
                    string groupProfilePath = Server.MapPath("~/images/groups/" + model.GroupID + ".jpg");
                    string groupThumbPath = Server.MapPath("~/images/groups/" + model.GroupID + "-thumb.jpg");

                    if (System.IO.File.Exists(groupOriginalPath))
                        System.IO.File.Delete(groupOriginalPath);

                    if (System.IO.File.Exists(groupProfilePath))
                        System.IO.File.Delete(groupProfilePath);

                    if (System.IO.File.Exists(groupThumbPath))
                        System.IO.File.Delete(groupThumbPath);

                    // save original for later
                    groupimage.SaveAs(groupOriginalPath);

                    // resize for profile
                    ImageTools.ScaleImage(groupOriginalPath, groupProfilePath, 180, 1000, 90);

                    // resize for thumb
                    ImageTools.ScaleImage(groupOriginalPath, groupThumbPath, 50, 50, 90);
                }

                return Redirect(group.GroupUrl);

            } catch (Exception ex) {
                ModelState.AddModelError("", "Edit Failure, see inner exception: " + ex.ToString());

                //throw ex;

                return View(model);
            }
        }
コード例 #8
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            data.TaskCompletionStatus = (TaskCompletionStatus)Int32.Parse(collection["TaskStatus"]);
            data.StudentSubmitDate = DateTime.Now;
            data.NumericGrade = null;

            db.SaveChanges();

            return new TaskTypeResult () { Success = true };
        }
コード例 #9
0
ファイル: EnterText.cs プロジェクト: dallasseminary/Didache
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            // store comments
            data.StudentSubmitDate = DateTime.Now;
            data.TaskCompletionStatus = TaskCompletionStatus.Completed;
            data.StudentComments = collection["usercomment"];

            db.SaveChanges();

            return new TaskTypeResult() { Success = true };
        }
コード例 #10
0
        public ActionResult CourseFile(int id, string filename)
        {
            CourseFile file = new DidacheDb().CourseFiles.Find(id);

            //string basePath = Settings.CourseFilesLocation;
            //string path = System.IO.Path.Combine(basePath, file.Filename);
            string path = file.PhysicalPath;

            if (System.IO.File.Exists(path)) {

                return File(path, file.ContentType);
            } else {
                return HttpNotFound("Cannot find: " + file.Filename + " at " + file.PhysicalPath);
            }
        }
コード例 #11
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            UserTaskData data = db.UserTasks.SingleOrDefault(d => d.TaskID == taskID && d.UserID == userID);

            data.TaskCompletionStatus = (TaskCompletionStatus)Int32.Parse(collection["TaskStatus"]);
            data.StudentSubmitDate = DateTime.Now;

            int percentComplete = -1;
            if (Int32.TryParse(collection["PercentComplete"], out percentComplete) && percentComplete >= 1 && percentComplete <= 100) {

                data.NumericGrade = percentComplete;

                db.SaveChanges();

                return new TaskTypeResult() { Success = true };

            } else {
                return new TaskTypeResult() { Success = false };

            }
        }
コード例 #12
0
        public ActionResult StudentFile(int id, string filename)
        {
            StudentFile file = new DidacheDb().StudentFiles.Find(id);

            string path = file.PhysicalPath;

            if (System.IO.File.Exists(path)) {

                return File(path, file.ContentType);
            } else {
                return HttpNotFound("Cannot find: " + file.Filename);
            }
        }
コード例 #13
0
        public ActionResult InteractionReply(FormCollection collection)
        {
            int threadID = 0;

            if (Int32.TryParse(collection["threadID"], out threadID)) {

                DidacheDb db = new DidacheDb();
                User user = Users.GetLoggedInUser();
                InteractionThread thread = db.InteractionThreads.Find(threadID);
                Task task = db.Tasks.Include("Course").SingleOrDefault(t => t.TaskID == thread.TaskID);

                InteractionPost post = new InteractionPost();
                post.PostContent = collection["text"];
                post.PostContentFormatted = Interactions.FormatPost(collection["text"]);
                post.IsApproved = true;
                post.IsDeleted = false;
                post.UserID = user.UserID;
                post.PostDate = DateTime.Now;
                post.ThreadID = threadID;
                post.TaskID = thread.TaskID;
                post.FileID = 0;
                post.Subject = "RE: " + thread.Subject;

                int replyToPostID = 0;
                if (!Int32.TryParse(collection["ReplyToPostID"], out replyToPostID)) {

                }
                post.ReplyToPostID = replyToPostID;

                db.InteractionPosts.Add(post);
                db.SaveChanges();

                // check for completion
                List<InteractionThread> threads = db.InteractionThreads.Where(t => t.TaskID == thread.TaskID).ToList();
                List<int> threadIDs = threads.Select(t => t.ThreadID).ToList();
                List<InteractionPost> usersPostsForTask = db.InteractionPosts
                                                    .Where(p => threadIDs.Contains(p.ThreadID) && p.UserID == user.UserID)
                                                    .ToList();

                int minimumInteractions = 4; // note: the student's initial task is also counted in this!
                bool isCompleted = false;
                if (usersPostsForTask.Count >= minimumInteractions) {
                    isCompleted = true;
                    UserTaskData data = db.UserTasks.SingleOrDefault(ud => ud.UserID == user.UserID && ud.TaskID == thread.TaskID);
                    if (data != null) {
                        data.TaskCompletionStatus = TaskCompletionStatus.Completed;
                        db.SaveChanges();
                    }
                }

                // get all the posts,
                // where a user wants to get followups
                List<User> usersToNotify = db.InteractionPosts
                                                .Where(p => p.ThreadID == threadID &&
                                                            !p.IsDeleted &&
                                                            p.IsApproved &&
                                                            p.User.NotifyInteractionPostReplies)
                                                .Select(p => p.User)
                                                .Distinct()
                                                .ToList();

                // check if thread starter wants replies
                if (thread.User.NotifyInteractionThreadsReplies) {
                    usersToNotify.Add(thread.User);
                }

                // remove dups
                usersToNotify = usersToNotify.Distinct().ToList();

                // remove commenter
                usersToNotify.RemoveAll(u => u.UserID == user.UserID);

                foreach (User userToNotify in usersToNotify) {

                    string message = Emails.FormatEmail(Didache.Resources.emails.interaction_reply,
                                task.Course,
                                null,
                                task,
                                user,
                                userToNotify,
                                null,
                                post,
                                null);

                    Emails.EnqueueEmail("*****@*****.**", userToNotify.Email, task.Course.CourseCode + ": Reply to " + task.Name, message, false);

                }

                /*
                // email responses
                List<User> usersToNotify = db.InteractionPosts
                                                .Where(p => p.ThreadID == threadID && !p.IsDeleted && p.IsApproved && p.UserID != user.UserID)
                                                .Select(p => p.User)
                                                .Distinct()
                                                .ToList();

                // remove thread starter from replies if not wanted
                if (!thread.User.NotifyInteractionThreadsReplies) {
                    usersToNotify.RemoveAll(u => u.UserID == thread.User.UserID);
                }

                foreach (User userToNotify in usersToNotify) {
                    if (userToNotify.NotifyInteractionPostReplies || (userToNotify.UserID == thread.UserID && userToNotify.NotifyInteractionThreadsReplies)) {

                        string message = Emails.FormatEmail(Didache.Resources.emails.interaction_reply,
                                    task.Course,
                                    null,
                                    task,
                                    user,
                                    userToNotify,
                                    null,
                                    post,
                                    null);

                        Emails.EnqueueEmail("*****@*****.**", userToNotify.Email, task.Course.CourseCode + ": Reply to " + task.Name, message, false);
                    }
                }
                 * */

                return Json(new {
                                    success = true,
                                    postID = post.PostID,
                                    user = serializer.Serialize(user),
                                    post = serializer.Serialize(post),
                                    isCompleted = isCompleted
                });

            } else {
                return Json(new {success= false});
            }
        }
コード例 #14
0
        public ActionResult TaskFile2(int taskID, FormCollection collection)
        {
            User user = Users.GetLoggedInUser();

            UserTaskData data = Tasks.GetUserTaskData(taskID, user.UserID);

            Guid uniqueID = Guid.NewGuid();
            string originalFilename = "";
            string originalExtension = "";
            int fileID = 0;
            HttpPostedFileBase file = null;

            // save file
            if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) {
                file = Request.Files[0];

                originalFilename = Path.GetFileName(file.FileName);
                originalExtension = Path.GetExtension(file.FileName);

                string filePath = Path.Combine(Settings.StudentFilesLocation, uniqueID.ToString() + originalExtension);
                file.SaveAs(filePath);

                StudentFile studentFile = new StudentFile();
                studentFile.UserID = user.UserID;
                studentFile.UniqueID = uniqueID;
                studentFile.ContentType = file.ContentType;
                studentFile.Length = file.ContentLength;
                studentFile.Filename = originalFilename;
                studentFile.UploadedDate = DateTime.Now;

                var db = new DidacheDb();
                db.StudentFiles.Add(studentFile);
                db.SaveChanges();

                fileID = studentFile.FileID;
            }

            // do processing
            object returnObject = new {
                success= true,
                fileID = fileID,
                fileLength=file.ContentLength,
                filename=originalFilename
            }; // Didache.TaskTypes.TaskTypeManager.ProcessFormCollection(data.Task.TaskTypeName, taskID, userID, collection, Request);

            return Json(returnObject);

            //return Redirect("/courses/" + data.Task.Course.Slug + "/schedule/" + data.Task.UnitID);
        }
コード例 #15
0
        public ActionResult Feed(string slug, int userID, string type, string extension)
        {
            DidacheDb db = new DidacheDb();
            Course course = Didache.Courses.GetCourseBySlug(slug);
            User user = Users.GetUser(userID);

            if (user == null || course == null)
                return HttpNotFound();

            // BEING XML/RSS
            StringWriter sw = new StringWriterWithEncoding(Encoding.UTF8);

            XmlTextWriter writer = new XmlTextWriter(sw);
            writer.Formatting = Formatting.Indented;
            //Response.ContentType = "application/rss+xml";
            //Response.ContentEncoding = Encoding.UTF8;
            writer.WriteStartDocument();

            // write RSS 2.0 starter
            writer.WriteStartElement("rss");
            writer.WriteAttributeString("version", "2.0");
            writer.WriteAttributeString("xmlns", "itunes", null, "http://www.itunes.com/dtds/podcast-1.0.dtd");
            writer.WriteStartElement("channel");

            writer.WriteElementString("title", "DTS-" + course.CourseCode + course.Section + "-" + course.Name);
            writer.WriteElementString("link", "https://online.dts.edu/courses/" + course.Slug);
            writer.WriteElementString("description", ""); //course.Description);
            writer.WriteElementString("language", user.Language);
            writer.WriteElementString("docs", "http://blogs.law.harvard.edu/tech/rss");
            writer.WriteElementString("copyright", "This work is copyright 2004-" + DateTime.Now.Year + " by Dallas Theological Seminary and the individual speakers.");
            //writer.WriteElementString("lastBuildDate", mediaItems[0].OnlineDate.ToString("ddd, d MMM yyyy hh:mm:ss") + " CST");
            writer.WriteElementString("webMaster", "[email protected] (Dallas Theological Seminary)");
            writer.WriteElementString("category", "Religion");

            // get current and next two units for this course
            DateTime unitStartDate = DateTime.Now.AddDays(21);
            //List<Unit> units = db.Units.Where(u => u.CourseID == course.CourseID && u.StartDate <= unitStartDate).ToList();
            List<Unit> units = db.Units.Where(u => u.CourseID == course.CourseID).ToList();

            // get all vidoes
            List<VideoInfo> videoInfos = GetVideoInfo(course, userID);

            foreach (Unit unit in units) {

                foreach (VideoInfo videoInfo in videoInfos.Where(vi => vi.UnitNumber == unit.SortOrder)) {

                    //string videoName = videoInfo.Title;
                    //int videoNumber = videoInfo.SortOrder;
                    //string duration = videoInfo.Duration;

                    // video
                    writer.WriteStartElement("item");

                    writer.WriteElementString("title", String.Format("{0} unit {1} video {2}", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteElementString("link", videoInfo.VideoUrl);
                    writer.WriteElementString("description", videoInfo.Title);

                    writer.WriteElementString("author", videoInfo.Speaker);
                    writer.WriteElementString("pubDate", unit.StartDate.AddMinutes(videoInfo.SortOrder).ToString("ddd, d MMM yyyy hh:mm:ss") + " CST"); //"DDD, dd MMM yyyy HH:mm:ss"

                    // VIDEO
                    writer.WriteStartElement("enclosure");
                    writer.WriteAttributeString("url", videoInfo.VideoUrl);
                    //writer.WriteAttributeString("length", mediaItem.VideoBytesLength.ToString());
                    writer.WriteAttributeString("type", "video/mp4");
                    writer.WriteEndElement(); // enclosure

                    writer.WriteStartElement("guid");
                    writer.WriteAttributeString("isPermaLink", "false");
                    writer.WriteString(String.Format("video-c{0}u{1}v{2}", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteEndElement(); // guid

                    writer.WriteStartElement("itunes", "author", null);
                    writer.WriteString(videoInfo.Speaker);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "subtitle", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "summary", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "duration", null);
                    writer.WriteString(videoInfo.Duration);
                    writer.WriteEndElement();

                    writer.WriteEndElement(); // item

                    /*
                    // PDF transcript
                    writer.WriteStartElement("item");

                    writer.WriteElementString("title", String.Format("{0} unit {1} video {2} transcript", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteElementString("link", "https://online.dts.edu/courses/" + course.Slug + "/schedule/" + unit.UnitID.ToString());
                    writer.WriteElementString("description", videoInfo.Title);

                    writer.WriteElementString("author", videoInfo.Speaker);
                    writer.WriteElementString("pubDate", unit.StartDate.AddMinutes(videoInfo.SortOrder).ToString("ddd, d MMM yyyy hh:mm:ss") + " CST"); //"DDD, dd MMM yyyy HH:mm:ss"

                    // PDF transcript
                    writer.WriteStartElement("enclosure");
                    writer.WriteAttributeString("url", videoInfo.TranscriptUrl);
                    writer.WriteAttributeString("type", "application/pdf");
                    writer.WriteEndElement(); // enclosure

                    writer.WriteStartElement("guid");
                    writer.WriteAttributeString("isPermaLink", "false");
                    writer.WriteString(String.Format("transcript-c{0}u{1}v{2}", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteEndElement(); // guid

                    writer.WriteStartElement("itunes", "author", null);
                    writer.WriteString(videoInfo.Speaker);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "subtitle", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "summary", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "duration", null);
                    writer.WriteString(videoInfo.Duration);
                    writer.WriteEndElement();

                    writer.WriteEndElement(); // item

                    // PDF Slides
                    writer.WriteStartElement("item");

                    writer.WriteElementString("title", String.Format("{0} unit {1} video {2} slides", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteElementString("link", "https://online.dts.edu/courses/" + course.Slug + "/schedule/" + unit.UnitID.ToString());
                    writer.WriteElementString("description", videoInfo.Title);

                    writer.WriteElementString("author", videoInfo.Speaker);
                    writer.WriteElementString("pubDate", unit.StartDate.AddMinutes(videoInfo.SortOrder).ToString("ddd, d MMM yyyy hh:mm:ss") + " CST"); //"DDD, dd MMM yyyy HH:mm:ss"

                    // PDF slides
                    writer.WriteStartElement("enclosure");
                    writer.WriteAttributeString("url", videoInfo.SlidesUrl);
                    writer.WriteAttributeString("type", "application/pdf");
                    writer.WriteEndElement(); // enclosure

                    writer.WriteStartElement("guid");
                    writer.WriteAttributeString("isPermaLink", "false");
                    writer.WriteString(String.Format("slides-c{0}u{1}v{2}", course.CourseCode, unit.SortOrder, videoInfo.SortOrder));
                    writer.WriteEndElement(); // guid

                    writer.WriteStartElement("itunes", "author", null);
                    writer.WriteString(videoInfo.Speaker);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "subtitle", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "summary", null);
                    writer.WriteString(videoInfo.Title);
                    writer.WriteEndElement();
                    writer.WriteStartElement("itunes", "duration", null);
                    writer.WriteString(videoInfo.Duration);
                    writer.WriteEndElement();

                    writer.WriteEndElement(); // item

                     */
                }
            }

            writer.WriteEndElement(); // channel
            writer.WriteEndElement(); // rss
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();

            return Content(sw.ToString(), "text/xml", Encoding.UTF8);
        }
コード例 #16
0
        public ActionResult EditProfile(User model)
        {
            DidacheDb db = new DidacheDb();

            try {
                // store the old email so we can know if it's changed
                User user = db.Users.Find(model.UserID);
                string oldEmail = user.Email;

                UpdateModel(user);

                // fix stuff
                if (!String.IsNullOrEmpty(user.Twitter) && user.Twitter.Contains("/")) {
                    user.Twitter = user.Twitter.Substring(user.Twitter.LastIndexOf("/") + 1);
                }
                if (!String.IsNullOrEmpty(user.Facebook) && user.Facebook.Contains("facebook.com")) {
                    user.Facebook = user.Facebook
                                            .Replace("http://", "")
                                            .Replace("https://", "")
                                            .Replace("www.facebook.com/", "")
                                            .Replace("facebook.com/", "");
                }
                if (!String.IsNullOrEmpty(user.Website) && !user.Website.Contains("http")) {
                    user.Website = "http://" + user.Website;
                }

                UserAction ua = new UserAction() {
                    SourceUserID = user.UserID,
                    TargetUserID = 0,
                    UserActionType = UserActionType.UpdateSettings,
                    ActionDate = DateTime.Now,
                    GroupID = 0,
                    MessageID = 0,
                    PostCommentID = 0,
                    PostID = 0,
                    Text = ""
                };
                db.UserActions.Add(ua);

                db.SaveChanges();

                // change of email changes
                if (user.Email != oldEmail) {

                    // change membership user
                    MembershipUser membershipUser = Membership.GetUser(user.Username, true);
                    membershipUser.Email = model.Email;
                    Membership.UpdateUser(membershipUser);

                    // send to CARS
                    // set to CampusNet
                    try {
                        string transactionUrl = "https://campus.dts.edu/cgi-bin/public/DSchkhold.cgi?id=" + user.UserID.ToString() + "&email=" + user.Email;
                        WebClient webClient = new WebClient();
                        string returnValue = webClient.DownloadString(transactionUrl);
                    }
                    catch {
                        // don't worry. be happy.
                    }
                }

                // save language to cookie for logout
                Response.Cookies.Add(new HttpCookie("Language", model.Language));

                Users.ClearUserCache(user);

                return Redirect(user.ProfileDisplayUrl); // RedirectToAction("EditProfile");

            } catch (Exception ex) {
                ModelState.AddModelError("", "Edit Failure, see inner exception: " + ex.ToString());

                return View(model);
            }
        }
コード例 #17
0
        public ActionResult iCal(string slug, string type, int userID, string extension)
        {
            DidacheDb db = new DidacheDb();

            Course course = Didache.Courses.GetCourseBySlug(slug);
            User user = Users.GetUser(userID);

            if (user == null || course == null)
                return HttpNotFound();

            List<UserTaskData> userTasks = db.UserTasks
                                            .Include("Task.Unit")
                                            .Where(ut => ut.UserID == user.UserID && ut.CourseID == course.CourseID)
                                            .OrderBy(t => t.Task.Unit.SortOrder)
                                                .ThenBy(t => t.Task.SortOrder)
                                            .ToList();

            List<ICalEvent> iEvents = new List<ICalEvent>();

            foreach (UserTaskData userTask in userTasks) {
                DateTime dueDate;

                if (userTask.Unit == null)
                    continue;

                if (userTask.Task.DueDate.HasValue)
                    dueDate = userTask.Task.DueDate.Value;
                else
                    dueDate = userTask.Task.Unit.EndDate;

                iEvents.Add(new ICalEvent() {
                    UID = userTask.TaskID.ToString(),
                    Summary = userTask.Task.Name + " (Unit " + userTask.Unit.SortOrder.ToString() + ")" +  ((userTask.TaskCompletionStatus == TaskCompletionStatus.Completed) ? " [completed]" : ""),
                    Description = Utility.StripHtml(userTask.Task.Instructions),
                    Location = "",
                    //StartUtc = dueDate.ToUniversalTime(),
                    //EndUtc = dueDate.ToUniversalTime()

                    StartUtc = dueDate,
                    EndUtc = dueDate

                });
            }

            return new ICalEventResult(
                        course.ToString() + " Tasks",
                        "Dallas Theological Seminary",
                        "", //"DTS-" + course.CourseCode + course.Section + ".ics",
                        iEvents);
        }
コード例 #18
0
        public ActionResult GradedFile(int id, string filename)
        {
            GradedFile file = new DidacheDb().GradedFiles.Find(id);

            string basePath = Settings.GradedFilesLocation;
            string path = System.IO.Path.Combine(basePath, file.StoredFilename);

            if (System.IO.File.Exists(path)) {

                return File(path, file.ContentType);
            } else {
                return HttpNotFound("Cannot find: " + file.Filename);
            }
        }
コード例 #19
0
        public ActionResult FeedOld(string slug, int userID, string type, string extension)
        {
            DidacheDb db = new DidacheDb();
            Course course = Didache.Courses.GetCourseBySlug(slug);
            User user = Users.GetUser(userID);

            if (user == null)
                return HttpNotFound();

            List<SyndicationItem> items = new List<SyndicationItem>();

            // get current and next two units for this course
            DateTime unitStartDate = DateTime.Now.AddDays(21);
            List<Unit> units = db.Units.Where(u => u.CourseID == course.CourseID && u.StartDate <= unitStartDate).ToList();

            // get all vidoes
            List<VideoInfo> videoInfos = GetVideoInfo(course, userID);

            foreach (Unit unit in units) {

                foreach (VideoInfo videoInfo in videoInfos.Where(vi=> vi.UnitNumber == unit.SortOrder)) {

                    // VIDEO
                    SyndicationItem item = new SyndicationItem(
                            videoInfo.Title,
                            videoInfo.Title,
                            new Uri("http://online.dts.edu/courses/" + course.Slug), // new Uri(Utility.BaseFullUrl + post.PostUrl),
                            String.Format("c{0}u{1}v{2}", videoInfo.CourseCode, videoInfo.UnitNumber, videoInfo.VideoNumber),
                            DateTime.Now // need to hook to unit start date
                        );

                    long videoLength = 10000;
                    item.Links.Add(
                        SyndicationLink.CreateMediaEnclosureLink(new Uri(videoInfo.VideoUrl), "video/mp4", videoLength)

                        //SyndicationLink.CreateMediaEnclosureLink(new Uri("http://online.dts.edu/" + String.Format("download/video/{0}-{1}-{2}-{3}-{4}.mp4", course.CourseID, course.CourseCode, videoInfo.UnitNumber, videoInfo.VideoNumber, userID)), "video/mp4", videoLength)
                    );

                    items.Add(item);
                }
            }

            SyndicationFeed feed = new SyndicationFeed(
                                        course.ToString() + " :: RSS",
                                        "Video, Slides, and Transcripts",
                                        new Uri("http://online.dts.edu/"),
                                        items);

            return new SyndicationResult(feed, extension);
        }
コード例 #20
0
        public TaskTypeResult ProcessFormCollection(int taskID, int userID, FormCollection collection, HttpRequestBase request)
        {
            DidacheDb db = new DidacheDb();

            Task task = db.Tasks.Find(taskID);
            UserTaskData data = db.UserTasks.SingleOrDefault(d=> d.TaskID == taskID && d.UserID == userID);

            StudentFile studentFile = null;

            // save file
            if (request.Files.Count > 0) {
                HttpPostedFileBase file = request.Files[0];

                /* What if this is a GTA?
                 * - Create a fake task for looking up and saving information
                 */
                UserTaskData dataForSaving = data;
                if (dataForSaving == null) {
                    dataForSaving = new UserTaskData() {
                        UserID = userID,
                        TaskID = taskID
                    };
                }

                studentFile = CourseFiles.SaveStudentFile(userID, dataForSaving, file);
            }

            if (studentFile == null) {
                return new TaskTypeResult() { Success = false, Message = "No file" };
            }
            else {

                // save this file, even if somethign messes up with the forums
                if (data != null) {
                    data.StudentFileID = studentFile.FileID;
                    db.SaveChanges();
                }

                int interactionTaskID = task.RelatedTaskID;

                // nasty lookup
                if (interactionTaskID == 0) {
                    List<Task> possibleMatches = db.Tasks
                                                        .Where(t => t.UnitID == task.UnitID && t.TaskTypeName == "CommentOnClassmatesFile")
                                                        .OrderBy(t => t.SortOrder)
                                                        .ToList();

                    if (possibleMatches.Count > 0) {
                        interactionTaskID = possibleMatches[0].TaskID;
                    }

                }

                //if (interactionTaskID == 0) {
                //	return new TaskTypeResult() { Success = false, Message = "No related task" };
                //}

                InteractionThread thread = null;
                InteractionPost post = null;
                bool isNewPost = true;

                // check for existing thread/post
                if (data != null && data.PostID > 0) {
                    post = db.InteractionPosts.SingleOrDefault(p => p.PostID == data.PostID);
                    if (post != null) {
                        thread = db.InteractionThreads.SingleOrDefault(t => t.ThreadID == post.ThreadID);

                        if (thread != null) {
                            isNewPost = false;
                        }
                    }
                }

                // CREATE POST
                if (isNewPost) {
                    thread = new InteractionThread();
                }
                thread.UserID = userID;
                thread.TotalReplies = 0;
                thread.IsDeleted = false;
                thread.Subject = "Assignment: " + task.Name;
                thread.TaskID = interactionTaskID;
                thread.ThreadDate = DateTime.Now;
                if (isNewPost) {
                    db.InteractionThreads.Add(thread);
                }
                db.SaveChanges();

                if (isNewPost) {
                    post = new InteractionPost();
                }
                post.IsApproved = true;
                post.IsDeleted = false;
                post.PostContent = request["usercomment"];
                post.PostContentFormatted = Interactions.FormatPost(request["usercomment"]);
                post.PostDate = DateTime.Now;
                post.ReplyToPostID = 0;
                post.ThreadID = thread.ThreadID;
                post.UserID = userID;
                post.Subject = "RE: Assignment: " + task.Name;
                post.TaskID = interactionTaskID;
                post.FileID = studentFile.FileID;
                if (isNewPost) {
                    db.InteractionPosts.Add(post);
                }
                db.SaveChanges();

                if (data != null) {
                    data.PostID = post.PostID;
                    data.StudentSubmitDate = DateTime.Now;
                    data.TaskCompletionStatus = TaskCompletionStatus.Completed;

                    db.SaveChanges();
                }

                return new TaskTypeResult() { Success = true, UrlHash = "thread-" + thread.ThreadID };
            }
        }