Ejemplo n.º 1
0
        public static IList <StandardGradingViewData> Create(IList <GradingStandardInfo> gradingStandards, IList <int> studentIds)
        {
            var gradigDic = gradingStandards.GroupBy(x => x.Standard.Id).ToDictionary(x => x.Key, x => x.ToList());
            var res       = new List <StandardGradingViewData>();

            foreach (var kv in gradigDic)
            {
                var gradingSt       = kv.Value.First();
                var standardGrading = new StandardGradingViewData
                {
                    Standard   = StandardViewData.Create(gradingSt.Standard),
                    NumericAvg = (int?)kv.Value.Average(x => x.NumericGrade),
                    Items      = new List <StandardGradingItemViewData>()
                };
                res.Add(standardGrading);
                foreach (var studentId in studentIds)
                {
                    var gradingInfo = kv.Value.FirstOrDefault(x => x.StudentId == studentId);
                    if (gradingInfo != null)
                    {
                        standardGrading.Items.Add(StandardGradingItemViewData.Create(gradingInfo));
                    }
                }
            }
            return(res);
        }
Ejemplo n.º 2
0
        public static StandardGradingItemViewData Create(GradingStandardInfo gradingStandard)
        {
            var res = new StandardGradingItemViewData
            {
                StudentId       = gradingStandard.StudentId,
                GradeId         = gradingStandard.AlphaGradeId,
                GradeValue      = gradingStandard.AlphaGradeName,
                StandardId      = gradingStandard.Standard.Id,
                GradingPeriodId = gradingStandard.GradingPeriodId,
                ClassId         = gradingStandard.ClassId,
                Comment         = gradingStandard.Note
            };

            if (string.IsNullOrEmpty(res.GradeValue) && gradingStandard.NumericGrade.HasValue)
            {
                res.GradeValue = gradingStandard.NumericGrade.Value.ToString();
            }
            res.NumericGrade = gradingStandard.NumericGrade;
            return(res);
        }