12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- @using HyperCube.Models
- @using Console = HyperCube.Utils.AdvConsole
- <div class="modal" tabindex="-1" role="dialog" style="display:none" id="@elementid">
- <div class="modal-container">
- <div class="modal__body">
- <div class="modal__body__header modal__body__header_noflex">
- <div class="modal__qual__header">
- <p class="modal__qual__header">Квалификация</p>
- </div>
- </div>
- <div class="modal__body__container modal__body__container_aligncenter">
- <div class="modal__body__container__left modal__body__container__left_blackborder">
- <p class="modal__qual__info">Здравствуй, @_userName</p>
- <p class="modal__qual__info">Что бы участвовать в Цифровом хакатоне вам необходимо ответить на вопросы теста.</p>
- <p class="modal__qual__info">Всего вопросов будет @_survey.SurveyItems.Count. И твои ответы сформируют уникальную
- матрицу компетенций, которая и определит твою роль в Цифровом хакатоне.</p>
- <p class="modal__qual__info">Правила найдешь в библиотеке.</p>
- </div>
- <div class="modal__body__container__right modal__body__container__right_blackborder">
- @if (_survey.SurveyItems.Count > 0)
- {
- <div class="modal__qual__question">
- Вопрос №@_currentQuestionPosition<br>
- @_survey.SurveyItems[_currentQuestionID].Text
- @foreach (var option in _survey.SurveyItems[_currentQuestionID].SurveyItemOptionsSorted)
- {
- <div>
- @(PositionToLetter(option.Value.Position)): @(option.Value.Text)
- </div>
- }
- </div>
- <div class="modal__qual__button">
- <div class="modal__qual__button__box">
- <button class="modal__qual__button__box__item" @onclick="(() => Answer(1))">А</button>
- <button class="modal__qual__button__box__item" @onclick="(() => Answer(2))">Б</button>
- <button class="modal__qual__button__box__item" @onclick="(() => Answer(3))">В</button>
- </div>
- @*<button class="modal__qual__button__item">Не знаю</button>*@
- </div>
- }
- </div>
- </div>
- </div>
- <a class="modal_close" style="cursor:pointer" @onclick="@Close">✖</a>
- </div>
- </div>
- @code {
- [Inject]
- public IJSRuntime JsRuntime { get; set; }
- [Parameter]
- public RenderFragment Title { get; set; }
- string elementid = "modal_survey";
- string _userName = "[UNKNOWN_USERNAME]";
- Survey _survey = new();
- int _currentQuestionPosition = 1;
- int _currentQuestionID = 1;
- public async Task Open(string userName, int eventID)
- {
- _userName = userName;
- await _survey.LoadByEventID(eventID);
- _currentQuestionID = _survey.SurveyItemsSorted.FirstOrDefault(i => i.Value.Position == _currentQuestionPosition).Key;
- await JsRuntime.InvokeVoidAsync("OpenModal", elementid);
- }
- public void Close() => JsRuntime.InvokeVoidAsync("CloseModal", elementid);
- void Answer(int position)
- {
- _survey.SurveyItems[_currentQuestionID].AnswerID = _survey.SurveyItems[_currentQuestionID].SurveyItemOptionsSorted.FirstOrDefault(o => o.Value.Position == position).Key;
- Console.WriteLine($"AnswerID: {_survey.SurveyItems[_currentQuestionID].AnswerID}.");
- if (_currentQuestionPosition < _survey.SurveyItems.Count)
- {
- _currentQuestionPosition++;
- _currentQuestionID = _survey.SurveyItemsSorted.FirstOrDefault(i => i.Value.Position == _currentQuestionPosition).Key;
- }
- else
- Close();
- }
- string PositionToLetter(int position)
- {
- char character = Char.Parse("А");
- return ((char)(position - 1 + character)).ToString();
- }
- }
|