< Summary

Information
Class: Syki.Front.Features.Teacher.AddExamGradeNote.AddExamGradeNotesDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Teacher/AddExamGradeNote/AddExamGradeNotesDialog.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 32
Coverable lines: 32
Total lines: 73
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
get_AfterSubmit()100%210%
Open()100%210%
Close()100%210%
Submit()0%2040%

File(s)

/home/runner/work/syki/syki/Front/Features/Teacher/AddExamGradeNote/AddExamGradeNotesDialog.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Teacher.AddExamGradeNote
 2
 3<MudDialog Class="pb-2" @bind-Visible="@_visible" Options="@_options">
 4    <TitleContent>
 5        <SykiDialogTitle Text="Adicionar notas" />
 6    </TitleContent>
 7    <DialogContent>
 8        <MudText Typo="Typo.h6" Class="px-0 py-2">@_item.Name</MudText>
 09        <MudForm @ref="@_form" Class="px-0 pt-2">
 010            @foreach (var grade in _item.ExamGrades)
 011            {
 012                <ExamGradeNoteField Data="@grade" />
 013            }
 014        </MudForm>
 15    </DialogContent>
 16    <DialogActions>
 17        <DialogCancelButton OnClick="@Close" />
 18        <SykiProgressCircular Loading="@_loading" />
 19        <DialogSaveButton OnClick="@Submit" />
 20    </DialogActions>
 21</MudDialog>
 22
 23@inject AddExamGradeNoteClient Client
 24@inject IBrowserViewportService BrowserViewportService
 25
 26@code
 27{
 28    private bool _visible;
 29    private MudForm _form;
 30    private bool _loading;
 031    private TeacherClassStudentOut _item = new();
 032    private List<CompareExamGradeOut> _initialValues = [];
 33
 034    private readonly DialogOptions _options = new()
 035    {
 036        FullWidth = true,
 037        CloseButton = true,
 038        MaxWidth = MaxWidth.ExtraSmall,
 039    };
 40
 41    [Parameter]
 042    public EventCallback AfterSubmit { get; set; }
 43
 44    public async Task Open(TeacherClassStudentOut item)
 45    {
 046        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 047        _options.FullScreen = breakpoint == Breakpoint.Xs;
 048        _item = item;
 049        _initialValues = item.ExamGrades.Select(x => new CompareExamGradeOut() { ExamType = x.ExamType, Note = x.Note })
 050        _visible = true;
 051    }
 52
 53    private void Close()
 54    {
 055        _visible = false;
 056    }
 57
 58    private async Task Submit()
 59    {
 060        _loading = true;
 061        foreach (var examGrade in _item.ExamGrades)
 62        {
 063            var initial = _initialValues.First(x => x.ExamType == examGrade.ExamType);
 064            if (examGrade.Note == initial.Note) continue;
 65
 066            await Client.Add(examGrade.Id, new(examGrade.Note));
 67        }
 68
 069        Close();
 070        await AfterSubmit.InvokeAsync();
 071        _loading = false;
 072    }
 73}