< Summary

Information
Class: Syki.Front.Pages.Academic.AcademicClassPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Academic/AcademicClassPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 237
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">
 9    <MudCard Class="px-2">
 10        <MudCardContent>
 011            @if (_loading)
 12            {
 13                <MudSkeleton Animation="Animation.Wave" />
 14            }
 15            else
 16            {
 17                <MudGrid Class="align-center">
 18                    <MudItem xs="12" sm="9" md="9" lg="9">
 19                        <MudText Typo="Typo.h5" Style="font-weight: bold">@_class.Discipline</MudText>
 20                    </MudItem>
 21                    <MudItem xs="12" sm="3" md="3" lg="3" Class="d-flex justify-end">
 22                        <MudTabs Elevation="0" Rounded="true" Outlined="true" TabPanelClass="px-6" @bind-ActivePanelInde
 23                            <MudTabPanel Text="Aulas" ID='"panel_0"'></MudTabPanel>
 24                            <MudTabPanel Text="Alunos" ID='"panel_1"'></MudTabPanel>
 25                        </MudTabs>
 26                    </MudItem>
 27                </MudGrid>
 28            }
 29        </MudCardContent>
 30    </MudCard>
 31
 032    @if (_index == 0)
 33    {
 34        <MudCard Class="my-4 px-2">
 35            <MudCardContent>
 036                @if (_loading)
 37                {
 38                    <MudSkeleton Animation="Animation.Wave" />
 39                }
 40                else
 41                {
 42                    <MudGrid Justify="Justify.FlexStart" Spacing="1">
 43                        <MudItem xs="12" sm="6" md="6" lg="6">
 44                            <MudStack Spacing="1">
 45                                <MudText><strong>Professor:</strong> @_class.Teacher</MudText>
 46                                <MudText><strong>Status:</strong> @_class.Status.GetDescription()</MudText>
 47                                <MudText><strong>Alunos:</strong> @_class.FillRatio</MudText>
 48                                <MudText><strong>Horário:</strong> @_class.SchedulesInline</MudText>
 49                            </MudStack>
 50                        </MudItem>
 51                        <MudItem xs="12" sm="6" md="6" lg="6">
 52                            <MudStack Spacing="1">
 53                                <MudText><strong>Período:</strong> @_class.Period</MudText>
 54                                <MudText><strong>Aulas Concluídas:</strong> @_class.Progress</MudText>
 55                                <MudText><strong>Carga Horária:</strong> @_class.Workload</MudText>
 56                                <MudStack Row="true" AlignItems="AlignItems.Center">
 57                                    <MudText><strong>Frequência:</strong></MudText>
 058                                    @if (_class.Lessons.Any(x => x.Status == LessonStatus.Finalized))
 59                                    {
 60                                        <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value=
 61                                            <MudText Typo="Typo.body1">
 62                                                <b>@_class.Frequency.Format()%</b>
 63                                            </MudText>
 64                                        </MudProgressLinear>
 65                                    }
 66                                </MudStack>
 67                            </MudStack>
 68                        </MudItem>
 69                        <MudItem>
 70                            <MudStack Spacing="1">
 71                            </MudStack>
 72                        </MudItem>
 73                    </MudGrid>
 74                }
 75            </MudCardContent>
 76        </MudCard>
 77
 78        <MudContainer Class="px-0 mb-4">
 79            <MudTable
 80                Items="@GetLessons()"
 81                Class="pa-4"
 82                Dense="true"
 83                Hover="true"
 84                Loading="@_loading"
 85                Filter="@_quickFilter"
 86                RowsPerPage="10"
 87            >
 88                <ToolBarContent>
 89                    <SykiDataGridSearchTextField @bind-Value="@_searchString" Placeholder="Busque por qualquer atributo"
 90                </ToolBarContent>
 91                <HeaderContent>
 92                    <MudTh>Aula</MudTh>
 93                    <MudTh>Data</MudTh>
 94                    <MudTh>Horário</MudTh>
 95                    <MudTh>Status</MudTh>
 96                    <MudTh>Frequência</MudTh>
 97                </HeaderContent>
 98                <RowTemplate>
 99                    <MudTd DataLabel="Aula">@context.Number</MudTd>
 100                    <MudTd DataLabel="Data">@context.Date</MudTd>
 101                    <MudTd DataLabel="Horário">@context.Schedule</MudTd>
 102                    <MudTd DataLabel="Status">@context.Status.GetDescription()</MudTd>
 103                    <MudTd DataLabel="Frequência">
 0104                        @if (context.Status == LessonStatus.Finalized)
 105                        {
 106                            <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value="@decimal.To
 107                                <MudText Typo="Typo.body1">
 108                                    <b>@context.Frequency.Format()%</b>
 109                                </MudText>
 110                            </MudProgressLinear>
 111                        }
 112                    </MudTd>
 113                </RowTemplate>
 114                <LoadingContent>
 0115                    @if (_breakpoint == Breakpoint.Xs)
 116                    {
 117                        <MudProgressLinear Color="Color.Info" Indeterminate="true" />
 118                    }
 119                </LoadingContent>
 120                <NoRecordsContent>
 121                    @(GetNotFoundMessage())
 122                </NoRecordsContent>
 123                <PagerContent>
 124                    <SykiTablePager />
 125                </PagerContent>
 126            </MudTable>
 127        </MudContainer>
 128    }
 129    else
 130    {
 131        <MudContainer Class="px-0 my-4">
 132            <MudTable
 133                Items="@_students"
 134                Class="pa-4"
 135                Hover="true"
 136                Loading="@_loading"
 137                Dense="true"
 138                RowsPerPage="10"
 139                Filter="@_quickFilterStudents"
 140            >
 141                <ToolBarContent>
 142                    <SykiDataGridSearchTextField @bind-Value="@_searchStringStudents" Placeholder="Busque por nome" />
 143                </ToolBarContent>
 144                <HeaderContent>
 145                    <MudTh>Nome</MudTh>
 146                    <MudTh>N1</MudTh>
 147                    <MudTh>N2</MudTh>
 148                    <MudTh>N3</MudTh>
 149                    <MudTh>Média</MudTh>
 150                    <MudTh>Frequência</MudTh>
 151                </HeaderContent>
 152                <RowTemplate>
 153                    <MudTd DataLabel="Nome">@context.Name</MudTd>
 154                    <MudTd DataLabel="N1">@context.GetNote(ExamType.N1)</MudTd>
 155                    <MudTd DataLabel="N2">@context.GetNote(ExamType.N2)</MudTd>
 156                    <MudTd DataLabel="N3">@context.GetNote(ExamType.N3)</MudTd>
 157                    <MudTd DataLabel="Média">@context.AverageNote.Format()</MudTd>
 158                    <MudTd DataLabel="Frequência">
 0159                        @if (ShowFrequencyColumn())
 160                        {
 161                            <MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Large" Value="@decimal.To
 162                                <MudText Typo="Typo.body1">
 163                                    <b>@context.Frequency.Format()%</b>
 164                                </MudText>
 165                            </MudProgressLinear>
 166                        }
 167                    </MudTd>
 168                </RowTemplate>
 169                <NoRecordsContent>
 170                    @(GetStudentsNotFoundMessage())
 171                </NoRecordsContent>
 172                <PagerContent>
 173                    <SykiTablePager/>
 174                </PagerContent>
 175            </MudTable>
 176        </MudContainer>
 177    }
 178</MudContainer>
 179
 180@inject GetAcademicClassClient GetAcademicClassClient
 181@inject IBrowserViewportService BrowserViewportService
 182
 183@code
 184{
 185  [Parameter]
 0186  public Guid Id { get; set; }
 187
 188    private int _index;
 189    private bool _loading;
 190    private string _searchString;
 191    private string _searchStringStudents;
 0192    private GetAcademicClassOut _class = new();
 0193    private List<AcademicClassStudentOut> _students = [];
 194
 195    private Breakpoint _breakpoint;
 196
 197    protected override async Task OnInitializedAsync()
 198    {
 0199        _breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 0200        await Load();
 0201    }
 202
 203    private bool ShowFrequencyColumn()
 204    {
 0205        return _class.Lessons.Any(x => x.Status == LessonStatus.Finalized);
 206    }
 207
 208    private async Task Load()
 209    {
 0210        _loading = true;
 0211        var response = await GetAcademicClassClient.Get(Id);
 0212        if (response.IsSuccess())
 213        {
 0214            _class = response.GetSuccess();
 0215            _students = _class.Students.OrderBy(x => x.Name).ToList();
 216        }
 0217        _loading = false;
 0218    }
 219
 220    private IEnumerable<LessonOut> GetLessons()
 221    {
 0222        return _class.Lessons.OrderBy(x => x.Number).ToList();
 223    }
 224
 0225    private Func<LessonOut, bool> _quickFilter => x => _searchString.IsIn(x.Date.ToShortDateString(), x.Schedule, x.Stat
 0226    private Func<AcademicClassStudentOut, bool> _quickFilterStudents => x => _searchStringStudents.IsIn(x.Name);
 227
 228    private string GetNotFoundMessage()
 229    {
 0230        return (_searchString.IsEmpty()) ? "Não existem aulas ainda." : "Nenhuma aula encontrada.";
 231    }
 232
 233    private string GetStudentsNotFoundMessage()
 234    {
 0235        return (_searchString.IsEmpty()) ? "Não existem alunos matriculados ainda." : "Nenhum aluno encontrado.";
 236    }
 237}