Пример #1
0
        public ActionResult StudentZip(string courseId, Guid?slideId)
        {
            if (!slideId.HasValue)
            {
                return(HttpNotFound());
            }
            var slide = courseManager.FindCourse(courseId)?.FindSlideById(slideId.Value);

            if (!(slide is ExerciseSlide))
            {
                return(HttpNotFound());
            }

            var exerciseSlide = slide as ExerciseSlide;

            if (!(exerciseSlide.Exercise is ProjectExerciseBlock))
            {
                return(HttpNotFound());
            }

            var block   = (ProjectExerciseBlock)exerciseSlide.Exercise;
            var zipFile = exerciseStudentZipsCache.GenerateOrFindZip(courseId, exerciseSlide);

            return(File(zipFile.FullName, "application/zip", block.CsprojFile.Name + ".zip"));
        }
Пример #2
0
        public ActionResult StudentZip(string courseId, Guid slideId)
        {
            var isInstructor = User.HasAccessFor(courseId, CourseRole.Instructor);
            var slide        = courseManager.FindCourse(courseId)?.FindSlideById(slideId, isInstructor);

            if (!(slide is ExerciseSlide))
            {
                return(HttpNotFound());
            }

            var exerciseSlide = slide as ExerciseSlide;

            if (exerciseSlide.Exercise is SingleFileExerciseBlock)
            {
                return(HttpNotFound());
            }
            if ((exerciseSlide.Exercise as UniversalExerciseBlock)?.NoStudentZip ?? false)
            {
                return(HttpNotFound());
            }

            var zipFile = exerciseStudentZipsCache.GenerateOrFindZip(courseId, exerciseSlide);

            var block    = exerciseSlide.Exercise;
            var fileName = (block as CsProjectExerciseBlock)?.CsprojFile.Name ?? new DirectoryInfo((block as UniversalExerciseBlock).ExerciseDirPath).Name;

            return(File(zipFile.FullName, "application/zip", fileName + ".zip"));
        }