Ejemplo n.º 1
0
        public async Task <StatusCheck> Get(string ouNetId, string assignmentId, string courseId, string minimumGrade)
        {
            var result = new StatusCheck();
            var assignmentSubmission = await CanvasHelper.GetSubmissionGradeOfAssignmentForUser(ouNetId, assignmentId, courseId);

            if (minimumGrade.IsNumber())
            {
                if (assignmentSubmission.Grade.IsNumber())
                {
                    if (Convert.ToDouble(assignmentSubmission.Grade) >= Convert.ToDouble(minimumGrade))
                    {
                        result.IsComplete      = true;
                        result.PercentComplete = 1.0;
                    }
                }
                else
                {
                    result.IsComplete = false;
                    result.Exception  = new ExceptionMessage()
                    {
                        Message = @"Grade passed in to check was a number, but the grade value for the assignment is not numeric."
                    };
                }
            }
            else if (minimumGrade.IsAlphaGrade())
            {
                if (minimumGrade.CompareAlphaGrades(assignmentSubmission.Grade) >= 0)
                {
                    result.IsComplete      = true;
                    result.PercentComplete = 1.0;
                }
                else
                {
                    result.IsComplete = false;
                }
            }
            else if (assignmentSubmission.Grade.IsPassed())
            {
                result.IsComplete      = true;
                result.PercentComplete = 1.0;
            }

            return(result);
        }