Ejemplo n.º 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);
        }
        public async Task <IActionResult> ValidateChallengeForTeam([FromBody] ChallengeSubmission toValidate)
        {
            try
            {
                await _challengeService.ValidateChallengeForTeamAsync(toValidate.ValidatorId, toValidate.ChallengeId);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok());
        }
        public async Task <IActionResult> SubmitChallengeForValidation([FromBody] ChallengeSubmission toSubmit, [FromHeader] string authorization)
        {
            try
            {
                await _challengeService.SubmitChallengeForValidationAsync(UserUtilities.UserIdFromAuth(authorization), toSubmit.ChallengeId, toSubmit.ProofImage);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok());
        }
 public void SaveChallengeSubmission(ChallengeSubmission submission)
 {
     _dbContext.ChallengeSubmissions.Add(submission);
     _dbContext.SaveChanges();
 }