Esempio n. 1
0
        public IActionResult Questions(string participantID, string testName, string obscuredIndexesCommaDelimited)
        {
            var obscuredIndexes = _commaDelimitedIntegersCollector.Collect(obscuredIndexesCommaDelimited);
            var sessionMeta     = _sessionMetaRepository.Get(participantID, testName);
            var phaseSets       = _phaseSetsGetter.Get(participantID);
            var testImages      = ((IEnumerable <string>)(phaseSets.GetType().GetProperty(testName) ?? throw new Exception("Unexpected phase name.")).GetValue(phaseSets)).ToList();
            var obscuredImages  = obscuredIndexes.Select(x => testImages[x]);

            _obscuredImagesRepository.Save(participantID, testName, obscuredImages);
            _sessionMetaRepository.Save(sessionMeta);
            return(View(new TestQuestionsViewModel(participantID, testName)));
        }
Esempio n. 2
0
        public IActionResult RecordResults(string participantID, string neglectedIndexesCommaDelimited, string obscuredIndexesCommaDelimited)
        {
            var neglectedIndexes = _commaDelimitedIntegersCollector.Collect(neglectedIndexesCommaDelimited);
            var obscuredIndexes  = _commaDelimitedIntegersCollector.Collect(obscuredIndexesCommaDelimited);
            var sessionMeta      = _sessionMetaRepository.Get(participantID, "Encoding");
            var phaseSets        = _phaseSetsGetter.Get(participantID);
            var neglectedImages  = neglectedIndexes.Select(x => phaseSets.Encoding.ElementAt(x)).ToList();
            var obscuredImages   = obscuredIndexes.Select(x => phaseSets.Encoding.ElementAt(x)).ToList();

            sessionMeta.FinishedWhenUtc = DateTime.UtcNow;
            _sessionMetaRepository.Save(sessionMeta);
            _neglectedImagesRepository.Save(participantID, "Encoding", neglectedImages);
            _obscuredImagesRepository.Save(participantID, "Encoding", obscuredImages);
            var nextAction = neglectedImages.Any() || obscuredImages.Any() ? Url.Action(nameof(Questions)) : Url.Action(nameof(Finished));

            return(Json(new { success = true, nextAction }));
        }