public StudentAssessment Build(EnterResultsStudentModel enterResultsStudentModel, Data.Entities.Assessment assessment)
        {
            var target = new StudentAssessment
            {
                StudentUSI = enterResultsStudentModel.StudentUsi,
                AssessmentTitle = assessment.AssessmentTitle,
                AcademicSubjectDescriptorId = assessment.AcademicSubjectDescriptorId,
                AssessedGradeLevelDescriptorId = assessment.AssessedGradeLevelDescriptorId,
                Version = assessment.Version,
                AdministrationDate = assessment.AdministeredDate
            };

            var studentAssessmentScoreResult =
                _enterResultsStudentModelToStudentAssessmentScoreResultMapper.Build(enterResultsStudentModel, assessment);
            target.StudentAssessmentScoreResults.Add(studentAssessmentScoreResult);

            return target;
        }
        private string GetPerformanceLevel(StudentAssessment studentAssessment)
        {
            var studentScore = Convert.ToDecimal(studentAssessment.StudentAssessmentScoreResults.First().Result);

            var assessmentPerformanceLevels = studentAssessment.Assessment.AssessmentPerformanceLevels.ToList();
            var sortedPerformanceLevels = assessmentPerformanceLevels.OrderByDescending(apl => Convert.ToDecimal(apl.MinimumScore));

            var studentPerformanceLevel = sortedPerformanceLevels.FirstOrDefault(pl => studentScore >= Convert.ToDecimal(pl.MinimumScore));

            var result = PerformanceLevelDescriptorEnum.NotMastered;

            if (studentPerformanceLevel != null)
            {
                result = ((PerformanceLevelDescriptorEnum) studentPerformanceLevel.PerformanceLevelDescriptorId);
            }

            return result.Humanize();
        }
        private AssessmentResultRowModel CreateAssessmentResultRow(StudentAssessment studentAssessment, DateTime startDate, DateTime endDate)
        {
            var results = new List<string>();

            while (startDate <= endDate)
            {
                if (studentAssessment.AdministrationDate == startDate)
                {
                    var result = GetPerformanceLevel(studentAssessment);
                    results.Add(result);
                }
                else
                {
                    results.Add(string.Empty);
                }
                startDate = startDate.AddDays(1);
            }

            var assessment = studentAssessment.Assessment;

            var commonCoreStandard = assessment.AssessmentLearningStandards.First().LearningStandard.Description;
            var sectionCode = assessment.AssessmentSections.First().Section.UniqueSectionCode;
            var grade = studentAssessment.StudentAssessmentScoreResults.First().Result;
            var assessmentTitle = assessment.AssessmentTitle;
            var date = studentAssessment.AdministrationDate;

            var assessmentCategoryType = _genericRepository.Get<AssessmentCategoryType>(act => act.AssessmentCategoryTypeId == assessment.AssessmentCategoryTypeId);

            return new AssessmentResultRowModel
            {
                CommonCoreStandard = commonCoreStandard,
                SectionCode = sectionCode,
                Results = results,
                Grade = grade,
                AssessmentTitle = assessmentTitle,
                Date = date,
                AssessmentTypeDescription = assessmentCategoryType.ShortDescription
            };
        }
 public void SaveStudentAssessment(StudentAssessment studentAssessment)
 {
     DbContext.Set<StudentAssessment>().Add(studentAssessment);
     DbContext.Set<StudentAssessmentScoreResult>().Add(studentAssessment.StudentAssessmentScoreResults.First());
 }