コード例 #1
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum.
        /// </summary>
        /// <param name="curriculum">The curriculum.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculum(Curriculum curriculum)
        {
            var validationStatus = new ValidationStatus();
            var currentGroupId = -1;
            // If update old curriculum
            if (curriculum.Id > 0)
            {
                var oldCurriculum = this.Storage.GetCurriculum(curriculum.Id);
                currentGroupId = oldCurriculum.UserGroupRef;
                curriculum.DisciplineRef = oldCurriculum.DisciplineRef;
            }

            if (curriculum.UserGroupRef > 0 && curriculum.DisciplineRef > 0)
            {
                var curriculums = this.Storage.GetCurriculums(c => c.DisciplineRef == curriculum.DisciplineRef).ToList();
                if (curriculums.Exists(item => item.UserGroupRef == curriculum.UserGroupRef) && curriculum.UserGroupRef != currentGroupId)
                {
                    validationStatus.AddLocalizedError("ChooseAnotherGroupForThisCurriculum");
                }
            }
            if (curriculum.UserGroupRef <= 0)
            {
                validationStatus.AddLocalizedError("ChooseGroup");
            }
            if (curriculum.DisciplineRef <= 0)
            {
                validationStatus.AddLocalizedError("ChooseDiscipline");
            }

            ValidateDate(curriculum.StartDate, curriculum.EndDate, validationStatus);

            return validationStatus;
        }
コード例 #2
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum chapter.
        /// </summary>
        /// <param name="data">The curriculum chapter.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumChapter(CurriculumChapter data)
        {
            var validationStatus = new ValidationStatus();

            ValidateDate(data.StartDate, data.EndDate, validationStatus);

            return validationStatus;
        }
コード例 #3
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum chapter.
        /// </summary>
        /// <param name="data">The curriculum chapter.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumChapter(CurriculumChapter data)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            ValidateDate(data.StartDate, data.EndDate, validationStatus);

            //TODO: check topic timelines and curriculum timelines!
            return validationStatus;
        }
コード例 #4
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the topic.
        /// </summary>
        /// <param name="data">The topic.</param>
        /// <returns></returns>
        public ValidationStatus ValidateTopic(Topic data)
        {
            ValidationStatus validationStatus = new ValidationStatus();
            if (String.IsNullOrEmpty(data.Name))
            {
                validationStatus.AddLocalizedError("NameReqiured");
            }
            else if (data.Name.Length > Constants.MaxStringFieldLength)
            {
                validationStatus.AddLocalizedError("NameCanNotBeLongerThan", Constants.MaxStringFieldLength);
            }

            if (!data.TestCourseRef.HasValue && !data.TheoryCourseRef.HasValue)
            {
                validationStatus.AddLocalizedError("ChooseAtLeastOneCourse");
            }
            else
            {
                if (data.TestCourseRef.HasValue)
                {
                    if (data.TestTopicTypeRef == 0)
                    {
                        validationStatus.AddLocalizedError("ChooseTopicType");
                    }
                    else
                    {
                        var testTopicType = Converter.ToTopicType(storage.GetTopicType(data.TestTopicTypeRef.Value));
                        if (testTopicType == TopicTypeEnum.TestWithoutCourse && data.TestCourseRef != Constants.NoCourseId)
                        {
                            validationStatus.AddLocalizedError("TestWithoutCourse");
                        }
                        if (testTopicType != TopicTypeEnum.TestWithoutCourse && (!data.TestCourseRef.HasValue || data.TestCourseRef <= 0))
                        {
                            validationStatus.AddLocalizedError("ChooseTestCourse");
                        }
                    }
                }

                if (data.TheoryCourseRef.HasValue)
                {
                    if (data.TheoryTopicTypeRef == 0)
                    {
                        validationStatus.AddLocalizedError("ChooseTopicType");
                    }
                    else
                    {
                        if (!data.TheoryCourseRef.HasValue || data.TheoryCourseRef <= 0)
                        {
                            validationStatus.AddLocalizedError("ChooseTheoryCourse");
                        }
                    }
                }
            }

            return validationStatus;
        }
