Example #1
0
        public ChallengeEvaluation EvaluateChallenge(ChallengeSubmission submission)
        {
            Challenge challenge = _learningObjectRepository.GetChallenge(submission.ChallengeId);

            if (!IsLearningObjectInLearnersCourses(challenge, submission.LearnerId))
            {
                throw new LearnerNotEnrolledInCourse(submission.LearnerId);
            }

            if (challenge == null)
            {
                return(null);
            }

            //var tester = new WorkspaceFunctionalityTester(_submissionRepository.GetWorkspacePath(submission.LearnerId));
            var evaluation = challenge.CheckChallengeFulfillment(submission.SourceCode, null);

            if (evaluation.ChallengeCompleted)
            {
                submission.MarkCorrect();
            }
            _submissionRepository.SaveChallengeSubmission(submission);

            //TODO: Tie in with Instructor and handle learnerId to get suitable LO for LO summaries.
            evaluation.ApplicableLOs =
                _learningObjectRepository.GetFirstLearningObjectsForSummaries(
                    evaluation.ApplicableHints.GetDistinctLearningObjectSummaries());
            evaluation.SolutionLO = _learningObjectRepository.GetLearningObjectForSummary(challenge.Solution.Id);

            return(evaluation);
        }
Example #2
0
        public void Evaluates_solution_submission(string[] submissionAttempt, List <ChallengeHint> expectedHints, bool expectedCompletion)
        {
            //TODO: Readonly lists
            var challenge = new Challenge(1, 1, new List <ChallengeFulfillmentStrategy>
            {
                new BasicNameChecker(null, new List <string> {
                    "Payment", "PaymentService", "compensation"
                }, new ChallengeHint(11)),
                new BasicNameChecker(new List <string> {
                    "Class", "List", "Method"
                }, null, new ChallengeHint(21))
            });

            var challengeEvaluation = challenge.CheckChallengeFulfillment(submissionAttempt, null);
            var actualHints         = challengeEvaluation.ApplicableHints.GetHints();

            actualHints.Count.ShouldBe(expectedHints.Count);
            actualHints.All(expectedHints.Contains).ShouldBeTrue();
            challengeEvaluation.ChallengeCompleted.ShouldBe(expectedCompletion);
        }