public async Task GradeSubmissionAsync_AllBlanksCorrect_FullCredit()
		{
			var question = new ShortAnswerQuestion()
			{
				Blanks = Collections.CreateList
				(
					new ShortAnswerQuestionBlank() { Name = "A", Answer = "One" },
					new ShortAnswerQuestionBlank() { Name = "B", Answer = "Two" }
				)
			};

			var submission = new ShortAnswerQuestionSubmission()
			{
				Blanks = Collections.CreateList
				(
					new SubmissionBlank() { Name = "A", Answer = "One" },
					new SubmissionBlank() { Name = "B", Answer = "Two" }
				)
			};

			var grader = new ShortAnswerQuestionGrader(question);
			var result = await grader.GradeSubmissionAsync(submission);

			Assert.Equal(new[] { true, true }, ((ShortAnswerQuestionResult)result.Result).Correct);
			Assert.Equal(1.0, result.Score);
		}
		public async Task GradeSubmissionAsync_SomeBlanksIncorrect_NoCredit()
		{
			var question = new ShortAnswerQuestion()
			{
				AllowPartialCredit = false,
				Blanks = Collections.CreateList
				(
					new ShortAnswerQuestionBlank() { Name = "A", Answer = "One" },
					new ShortAnswerQuestionBlank() { Name = "B", Answer = "Two" }
				)
			};

			var submission = new ShortAnswerQuestionSubmission()
			{
				Blanks = Collections.CreateList
				(
					new SubmissionBlank() { Name = "A", Answer = "One" },
					new SubmissionBlank() { Name = "B", Answer = "Wrong" }
				)
			};

			var grader = new ShortAnswerQuestionGrader(question);
			var result = await grader.GradeSubmissionAsync(submission);

			Assert.Equal(new[] { true, false }, ((ShortAnswerQuestionResult)result.Result).Correct);
			Assert.Equal(0.0, result.Score);
		}
        public async Task GradeSubmissionAsync_BlankNamesContainCarriageReturns_ParsedCorrectly()
        {
            var question = new ShortAnswerQuestion()
            {
                Blanks = Collections.CreateList
                         (
                    new ShortAnswerQuestionBlank()
                {
                    Name = "A\n", Answer = "One"
                }
                         )
            };

            var submission = new ShortAnswerQuestionSubmission()
            {
                Blanks = Collections.CreateList
                         (
                    new SubmissionBlank()
                {
                    Name = "A\r\n", Answer = "One"
                }
                         )
            };

            var grader = new ShortAnswerQuestionGrader(question);
            var result = await grader.GradeSubmissionAsync(submission);

            Assert.Equal(new[] { true }, ((ShortAnswerQuestionResult)result.Result).Correct);
            Assert.Equal(1.0, result.Score);
        }
예제 #4
0
        public async Task GradeSubmissionAsync_SomeBlanksIncorrect_NoCredit()
        {
            var question = new ShortAnswerQuestion()
            {
                AllowPartialCredit = false,
                Blanks             = Collections.CreateList
                                     (
                    new ShortAnswerQuestionBlank()
                {
                    Name = "A", Answer = "One"
                },
                    new ShortAnswerQuestionBlank()
                {
                    Name = "B", Answer = "Two"
                }
                                     )
            };

            var submission = new ShortAnswerQuestionSubmission()
            {
                Blanks = Collections.CreateList
                         (
                    new SubmissionBlank()
                {
                    Name = "A", Answer = "One"
                },
                    new SubmissionBlank()
                {
                    Name = "B", Answer = "Wrong"
                }
                         )
            };

            var grader = new ShortAnswerQuestionGrader(question);
            var result = await grader.GradeSubmissionAsync(submission);

            Assert.Equal(new[] { true, false }, ((ShortAnswerQuestionResult)result.Result).Correct);
            Assert.Equal(0.0, result.Score);
        }
예제 #5
0
        public async Task GradeSubmissionAsync_AllBlanksCorrect_FullCredit()
        {
            var question = new ShortAnswerQuestion()
            {
                Blanks = Collections.CreateList
                         (
                    new ShortAnswerQuestionBlank()
                {
                    Name = "A", Answer = "One"
                },
                    new ShortAnswerQuestionBlank()
                {
                    Name = "B", Answer = "Two"
                }
                         )
            };

            var submission = new ShortAnswerQuestionSubmission()
            {
                Blanks = Collections.CreateList
                         (
                    new SubmissionBlank()
                {
                    Name = "A", Answer = "One"
                },
                    new SubmissionBlank()
                {
                    Name = "B", Answer = "Two"
                }
                         )
            };

            var grader = new ShortAnswerQuestionGrader(question);
            var result = await grader.GradeSubmissionAsync(submission);

            Assert.Equal(new[] { true, true }, ((ShortAnswerQuestionResult)result.Result).Correct);
            Assert.Equal(1.0, result.Score);
        }