コード例 #5
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum chapter topic.
        /// </summary>
        /// <param name="curriculumChapter">The curriculum chapter topic.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumChapterTopic(CurriculumChapterTopic data)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            ValidateDate(data.TestStartDate, data.TestEndDate, validationStatus);
            ValidateDate(data.TheoryStartDate, data.TheoryEndDate, validationStatus);

            //TODO: check topic timelines and curriculum timelines!

            return validationStatus;
        }
コード例 #6
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum assignment.
        /// </summary>
        /// <param name="curriculumAssignment">The curriculum assignment.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumAssignment(CurriculumAssignment curriculumAssignment)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            if (curriculumAssignment.UserGroupRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("ChooseStage")));
            }

            return validationStatus;
        }
コード例 #7
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum.
        /// </summary>
        /// <param name="curriculum">The curriculum.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculum(Curriculum curriculum)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            if (curriculum.UserGroupRef <= 0)
            {
                validationStatus.AddLocalizedError("ChooseGroup");
            }
            ValidateDate(curriculum.StartDate, curriculum.EndDate, validationStatus);

            return validationStatus;
        }
コード例 #8
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum chapter topic.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumChapterTopic(CurriculumChapterTopic data)
        {
            var validationStatus = new ValidationStatus();

            ValidateDate(data.TestStartDate, data.TestEndDate, validationStatus);
            ValidateDate(data.TheoryStartDate, data.TheoryEndDate, validationStatus);

            if (data.ThresholdOfSuccess <= 0)
            {
                validationStatus.AddLocalizedError("MaxScoreMustBeGreaterThanZero");
            }

            return validationStatus;
        }
コード例 #9
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the stage timeline.
        /// </summary>
        /// <param name="timeline">The stage timeline.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public ValidationStatus ValidateStageTimeline(Timeline timeline)
        {
            ValidationStatus validationStatus = new ValidationStatus();

			DateTime minAllowedDate = Constants.MinAllowedDateTime;
			DateTime maxAllowedDate = Constants.MaxAllowedDateTime;
			if (timeline.StageRef <= 0)
			{
				validationStatus.Errors.Add(String.Format(Localization.getMessage("ChooseStage")));
			}
			if (timeline.StartDate > timeline.EndDate)
			{
				validationStatus.Errors.Add(Localization.getMessage("StartDateMustLessThanEndDate"));
			}
			if (timeline.StartDate < minAllowedDate || timeline.StartDate > maxAllowedDate)
			{
				validationStatus.Errors.Add(String.Format(Localization.getMessage("StartDateMustBeBetween"),
					 minAllowedDate.ToString(), maxAllowedDate.ToString()));
			}
			if (timeline.EndDate < minAllowedDate || timeline.EndDate > maxAllowedDate)
			{
				validationStatus.Errors.Add(String.Format(Localization.getMessage("EndDateMustBeBetween"),
					 minAllowedDate.ToString(), maxAllowedDate.ToString()));
			}

            var timelines = storage.GetCurriculumAssignmentTimelines(timeline.CurriculumAssignmentRef);

            bool errorCheck = true;
            List<string> errors = new List<string>();
            foreach (var item in timelines)
            {
                if (timeline.StartDate >= item.StartDate && item.EndDate >= timeline.EndDate)
                {
                    errorCheck = false;
                    break;
                }
                else
                {
                    errors.Add(String.Format("{0} - {1}", String.Format("{0:g}", item.StartDate), String.Format("{0:g}", item.EndDate)));
                }
            }
            if (errorCheck == true)
            {
                validationStatus.Errors.Add(Localization.getMessage("StageTimelineBiggerThanCurriculumTimeline"));
                validationStatus.Errors.AddRange(errors);
            }

            return validationStatus;
        }
