feat: merge event rankings and attribute badges into the page printer
Interview notes can print each student's ranked events and a shared attribute legend from the same catalog as the ranking index, without leftover table markup or collapsed answer space. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using Core.Entities;
|
||||
|
||||
namespace Core.Printing;
|
||||
|
||||
/// <summary>
|
||||
/// Rank labels and colors shared by the ranking index, print badges, and legend.
|
||||
/// </summary>
|
||||
public static class EventRankLegend
|
||||
{
|
||||
public static readonly IReadOnlyList<(int Rank, string Label)> Items =
|
||||
[
|
||||
.. Enumerable.Range(1, StudentEventRanking.MaxRank)
|
||||
.Select(rank => (rank, Ordinal(rank)))
|
||||
];
|
||||
|
||||
public static string Ordinal(int num)
|
||||
{
|
||||
if (num <= 0)
|
||||
return num.ToString();
|
||||
|
||||
switch (num % 100)
|
||||
{
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
return num + "th";
|
||||
}
|
||||
|
||||
return (num % 10) switch
|
||||
{
|
||||
1 => num + "st",
|
||||
2 => num + "nd",
|
||||
3 => num + "rd",
|
||||
_ => num + "th"
|
||||
};
|
||||
}
|
||||
|
||||
public static string ColorHex(int rank) =>
|
||||
rank switch
|
||||
{
|
||||
1 => "#dd7e6b",
|
||||
2 => "#ea9999",
|
||||
3 => "#f9cb9c",
|
||||
4 => "#ffe599",
|
||||
5 => "#fff2cc",
|
||||
6 => "#fffaea",
|
||||
7 => "#fffefa",
|
||||
8 => "#fffefc",
|
||||
9 => "#fffffd",
|
||||
10 => "#fffffe",
|
||||
_ => "#ddd"
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user