コード例 #1
0
        public ActionResult AddTypeInCourseLevel(int courseId, int levelId)
        {
            string uid = User.Identity.GetUserId();

            if (!courseService.CanUserModifyCourseLevelsAndTypes(uid, courseId))
            {
                this.AddNotification("Ju nuk mund te shtoni tipe ne kursin me id:" + courseId, NotificationType.ERROR);
                return(RedirectToAction("CourseLevelTypes", "Course", new { @courseId = courseId, @levelId = levelId }));
            }
            var course = courseService.GetCourseById(courseId);
            var level  = levelService.GetLevelById(levelId);

            if (level == null || course == null)
            {
                return(new HttpNotFoundResult());
            }
            var availableTypes = typeService.GetAvailableTypesForCourseLevel(courseId, levelId);

            ViewBag.CourseId       = courseId;
            ViewBag.AvaliableTypes = new SelectList(availableTypes, "Id", "Tipi");
            ViewBag.Course         = course.Emri;
            ViewBag.Level          = level.Emri;
            ViewBag.LevelId        = levelId;
            return(View());
        }
コード例 #2
0
        public ActionResult AddLevelInCourse(Nivel selectedLevel, int courseId)
        {
            string uid = User.Identity.GetUserId();

            if (!courseService.CanUserModifyCourseLevelsAndTypes(uid, courseId))
            {
                this.AddNotification("Ju nuk mund te shtoni nivele ne kursin me id:" + courseId, NotificationType.ERROR);
                return(RedirectToAction("CourseLevels", "Course", new { @id = courseId }));
            }
            if (selectedLevel.Id == 0)
            {
                this.AddNotification("Opsioni qe ju zgjodhet nuk eshte i vlefshem.", NotificationType.ERROR);
                return(RedirectToAction("AddLevelInCourse", "Level", new { @id = courseId }));
            }
            var levelToAdd = levelService.GetLevelById(selectedLevel.Id);

            if (levelToAdd == null)
            {
                return(new HttpNotFoundResult());
            }
            KursNivelTip newSection = new KursNivelTip()
            {
                KursiId  = courseId,
                NiveliId = selectedLevel.Id
            };

            sectionService.CreateSection(newSection);
            this.AddNotification(levelToAdd.Emri + " u shtua me sukses ne kursin " + TempData["Course"], NotificationType.SUCCESS);
            return(RedirectToAction("CourseLevels", "Course", new { @id = courseId }));
        }
コード例 #3
0
        public ActionResult CourseLevelTypes(int courseId, int levelId)
        {
            Kurs  course = courseService.GetCourseById(courseId);
            Nivel level  = levelService.GetLevelById(levelId);

            if (course == null || level == null)
            {
                return(HttpNotFound());
            }

            List <KursNivelTip> courseSections = courseService.GetCourseSections(courseId);

            //marrim nga lista vetem seksionet e kursit perkates qe kane si nivel
            //nivelin e perzgjedhur nga useri
            courseSections = courseSections.Where(x => x.Kursi.KursId == courseId && x.Niveli.Id == levelId).ToList();
            Dictionary <int, Tip> section_types = new Dictionary <int, Tip>();

            foreach (var section in courseSections)
            {
                if (section.Tipi != null && !section_types.ContainsValue(section.Tipi))
                {
                    section_types.Add(section.Id, section.Tipi);
                }
            }
            ViewBag.Kursi        = course.Emri;
            ViewBag.KursId       = course.KursId;
            ViewBag.Niveli       = level.Emri;
            ViewBag.NivelId      = level.Id;
            ViewBag.InstruktorId = course.InstruktoriId;
            return(View(section_types.OrderBy(x => x.Value.Id).ToDictionary(x => x.Key, x => section_types[x.Key])));
        }
