@using Core.Entities
@model Tuple<Student[]>
@{
    ViewData["Title"] = "Student Handout Page";
}

@foreach (var s in Model.Item1.OrderBy(n => n.FirstName))
{
	<div class="container nobrk pt-5">
		<p><i>@DateTime.Today.ToShortDateString()</i></p>
		<h2><i>TSA teams and eventDefinitions:</i> @s.FirstNameLastName </h2>

		@foreach (var team in 
			s.Teams.OrderByDescending(t => t.EventDefinition.EventFormat == EventFormat.Team)
				.ThenByDescending(t => t.EventDefinition.LevelOfEffort)
				.ThenByDescending(t => t.Name))
		{
			var evt = team.EventDefinition;
			<div>
				@if (evt.RegionalEvent)
				{
					<div class="row">
						<div class="col">
							<i>Regional EventDefinition</i>
						</div>
					</div>
				}
				<div div class="row">
					<div class="col-6">
						<h5>@evt.Name&nbsp;&nbsp;&nbsp;@Html.Partial("EffortStarsPartial", evt.LevelOfEffort)</h5>
					</div>
					<div class="col-4">
						@if (evt.EventFormat is EventFormat.Team)
						{
							<html>
							<strong>Teammates</strong><br/>
							@string.Join(", ", team.Students.OrderByDescending(s => s.Grade + s.TsaYear).ThenBy(s => s.FirstName).Where(tm => tm != s).Select(tm => tm.FirstName))
							</html>
						}
						else
						{
							<html>
							<strong>@evt.EventFormat</strong>
							</html>
						}

					</div>
					<div class="col-2">
						@evt.SemifinalistActivity
						@if (evt.StatePresubmission)
						{<text>, State Presubmission <strong>due March 14th</strong></text>}
						@if (evt.StatePretesting)
						{<text>, State Pre-testing <strong>April 2nd</strong></text>}
						@if (evt.StatePreliminaryRound)
						{<text>, State Preliminary and Semifinalist Rounds</text>}
					</div>
				</div>
				<div div class="row mt-3">
					<div class="col">@evt.Description</div></div>
				@if (!string.IsNullOrEmpty(evt.Theme))
				{
					<div div class="row mt-2">
						<div class="col-3 text-center"><i>Theme for 2024-25:</i></div>
						<div class="col">@evt.Theme</div>
					</div>
				}

				@if (!string.IsNullOrEmpty(evt.Documentation))
				{
					<div div class="row mt-2">
						<div class="col-3 text-center"><i>Materials:</i></div>
						<div class="col">@evt.Documentation</div>
					</div>
				}
				<hr/>
			</div>
		}
	</div>
}