コード例 #10
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the curriculum assignment timeline.
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculumAssignmentTimeline(Timeline timeline)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            DateTime minAllowedDate = Constants.MinAllowedDateTime;
            DateTime maxAllowedDate = Constants.MaxAllowedDateTime;
            if (timeline.StartDate > timeline.EndDate)
            {
                validationStatus.Errors.Add(IUDICO.CurriculumManagement.Localization.getMessage("StartDateMustLessThanEndDate"));
            }
            if (timeline.StartDate < minAllowedDate || timeline.StartDate > maxAllowedDate)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("StartDateMustBeBetween"),
                     minAllowedDate.ToString(), maxAllowedDate.ToString()));
            }
            if (timeline.EndDate < minAllowedDate || timeline.EndDate > maxAllowedDate)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("EndDateMustBeBetween"),
                     minAllowedDate.ToString(), maxAllowedDate.ToString()));
            }

            return validationStatus;
        }
コード例 #11
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
 private void ValidateDate(DateTime? startDate, DateTime? endDate, ValidationStatus validationStatus)
 {
     DateTime minAllowedDate = Constants.MinAllowedDateTime;
     DateTime maxAllowedDate = Constants.MaxAllowedDateTime;
     if (endDate.HasValue ^ startDate.HasValue)
     {
         validationStatus.AddLocalizedError("ChooseStartAndEndDate");
     }
     else if (endDate.HasValue && startDate.HasValue)
     {
         if (startDate > endDate)
         {
             validationStatus.AddLocalizedError("StartDateMustLessThanEndDate");
         }
         if (startDate < minAllowedDate || startDate > maxAllowedDate)
         {
             validationStatus.AddLocalizedError("StartDateMustBeBetween", minAllowedDate.ToString(), maxAllowedDate.ToString());
         }
         if (endDate < minAllowedDate || endDate > maxAllowedDate)
         {
             validationStatus.AddLocalizedError("EndDateMustBeBetween", minAllowedDate.ToString(), maxAllowedDate.ToString());
         }
     }
 }
コード例 #12
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the theme.
        /// </summary>
        /// <param name="theme">The theme.</param>
        /// <returns></returns>
        public ValidationStatus ValidateTheme(Theme theme)
        {
            ValidationStatus validationStatus = new ValidationStatus();
            var themeType = Converters.ConvertToThemeType(storage.GetThemeType(theme.ThemeTypeRef));

            if (theme.CourseRef <= 0 || (!theme.CourseRef.HasValue && themeType != Enums.ThemeType.TestWithoutCourse))
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("ChooseCourse")));
            }
            if (themeType == Enums.ThemeType.TestWithoutCourse && theme.CourseRef > 0)
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("TestWithoutCourse")));
            }
            if (theme.ThemeTypeRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("ChooseThemeType")));
            }
            if (theme.Name == null || theme.Name == "")
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("NameReqiured")));
            }
            if (theme.Name != null && theme.Name.Length > Constants.MaxStringFieldLength)
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("NameCanNotBeLongerThan"), Constants.MaxStringFieldLength));
            }

            return validationStatus;
        }
コード例 #13
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the theme.
        /// </summary>
        /// <param name="theme">The theme.</param>
        /// <returns></returns>
        public ValidationStatus ValidateTheme(Theme theme)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            if (theme.CourseRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("ChooseCourse")));
            }
            if (theme.ThemeTypeRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("ChooseThemeType")));
            }
            if (theme.Name == null || theme.Name == "")
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("NameReqiured")));
            }
            if (theme.Name != null && theme.Name.Length > Constants.MaxStringFieldLength)
            {
                validationStatus.Errors.Add(String.Format(IUDICO.CurriculumManagement.Localization.getMessage("NameCanNotBeLongerThan"), Constants.MaxStringFieldLength));
            }

            return validationStatus;
        }
コード例 #14
0
ファイル: Validator.cs プロジェクト: supermuk/iudico
        /// <summary>
        /// Validates the discipline assignment.
        /// </summary>
        /// <param name="curriculum">The discipline assignment.</param>
        /// <returns></returns>
        public ValidationStatus ValidateCurriculum(Curriculum curriculum)
        {
            ValidationStatus validationStatus = new ValidationStatus();

            if (curriculum.UserGroupRef <= 0)
            {
                validationStatus.Errors.Add(String.Format(Localization.getMessage("ChooseChapter")));
            }

            return validationStatus;
        }