コード例 #4
0
        public async Task <IActionResult> GetLevel(int id)
        {
            try
            {
                var level = await levelService.GetLevelById(id);

                if (level == null)
                {
                    return(NotFound());
                }
                return(Ok(level));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
コード例 #5
0
        public HttpResponseMessage GetLevel(string id)
        {
            var Level = _levelService.GetLevelById(Convert.ToInt32(id));

            return(PageHelper.toJson(Level));
        }
コード例 #6
0
        public List <PartOfExamViewModel> GetPartOfExamByExamId(int examinationId)
        {
            IQueryable <PartOfExamination> partOfExams         = unitOfWork.Repository <PartOfExamination>().GetAll();
            List <PartOfExamination>       partOfExamsByExamId = partOfExams.Where(p => p.ExaminationId == examinationId).ToList();
            List <PartOfExamViewModel>     result = new List <PartOfExamViewModel>();

            foreach (PartOfExamination part in partOfExamsByExamId)
            {
                List <QuestionInExamViewModel> questions = part.QuestionInExams.Where(q => q.IsDisable != true).Select(c => new QuestionInExamViewModel
                {
                    Id = (int)c.Id,
                    QuestionContent   = c.QuestionContent,
                    Level             = levelService.GetLevelById(c.LevelId.HasValue ? (int)c.LevelId : 0),
                    LevelId           = c.LevelId.HasValue ? (int)c.LevelId : 0,
                    CategoryId        = c.CategoryId.HasValue ? (int)c.CategoryId : 0,
                    Category          = categoryService.GetCategoryById(c.CategoryId.HasValue ? (int)c.CategoryId : 0),
                    QuestionCode      = c.QuestionCode,
                    QuestionReference = c.QuestionReference.HasValue ? (int)c.QuestionReference : 0,
                    Frequency         = c.Frequency.HasValue ? (int)c.Frequency : 0,
                    Priority          = c.Priority.HasValue ? (int)c.Priority : 0,
                    Image             = c.Image,
                    Images            = c.Images.Select(i => new ImageViewModel {
                        Source           = i.Source,
                        Id               = i.Id,
                        QuestionId       = i.QuestionId,
                        QuestionInExamId = i.QuestionInExamId,
                        QuestionTempId   = i.QuestionTempId
                    }).ToList(),
                    Options = c.OptionInExams.Select(d => new OptionViewModel
                    {
                        Id            = d.Id,
                        OptionContent = d.OptionContent,
                        IsCorrect     = (bool)d.IsCorrect,
                        Images        = d.Images.Select(i => new ImageViewModel
                        {
                            Id               = i.Id,
                            OptionId         = i.OptionId,
                            OptionInExamId   = i.OptionInExamId,
                            OptionTempId     = i.OptionTempId,
                            QuestionId       = i.QuestionId,
                            QuestionInExamId = i.QuestionInExamId,
                            QuestionTempId   = i.QuestionTempId,
                            Source           = i.Source
                        }).ToList(),
                        Image = d.Image
                    }).ToList()
                }).ToList();

                PartOfExamViewModel partViewModel = new PartOfExamViewModel()
                {
                    ExaminationId = part.ExaminationId.HasValue ? (int)part.ExaminationId : 0,
                    Question      = questions
                };
                if (part.LearningOutcome != null)
                {
                    partViewModel.LearningOutcome = new LearningOutcomeViewModel()
                    {
                        Id        = part.LearningOutcome.Id,
                        Code      = part.LearningOutcome.Code != null ? part.LearningOutcome.Code : "",
                        CourseId  = part.LearningOutcome.CourseId.HasValue ? part.LearningOutcome.CourseId.Value : 0,
                        IsDisable = part.LearningOutcome.IsDisable.HasValue && part.LearningOutcome.IsDisable.Value,
                        Name      = part.LearningOutcome.Name
                    };
                }
                result.Add(partViewModel);
            }
            ;
            return(result);
        }
コード例 #7
0
        public ActionResult LevelEdit(int levelId)
        {
            LevelDTO levelbyid = _levelService.GetLevelById(levelId);

            return(View(levelbyid));
        }