|
|
@ -1,6 +1,7 @@
|
|
|
|
using Blazor.Models;
|
|
|
|
using Blazor.Models;
|
|
|
|
using Blazor.Services;
|
|
|
|
using Blazor.Services;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
using static Blazor.Pages.Questions.AddQuestion;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Pages.Questions
|
|
|
|
namespace Blazor.Pages.Questions
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -24,13 +25,36 @@ namespace Blazor.Pages.Questions
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public required ILogger<EditQuestion> Logger { get; set; }
|
|
|
|
public required ILogger<EditQuestion> Logger { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var question = await DataService.GetQuestionById(Id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
questionModel = new QuestionModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = question.Id,
|
|
|
|
|
|
|
|
Content = question.Content
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
private async Task HandleValidSubmit()
|
|
|
|
private async Task HandleValidSubmit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await DataService.Update(Id, questionModel);
|
|
|
|
await DataService.Update(Id, questionModel);
|
|
|
|
|
|
|
|
|
|
|
|
var formData = new List<KeyValuePair<string, string>>();
|
|
|
|
var formData = new List<KeyValuePair<string, string>>();
|
|
|
|
formData.Add(new KeyValuePair<string, string>("content", questionModel.Content));
|
|
|
|
formData.Add(new KeyValuePair<string, string>("content", questionModel.Content));
|
|
|
|
|
|
|
|
formData.Add(new KeyValuePair<string, string>("idchapter", questionModel.IdChapter.ToString()));
|
|
|
|
|
|
|
|
//foreach (var answerModel in answerModels)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// var answercontent = $"answerContent{answerModel.Id + 1}";
|
|
|
|
|
|
|
|
// formData.Add(new KeyValuePair<string, string>(answercontent, answerModel.Content));
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//foreach (var checkbox in checkboxs)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// if (checkbox.IsCorrect != false)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// var idgood = checkbox.Id + 1;
|
|
|
|
|
|
|
|
// formData.Add(new KeyValuePair<string, string>("idanswergood", idgood.ToString()));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
var formContent = new FormUrlEncodedContent(formData);
|
|
|
|
var formContent = new FormUrlEncodedContent(formData);
|
|
|
|
|
|
|
|
|
|
|
|