223 lines
8.6 KiB
Plaintext
223 lines
8.6 KiB
Plaintext
@using Core.Calculation
|
|
@using Microsoft.EntityFrameworkCore
|
|
@page "/meeting-schedule"
|
|
@inject IConfiguration Configuration
|
|
@inject AppDbContext Context
|
|
|
|
<PageTitle>@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"]</PageTitle>
|
|
|
|
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"]</MudText>
|
|
|
|
|
|
<MudPaper Class="pa-4 mt-5">
|
|
@* <MudText>Include: @string.Join(", ", _requiredTeams) </MudText> *@
|
|
<MudGrid>
|
|
<MudItem xs="6" lg="3">
|
|
|
|
<MudStack>
|
|
|
|
<MudButton OnClick="() => AddHighLevelOfEffort()">Add High Effort</MudButton>
|
|
<MudButton OnClick="() => AddRegionals()">Add Regionals</MudButton>
|
|
|
|
<MudButton OnClick="() => RemoveIndividual()">Remove Individual</MudButton>
|
|
<MudButton OnClick="() => RemoveLowLevelOfEffort()">Remove Low Effort</MudButton>
|
|
|
|
<MudItem>@string.Join(", ", (_possibleAdditions ?? []).Select(e => e.ToString()))</MudItem>
|
|
|
|
<MudToggleGroup T="Team"
|
|
SelectionMode="SelectionMode.MultiSelection"
|
|
@bind-Values="_requiredTeams"
|
|
Vertical="true"
|
|
CheckMark>
|
|
@foreach (var team in _teams.OrderBy(e => e.Event.Name))
|
|
{
|
|
<MudToggleItem Value="@team" Style="font-size: .75rem;">
|
|
<MudTooltip Text="@string.Join(", ", team.Students.Select(s => s.FirstName))">
|
|
<div class="d-flex align-center justify-space-between flex-wrap">
|
|
<MudText Class="ellipsis">@team.ToString()</MudText>
|
|
<EventAttributes EventDefinition="@team.Event"></EventAttributes>
|
|
</div>
|
|
</MudTooltip>
|
|
</MudToggleItem>
|
|
}
|
|
</MudToggleGroup>
|
|
</MudStack>
|
|
</MudItem>
|
|
<MudItem xs="6" lg="9">
|
|
<MudText Typo="Typo.h4">Time Slots</MudText>
|
|
<MudNumericField @bind-Value="_parameters.TimeSlots"
|
|
Label="Time Slots" Min="1" Max="4"></MudNumericField>
|
|
<MudButton Class="ma-3" OnClick="Solve" Variant="Variant.Filled" Color="Color.Primary" Disabled="@_isSolving">Solve</MudButton>
|
|
<MudTable T="Team[]" ServerData="SolveSchedule" @ref="_solutionData">
|
|
<HeaderContent>
|
|
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
<MudTd>
|
|
<MudItem>Time slot: @context</MudItem>
|
|
@{
|
|
var ol = TeamSchedulerSolution.GetStudentTeamOverlaps(context);
|
|
}
|
|
@foreach (var t in context)
|
|
{
|
|
<MudItem>
|
|
@t.ToString() -
|
|
@string.Join(", ", t.Students.Select(s => s.FirstName + " " + (ol.Any(o => o.Item1.Equals(s)) ? "*" : "")))
|
|
</MudItem>
|
|
}
|
|
@* @foreach (var overlap in ol)
|
|
{
|
|
<MudItem>
|
|
@string.Join(", ", overlap.Item1)
|
|
</MudItem>
|
|
} *@
|
|
|
|
@{ var unscheduled = TeamSchedulerSolution.GetStudentsNotInTimSlot(context, _students); }
|
|
@if (unscheduled.Any())
|
|
{
|
|
<MudItem>Unscheduled</MudItem>
|
|
foreach (var student in unscheduled)
|
|
{
|
|
<MudItem>
|
|
<i>@student.FirstName</i>
|
|
@string.Join(", ", _solution.StudentUnassignedTeams(student).Select(e => e.ToString()))
|
|
</MudItem>
|
|
}
|
|
|
|
}
|
|
|
|
</MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
private Team[]? _teams;
|
|
private Student[]? _students;
|
|
MudTable<Team[]> _solutionData;
|
|
private TeamSchedulerSolution _solution;
|
|
private TeamSchedulerOptions _parameters;
|
|
bool _isSolving = false;
|
|
private IEnumerable<Team> _requiredTeams = [];
|
|
|
|
private Team[]? _possibleAdditions;
|
|
//private Team[] _requiredTeams = [];
|
|
|
|
private async Task OnSelectedValuesChanged(IEnumerable<Team> obj)
|
|
{
|
|
await _solutionData.ReloadServerData();
|
|
}
|
|
|
|
private async Task AddRegionals()
|
|
{
|
|
_requiredTeams
|
|
= _teams.Where(e => e.Event.RegionalEvent).Concat(_requiredTeams).Distinct();
|
|
}
|
|
|
|
private async Task AddHighLevelOfEffort()
|
|
{
|
|
_requiredTeams
|
|
= _teams.Where(e => e.Event.LevelOfEffort >= 3).Concat(_requiredTeams).Distinct();
|
|
}
|
|
|
|
private async Task RemoveIndividual()
|
|
{
|
|
_requiredTeams
|
|
= _requiredTeams.Where(t => t.Event.EventFormat != EventFormat.Individual);
|
|
}
|
|
|
|
private async Task RemoveLowLevelOfEffort()
|
|
{
|
|
_requiredTeams
|
|
= _requiredTeams.Where(t => t.Event.LevelOfEffort > 1);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_parameters =
|
|
new TeamSchedulerOptions(
|
|
timeSlots: 2,
|
|
mustIncludeEvents:
|
|
[
|
|
// "Medical Technology", "Electrical Applications" , "RegionalTeam",
|
|
// ,"Dragster", "Flight"
|
|
],
|
|
extended:
|
|
[
|
|
// "Invention", "Construction Challenge", "Mechanical", "Mass", "Micro"
|
|
//"STEM"
|
|
//"Community", "Vlogging"// "Microcontroller"
|
|
],
|
|
omittedEvents:
|
|
[
|
|
// "Vlogging", "Junior", "Community Service Video", "Digital Photography",
|
|
// "STEM"
|
|
|
|
//"Leadership",// "Electrical", //"Construction"
|
|
// "Forensic",
|
|
//"CAD"
|
|
//"I&I Team 1", "I&I Team 2"//, "Website Design",
|
|
],
|
|
absentStudents:
|
|
[
|
|
]
|
|
);
|
|
|
|
_teams
|
|
= await Context.Teams
|
|
.Include(e => e.Event)
|
|
.Include(e => e.Students)
|
|
.OrderBy(e => e.Event.Name)
|
|
.ThenBy(e => e.Identifier)
|
|
.ToArrayAsync();
|
|
|
|
_students =
|
|
await Context.Students
|
|
.Include(e => e.Teams)
|
|
.ThenInclude(e => e.Captain)
|
|
.Include(e => e.EventRankings)
|
|
.ThenInclude(e => e.EventDefinition)
|
|
.OrderBy(e => e.FirstName).ToArrayAsync();
|
|
}
|
|
|
|
private async Task<TableData<Team[]>> SolveSchedule(TableState arg1, CancellationToken arg2)
|
|
{
|
|
_isSolving = true;
|
|
var teamScheduler = new TeamScheduler(_requiredTeams, _parameters.TimeSlots);
|
|
|
|
// teamScheduler
|
|
// .ScheduleSeparate(
|
|
// _teams.First(e => e.Event.Name.Contains("Data Science")),
|
|
// _teams.First(e => e.Event.Name.Contains("Microcontroller Design"))
|
|
// );
|
|
|
|
_solution = teamScheduler.Solve();
|
|
|
|
var loe = new UnassignedStudentScheduler(_teams, _solution.TimeSlots).ScheduleStrategy(UnassignedScheduleStrategy.LevelOfEffort);
|
|
var biggest = new UnassignedStudentScheduler(_teams, _solution.TimeSlots).ScheduleStrategy(UnassignedScheduleStrategy.BiggestGroup);
|
|
var individual = new UnassignedStudentScheduler(_teams, _solution.TimeSlots).ScheduleStrategy(UnassignedScheduleStrategy.IndividualEvents);
|
|
var anyNotMeetingAlready = new UnassignedStudentScheduler(_teams, _solution.TimeSlots).ScheduleStrategy(UnassignedScheduleStrategy.AnyNotMeetingAlready);
|
|
|
|
_possibleAdditions = loe;
|
|
if (_possibleAdditions.Length == 0)
|
|
_possibleAdditions = biggest;
|
|
if (_possibleAdditions.Length == 0)
|
|
_possibleAdditions = anyNotMeetingAlready;
|
|
|
|
if (_possibleAdditions.Length == 0)
|
|
_possibleAdditions = individual;
|
|
|
|
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
|
|
|
|
_isSolving = false;
|
|
return new TableData<Team[]> { Items = _solution.TimeSlots};
|
|
}
|
|
|
|
private void Solve()
|
|
{
|
|
_solutionData.ReloadServerData();
|
|
}
|
|
}
|