Exemple #1
0
        /// <summary>
        /// A Course Shell is an unpublished course that has no content or activity
        /// </summary>
        private bool IsUnusedCourse(Course course)
        {
            var client = new CoursesClient();

            var courseWithSyllabus = client.GetWithSyllabusBody(course.Id).Result;

            if (!string.IsNullOrWhiteSpace(courseWithSyllabus.SyllabusBody))
            {
                return(false);
            }

            var enrollments = client.GetEnrollments(course.Id).Result;

            if (enrollments.Any(x => x.LastActivityAt != null))
            {
                return(false);
            }

            var assignments = client.GetCourseAssignments(course.Id).Result;

            if (assignments.Any())
            {
                return(false);
            }

            var modules = client.GetCourseModules(course.Id).Result;

            if (modules.Any())
            {
                return(false);
            }

            var files = client.GetCourseFiles(course.Id).Result;

            if (files.Any())
            {
                return(false);
            }

            var pages = client.GetCoursePages(course.Id).Result;

            if (pages.Any())
            {
                return(false);
            }

            var discussions = client.GetCourseDiscussions(course.Id).Result;

            if (discussions.Any())
            {
                return(false);
            }

            var quizzes = client.GetCourseQuizzes(course.Id).Result;

            if (quizzes.Any())
            {
                return(false);
            }

            return(true);
        }