Refactor Delete
Add Scheduler
This commit is contained in:
@@ -3,18 +3,21 @@
|
||||
|
||||
<MudPaper Width="250px" Class="d-inline-flex py-3" Elevation="0">
|
||||
<MudNavMenu Class="mud-width-full">
|
||||
<MudText Typo="Typo.h6" Class="px-4">TSA Chapter Organizer</MudText>
|
||||
<MudLink Typo="Typo.h6" Href="/" Class="px-4">TSA Chapter Organizer</MudLink>
|
||||
<MudText Typo="Typo.body2" Class="px-4 mud-text-secondary">@Configuration["ChapterSettings:Name"]</MudText>
|
||||
<MudDivider Class="my-2" />
|
||||
<MudDivider Class="my-2"/>
|
||||
<MudNavLink Href="/events" Icon="@AppIcons.Events">Events</MudNavLink>
|
||||
<MudNavGroup Title="Students" Icon="@Icons.Material.Filled.People" Expanded="true">
|
||||
<MudNavLink Href="/students" Icon="@Icons.Material.Filled.People">Students</MudNavLink>
|
||||
<MudNavLink Href="/students/event-ranking" Icon="@AppIcons.EventRank">Event Ranking</MudNavLink>
|
||||
</MudNavGroup>
|
||||
<MudNavLink Href="/students" Icon="@Icons.Material.Filled.People">Students</MudNavLink>
|
||||
|
||||
<MudNavGroup Title="Teams" Icon="@Icons.Material.Outlined.Groups" Expanded="true">
|
||||
<MudNavLink Href="/teams" Icon="@AppIcons.Teams">Teams</MudNavLink>
|
||||
<MudNavLink Href="/teams/assignment" Icon="@AppIcons.TeamAssignment">Event Assignment</MudNavLink>
|
||||
<MudNavLink Href="/teams/scheduler" Icon="@AppIcons.TeamAssignment">Schedule</MudNavLink>
|
||||
<MudNavLink Href="/teams/printout" Icon="@Icons.Material.Filled.Print">Print out</MudNavLink>
|
||||
<MudNavLink Href="/teams/handout" Icon="@Icons.Material.Filled.Print">Handout</MudNavLink>
|
||||
</MudNavGroup>
|
||||
<MudNavLink Href="/meeting-schedule/scheduler" Icon="@AppIcons.Scheduler">Schedule</MudNavLink>
|
||||
<MudNavGroup Title="Team Building" Icon="@Icons.Material.Filled.GroupAdd" Expanded="true">
|
||||
<MudNavLink Href="/students/event-ranking" Icon="@AppIcons.EventRank">Event Ranking</MudNavLink>
|
||||
<MudNavLink Href="/teams/assignment" Icon="@AppIcons.TeamAssignment">Team Assignment</MudNavLink>
|
||||
</MudNavGroup>
|
||||
</MudNavMenu>
|
||||
</MudPaper>
|
||||
@@ -2,6 +2,8 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using WebApp.Models
|
||||
@inject AppDbContext Context
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<PageTitle>Events - TSA Chapter Organizer</PageTitle>
|
||||
|
||||
@@ -46,7 +48,9 @@
|
||||
<MudIconButton Href="@($"/events/edit?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Edit">Edit</MudIconButton>
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Delete">
|
||||
<MudIconButton Href="@($"/events/delete?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Delete" Color="@Color.Warning">Delete</MudIconButton>
|
||||
<MudIconButton Icon="@Icons.Material.Outlined.Delete"
|
||||
Color="Color.Error"
|
||||
OnClick="() => DeleteEventDefinition(context.Item)" />
|
||||
</MudTooltip>
|
||||
</MudButtonGroup>
|
||||
</MudStack>
|
||||
@@ -75,4 +79,26 @@
|
||||
Items = pagedData
|
||||
};
|
||||
}
|
||||
|
||||
private async Task DeleteEventDefinition(EventDefinition evt)
|
||||
{
|
||||
//_isRowBlocked = true;
|
||||
|
||||
var result = await DialogService
|
||||
.ShowMessageBox("Delete Event",
|
||||
(MarkupString)$"Are you sure want to delete <b>{evt.Name}</b>? This cannot be undone.",
|
||||
yesText:"Yes",
|
||||
noText:"Cancel");
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
Context.Events.Remove(evt!);
|
||||
await Context.SaveChangesAsync();
|
||||
Snackbar.Add($"Delete event: Delete of Event {evt.Name}", Severity.Info);
|
||||
}
|
||||
|
||||
//_isRowBlocked = false;
|
||||
StateHasChanged();
|
||||
_dataGrid.ReloadServerData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<PageTitle>Home</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h2">TSA Chapter Organizer</MudText>
|
||||
<MudImage Fluid="true" Src="TCO_Title.png" Alt="TSA Chapter Organizer"></MudImage>
|
||||
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Name"]</MudText>
|
||||
|
||||
<MudLink Href="events">
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
@using WebApp.Models
|
||||
<MudPaper>
|
||||
<h3>Legend</h3>
|
||||
|
||||
<MudContainer>
|
||||
<ul>
|
||||
<li>@AppIcons.LevelOfEffortIcon(1) - Level of Effort </li>
|
||||
<li>@AppIcons.IndividualEvent - Individual Event </li>
|
||||
<li>@AppIcons.RegionalEvent - Regional </li>
|
||||
<li>@AppIcons.OnSiteActivity - On-site Activity</li>
|
||||
<li>@AppIcons.PresubmissionEvent - Pre-submission</li>
|
||||
<li>@AppIcons.PresentationEvent - Interview Or Presentation</li>
|
||||
</ul>
|
||||
</MudContainer>
|
||||
</MudPaper>
|
||||
@@ -0,0 +1,287 @@
|
||||
@using Core.Calculation
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@page "/meeting-schedule/scheduler"
|
||||
@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">
|
||||
<MudGrid>
|
||||
<MudItem Style="width:160px;">
|
||||
<MudNumericField @bind-Value="_parameters.TimeSlots"
|
||||
Label="Time Slots" Min="1" Max="4"></MudNumericField>
|
||||
</MudItem>
|
||||
@foreach (var evt in _options)
|
||||
{
|
||||
<MudItem Style="width:200px">
|
||||
|
||||
<MudButtonGroup>
|
||||
<MudTooltip Text="Require">
|
||||
<MudToggleIconButton @bind-Toggled="@evt.Require"
|
||||
Icon="@Icons.Material.Filled.CheckBoxOutlineBlank"
|
||||
ToggledIcon="@Icons.Material.Filled.CheckBox"
|
||||
ToggledColor="@Color.Success"
|
||||
Disabled="@evt.Omit"
|
||||
Size="Size.Small"
|
||||
title="@(evt.Require ? "Required" : "Optional")" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Extend">
|
||||
<MudToggleIconButton @bind-Toggled="@evt.Extend"
|
||||
Icon="@Icons.Material.Filled.PlusOne"
|
||||
ToggledIcon="@Icons.Material.Filled.PlusOne"
|
||||
ToggledColor="@Color.Success"
|
||||
Disabled="@evt.Omit"
|
||||
Size="Size.Small"
|
||||
title="@(evt.Extend ? "Extend" : "Single")" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Extend">
|
||||
<MudToggleIconButton @bind-Toggled="@evt.Omit"
|
||||
Icon="@Icons.Material.Filled.EventBusy"
|
||||
ToggledIcon="@Icons.Material.Filled.EventBusy"
|
||||
ToggledColor="@Color.Error"
|
||||
Size="Size.Small"
|
||||
title="@(evt.Omit ? "Omit" : "Optional")" />
|
||||
</MudTooltip>
|
||||
</MudButtonGroup>
|
||||
<MudTooltip Text="@string.Join(", ", evt.Team.Students.Select(e => e.FirstName))">
|
||||
<MudText>@evt.Team.ToString()</MudText>
|
||||
</MudTooltip>
|
||||
</MudItem>
|
||||
}
|
||||
@* <MudItem>
|
||||
<MudTooltip Text="Require at least one On-Site Event">
|
||||
<MudSwitch @bind-Value="_parameters" Color="Color.Info"
|
||||
Label="On-Site" />
|
||||
</MudTooltip>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudTooltip Text="Require at least one Regional Event">
|
||||
<MudSwitch @bind-Value="_parameters.RequireRegional" Color="Color.Info"
|
||||
Label="Regional" />
|
||||
</MudTooltip>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudStack Style="width:100px;">
|
||||
<MudTooltip Text="Student Event Count Assignment Range">
|
||||
<MudInputLabel>Event Count</MudInputLabel>
|
||||
</MudTooltip>
|
||||
<MudNumericField @bind-Value="_parameters.EventsLowerBound"
|
||||
Label="At Least" Min="2" Max="4"></MudNumericField>
|
||||
|
||||
<MudNumericField @bind-Value="_parameters.EventsUpperBound"
|
||||
Label="Up to" Min="3" Max="5"></MudNumericField>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudStack Style="width:100px;">
|
||||
<MudTooltip Text="Student Level of Effort Range">
|
||||
<MudInputLabel>LOE</MudInputLabel>
|
||||
</MudTooltip>
|
||||
<MudNumericField @bind-Value="_parameters.EffortLowerBound"
|
||||
Label="At Least" Min="4" Max="7"></MudNumericField>
|
||||
|
||||
<MudNumericField @bind-Value="_parameters.EffortUpperBound"
|
||||
Label="Up to" Min="7" Max="12"></MudNumericField>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudInputLabel>Assignment Requirements</MudInputLabel>
|
||||
<MudTable T="AssignmentRequirement" ServerData="ReloadAssignmentRequirements" @ref="_assignmentRequirementData">
|
||||
|
||||
<RowTemplate Context="item">
|
||||
<MudTd Class="align-center">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.RemoveCircle" Size="Size.Small"
|
||||
OnClick="() => RemoveRequireEvent(item)"></MudIconButton>
|
||||
</MudTd>
|
||||
<MudTd Class="align-center">
|
||||
@item.Student.FirstName
|
||||
@item.EventDefinition.ShortName
|
||||
@if (item.Requirement == Requirement.Include)
|
||||
{
|
||||
<MudIcon Class="ml-3" Icon="@Icons.Material.Filled.ThumbUp" Size="Size.Small"></MudIcon>
|
||||
}
|
||||
@if (item.Requirement == Requirement.Exclude)
|
||||
{
|
||||
<MudIcon Class="ml-3" Icon="@Icons.Material.Filled.ThumbDownAlt" Size="Size.Small"></MudIcon>
|
||||
}
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudInputLabel>Two Team Events</MudInputLabel>
|
||||
<MudTable T="EventDefinition" ServerData="ReloadEventTwoTeam" @ref="_eventTwoTeamData">
|
||||
|
||||
<RowTemplate Context="item">
|
||||
<MudTd Class="align-center">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.RemoveCircle" Size="Size.Small"
|
||||
OnClick="() => RemoveTwoTeam(item)"></MudIconButton>
|
||||
</MudTd>
|
||||
<MudTd Class="align-center">@item.ShortName</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudItem>
|
||||
<MudItem>
|
||||
<MudInputLabel>Omitted Events</MudInputLabel>
|
||||
<MudTable T="EventDefinition" ServerData="ReloadOmittedEvents" @ref="_eventOmittedData">
|
||||
|
||||
<RowTemplate Context="item">
|
||||
<MudTd Class="align-center">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.RemoveCircle" Size="Size.Small"
|
||||
OnClick="() => RemoveOmitted(item)"></MudIconButton>
|
||||
</MudTd>
|
||||
<MudTd Class="align-center">@item.ShortName</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudItem> *@
|
||||
</MudGrid>
|
||||
<MudButton Class="ma-3" OnClick="Solve" Variant="Variant.Filled" Color="Color.Primary" Disabled="@_isSolving">Solve</MudButton>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
<MudItem xs="12" lg="4">
|
||||
<MudText Typo="Typo.h4">Time Slots</MudText>
|
||||
<MudTable T="Team[]" ServerData="SolveSchedule" @ref="_solutionData">
|
||||
<HeaderContent>
|
||||
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
@{
|
||||
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 notInTimeSLot = TeamSchedulerSolution.GetStudentsNotInTimSlot(context, _students); }
|
||||
@if (notInTimeSLot.Any()) {
|
||||
<MudItem>
|
||||
<i>
|
||||
Not scheduled: @string.Join(", ", notInTimeSLot.Select(s => s.FirstName))
|
||||
</i>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudItem>
|
||||
|
||||
@code {
|
||||
private Team[]? _teams;
|
||||
private Student[]? _students;
|
||||
MudTable<Team[]> _solutionData;
|
||||
private TeamSchedulerSolution _solution;
|
||||
private TeamSchedulerOptions _parameters;
|
||||
bool _isSolving = false;
|
||||
|
||||
public class TeamOptions
|
||||
{
|
||||
public Team Team { get; set; }
|
||||
public bool Require { get; set; } = false;
|
||||
public bool Omit { get; set; } = false;
|
||||
public bool Extend { get; set; } = false;
|
||||
}
|
||||
|
||||
private TeamOptions[]? _options;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_parameters =
|
||||
new TeamSchedulerOptions(
|
||||
timeSlots: 4,
|
||||
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.Number)
|
||||
.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();
|
||||
|
||||
_options = _teams
|
||||
.Select(e => new TeamOptions { Team = e })
|
||||
.ToArray();
|
||||
|
||||
}
|
||||
|
||||
private async Task<TableData<Team[]>> SolveSchedule(TableState arg1, CancellationToken arg2)
|
||||
{
|
||||
//_isSolving = true;
|
||||
|
||||
|
||||
|
||||
var mustIncludeTeams = _teams;
|
||||
mustIncludeTeams = mustIncludeTeams.Where(t => t.Event.EventFormat != EventFormat.Individual).ToArray();
|
||||
mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("#1")).ToArray();
|
||||
//mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("Photo")).ToArray();
|
||||
|
||||
var teamScheduler = new TeamScheduler(mustIncludeTeams, 3);
|
||||
|
||||
// teamScheduler
|
||||
// .ScheduleSeparate(
|
||||
// _teams.First(e => e.Event.Name.Contains("Data Science")),
|
||||
// _teams.First(e => e.Event.Name.Contains("Microcontroller Design"))
|
||||
// );
|
||||
|
||||
_solution = teamScheduler.Solve();
|
||||
|
||||
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
|
||||
|
||||
return new TableData<Team[]> { Items = _solution.TimeSlots};
|
||||
}
|
||||
|
||||
|
||||
private void Solve()
|
||||
{
|
||||
_solutionData.ReloadServerData();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<h3>Index</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
@page "/students/delete"
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@inject AppDbContext context
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<PageTitle>Delete Student - TSA Chapter Organizer</PageTitle>
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<p>Are you sure you want to delete this?</p>
|
||||
<div>
|
||||
<h2>Student</h2>
|
||||
<hr />
|
||||
@if (student is null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else {
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">FirstName</dt>
|
||||
<dd class="col-sm-10">@student.FirstName</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">LastName</dt>
|
||||
<dd class="col-sm-10">@student.LastName</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">Grade</dt>
|
||||
<dd class="col-sm-10">@student.Grade</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">StateId</dt>
|
||||
<dd class="col-sm-10">@student.StateId</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">RegionalId</dt>
|
||||
<dd class="col-sm-10">@student.RegionalId</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">NationalId</dt>
|
||||
<dd class="col-sm-10">@student.NationalId</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">TsaYear</dt>
|
||||
<dd class="col-sm-10">@student.TsaYear</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">OfficerRole</dt>
|
||||
<dd class="col-sm-10">@student.OfficerRole</dd>
|
||||
</dl>
|
||||
<EditForm method="post" Model="student" OnValidSubmit="DeleteStudent" FormName="delete" Enhance>
|
||||
<button type="submit" class="btn btn-danger" disabled="@(student is null)">Delete</button> |
|
||||
<a href="/students">Back to List</a>
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private Student? student;
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
private int Id { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
student = await context.Students.FirstOrDefaultAsync(m => m.Id == Id);
|
||||
|
||||
if (student is null)
|
||||
{
|
||||
NavigationManager.NavigateTo("notfound");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteStudent()
|
||||
{
|
||||
context.Students.Remove(student!);
|
||||
await context.SaveChangesAsync();
|
||||
NavigationManager.NavigateTo("/students");
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
@using WebApp.Models
|
||||
@inject AppDbContext Context
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<PageTitle>Students - TSA Chapter Organizer</PageTitle>
|
||||
|
||||
@@ -41,8 +42,7 @@
|
||||
<MudTooltip Text="Delete">
|
||||
<MudIconButton Icon="@Icons.Material.Outlined.Delete"
|
||||
Color="Color.Error"
|
||||
|
||||
OnClick="() => DeleteElement(context.Item)" />
|
||||
OnClick="() => DeleteStudent(context.Item)" />
|
||||
</MudTooltip>
|
||||
</MudButtonGroup>
|
||||
</MudStack>
|
||||
@@ -74,24 +74,21 @@
|
||||
};
|
||||
}
|
||||
|
||||
private async Task DeleteElement(object obj)
|
||||
private async Task DeleteStudent(Student student)
|
||||
{
|
||||
//_isRowBlocked = true;
|
||||
|
||||
if (obj is Student student)
|
||||
{
|
||||
var result = await DialogService
|
||||
.ShowMessageBox("Delete student",
|
||||
(MarkupString)$"Are you sure want to delete <b>{student.Name}</b>?",
|
||||
yesText:"Yes",
|
||||
noText:"Cancel");
|
||||
var result = await DialogService
|
||||
.ShowMessageBox("Delete student",
|
||||
(MarkupString)$"Are you sure want to delete <b>{student.Name}</b>? This cannot be undone.",
|
||||
yesText:"Yes",
|
||||
noText:"Cancel");
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
Context.Students.Remove(student!);
|
||||
await Context.SaveChangesAsync();
|
||||
//Snackbar.Add($"Delete event: Delete of Element {element.Name}", Severity.Info);
|
||||
}
|
||||
if (result == true)
|
||||
{
|
||||
Context.Students.Remove(student!);
|
||||
await Context.SaveChangesAsync();
|
||||
Snackbar.Add($"Delete event: Delete of Student {student.Name}", Severity.Info);
|
||||
}
|
||||
|
||||
//_isRowBlocked = false;
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
@page "/teams/delete"
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@inject AppDbContext context
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<PageTitle>Delete Team</PageTitle>
|
||||
|
||||
<h1>Delete</h1>
|
||||
|
||||
<p>Are you sure you want to delete this?</p>
|
||||
<div>
|
||||
<h2>Team</h2>
|
||||
<hr />
|
||||
@if (team is null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else {
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">Team</dt>
|
||||
<dd class="col-sm-10">@team.Event.Name</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">Students</dt>
|
||||
<dd class="col-sm-10">@string.Join(",", team.Students.Select(e => e.Name))</dd>
|
||||
</dl>
|
||||
|
||||
<EditForm method="post" Model="team" OnValidSubmit="DeleteTeam" FormName="delete" Enhance>
|
||||
<button type="submit" class="btn btn-danger" disabled="@(team is null)">Delete</button> |
|
||||
<a href="/teams">Back to List</a>
|
||||
</EditForm>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private Team? team;
|
||||
|
||||
[SupplyParameterFromQuery]
|
||||
private int Id { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
team = await context.Teams
|
||||
.Include(e => e.Event)
|
||||
.Include(e => e.Students)
|
||||
.FirstOrDefaultAsync(m => m.Id == Id);
|
||||
|
||||
if (team is null)
|
||||
{
|
||||
NavigationManager.NavigateTo("notfound");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteTeam()
|
||||
{
|
||||
context.Teams.Remove(team!);
|
||||
await context.SaveChangesAsync();
|
||||
NavigationManager.NavigateTo("/teams");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using WebApp.Models
|
||||
@page "/teams/handout"
|
||||
@inject IConfiguration Configuration
|
||||
@inject AppDbContext Context
|
||||
|
||||
<PageTitle>@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</MudText>
|
||||
<MudText Typo="Typo.h5" Class="mb-4">Yearly theme: Unity Through Community</MudText>
|
||||
|
||||
@if (_teams == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudContainer>
|
||||
@foreach (var studentForEvents in _students)
|
||||
{
|
||||
<MudContainer Class="pagebreak">
|
||||
<MudText Typo="Typo.h4">@studentForEvents.Name</MudText>
|
||||
@foreach (var team in studentForEvents.Teams)
|
||||
{
|
||||
<MudContainer Class="mt-3 mb-1 nobrk">
|
||||
<MudGrid>
|
||||
<MudItem xs="6">
|
||||
<MudStack>
|
||||
<MudItem>
|
||||
<MudText Class="d-flex py-1" Typo="Typo.h5">
|
||||
@team.ToString()
|
||||
</MudText>
|
||||
</MudItem>
|
||||
|
||||
@if (team.Event.RegionalEvent)
|
||||
{
|
||||
<MudItem>
|
||||
<MudText Class="d-flex" Typo="Typo.caption"><i>Regional Event</i></MudText>
|
||||
</MudItem>
|
||||
}
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
<MudItem xs="2">
|
||||
<MudText>
|
||||
<strong>@team.Event.EventFormat</strong>
|
||||
</MudText>
|
||||
|
||||
</MudItem>
|
||||
<MudItem xs="1">
|
||||
<strong>Effort</strong>: @AppIcons.LevelOfEffortIcon(@team.Event.LevelOfEffort)
|
||||
</MudItem>
|
||||
<MudItem xs="3">
|
||||
<strong>Activity</strong>: @team.Event.SemifinalistActivity
|
||||
</MudItem>
|
||||
@if (team.Event.EventFormat == EventFormat.Team)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudText Class="d-flex py-1" Typo="Typo.h6">
|
||||
Team Members: @string.Join(", ", team.Students.OrderByDescending(e => e.Grade + e.TsaYear).Select(e => e.FirstName))
|
||||
</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
<MudItem xs="12">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Description</MudText>
|
||||
</MudItem>
|
||||
@if (!string.IsNullOrEmpty(team.Event.Theme))
|
||||
{
|
||||
<MudItem xs="3">
|
||||
<MudText Class="d-flex py-1">
|
||||
<i>Theme for 2025-26:</i>
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Theme</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(team.Event.Documentation))
|
||||
{
|
||||
<MudItem xs="3">
|
||||
<MudText Class="d-flex py-1">
|
||||
<i>Materials:</i>
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Documentation</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
</MudGrid>
|
||||
</MudContainer>
|
||||
<MudDivider/>
|
||||
}
|
||||
</MudContainer>
|
||||
}
|
||||
</MudContainer>
|
||||
}
|
||||
@code {
|
||||
private Team[]? _teams;
|
||||
private int _maxTeamSize;
|
||||
private Student[]? _students;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_teams
|
||||
= await Context.Teams
|
||||
.Include(e => e.Event)
|
||||
.Include(e => e.Students)
|
||||
.OrderBy(e => e.Event.Name)
|
||||
.ThenBy(e => e.Number)
|
||||
.ToArrayAsync();
|
||||
|
||||
_maxTeamSize = _teams.Max(t => t.Students.Count);
|
||||
_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();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using WebApp.Models
|
||||
@inject AppDbContext Context
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<PageTitle>TimeSlots</PageTitle>
|
||||
|
||||
@@ -11,6 +13,7 @@
|
||||
<MudButton StartIcon="@Icons.Material.Filled.Assignment" Href="teams/assignment">Assignment</MudButton>
|
||||
<MudButton StartIcon="@Icons.Material.Filled.Print" Href="teams/printout">Printout</MudButton>
|
||||
|
||||
|
||||
<MudDataGrid T="Team" ServerData="ServerReload" @ref="_dataGrid" Filterable="true" RowsPerPage="35">
|
||||
<Columns>
|
||||
<PropertyColumn Property="@(e => e.ToString())" Title="Event" />
|
||||
@@ -51,7 +54,9 @@
|
||||
<MudIconButton Href="@($"/teams/edit?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Edit">Edit</MudIconButton>
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Delete">
|
||||
<MudIconButton Href="@($"/teams/delete?id={context.Item.Id}")" Icon="@Icons.Material.Filled.Delete" Color="@Color.Warning">Delete</MudIconButton>
|
||||
<MudIconButton Icon="@Icons.Material.Outlined.Delete"
|
||||
Color="Color.Error"
|
||||
OnClick="() => DeleteTeam(context.Item)" />
|
||||
</MudTooltip>
|
||||
</MudButtonGroup>
|
||||
</MudStack>
|
||||
@@ -87,4 +92,26 @@
|
||||
Items = pagedData
|
||||
};
|
||||
}
|
||||
|
||||
private async Task DeleteTeam(Team team)
|
||||
{
|
||||
//_isRowBlocked = true;
|
||||
|
||||
var result = await DialogService
|
||||
.ShowMessageBox("Delete team",
|
||||
(MarkupString)$"Are you sure want to delete <b>{team}</b>? This cannot be undone.",
|
||||
yesText: "Yes",
|
||||
noText: "Cancel");
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
Context.Teams.Remove(team!);
|
||||
await Context.SaveChangesAsync();
|
||||
Snackbar.Add($"Delete event: Delete of Team {team}", Severity.Info);
|
||||
}
|
||||
|
||||
//_isRowBlocked = false;
|
||||
StateHasChanged();
|
||||
_dataGrid.ReloadServerData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</MudText>
|
||||
<MudText Typo="Typo.h5" Class="mb-4">Yearly theme: Unity Through Community</MudText>
|
||||
|
||||
<Legend></Legend>
|
||||
@if (_teams == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
@@ -199,86 +200,6 @@ else
|
||||
</MudTable>
|
||||
|
||||
</MudContainer>
|
||||
|
||||
<MudContainer>
|
||||
@foreach (var studentForEvents in _students)
|
||||
{
|
||||
<MudContainer Class="pagebreak">
|
||||
<MudText Typo="Typo.h4">@studentForEvents.Name</MudText>
|
||||
@foreach (var team in studentForEvents.Teams)
|
||||
{
|
||||
<MudContainer Class="mt-3 mb-1 nobrk">
|
||||
<MudGrid>
|
||||
<MudItem xs="6">
|
||||
<MudStack>
|
||||
<MudItem>
|
||||
<MudText Class="d-flex py-1" Typo="Typo.h5">
|
||||
@team.ToString()
|
||||
</MudText>
|
||||
</MudItem>
|
||||
|
||||
@if (team.Event.RegionalEvent)
|
||||
{
|
||||
<MudItem>
|
||||
<MudText Class="d-flex" Typo="Typo.caption"><i>Regional Event</i></MudText>
|
||||
</MudItem>
|
||||
}
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
<MudItem xs="2">
|
||||
<MudText>
|
||||
<strong>@team.Event.EventFormat</strong>
|
||||
</MudText>
|
||||
|
||||
</MudItem>
|
||||
<MudItem xs="1">
|
||||
<strong>Effort</strong>: @AppIcons.LevelOfEffortIcon(@team.Event.LevelOfEffort)
|
||||
</MudItem>
|
||||
<MudItem xs="3">
|
||||
<strong>Activity</strong>: @team.Event.SemifinalistActivity
|
||||
</MudItem>
|
||||
@if (team.Event.EventFormat == EventFormat.Team)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudText Class="d-flex py-1" Typo="Typo.h6">
|
||||
Team Members: @string.Join(", ", team.Students.OrderByDescending(e => e.Grade + e.TsaYear).Select(e => e.FirstName))
|
||||
</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
<MudItem xs="12">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Description</MudText>
|
||||
</MudItem>
|
||||
@if (!string.IsNullOrEmpty(team.Event.Theme))
|
||||
{
|
||||
<MudItem xs="3">
|
||||
<MudText Class="d-flex py-1">
|
||||
<i>Theme for 2025-26:</i>
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Theme</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(team.Event.Documentation))
|
||||
{
|
||||
<MudItem xs="3">
|
||||
<MudText Class="d-flex py-1">
|
||||
<i>Materials:</i>
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="8">
|
||||
<MudText Class="d-flex py-1" Style="white-space:pre-wrap;">@team.Event.Documentation</MudText>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
</MudGrid>
|
||||
</MudContainer>
|
||||
<MudDivider/>
|
||||
}
|
||||
</MudContainer>
|
||||
}
|
||||
</MudContainer>
|
||||
}
|
||||
@code {
|
||||
private Team[]? _teams;
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
@using Core.Calculation
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@page "/teams/scheduler"
|
||||
@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>
|
||||
|
||||
<MudItem xs="12" lg="4">
|
||||
<MudText Typo="Typo.h4">Time Slots</MudText>
|
||||
<MudTable T="Team[]" ServerData="SolveSchedule" @ref="_solutionData">
|
||||
<HeaderContent>
|
||||
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>
|
||||
@{
|
||||
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 notInTimeSLot = TeamSchedulerSolution.GetStudentsNotInTimSlot(context, _students); }
|
||||
@if (notInTimeSLot.Any()) {
|
||||
<MudItem>
|
||||
<i>
|
||||
Not scheduled: @string.Join(", ", notInTimeSLot.Select(s => s.FirstName))
|
||||
</i>
|
||||
</MudItem>
|
||||
}
|
||||
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudItem>
|
||||
|
||||
@code {
|
||||
private Team[]? _teams;
|
||||
private Student[]? _students;
|
||||
MudTable<Team[]> _solutionData;
|
||||
private TeamSchedulerSolution _solution;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_teams
|
||||
= await Context.Teams
|
||||
.Include(e => e.Event)
|
||||
.Include(e => e.Students)
|
||||
.OrderBy(e => e.Event.Name)
|
||||
.ThenBy(e => e.Number)
|
||||
.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 scheduleOptions =
|
||||
new TeamSchedulerOptions(
|
||||
timeSlots: 4,
|
||||
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:
|
||||
[
|
||||
]
|
||||
);
|
||||
|
||||
var mustIncludeTeams = _teams;
|
||||
mustIncludeTeams = mustIncludeTeams.Where(t => t.Event.EventFormat != EventFormat.Individual).ToArray();
|
||||
mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("#1")).ToArray();
|
||||
//mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("Photo")).ToArray();
|
||||
|
||||
var teamScheduler = new TeamScheduler(mustIncludeTeams, 3);
|
||||
|
||||
|
||||
// teamScheduler
|
||||
// .ScheduleSeparate(
|
||||
// _teams.First(e => e.Event.Name.Contains("Data Science")),
|
||||
// _teams.First(e => e.Event.Name.Contains("Microcontroller Design"))
|
||||
// );
|
||||
|
||||
_solution = teamScheduler.Solve();
|
||||
|
||||
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
|
||||
|
||||
return new TableData<Team[]> { Items = _solution.TimeSlots};
|
||||
}
|
||||
}
|
||||
+12
-10
@@ -10,6 +10,7 @@ namespace WebApp.Models
|
||||
public static string Student = Icons.Material.Filled.Person;
|
||||
public static string TeamAssignment = Icons.Material.Filled.GroupAdd;
|
||||
public static string Events = Icons.Material.Filled.Dashboard;
|
||||
public static string Scheduler = Icons.Material.Filled.CalendarViewDay;
|
||||
public static string LevelOfEffortIcon(int? loe)
|
||||
{
|
||||
|
||||
@@ -22,10 +23,11 @@ namespace WebApp.Models
|
||||
};
|
||||
}
|
||||
|
||||
public static string OnSiteActivity = "ⓐ";
|
||||
public static string RegionalEvent = "ⓡ";
|
||||
public static string IndividualEvent = "ⓘ";
|
||||
public static string PresubmissionEvent = "🕑";
|
||||
/*https://unicodeplus.com/search*/
|
||||
public static string OnSiteActivity = "𝔸";
|
||||
public static string RegionalEvent = "ℝ";
|
||||
public static string IndividualEvent = "ⅈ";
|
||||
public static string PresubmissionEvent = "↩";
|
||||
public static string PresentationEvent = "ⓟ";
|
||||
public static string QuestionMark = "❔";
|
||||
|
||||
@@ -40,14 +42,14 @@ namespace WebApp.Models
|
||||
|
||||
if (eventDefinition.EventFormat == EventFormat.Individual)
|
||||
v.Add(IndividualEvent);
|
||||
if (eventDefinition.InterviewOrPresentation)
|
||||
v.Add(PresentationEvent);
|
||||
if (eventDefinition.OnSiteActivity)
|
||||
v.Add(OnSiteActivity);
|
||||
if (eventDefinition.Presubmission)
|
||||
v.Add(PresubmissionEvent);
|
||||
if (eventDefinition.RegionalEvent)
|
||||
v.Add(RegionalEvent);
|
||||
if (eventDefinition.InterviewOrPresentation)
|
||||
v.Add(PresentationEvent);
|
||||
if (eventDefinition.Presubmission)
|
||||
v.Add(PresubmissionEvent);
|
||||
if (eventDefinition.OnSiteActivity)
|
||||
v.Add(OnSiteActivity);
|
||||
|
||||
return string.Join(" ", v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user