重构项目结构,移除Assignment相关功能,优化Submission模块
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
@using Entities.DTO
|
||||
@using Entities.Contracts
|
||||
@using Newtonsoft.Json
|
||||
@using TechHelper.Client.Exam
|
||||
@using TechHelper.Client.Pages.Exam.QuestionCard
|
||||
|
||||
|
||||
<MudPaper Elevation="0" Class="rounded-xl" Style="background-color: transparent">
|
||||
@* <MudText>@AssignmentQuestion.Id</MudText> *@
|
||||
<MudPaper Class="ma-4 pa-5 rounded-xl">
|
||||
<MudText Class="mt-3" Typo="Typo.button"><b>包裹器属性</b></MudText>
|
||||
<MudTextField @bind-Value="AssignmentQuestion.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
|
||||
<MudTextField @bind-Value="AssignmentQuestion.Index" Label="Index" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
||||
<MudTextField @bind-Value="AssignmentQuestion.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
||||
<MudChipSet T="AssignmentStructType" SelectedValue="AssignmentQuestion.StructType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleSelectedValueChanged">
|
||||
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Root">@AssignmentStructType.Root</MudChip>
|
||||
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Struct">@AssignmentStructType.Struct</MudChip>
|
||||
<MudChip Text="purple" Color="Color.Primary" Value="@AssignmentStructType.Group">@AssignmentStructType.Group</MudChip>
|
||||
<MudChip Text="blue" Color="Color.Info" Value="@AssignmentStructType.Question">@AssignmentStructType.Question</MudChip>
|
||||
<MudChip Text="green" Color="Color.Warning" Value="@AssignmentStructType.SubQuestion">@AssignmentStructType.SubQuestion</MudChip>
|
||||
<MudChip Text="orange" Color="Color.Error" Value="@AssignmentStructType.Option">@AssignmentStructType.Option</MudChip>
|
||||
</MudChipSet>
|
||||
|
||||
|
||||
<MudChipSet T="string" SelectedValue="@AssignmentQuestion.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
|
||||
|
||||
@foreach (var item in QuestionTypes)
|
||||
{
|
||||
var qt = item;
|
||||
@* Style = "@($"background - color:{ item.Value.Color} ")"*@
|
||||
|
||||
<MudChip Style="@(qt.Key == AssignmentQuestion.QType ?
|
||||
$"background-color:#ffffff; color:{item.Value.Color}" :
|
||||
$"background-color:{item.Value.Color}; color:#ffffff")"
|
||||
Value="@item.Key">
|
||||
@item.Value.DisplayName
|
||||
</MudChip>
|
||||
}
|
||||
</MudChipSet>
|
||||
</MudPaper>
|
||||
@if (AssignmentQuestion.Question != null)
|
||||
{
|
||||
<QuestionEdit Question="AssignmentQuestion.Question" />
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public AssignmentQuestionDto AssignmentQuestion { get; set; } = new AssignmentQuestionDto();
|
||||
public QuestionDto TempQuesdto;
|
||||
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
||||
|
||||
[Inject]
|
||||
private ILocalStorageService LocalStorageService { get; set; }
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
if (AssignmentQuestion.Question != null)
|
||||
{
|
||||
TempQuesdto = AssignmentQuestion.Question;
|
||||
}
|
||||
|
||||
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
||||
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
||||
if(GlobalInfo != null)
|
||||
{
|
||||
QuestionTypes = GlobalInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleQTSelectedValueChanged(string type)
|
||||
{
|
||||
AssignmentQuestion.QType = type;
|
||||
if (AssignmentQuestion.ChildrenAssignmentQuestion.Count > 0 && AssignmentQuestion.StructType == AssignmentStructType.Group)
|
||||
{
|
||||
foreach (var item in AssignmentQuestion.ChildrenAssignmentQuestion)
|
||||
{
|
||||
item.QType = type;
|
||||
if (item.Question != null)
|
||||
{
|
||||
item.Question.QType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void HandleSelectedValueChanged(AssignmentStructType type)
|
||||
{
|
||||
AssignmentQuestion.StructType = type;
|
||||
if (type != AssignmentStructType.Question && AssignmentQuestion.Question != null)
|
||||
{
|
||||
AssignmentQuestion.Title = AssignmentQuestion.Question.Title;
|
||||
AssignmentQuestion.Question = null;
|
||||
}
|
||||
|
||||
if (type == AssignmentStructType.Question && AssignmentQuestion.Question == null)
|
||||
{
|
||||
if (TempQuesdto != null)
|
||||
{
|
||||
AssignmentQuestion.Question = TempQuesdto;
|
||||
if (AssignmentQuestion.Title == AssignmentQuestion.Question.Title)
|
||||
{
|
||||
AssignmentQuestion.Title = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
AssignmentQuestion.Question = new QuestionDto { };
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,9 @@ else if (_questionsForTable.Any() && _students.Any())
|
||||
@student.DisplayName: <MudText Typo="Typo.h5" Color="Color.Primary" Class="d-inline-block ml-2">@GetStudentTotalScore(student.Id)</MudText>
|
||||
</MudText>
|
||||
}
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Class="mt-4" @onclick="SubmitGrading">
|
||||
@* <MudButton Variant="Variant.Filled" Color="Color.Success" Class="mt-4" @onclick="SubmitGrading">
|
||||
提交批改结果 (模拟)
|
||||
</MudButton>
|
||||
</MudButton> *@
|
||||
</MudPaper>
|
||||
|
||||
}
|
||||
@@ -86,10 +86,10 @@ else
|
||||
private NavigationManager Navigation { get; set; }
|
||||
|
||||
private MudTable<QuestionRowData> _table = new();
|
||||
private AssignmentDto Assignment { get; set; } = new AssignmentDto();
|
||||
private ExamDto Assignment { get; set; } = new ExamDto();
|
||||
private AssignmentCheckData _examStruct = new AssignmentCheckData();
|
||||
|
||||
private List<StudentDto> _students = new List<StudentDto>();
|
||||
private List<UserListDto> _students = new List<UserListDto>();
|
||||
private List<QuestionRowData> _questionsForTable = new List<QuestionRowData>();
|
||||
|
||||
private bool _isLoading = true;
|
||||
@@ -99,14 +99,14 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_isLoading = true;
|
||||
await LoadExamData();
|
||||
// _isLoading = true;
|
||||
// await LoadExamData();
|
||||
|
||||
var result = await ClassServices.GetClassStudents();
|
||||
if (!result.Status) Snackbar.Add($"获取学生失败, {result.Message}", Severity.Error);
|
||||
_students = result.Result as List<StudentDto> ?? new List<StudentDto>();
|
||||
BuildTable();
|
||||
_isLoading = false;
|
||||
// var result = await ClassServices.GetClassStudents();
|
||||
// if (!result.Status) Snackbar.Add($"获取学生失败, {result.Message}", Severity.Error);
|
||||
// _students = result.Result as List<StudentDto> ?? new List<StudentDto>();
|
||||
// BuildTable();
|
||||
// _isLoading = false;
|
||||
}
|
||||
|
||||
private void BuildTable()
|
||||
@@ -135,7 +135,7 @@ else
|
||||
var result = await ExamService.GetExam(parsedExamId);
|
||||
if (result.Status)
|
||||
{
|
||||
Assignment = result.Result as AssignmentDto ?? new AssignmentDto();
|
||||
Assignment = result.Result as ExamDto ?? new ExamDto();
|
||||
_examStruct = Assignment.GetStruct();
|
||||
}
|
||||
else
|
||||
@@ -188,52 +188,52 @@ else
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SubmitGrading()
|
||||
{
|
||||
// private void SubmitGrading()
|
||||
// {
|
||||
|
||||
List<SubmissionDto> submissionDto = new List<SubmissionDto>();
|
||||
// List<SubmissionDto> submissionDto = new List<SubmissionDto>();
|
||||
|
||||
|
||||
foreach (var student in _students)
|
||||
{
|
||||
var newSubmission = new SubmissionDto();
|
||||
newSubmission.StudentId = student.Id;
|
||||
newSubmission.AssignmentId = Assignment.Id;
|
||||
newSubmission.SubmissionTime = DateTime.Now;
|
||||
newSubmission.Status = Entities.Contracts.SubmissionStatus.Graded;
|
||||
// foreach (var student in _students)
|
||||
// {
|
||||
// var newSubmission = new SubmissionDto();
|
||||
// newSubmission.StudentId = student.Id;
|
||||
// newSubmission.AssignmentId = Assignment.Id;
|
||||
// newSubmission.SubmissionTime = DateTime.Now;
|
||||
// newSubmission.Status = Entities.Contracts.SubmissionStatus.Graded;
|
||||
|
||||
|
||||
foreach (var row in _questionsForTable)
|
||||
{
|
||||
if (row.QuestionItem.AssignmentQuestionDto.StructType == Entities.Contracts.AssignmentStructType.Struct) continue;
|
||||
if (row.StudentAnswers.TryGetValue(student.Id, out bool isCorrect))
|
||||
{
|
||||
newSubmission.SubmissionDetails.Add(new SubmissionDetailDto
|
||||
{
|
||||
IsCorrect = isCorrect,
|
||||
StudentId = student.Id,
|
||||
AssignmentQuestionId = row.QuestionItem.AssignmentQuestionDto.Id,
|
||||
PointsAwarded = isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0
|
||||
});
|
||||
// foreach (var row in _questionsForTable)
|
||||
// {
|
||||
// if (row.QuestionItem.AssignmentQuestionDto.StructType == Entities.Contracts.AssignmentStructType.Struct) continue;
|
||||
// if (row.StudentAnswers.TryGetValue(student.Id, out bool isCorrect))
|
||||
// {
|
||||
// newSubmission.SubmissionDetails.Add(new SubmissionDetailDto
|
||||
// {
|
||||
// IsCorrect = isCorrect,
|
||||
// StudentId = student.Id,
|
||||
// AssignmentQuestionId = row.QuestionItem.AssignmentQuestionDto.Id,
|
||||
// PointsAwarded = isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0
|
||||
// });
|
||||
|
||||
newSubmission.OverallGrade += isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0;
|
||||
}
|
||||
}
|
||||
submissionDto.Add(newSubmission);
|
||||
}
|
||||
// newSubmission.OverallGrade += isCorrect ? row.QuestionItem.AssignmentQuestionDto.Score : 0;
|
||||
// }
|
||||
// }
|
||||
// submissionDto.Add(newSubmission);
|
||||
// }
|
||||
|
||||
submissionDto.ForEach(async s =>
|
||||
{
|
||||
Snackbar?.Add($"正在提交: {_students.FirstOrDefault(std => std.Id == s.StudentId)?.DisplayName} 的试卷", Severity.Info);
|
||||
var submidResult = await ExamService.SubmissionAssignment(s);
|
||||
if (submidResult.Status)
|
||||
Snackbar?.Add($"批改结果已提交 {_students.FirstOrDefault(st => st.Id == s.StudentId)?.DisplayName}", Severity.Success);
|
||||
else
|
||||
Snackbar?.Add("批改结果提交失败", Severity.Error);
|
||||
// submissionDto.ForEach(async s =>
|
||||
// {
|
||||
// Snackbar?.Add($"正在提交: {_students.FirstOrDefault(std => std.Id == s.StudentId)?.DisplayName} 的试卷", Severity.Info);
|
||||
// var submidResult = await ExamService.SubmissionAssignment(s);
|
||||
// if (submidResult.Status)
|
||||
// Snackbar?.Add($"批改结果已提交 {_students.FirstOrDefault(st => st.Id == s.StudentId)?.DisplayName}", Severity.Success);
|
||||
// else
|
||||
// Snackbar?.Add("批改结果提交失败", Severity.Error);
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
@@ -16,54 +16,34 @@
|
||||
@inject IDialogService DialogService
|
||||
|
||||
<MudPaper Elevation="5" Class="d-flex overflow-hidden flex-grow-1 pa-1 rounded-xl " Style="overflow:hidden; position:relative;height:100%">
|
||||
<MudDrawerContainer Class="mud-height-full flex-grow-1" Style="height:100%">
|
||||
<MudDrawer @bind-Open="@_open" Elevation="0" Variant="@DrawerVariant.Persistent" Color="Color.Primary" Anchor="Anchor.End" OverlayAutoClose="true">
|
||||
|
||||
@if (_edit)
|
||||
|
||||
<MudStack Class="flex-grow-1 h-100">
|
||||
|
||||
<MudPaper Class="rounded-xl ma-1 pa-2" Style="background-color:#fefefefe">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenEditor">文本编辑器</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="ParseExam">载入</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">发布</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">指派</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenTest">Test</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="HandleGlobalInfo">GlobalExamInfo</MudButton>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
<ExamView Class="overflow-auto ma-1 pa-2 rounded-xl" ClickedStruct="HandleClickedStruct" ParsedExam="ExamContent"></ExamView>
|
||||
|
||||
<MudPaper MaxWidth="300">
|
||||
|
||||
@if (_parsedExam.Errors.Any())
|
||||
{
|
||||
<AssignmentQuestionEdit AssignmentQuestion="selectedAssignmentQuestion" />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
<MudDrawerHeader>
|
||||
<MudText Typo="Typo.h6"> 配置 </MudText>
|
||||
</MudDrawerHeader>
|
||||
|
||||
<MudStack Class="overflow-auto">
|
||||
<ParseRoleConfig />
|
||||
<MudButton Color="Color.Success"> ParseExam </MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
|
||||
</MudDrawer>
|
||||
<MudStack Class="flex-grow-1 h-100">
|
||||
|
||||
<MudPaper Class="rounded-xl ma-1 pa-2" Style="background-color:#fefefefe">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenEditor">文本编辑器</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="ParseExam">载入</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">发布</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenPublish">指派</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="OpenTest">Test</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Secondary" Class="rounded-xl" Size="Size.Small" OnClick="HandleGlobalInfo">GlobalExamInfo</MudButton>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
<ExamView Class="overflow-auto ma-1 pa-2 rounded-xl" ClickedStruct="HandleClickedStruct" ParsedExam="ExamContent"></ExamView>
|
||||
|
||||
<MudPaper MaxWidth="300">
|
||||
|
||||
@if (_parsedExam.Errors.Any())
|
||||
foreach (var item in _parsedExam.Errors)
|
||||
{
|
||||
foreach (var item in _parsedExam.Errors)
|
||||
{
|
||||
<MudText> @item.Message </MudText>
|
||||
}
|
||||
<MudText> @item.Message </MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
</MudDrawerContainer>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
@@ -71,19 +51,11 @@
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState> authenticationStateTask { get; set; }
|
||||
|
||||
private AssignmentQuestionDto selectedAssignmentQuestion = new AssignmentQuestionDto();
|
||||
private IReadOnlyCollection<string> _selected;
|
||||
private bool _open = false;
|
||||
private bool _edit = false;
|
||||
private ExamQuestionDto selectedAssignmentQuestion = new ExamQuestionDto();
|
||||
|
||||
private void ToggleDrawer()
|
||||
{
|
||||
_open = !_open;
|
||||
_edit = false;
|
||||
}
|
||||
private BlazoredTextEditor _textEditor = new BlazoredTextEditor();
|
||||
private AssignmentEx _parsedExam = new AssignmentEx();
|
||||
private AssignmentDto ExamContent = new AssignmentDto();
|
||||
private ExamEx _parsedExam = new ExamEx();
|
||||
private ExamDto ExamContent = new ExamDto();
|
||||
|
||||
private ExamParserConfig _examParserConfig { get; set; } = new ExamParserConfig();
|
||||
private string EditorText = "";
|
||||
@@ -98,20 +70,6 @@
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
var response = await NoteService.GetNote((byte)SubjectAreaEnum.Literature);
|
||||
|
||||
if (response.Status)
|
||||
{
|
||||
try
|
||||
{
|
||||
LocalStorageService.SetItem("GlobalInfo", response.Result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void OpenEditor()
|
||||
@@ -141,12 +99,8 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async void HandleClickedStruct(AssignmentQuestionDto dto)
|
||||
private async void HandleClickedStruct(ExamQuestionDto dto)
|
||||
{
|
||||
// _open = true;
|
||||
// _edit = true;
|
||||
// StateHasChanged();
|
||||
|
||||
var parameters = new DialogParameters<QuestionCardDialog> { { x => x.Questions, dto } };
|
||||
|
||||
var dialog = await DialogService.ShowAsync<QuestionCardDialog>("Edit_Question", parameters);
|
||||
@@ -157,6 +111,9 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public ICommonService commonService { get; set; }
|
||||
|
||||
private async Task ParseExam()
|
||||
{
|
||||
|
||||
@@ -167,12 +124,12 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
var exampar = new ExamParser(_examParserConfig);
|
||||
var exampar = new ExamParser(_examParserConfig, commonService);
|
||||
_parsedExam = exampar.ParseExamPaper(plainText);
|
||||
Snackbar.Add("试卷解析成功。", Severity.Success);
|
||||
Snackbar.Add($"{_parsedExam.Errors}。", Severity.Success);
|
||||
StateHasChanged();
|
||||
ExamContent = Mapper.Map<AssignmentDto>(_parsedExam);
|
||||
ExamContent = Mapper.Map<ExamDto>(_parsedExam);
|
||||
ExamContent.SeqIndex();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -194,8 +151,6 @@
|
||||
[Inject]
|
||||
public IExamService examService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public INoteService NoteService { get; set; }
|
||||
|
||||
|
||||
public async Task Publish()
|
||||
@@ -207,7 +162,6 @@
|
||||
{
|
||||
Dictionary<string, (Color, string)> Note = new Dictionary<string, (Color, string)> { { "Hello", (Color.Surface, "World") }, { "My", (Color.Surface, "App") }, };
|
||||
var json = JsonConvert.SerializeObject(Note);
|
||||
var result = await NoteService.AddNote(new GlobalDto { SubjectArea = Entities.Contracts.SubjectAreaEnum.Physics, Data = json });
|
||||
|
||||
|
||||
|
||||
@@ -218,9 +172,6 @@
|
||||
|
||||
private async void HandleGlobalInfo()
|
||||
{
|
||||
// _open = true;
|
||||
// _edit = true;
|
||||
// StateHasChanged();
|
||||
|
||||
var parameters = new DialogParameters<ExamGlobalInfoDialog> { { x => x.Assignment, ExamContent } };
|
||||
|
||||
@@ -232,53 +183,3 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- #region name -->
|
||||
@* <MudButtonGroup Vertical="true" Color="Color.Primary" Variant="Variant.Filled">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Settings" OnClick="@ToggleDrawer" Color="Color.Secondary" />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.TransitEnterexit" OnClick="@ParseExam" Color="Color.Secondary" />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Save" OnClick="@ToggleDrawer" Color="Color.Secondary" />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Publish" OnClick="@Publish" Color="Color.Secondary" />
|
||||
</MudButtonGroup> *@
|
||||
@* <MudPaper Class="ma-2 h-100">
|
||||
<MudPaper Elevation="0" Style="height:calc(100% - 80px)">
|
||||
<BlazoredTextEditor @ref="@_textEditor">
|
||||
<ToolbarContent>
|
||||
<select class="ql-header">
|
||||
<option selected=""></option>
|
||||
<option value="1"></option>
|
||||
<option value="2"></option>
|
||||
<option value="3"></option>
|
||||
<option value="4"></option>
|
||||
<option value="5"></option>
|
||||
</select>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold"></button>
|
||||
<button class="ql-italic"></button>
|
||||
<button class="ql-underline"></button>
|
||||
<button class="ql-strike"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<select class="ql-color"></select>
|
||||
<select class="ql-background"></select>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-list" value="ordered"></button>
|
||||
<button class="ql-list" value="bullet"></button>
|
||||
</span>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-link"></button>
|
||||
</span>
|
||||
</ToolbarContent>
|
||||
<EditorContent>
|
||||
</EditorContent>
|
||||
</BlazoredTextEditor>
|
||||
</MudPaper>
|
||||
</MudPaper> *@
|
||||
|
||||
<!-- #endregion -->
|
||||
@@ -2,7 +2,6 @@
|
||||
@using Entities.DTO
|
||||
@using TechHelper.Client.Pages.Exam.ExamView
|
||||
@using TechHelper.Client.Services
|
||||
@using Entities.DTO
|
||||
@using TechHelper.Client.Exam
|
||||
|
||||
<ExamView ParsedExam="@ExamDto"/>
|
||||
@@ -20,7 +19,7 @@
|
||||
[Inject]
|
||||
private ISnackbar Snackbar { get; set; }
|
||||
|
||||
private AssignmentDto ExamDto { get; set; }
|
||||
private ExamDto ExamDto { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -31,7 +30,7 @@
|
||||
try
|
||||
{
|
||||
var result = await ExamService.GetExam(parsedExamId);
|
||||
if (result.Status) ExamDto = result.Result as AssignmentDto ?? new AssignmentDto();
|
||||
if (result.Status) ExamDto = result.Result as ExamDto ?? new ExamDto();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
@using TechHelper.Client.Pages.Common.Exam
|
||||
|
||||
@page "/exam/manage"
|
||||
@using Entities.DTO
|
||||
@using TechHelper.Client.Services
|
||||
@attribute [Authorize]
|
||||
|
||||
@@ -34,7 +33,7 @@ else
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState> authenticationStateTask { get; set; }
|
||||
|
||||
private List<AssignmentDto> examDtos = new List<AssignmentDto>();
|
||||
private List<ExamDto> examDtos = new List<ExamDto>();
|
||||
|
||||
private bool isloding = true;
|
||||
|
||||
@@ -51,7 +50,7 @@ else
|
||||
var result = await ExamService.GetAllExam();
|
||||
if (result.Status)
|
||||
{
|
||||
examDtos = result.Result as List<AssignmentDto> ?? new List<AssignmentDto>();
|
||||
examDtos = result.Result as List<ExamDto> ?? new List<ExamDto>();
|
||||
Snackbar.Add("加载成功", Severity.Info);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<MudPaper Class="overflow-hidden " Style="background-color:pink" Width="@Width" Height="@Height" MaxHeight="@MaxHeight" MaxWidth="@MaxWidth">
|
||||
<MudPaper Class="d-flex flex-column flex-grow-1 justify-content-between" Height="100%" Style="background-color:green">
|
||||
|
||||
<MudText Typo="Typo.body2"> @AssignmentDto.Title </MudText>
|
||||
<MudText Typo="Typo.body2"> @ExamDto.Title </MudText>
|
||||
|
||||
|
||||
<MudPaper>
|
||||
@@ -34,7 +34,7 @@
|
||||
public NavigationManager navigationManager { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public AssignmentDto AssignmentDto { get; set; }
|
||||
public ExamDto ExamDto { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
@@ -61,11 +61,11 @@
|
||||
|
||||
private void ExamClick()
|
||||
{
|
||||
navigationManager.NavigateTo($"exam/edit/{AssignmentDto.Id}");
|
||||
navigationManager.NavigateTo($"exam/edit/{ExamDto.Id}");
|
||||
}
|
||||
|
||||
private void CheckExam()
|
||||
{
|
||||
navigationManager.NavigateTo($"exam/check/{AssignmentDto.Id}");
|
||||
navigationManager.NavigateTo($"exam/check/{ExamDto.Id}");
|
||||
}
|
||||
}
|
||||
|
||||
112
TechHelper.Client/Pages/Exam/ExamQuestionEdit.razor
Normal file
112
TechHelper.Client/Pages/Exam/ExamQuestionEdit.razor
Normal file
@@ -0,0 +1,112 @@
|
||||
@using Entities.Contracts
|
||||
@using Entities.DTO
|
||||
@using Newtonsoft.Json
|
||||
@using TechHelper.Client.Exam
|
||||
@using TechHelper.Client.Pages.Exam.QuestionCard
|
||||
|
||||
|
||||
<MudPaper Elevation="0" Class="rounded-xl" Style="background-color: transparent">
|
||||
@* <MudText>@AssignmentQuestion.Id</MudText> *@
|
||||
<MudPaper Class="ma-4 pa-5 rounded-xl">
|
||||
<MudText Class="mt-3" Typo="Typo.button"><b>包裹器属性</b></MudText>
|
||||
<MudTextField @bind-Value="ExamQuestion.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
|
||||
<MudTextField @bind-Value="ExamQuestion.Index" Label="Index" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
||||
<MudTextField @bind-Value="ExamQuestion.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
|
||||
@* <MudChipSet T="AssignmentStructType" SelectedValue="AssignmentQuestion.StructType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleSelectedValueChanged">
|
||||
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Root">@AssignmentStructType.Root</MudChip>
|
||||
<MudChip Text="pink" Color="Color.Secondary" Value="@AssignmentStructType.Struct">@AssignmentStructType.Struct</MudChip>
|
||||
<MudChip Text="purple" Color="Color.Primary" Value="@AssignmentStructType.Group">@AssignmentStructType.Group</MudChip>
|
||||
<MudChip Text="blue" Color="Color.Info" Value="@AssignmentStructType.Question">@AssignmentStructType.Question</MudChip>
|
||||
<MudChip Text="green" Color="Color.Warning" Value="@AssignmentStructType.SubQuestion">@AssignmentStructType.SubQuestion</MudChip>
|
||||
<MudChip Text="orange" Color="Color.Error" Value="@AssignmentStructType.Option">@AssignmentStructType.Option</MudChip>
|
||||
</MudChipSet> *@
|
||||
|
||||
|
||||
@* <MudChipSet T="string" SelectedValue="@AssignmentQuestion.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
|
||||
|
||||
@foreach (var item in QuestionTypes)
|
||||
{
|
||||
var qt = item;
|
||||
|
||||
<MudChip Style="@(qt.Key == AssignmentQuestion.QType ?
|
||||
$"background-color:#ffffff; color:{item.Value.Color}" :
|
||||
$"background-color:{item.Value.Color}; color:#ffffff")"
|
||||
Value="@item.Key">
|
||||
@item.Value.DisplayName
|
||||
</MudChip>
|
||||
}
|
||||
</MudChipSet> *@
|
||||
</MudPaper>
|
||||
@if (ExamQuestion.Question != null)
|
||||
{
|
||||
<QuestionEdit Question="ExamQuestion.Question" />
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public ExamQuestionDto ExamQuestion { get; set; } = new ExamQuestionDto();
|
||||
public QuestionDto TempQuesdto;
|
||||
// Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
||||
|
||||
[Inject]
|
||||
private ILocalStorageService LocalStorageService { get; set; }
|
||||
// protected override void OnInitialized()
|
||||
// {
|
||||
// base.OnInitialized();
|
||||
// if (AssignmentQuestion.Question != null)
|
||||
// {
|
||||
// TempQuesdto = AssignmentQuestion.Question;
|
||||
// }
|
||||
|
||||
// var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
||||
// var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
||||
// if(GlobalInfo != null)
|
||||
// {
|
||||
// QuestionTypes = GlobalInfo;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private void HandleQTSelectedValueChanged(string type)
|
||||
// {
|
||||
// AssignmentQuestion.QType = type;
|
||||
// if (AssignmentQuestion.ChildrenAssignmentQuestion.Count > 0 && AssignmentQuestion.StructType == AssignmentStructType.Group)
|
||||
// {
|
||||
// foreach (var item in AssignmentQuestion.ChildrenAssignmentQuestion)
|
||||
// {
|
||||
// item.QType = type;
|
||||
// if (item.Question != null)
|
||||
// {
|
||||
// item.Question.QType = type;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// StateHasChanged();
|
||||
// }
|
||||
|
||||
// private void HandleSelectedValueChanged(AssignmentStructType type)
|
||||
// {
|
||||
// AssignmentQuestion.StructType = type;
|
||||
// if (type != AssignmentStructType.Question && AssignmentQuestion.Question != null)
|
||||
// {
|
||||
// AssignmentQuestion.Title = AssignmentQuestion.Question.Title;
|
||||
// AssignmentQuestion.Question = null;
|
||||
// }
|
||||
|
||||
// if (type == AssignmentStructType.Question && AssignmentQuestion.Question == null)
|
||||
// {
|
||||
// if (TempQuesdto != null)
|
||||
// {
|
||||
// AssignmentQuestion.Question = TempQuesdto;
|
||||
// if (AssignmentQuestion.Title == AssignmentQuestion.Question.Title)
|
||||
// {
|
||||
// AssignmentQuestion.Title = "";
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// AssignmentQuestion.Question = new QuestionDto { };
|
||||
// }
|
||||
// StateHasChanged();
|
||||
// }
|
||||
}
|
||||
@@ -10,23 +10,15 @@
|
||||
<MudStack Row="true" Class="justify-content-between align-content-center" Style="background-color: transparent">
|
||||
<MudText Class="justify-content-lg-start" Typo="Typo.h6">@ExamStruct.Title</MudText>
|
||||
<MudStack Row="true" Class="align-content-center">
|
||||
<MudText Class="ma-auto" Align="Align.Center" Typo="Typo.body2"> Num: @ExamStruct.ChildrenAssignmentQuestion.Count</MudText>
|
||||
<MudText Class="ma-auto" Align="Align.Center" Typo="Typo.body2"> Num: @ExamStruct.ChildExamQuestions.Count</MudText>
|
||||
<MudText Class="ma-auto" Align="Align.Center" Typo="Typo.body2"><b>总分:</b> @ExamStruct.Score 分</MudText>
|
||||
<MudToggleIconButton @bind-Toggled="ExamStruct.BCorrect"
|
||||
Icon="@Icons.Material.Filled.Close"
|
||||
Color="@Color.Error"
|
||||
ToggledIcon="@Icons.Material.Filled.Check"
|
||||
ToggledColor="@Color.Success"
|
||||
title="@(ExamStruct.BCorrect ? "On" : "Off")" />
|
||||
|
||||
<MudIconButton Color="Color.Tertiary" Icon="@Icons.Material.Filled.ExpandLess" Size="Size.Small" />
|
||||
<MudIconButton Color="Color.Tertiary" Icon="@Icons.Material.Filled.ExpandMore" Size="Size.Small" />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" aria-label="delete" Size="Size.Small" />
|
||||
<MudChip T="string" Color="Color.Info" Class="justify-content-end">@ExamStruct.StructType</MudChip>
|
||||
<MudChip T="string" Color="Color.Warning" Class="justify-content-end">@(ExamStruct.QType == string.Empty ? "" : QuestionTypes[ExamStruct.QType].DisplayName)</MudChip>
|
||||
@* <MudChip T="string" Color="Color.Info" Class="justify-content-end">@ExamStruct.Type.Name</MudChip> *@
|
||||
@if(ExamStruct.Question!=null)
|
||||
{
|
||||
<MudRating SelectedValue="@((int)ExamStruct.Question.DifficultyLevel)" ReadOnly="true" Size="Size.Small" />
|
||||
@* <MudRating SelectedValue="@((int)ExamStruct.Question.DifficultyLevel)" ReadOnly="true" Size="Size.Small" /> *@
|
||||
}
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
@@ -36,41 +28,16 @@
|
||||
<QuestionCard Question="ExamStruct.Question" Index="ExamStruct.Index" Elevation=0 Class="my-2 pa-1 rounded-xl" />
|
||||
}
|
||||
|
||||
@foreach (var examStruct in ExamStruct.ChildrenAssignmentQuestion)
|
||||
{
|
||||
<ExamStructView ExamStruct="examStruct" ClickedStruct="HandleChildStructClick" Elevation=@(examStruct.Question != null
|
||||
&& examStruct.ChildrenAssignmentQuestion.Count == 0 ? 0 : 0) Class="@($"my-2 pa-1 rounded-xl {(examStruct.StructType != AssignmentStructType.Question ? "my-5" : "my-1")}")"
|
||||
Style=@(examStruct.StructType switch
|
||||
{
|
||||
AssignmentStructType.Question => "background-color: #ececec",
|
||||
AssignmentStructType.Group => "background-color: #ffffff",
|
||||
AssignmentStructType.Struct => "background-color: #cccccccc",
|
||||
AssignmentStructType.SubQuestion => "background-color: #ffffff",
|
||||
AssignmentStructType.Option => "background-color: #ffffff",
|
||||
_ => "background-color: transparent"
|
||||
}) />
|
||||
}
|
||||
|
||||
</MudPaper>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@* Style=@(examStruct.StructType switch
|
||||
{
|
||||
AssignmentStructType.Question => "background-color: #ffffff",
|
||||
AssignmentStructType.Composite => "background-color: #ececec",
|
||||
AssignmentStructType.Struct => "background-color: #dcdcdc",
|
||||
AssignmentStructType.SubQuestion => "background-color: #ffffff",
|
||||
AssignmentStructType.Option => "background-color: #dddddd",
|
||||
_ => "background-color: transparent"
|
||||
}) *@
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public AssignmentQuestionDto ExamStruct { get; set; } = new AssignmentQuestionDto();
|
||||
public ExamQuestionDto ExamStruct { get; set; } = new ExamQuestionDto();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<AssignmentQuestionDto> ClickedStruct { get; set; }
|
||||
public EventCallback<ExamQuestionDto> ClickedStruct { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Class { get; set; } = "my-2 pa-1";
|
||||
@@ -81,20 +48,11 @@
|
||||
[Parameter]
|
||||
public string Style { get; set; } = "background-color : #eeeeee";
|
||||
|
||||
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
||||
|
||||
[Inject]
|
||||
private ILocalStorageService LocalStorageService { get; set; }
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
||||
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
||||
if (GlobalInfo != null)
|
||||
{
|
||||
QuestionTypes = GlobalInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private async void HandleClick()
|
||||
@@ -102,14 +60,14 @@
|
||||
await ClickedStruct.InvokeAsync(ExamStruct);
|
||||
}
|
||||
|
||||
private async void HandleChildStructClick(AssignmentQuestionDto clickedChildExamStruct)
|
||||
private async void HandleChildStructClick(ExamQuestionDto clickedChildExamStruct)
|
||||
{
|
||||
await ClickedStruct.InvokeAsync(clickedChildExamStruct);
|
||||
}
|
||||
|
||||
private void HandleSelected(int num)
|
||||
{
|
||||
ExamStruct.Question.DifficultyLevel = (DifficultyLevel)num;
|
||||
// ExamStruct.Question.DifficultyLevel = (DifficultyLevel)num;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,10 +24,10 @@ else
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public AssignmentDto ParsedExam { get; set; } = new AssignmentDto();
|
||||
public ExamDto ParsedExam { get; set; } = new ExamDto();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<AssignmentQuestionDto> ClickedStruct { get; set; }
|
||||
public EventCallback<ExamQuestionDto> ClickedStruct { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Height { get; set; } = "100%";
|
||||
@@ -39,7 +39,7 @@ else
|
||||
public string Style { get; set; } = "";
|
||||
|
||||
|
||||
private void HandleClickedStruct(AssignmentQuestionDto dto)
|
||||
private void HandleClickedStruct(ExamQuestionDto dto)
|
||||
{
|
||||
ClickedStruct.InvokeAsync(dto);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
public QuestionDto Question { get; set; } = new QuestionDto();
|
||||
|
||||
[Parameter]
|
||||
public AssignmentStructType Type { get; set; } = AssignmentStructType.Question;
|
||||
public ExamStructType Type { get; set; } = ExamStructType.Question;
|
||||
|
||||
[Parameter]
|
||||
public byte Index { get; set; } = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@using Entities.DTO
|
||||
@using Entities.Contracts
|
||||
@using Entities.Contracts
|
||||
@using Entities.DTO
|
||||
@using Newtonsoft.Json
|
||||
@using TechHelper.Client.Exam
|
||||
|
||||
@@ -8,13 +8,10 @@
|
||||
@* <MudText>@Question.Id</MudText> *@
|
||||
<MudText Class="mt-3" Typo="Typo.button"><b>问题属性</b></MudText>
|
||||
|
||||
<MudChipSet T="string" SelectedValue="@Question.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
|
||||
|
||||
@* <MudChipSet T="string" SelectedValue="@Question.QType" CheckMark SelectionMode="SelectionMode.SingleSelection" SelectedValueChanged="HandleQTSelectedValueChanged">
|
||||
@foreach (var item in QuestionTypes)
|
||||
{
|
||||
var qt = item;
|
||||
@* Style = "@($"background - color:{ item.Value.Color} ")"*@
|
||||
|
||||
<MudChip Style="@(qt.Key == Question.QType ?
|
||||
$"background-color:#ffffff; color:{item.Value.Color}" :
|
||||
$"background-color:{item.Value.Color}; color:#ffffff")"
|
||||
@@ -22,7 +19,9 @@
|
||||
@item.Value.DisplayName
|
||||
</MudChip>
|
||||
}
|
||||
</MudChipSet>
|
||||
</MudChipSet> *@
|
||||
|
||||
|
||||
<MudRating SelectedValue="@(diffi)" SelectedValueChanged="HandleSelected" Size="Size.Small" />
|
||||
<MudTextField @bind-Value="Question.Title" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoGrow="true" />
|
||||
<MudTextField @bind-Value="Question.Answer" Label="Answer" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoGrow="true" />
|
||||
@@ -35,7 +34,7 @@
|
||||
[Parameter]
|
||||
public QuestionDto Question { get; set; } = new QuestionDto();
|
||||
public int diffi = 0;
|
||||
Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
||||
// Dictionary<string, QuestionDisplayTypeData> QuestionTypes = new Dictionary<string, QuestionDisplayTypeData>();
|
||||
|
||||
[Inject]
|
||||
private ILocalStorageService LocalStorageService { get; set; }
|
||||
@@ -43,26 +42,23 @@
|
||||
{
|
||||
base.OnInitialized();
|
||||
|
||||
var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
||||
var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
||||
if (GlobalInfo != null)
|
||||
{
|
||||
QuestionTypes = GlobalInfo;
|
||||
}
|
||||
// var cs = LocalStorageService.GetItem<string>("GlobalInfo");
|
||||
// var GlobalInfo = JsonConvert.DeserializeObject<Dictionary<string, QuestionDisplayTypeData>>(cs);
|
||||
// if (GlobalInfo != null)
|
||||
// {
|
||||
// }
|
||||
}
|
||||
private void HandleSelectedValueChanged(QuestionType type)
|
||||
{
|
||||
Question.Type = type;
|
||||
}
|
||||
|
||||
private void HandleSelected(int num)
|
||||
{
|
||||
Question.DifficultyLevel = (DifficultyLevel)num;
|
||||
// Question.DifficultyLevel = (DifficultyLevel)num;
|
||||
}
|
||||
|
||||
private void HandleQTSelectedValueChanged(string type)
|
||||
{
|
||||
Question.QType = type;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user