public async Task <IActionResult> CheckMultipleChoiceInputAsync(MultipleChoiceExerciseInputData inputData) { try { ViewData["LastMultipleChoiceInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.SelectedOptions)) { AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:Success"], StatusMessageTypes.Success); return(await RenderAsync()); } catch (Exception ex) { _logger.LogError(ex, "Check multiple choice input"); AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:UnknownError"], StatusMessageTypes.Error); return(await RenderAsync()); } }
public async Task <IActionResult> CheckMultipleChoiceInputAsync(MultipleChoiceExerciseInputData inputData) { try { ViewData["LastMultipleChoiceInput"] = inputData; if (!ModelState.IsValid) { AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:InvalidInput"], StatusMessageTypes.Error); return(await RenderAsync()); } // Check input if (!await CheckInputAsync(inputData.ExerciseId, inputData.SelectedOptions)) { AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:Wrong"], StatusMessageTypes.Error); return(await RenderAsync()); } AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:Success"], StatusMessageTypes.Success); return(await RenderAsync()); } catch (CtfApiException ex) { _logger.LogError(ex, "CTF error"); if (GetAdminMode()) { AddStatusMessage(_localizer["CtfError:Admin"], StatusMessageTypes.Error); AddStatusMessage(ex.FormattedResponseContent ?? "(none)", StatusMessageTypes.Info, true); } else { AddStatusMessage(_localizer["CtfError:Default"], StatusMessageTypes.Error); } return(await RenderAsync()); } catch (Exception ex) { _logger.LogError(ex, "Check multiple choice input"); AddStatusMessage(_localizer["CheckMultipleChoiceInputAsync:UnknownError"], StatusMessageTypes.Error); // Show more details for admins, so they can debug the issue if (GetAdminMode()) { AddStatusMessage(_localizer["ExceptionMessage", ex.Message], StatusMessageTypes.Info); } return(await RenderAsync()); } }