public IActionResult OnGet(int?id) { if (!id.HasValue) { return(NotFound()); } var task = taskRepository.GetTask(id.Value); if (task == null) { return(NotFound()); } ViewModel = new TaskDetailModel { Id = task.TournamentTaskId, Desc = task.Desc, DueDate = task.DueDate, CreatedAt = task.CreatedAt, LecturerFullName = task.Owner.FirstName + " " + task.Owner.SecondName, Name = task.Name, InputFilePath = task.InputFilePath, MaxAttempts = task.MaxAttempt, Langs = task.SupportedLanguages, ExpectedFilePath = task.ExpectedFilePath }; List <AssigneesViewModel> assignees = new List <AssigneesViewModel>(); if (task.Assignees != null) { foreach (var item in task.Assignees) { assignees.Add(new AssigneesViewModel { Id = item.Id, FirstName = item.User.FirstName, SecondName = item.User.SecondName, Passed = item.IsPassed, LastAttemptAt = item.LastAttemptedAt }); } } if (task.SupportedLanguages == null) { ViewModel.Langs = new List <SupportedProgrammingLanguage>(); } ViewModel.Students = assignees; 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()); }
public IActionResult OnGet(int?id) { if (!id.HasValue) { return(NotFound()); } var task = taskRepository.GetTask(id.Value); if (task == null) { return(NotFound()); } ViewModel = new TaskEditViewModel { Id = task.TournamentTaskId, Desc = task.Desc, DueDate = task.DueDate, CreatedAt = task.CreatedAt, LecturerName = task.Owner.FirstName + " " + task.Owner.SecondName, MaxAttempts = task.MaxAttempt, Name = task.Name, InputFilePath = task.InputFilePath, ExpectedFilePath = task.ExpectedFilePath }; var tournamentStudents = userRepository.GetStudentsWithTournament(task.Tournament.TournamentId); var allLanguages = languageRepository.GetAll(); var allStudents = new List <StudentViewModel>(); if (tournamentStudents != null) { foreach (var item in tournamentStudents) { allStudents.Add(new StudentViewModel { Id = item.Id, FirstName = item.FirstName, SecondName = item.SecondName }); } } var studentsId = new List <string>(); var languagesId = new List <int>(); if (task.SupportedLanguages != null && task.SupportedLanguages.Count() != 0) { foreach (var item in task.SupportedLanguages) { languagesId.Add(item.SupportedProgrammingLanguageId); } } if (task.Assignees != null && task.Assignees.Count() != 0) { foreach (var item in task.Assignees) { studentsId.Add(item.User.Id); } } ViewModel.LanguagesSelectList = new MultiSelectList(allLanguages, "SupportedProgrammingLanguageId", "Name", languagesId); ViewModel.StudentsSelectList = new MultiSelectList(allStudents, "Id", "FullName", studentsId); return(Page()); }