Beispiel #1
0
        public static ChalkableStudentAverageComment Create(StudentAverageComment stcomment)
        {
            var res = new ChalkableStudentAverageComment
            {
                AverageId      = stcomment.StudentId,
                HeaderId       = stcomment.HeaderId,
                HeaderSequence = stcomment.HeaderSequence,
                HeaderText     = stcomment.HeaderText,
            };

            if (stcomment.CommentId.HasValue)
            {
                res.GradingComment = new GradingComment
                {
                    Id      = stcomment.CommentId.Value,
                    Code    = stcomment.CommentCode,
                    Comment = stcomment.CommentText
                };
            }
            return(res);
        }
Beispiel #2
0
        public ChalkableStudentAverage UpdateStudentAverage(int classId, int studentId, int averageId, int?gradingPeriodId, string averageValue, bool exempt, IList <ChalkableStudentAverageComment> comments, string note)
        {
            var studentAverage = new StudentAverage
            {
                AverageId           = averageId,
                StudentId           = studentId,
                GradingPeriodId     = gradingPeriodId,
                EnteredAverageValue = averageValue,
                Exempt = exempt
            };

            if (comments != null)
            {
                studentAverage.Comments = new List <StudentAverageComment>();
                foreach (var comment in comments)
                {
                    var stAvgComment = new StudentAverageComment
                    {
                        AverageId      = averageId,
                        StudentId      = studentId,
                        HeaderId       = comment.HeaderId,
                        HeaderText     = comment.HeaderText,
                        HeaderSequence = comment.HeaderSequence,
                    };
                    if (comment.GradingComment != null)
                    {
                        stAvgComment.CommentId   = comment.GradingComment.Id;
                        stAvgComment.CommentCode = comment.GradingComment.Code;
                        stAvgComment.CommentText = comment.GradingComment.Comment;
                    }
                    studentAverage.Comments.Add(stAvgComment);
                }
            }
            if (note != null)
            {
                studentAverage.ReportCardNote = note;
            }
            studentAverage = ConnectorLocator.GradebookConnector.UpdateStudentAverage(classId, studentAverage);
            return(ChalkableStudentAverage.Create(studentAverage));
        }
Beispiel #3
0
        public ChalkableStudentAverage UpdateStudentAverage(int classId, int studentId, int averageId, int?gradingPeriodId, string averageValue, bool exempt, IList <ChalkableStudentAverageComment> comments, string note)
        {
            var studentAverage = new StudentAverage
            {
                AverageId              = averageId,
                StudentId              = studentId,
                GradingPeriodId        = gradingPeriodId,
                EnteredAverageValue    = averageValue,
                SectionId              = classId,
                IsGradingPeriodAverage = true
            };

            decimal numericScore = -1;
            var     isAlphaGrade = !decimal.TryParse(averageValue, out numericScore);

            if (isAlphaGrade)
            {
                var alphaGrade = ServiceLocator.AlphaGradeService.GetAlphaGrades().FirstOrDefault(x => x.Name.ToLowerInvariant() == averageValue);
                if (alphaGrade != null)
                {
                    var gradingScaleRange = ((DemoGradingScaleService)ServiceLocator.GradingScaleService).GetByAlphaGradeId(alphaGrade.Id);

                    if (gradingScaleRange != null)
                    {
                        numericScore = gradingScaleRange.AveragingEquivalent;
                    }

                    studentAverage.EnteredAlphaGradeId      = alphaGrade.Id;
                    studentAverage.EnteredAlphaGradeName    = alphaGrade.Name;
                    studentAverage.CalculatedAlphaGradeId   = alphaGrade.Id;
                    studentAverage.CalculatedAlphaGradeName = alphaGrade.Name;
                }
            }

            studentAverage.EnteredNumericAverage    = numericScore;
            studentAverage.CalculatedNumericAverage = numericScore;

            if (comments != null)
            {
                studentAverage.Comments = new List <StudentAverageComment>();
                foreach (var comment in comments)
                {
                    var stAvgComment = new StudentAverageComment
                    {
                        AverageId      = averageId,
                        StudentId      = studentId,
                        HeaderId       = comment.HeaderId,
                        HeaderText     = comment.HeaderText,
                        HeaderSequence = comment.HeaderSequence,
                    };
                    if (comment.GradingComment != null)
                    {
                        stAvgComment.CommentId   = comment.GradingComment.Id;
                        stAvgComment.CommentCode = comment.GradingComment.Code;
                        stAvgComment.CommentText = comment.GradingComment.Comment;
                    }
                    studentAverage.Comments.Add(stAvgComment);
                }
            }
            if (note != null)
            {
                studentAverage.ReportCardNote = note;
            }
            studentAverage = UpdateStudentAverage(studentAverage);
            return(ChalkableStudentAverage.Create(studentAverage));
        }