Beispiel #1
0
        public IActionResult OnGet(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var assignment = assignmentRepository.Get(id.Value);

            if (assignment == null)
            {
                return(NotFound());
            }

            ViewModel             = new LecturerTaskResultViewModel(assignment);
            ViewModel.SrcFilePath = storageManager.GetSrcFilePath(assignment.WorkDir);

            var result = ProcessManager.GetProcessResult(assignment.ProcessResultId);

            if (result != null)
            {
                ViewModel.OutputFilePath = result.OutputFilePath;
                ViewModel.LogFilePath    = result.LogFilePath;
                ViewModel.LangName       = GetLangName(result.Condition.Language);

                var resultsText = processResultHelper.GetResultsTexts(result);
                ViewModel.ResultText = resultsText.Item1;
                ViewModel.ErrorText  = resultsText.Item2;
                ViewModel.ErrorDesc  = resultsText.Item3;
            }

            return(Page());
        }
        public IActionResult OnGet(int?id)
        {
            if (!id.HasValue)
            {
                return(NotFound());
            }

            var task = taskRepository.GetTask(id.Value);

            if (task == null)
            {
                return(NotFound());
            }

            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            DetailsViewModel = new StudentTaskDetailsViewModel(task, userId);
            InputViewModel   = new StudentTaskInputViewModel(task.SupportedLanguages);


            var assignee = task.Assignees.FirstOrDefault(x => x.User.Id == userId);

            DetailsViewModel.SrcFilePath = storageManager.GetSrcFilePath(assignee.WorkDir);

            if (!string.IsNullOrEmpty(assignee.ProcessResultId))
            {
                var result = processManager.RetrieveProcessResult(assignee.ProcessResultId);
                if (result != null)
                {
                    DetailsViewModel.OutputFilePath = result.OutputFilePath;
                    DetailsViewModel.LogFilePath    = result.LogFilePath;

                    var resultsText = processResultHelper.GetResultsTexts(result);
                    DetailsViewModel.ResultText = resultsText.Item1;
                    DetailsViewModel.ErrorText  = resultsText.Item2;
                    DetailsViewModel.ErrorDesc  = resultsText.Item3;
                }
            }

            return(Page());
        }