Multiplayer_Php
Yvan CALATAYUD 1 year ago
commit b43bc329e0

@ -21,7 +21,6 @@ namespace Blazor.Pages.Admins
[Inject]
public required ILogger<AddAdministrator> Logger { get; set; }
private async Task HandleValidSubmit()
{
if (administratorModel != null)

@ -42,6 +42,8 @@ namespace Blazor.Pages.Questions
public Checkbox(int id, bool isCorrect) { Id = id; IsCorrect = isCorrect; }
}
public int IdAgood { get; set; }
protected override async Task OnInitializedAsync()
{
var response = Http.GetFromJsonAsync<Chapter[]>(API.API_URL + "chapters/" + API.TOKEN).Result;
@ -75,6 +77,7 @@ namespace Blazor.Pages.Questions
if (checkbox.IsCorrect != false)
{
var idgood = checkbox.Id + 1;
IdAgood = idgood;
formData.Add(new KeyValuePair<string, string>("idanswergood", idgood.ToString()));
}
}
@ -97,6 +100,8 @@ namespace Blazor.Pages.Questions
}
}
Logger.LogInformation("Question '{questionContent}' added for Chapter '{chapterId}' with 4 answers : '{IdAnswer1}':'{AnswerContent1}', '{IdAnswer2}':'{AnswerContent2}' , '{IdAnswer3}':'{AnswerContent3}' , '{IdAnswer4}':'{AnswerContent4}' and the correct '{IdAnswerGood}' ", questionModel.Content, questionModel.IdChapter, answerModels[0].Id+1, answerModels[0].Content, answerModels[1].Id+1,answerModels[1].Content, answerModels[2].Id + 1, answerModels[2].Content, answerModels[3].Id + 1, answerModels[3].Content, IdAgood);
NavigationManager.NavigateTo("questions");
}
}

@ -1,4 +1,5 @@
using Blazor.Models;
using Blazor.Pages.Admins;
using Blazor.Services;
using Blazor.ViewClasses;
using Microsoft.AspNetCore.Components;
@ -44,6 +45,12 @@ namespace Blazor.Pages.Questions
[Inject]
public required ILogger<EditQuestion> Logger { get; set; }
private string OldQuestionContent { get; set; }
private int OldQuestionIdChapter { get; set; }
private int OldIdAnswerGood { get; set; }
public int IdAgood { get; set; }
protected override async Task OnInitializedAsync()
{
var response = Http.GetFromJsonAsync<Chapter[]>(API.API_URL + "chapters/" + API.TOKEN).Result;
@ -65,6 +72,7 @@ namespace Blazor.Pages.Questions
checkboxs.Add(new Checkbox(q.A_id,false));
}
foreach (var checkbox in checkboxs)
{
if (question.IdAnswerGood == checkbox.Id)
@ -72,7 +80,9 @@ namespace Blazor.Pages.Questions
checkbox.IsCorrect = true;
}
}
OldQuestionContent = question.Content;
OldQuestionIdChapter = question.IdChapter;
OldIdAnswerGood = question.IdAnswerGood;
}
private async Task HandleValidSubmit()
{
@ -90,6 +100,7 @@ namespace Blazor.Pages.Questions
{
if (checkbox.IsCorrect == true)
{
IdAgood = checkbox.Id;
formData.Add(new KeyValuePair<string, string>("idanswergood", checkbox.Id.ToString()));
}
}
@ -111,6 +122,9 @@ namespace Blazor.Pages.Questions
var errorResponse = await response.Content.ReadAsStringAsync();
}
}
Logger.LogInformation("Question '{OldQuestionContent}', Chapter '{OldchapterId}' and the correct answer '{OldIdAnswerGood}' edited in '{NewQuestionContent}' for Chapter '{NewchapterId}' with 4 answers : '{IdAnswer1}':'{NewAnswerContent1}', '{IdAnswer2}':'{NewAnswerContent2}', '{IdAnswer3}':'{NewAnswerContent3}', '{IdAnswer4}':'{NewAnswerContent4}' the correct '{IdAnswerGood}'", OldQuestionContent, OldQuestionIdChapter,OldIdAnswerGood, question.Content, question.IdChapter, answers[0].Id, answers[0].Content, answers[1].Id, answers[1].Content, answers[2].Id, answers[2].Content, answers[3].Id, answers[3].Content,IdAgood);
NavigationManager.NavigateTo("questions");
}

Loading…
Cancel
Save