< Summary - Syki

Information
Class: Syki.Front.Pages.Academic.AcademicClassPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicClassPage.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 48
Coverable lines: 48
Total lines: 236
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 24
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%210%
.ctor()100%210%
OnInitializedAsync()100%210%
ShowFrequencyColumn()100%210%
Load()0%620%
GetLessons()100%210%
get__quickFilter()100%210%
get__quickFilterStudents()100%210%
GetNotFoundMessage()0%620%
GetStudentsNotFoundMessage()0%620%

File(s)

/home/runner/work/syki/syki/Front/Pages/Academic/AcademicClassPage.razor

#LineLine coverage
 1@namespace Syki.Front.Pages.Academic
 2
 3@page "/academic/classes/{id:guid}"
 4@attribute [Authorize(Roles = "Academic")]
 5
 6<SykiPageTitle Title="Turma" />
 7
 8<MudContainer Class="my-4 px-4">
 09    @if (_loading)
 10    {
 11        <MudSkeleton Animation="Animation.Wave" />
 12    }
 13    else
 14    {
 15        <MudGrid Class="align-center">
 16            <MudItem xs="12" sm="9" md="9" lg="9">
 17                <MudStack Row="true" AlignItems="AlignItems.Center">
 18                    <MudIcon Icon="@Icons.Material.Filled.CenterFocusStrong" Class="mb-1" Size="Size.Large" />
 019                    <MudText Typo="Typo.h5" Style="font-weight: bold">@_class.Discipline</MudText>
 20                </MudStack>
 21            </MudItem>
 22            <MudItem xs="12" sm="3" md="3" lg="3" Class="d-flex justify-end">
 23                <MudTabs Elevation="0" Rounded="true" Outlined="true" TabPanelClass="px-6" @bind-ActivePanelIndex="@_ind
 24                    <MudTabPanel Text="Aulas" ID='"panel_0"'></MudTabPanel>
 25                    <MudTabPanel Text="Alunos" ID='"panel_1"'></MudTabPanel>
 26                </MudTabs>
 27            </MudItem>
 28        </MudGrid>
 29    }
 30
 031    @if (_index == 0)
 32    {
 33        <MudCard Class="my-4 px-2">
 34            <MudCardContent>
 035                @if (_loading)
 36                {
 37                    <MudSkeleton Animation="Animation.Wave" />
 38                }
 39                else
 40                {
 41                    <MudGrid Justify="Justify.FlexStart" Spacing="1">
 42                        <MudItem xs="12" sm="6" md="6" lg="6">
 43                            <MudStack Spacing="1">
 044                                <MudText><strong>Professor:</strong> @_class.Teacher</MudText>
 045                                <MudText><strong>Status:</strong> @_class.Status.GetDescription()</MudText>
 046                                <MudText><strong>Alunos:</strong> @_class.FillRatio</MudText>
 047                                <MudText><strong>Horário:</strong> @_class.SchedulesInline</MudText>
 48                            </MudStack>
 49                        </MudItem>
 50                        <MudItem xs="12" sm="6" md="6" lg="6">
 51                            <MudStack Spacing="1">
 052                                <MudText><strong>Período:</strong> @_class.Period</MudText>
 053                                <MudText><strong>Aulas Concluídas:</strong> @_class.Progress</MudText>
 054                                <MudText><strong>Carga Horária:</strong> @_class.Workload</MudText>
 55                                <MudStack Row="true" AlignItems="AlignItems.Center">
 56                                    <MudText><strong>Frequência:</strong></MudText>
 057                                    @if (_class.Lessons.Any(x => x.Status == ClassLessonStatus.Finalized))
 58                                    {
 59                                        <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value=
 60                                            <MudText Typo="Typo.body1">
 061                                                <b>@_class.Frequency.Format()%</b>
 62                                            </MudText>
 63                                        </MudProgressLinear>
 64                                    }
 65                                </MudStack>
 66                            </MudStack>
 67                        </MudItem>
 68                        <MudItem>
 69                            <MudStack Spacing="1">
 70                            </MudStack>
 71                        </MudItem>
 72                    </MudGrid>
 73                }
 74            </MudCardContent>
 75        </MudCard>
 76
 77        <MudContainer Class="px-0 mb-4">
 78            <MudTable
 79                Items="@GetLessons()"
 80                Class="pa-4"
 81                Dense="true"
 82                Hover="true"
 83                Loading="@_loading"
 84                Filter="@_quickFilter"
 85                RowsPerPage="10"
 86            >
 87                <ToolBarContent>
 88                    <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo"
 89                </ToolBarContent>
 90                <HeaderContent>
 91                    <MudTh>Aula</MudTh>
 92                    <MudTh>Data</MudTh>
 93                    <MudTh>Horário</MudTh>
 94                    <MudTh>Status</MudTh>
 95                    <MudTh>Frequência</MudTh>
 96                </HeaderContent>
 97                <RowTemplate>
 098                    <MudTd DataLabel="Aula">@context.Number</MudTd>
 099                    <MudTd DataLabel="Data">@context.Date</MudTd>
 0100                    <MudTd DataLabel="Horário">@context.Schedule</MudTd>
 0101                    <MudTd DataLabel="Status">@context.Status.GetDescription()</MudTd>
 102                    <MudTd DataLabel="Frequência">
 0103                        @if (context.Status == ClassLessonStatus.Finalized)
 104                        {
 105                            <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value="@decimal.To
 106                                <MudText Typo="Typo.body1">
 0107                                    <b>@context.Frequency.Format()%</b>
 108                                </MudText>
 109                            </MudProgressLinear>
 110                        }
 111                    </MudTd>
 112                </RowTemplate>
 113                <LoadingContent>
 0114                    @if (_breakpoint == Breakpoint.Xs)
 115                    {
 116                        <MudProgressLinear Color="Color.Info" Indeterminate="true" />
 117                    }
 118                </LoadingContent>
 119                <NoRecordsContent>
 0120                    @(GetNotFoundMessage())
 121                </NoRecordsContent>
 122                <PagerContent>
 123                    <SykiTablePager />
 124                </PagerContent>
 125            </MudTable>
 126        </MudContainer>
 127    }
 128    else
 129    {
 130        <MudContainer Class="px-0 my-4">
 131            <MudTable
 132                Items="@_students"
 133                Class="pa-4"
 134                Hover="true"
 135                Loading="@_loading"
 136                Dense="true"
 137                RowsPerPage="10"
 138                Filter="@_quickFilterStudents"
 139            >
 140                <ToolBarContent>
 141                    <SykiDataGridSearchTextField @bind-Value="@_searchStringStudents" Placeholder="Busque por nome" />
 142                </ToolBarContent>
 143                <HeaderContent>
 144                    <MudTh>Nome</MudTh>
 145                    <MudTh>N1</MudTh>
 146                    <MudTh>N2</MudTh>
 147                    <MudTh>N3</MudTh>
 148                    <MudTh>Média</MudTh>
 149                    <MudTh>Frequência</MudTh>
 150                </HeaderContent>
 151                <RowTemplate>
 0152                    <MudTd DataLabel="Nome">@context.Name</MudTd>
 0153                    <MudTd DataLabel="N1">@context.GetNote(ClassNoteType.N1)</MudTd>
 0154                    <MudTd DataLabel="N2">@context.GetNote(ClassNoteType.N2)</MudTd>
 0155                    <MudTd DataLabel="N3">@context.GetNote(ClassNoteType.N3)</MudTd>
 0156                    <MudTd DataLabel="Média">@context.AverageNote.Format()</MudTd>
 157                    <MudTd DataLabel="Frequência">
 0158                        @if (ShowFrequencyColumn())
 159                        {
 160                            <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value="@decimal.To
 161                                <MudText Typo="Typo.body1">
 0162                                    <b>@context.Frequency.Format()%</b>
 163                                </MudText>
 164                            </MudProgressLinear>
 165                        }
 166                    </MudTd>
 167                </RowTemplate>
 168                <NoRecordsContent>
 0169                    @(GetStudentsNotFoundMessage())
 170                </NoRecordsContent>
 171                <PagerContent>
 172                    <SykiTablePager/>
 173                </PagerContent>
 174            </MudTable>
 175        </MudContainer>
 176    }
 177</MudContainer>
 178
 179@inject GetAcademicClassClient GetAcademicClassClient
 180@inject IBrowserViewportService BrowserViewportService
 181
 182@code
 183{
 184  [Parameter]
 0185  public Guid Id { get; set; }
 186
 187    private int _index;
 188    private bool _loading;
 189    private string _searchString;
 190    private string _searchStringStudents;
 0191    private GetAcademicClassOut _class = new();
 0192    private List<AcademicClassStudentOut> _students = [];
 193
 194    private Breakpoint _breakpoint;
 195
 196    protected override async Task OnInitializedAsync()
 197    {
 0198        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0199        await Load();
 0200    }
 201
 202    private bool ShowFrequencyColumn()
 203    {
 0204        return _class.Lessons.Any(x => x.Status == ClassLessonStatus.Finalized);
 205    }
 206
 207    private async Task Load()
 208    {
 0209        _loading = true;
 0210        var response = await GetAcademicClassClient.Get(Id);
 0211        if (response.IsSuccess)
 212        {
 0213            _class = response.Success;
 0214            _students = _class.Students.OrderBy(x => x.Name).ToList();
 215        }
 0216        _loading = false;
 0217    }
 218
 219    private IEnumerable<ClassLessonOut> GetLessons()
 220    {
 0221        return _class.Lessons.OrderBy(x => x.Number).ToList();
 222    }
 223
 0224    private Func<ClassLessonOut, bool> _quickFilter => x => _searchString.IsIn(x.Date.ToShortDateString(), x.Schedule, x
 0225    private Func<AcademicClassStudentOut, bool> _quickFilterStudents => x => _searchStringStudents.IsIn(x.Name);
 226
 227    private string GetNotFoundMessage()
 228    {
 0229        return (_searchString.IsEmpty()) ? "Não existem aulas ainda." : "Nenhuma aula encontrada.";
 230    }
 231
 232    private string GetStudentsNotFoundMessage()
 233    {
 0234        return (_searchString.IsEmpty()) ? "Não existem alunos matriculados ainda." : "Nenhum aluno encontrado.";
 235    }
 236}