Compare commits
20 Commits
6753acc04f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a1bf573a07 | |||
| 525f3fb4ae | |||
| 9f298d8ce8 | |||
| 11d9c641a6 | |||
| c2f7adc1d0 | |||
| c19f96ea37 | |||
| 9bbde62d70 | |||
| a83f97828c | |||
| 44654dd784 | |||
| 410055c9f2 | |||
| ce75d8aa0b | |||
| be436f1b1c | |||
| 14c11b81b6 | |||
| dd38b91d68 | |||
| 987f27fcbc | |||
| 42ecde799c | |||
| ce70d86fd3 | |||
| ea280ea05d | |||
| c2e230ca48 | |||
| 30317dd1bb |
@@ -4,7 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="spplus.MainWindow" WindowState="Maximized"
|
x:Class="spplus.MainWindow" WindowState="Maximized"
|
||||||
Title="SP+">
|
Title="spplus">
|
||||||
<Border>
|
<Border>
|
||||||
<Grid RowDefinitions="30,*">
|
<Grid RowDefinitions="30,*">
|
||||||
<Menu Background="#50888888">
|
<Menu Background="#50888888">
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<MenuItem Header="Über" x:Name="MnuAbout" Click="MnuAbout_OnClick" />
|
<MenuItem Header="Über" x:Name="MnuAbout" Click="MnuAbout_OnClick" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<TabControl x:Name="TclMainView" Grid.Row="1">
|
<TabControl x:Name="TclMainView" Grid.Row="1" TabStripPlacement="Left">
|
||||||
<TabItem>
|
<TabItem>
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -88,6 +88,11 @@
|
|||||||
<Label Content="Anzahl gewählte Kurse"></Label>
|
<Label Content="Anzahl gewählte Kurse"></Label>
|
||||||
<Label Grid.Column="1" x:Name="LblSelectedAmount"></Label>
|
<Label Grid.Column="1" x:Name="LblSelectedAmount"></Label>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="*,3*">
|
||||||
|
<Label Content="Wahlzahlen"></Label>
|
||||||
|
<Label Grid.Column="1" x:Name="LblNumVoted"></Label>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
@@ -171,23 +176,28 @@
|
|||||||
<StackPanel Grid.Column="1" Orientation="Vertical">
|
<StackPanel Grid.Column="1" Orientation="Vertical">
|
||||||
<Grid ColumnDefinitions="*,50,50">
|
<Grid ColumnDefinitions="*,50,50">
|
||||||
<TextBox Grid.Column="0" Height="35" HorizontalAlignment="Stretch" x:Name="TbSportAlternativeName"></TextBox>
|
<TextBox Grid.Column="0" Height="35" HorizontalAlignment="Stretch" x:Name="TbSportAlternativeName"></TextBox>
|
||||||
<Button Grid.Column="1" Margin="0,10,0,0" x:Name="BtnAlternativeNameAdd" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnAlternativeNameAdd_OnClick" HorizontalContentAlignment="Center">
|
<Button Grid.Column="1" Margin="5,0,0,0" x:Name="BtnAlternativeNameAdd" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnAlternativeNameAdd_OnClick" HorizontalContentAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="Plus" Width="24" Height="24" />
|
<LucideIcon Kind="Plus" Width="24" Height="24" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="2" Margin="0,10,0,0" x:Name="BtnAlternativeNameRemove" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnAlternativeNameRemove_OnClick" HorizontalContentAlignment="Center">
|
<Button Grid.Column="2" Margin="5,0,0,0" x:Name="BtnAlternativeNameRemove" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnAlternativeNameRemove_OnClick" HorizontalContentAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="Minus" Width="24" Height="24" />
|
<LucideIcon Kind="Minus" Width="24" Height="24" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ListBox x:Name="LbAlternativeNames">
|
<ListBox Margin="0,5,0,0" x:Name="LbAlternativeNames">
|
||||||
|
|
||||||
</ListBox>
|
</ListBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Line />
|
||||||
|
<Grid ColumnDefinitions="*,3*">
|
||||||
|
<Label Content="Maximale Sportkursanzahl pro Semester"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester" ValueChanged="NudSportMaxPerSemester_OnValueChanged"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
@@ -200,21 +210,30 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid ColumnDefinitions="*,*" RowDefinitions="50,2*,*">
|
<Grid ColumnDefinitions="*,*" RowDefinitions="50,2*,*">
|
||||||
<ListBox Grid.RowSpan="2" x:Name="LbResult" Margin="10,10,10,10"></ListBox>
|
<ListBox Grid.RowSpan="2" x:Name="LbResult" Margin="0,10,10,10"></ListBox>
|
||||||
<Button Grid.Row="0" Grid.Column="1" Margin="0,10,0,0" x:Name="BtnExportCoursePDF" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnExportCoursePDF_OnClick" HorizontalContentAlignment="Center">
|
<Grid Grid.Row="0" Grid.Column="1" Grid.ColumnDefinitions="*,*">
|
||||||
<StackPanel Orientation="Horizontal">
|
<Button Grid.Column="0" Margin="0,10,0,0" x:Name="BtnExportCoursePDF" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnExportCoursePDF_OnClick" HorizontalContentAlignment="Center">
|
||||||
<LucideIcon Kind="FileText" Width="24" Height="24" />
|
<StackPanel Orientation="Horizontal">
|
||||||
<Label Content="Export (PDF)..." VerticalContentAlignment="Center" FontSize="12"
|
<LucideIcon Kind="FileText" Width="24" Height="24" />
|
||||||
FontWeight="Bold" />
|
<Label Content="Export (PDF)..." VerticalContentAlignment="Center" FontSize="12"
|
||||||
</StackPanel>
|
FontWeight="Bold" />
|
||||||
</Button>
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="1" Margin="5,10,0,0" x:Name="BtnExportCourseCSV" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnExportCourseCSV_OnClick" HorizontalContentAlignment="Center">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<LucideIcon Kind="FileJson" Width="24" Height="24" />
|
||||||
|
<Label Content="Export (CSV)..." VerticalContentAlignment="Center" FontSize="12"
|
||||||
|
FontWeight="Bold" />
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
<ScrollViewer Grid.Row="1" Grid.Column="1" Margin="0,5,0,10" Background="#44CCCCCC">
|
<ScrollViewer Grid.Row="1" Grid.Column="1" Margin="0,5,0,10" Background="#44CCCCCC">
|
||||||
<TextBlock x:Name="TbResultStatistics"></TextBlock>
|
<TextBlock x:Name="TbResultStatistics"></TextBlock>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<ScrollViewer Grid.Row="2" Grid.Column="1" Margin="0" Background="#44CCCCCC">
|
<ScrollViewer Grid.Row="2" Grid.Column="1" Margin="0,0,0,10" Background="#44CCCCCC">
|
||||||
<TextBlock x:Name="TbResultTextout" FontFamily="Consolas"></TextBlock>
|
<TextBlock x:Name="TbResultTextout" FontFamily="Consolas"></TextBlock>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<ScrollViewer Grid.Row="2" Grid.Column="0" Margin="0" Background="#44CCCCCC">
|
<ScrollViewer Grid.Row="2" Grid.Column="0" Margin="0,0,10,10" Background="#44CCCCCC">
|
||||||
<TextBlock x:Name="TbResultLog" FontFamily="Consolas"></TextBlock>
|
<TextBlock x:Name="TbResultLog" FontFamily="Consolas"></TextBlock>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -11,11 +11,17 @@ namespace spplus;
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public static MainWindow Instance { get; set; }
|
public static MainWindow Instance { get; set; }
|
||||||
|
public static string ApplicationVersion = "v1.2.24";
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Settings.ImportInitial();
|
Settings.ImportInitial();
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
RefreshCoursesList();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
|
private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
|
||||||
@@ -35,7 +41,7 @@ public partial class MainWindow : Window
|
|||||||
Process.Start(new ProcessStartInfo
|
Process.Start(new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "https://git.mypapercloud.de/fierke/spplus/wiki",
|
FileName = "https://git.mypapercloud.de/fierke/spplus/wiki",
|
||||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
UseShellExecute = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -51,7 +57,7 @@ public partial class MainWindow : Window
|
|||||||
Process.Start(new ProcessStartInfo
|
Process.Start(new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "https://git.mypapercloud.de/fierke/spplus",
|
FileName = "https://git.mypapercloud.de/fierke/spplus",
|
||||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
UseShellExecute = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -70,7 +76,7 @@ public partial class MainWindow : Window
|
|||||||
Grid g = new();
|
Grid g = new();
|
||||||
TextBlock tb = new()
|
TextBlock tb = new()
|
||||||
{
|
{
|
||||||
Text = "spplus v1.0.0\n(c)2026 MyPapertown, Elias Fierke"
|
Text = $"spplus {MainWindow.ApplicationVersion}\n(c)2026 MyPapertown, Elias Fierke"
|
||||||
};
|
};
|
||||||
g.Children.Add(tb);
|
g.Children.Add(tb);
|
||||||
w.Content = g;
|
w.Content = g;
|
||||||
@@ -117,14 +123,40 @@ public partial class MainWindow : Window
|
|||||||
LblStudentAmount.Content = Settings.Instance.Students.Count.ToString();
|
LblStudentAmount.Content = Settings.Instance.Students.Count.ToString();
|
||||||
LblSelectedAmount.Content = count_selected.ToString();
|
LblSelectedAmount.Content = count_selected.ToString();
|
||||||
|
|
||||||
|
List<(Sport, List<string>)> initial_sportlist = new();
|
||||||
|
foreach (var sp in Settings.Instance.Sports)
|
||||||
|
{
|
||||||
|
initial_sportlist.Add((sp, new()));
|
||||||
|
}
|
||||||
|
foreach (Student s in Settings.Instance.Students)
|
||||||
|
{
|
||||||
|
foreach (var sp in s.SelectedCourseNames)
|
||||||
|
{
|
||||||
|
foreach (var item in initial_sportlist)
|
||||||
|
{
|
||||||
|
if (item.Item1.AlternativeNames.Contains(sp))
|
||||||
|
{
|
||||||
|
item.Item2.Add(s.ID);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LblNumVoted.Content = "";
|
||||||
|
foreach (var s in initial_sportlist)
|
||||||
|
{
|
||||||
|
LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Craft courses here / call course-crafter
|
|
||||||
CourseCrafter.Craft();
|
CourseCrafter.Craft();
|
||||||
RefreshResultView();
|
RefreshResultView();
|
||||||
TbiResults.Focus();
|
TclMainView.SelectedIndex = 2;
|
||||||
|
//TbiResults.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshResultView()
|
private void RefreshResultView()
|
||||||
@@ -134,7 +166,7 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(int i = 0; i<s.Result.Count;i++)
|
for(int i = 0; i<s.Result.Length;i++)
|
||||||
{
|
{
|
||||||
LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}");
|
LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}");
|
||||||
}
|
}
|
||||||
@@ -383,4 +415,31 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
// Export as PDF
|
// Export as PDF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NudSportMaxPerSemester_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Settings.Instance.NumCoursesPerSemester = Convert.ToInt32(NudSportMaxPerSemester.Value);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void BtnExportCourseCSV_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var topLevel = GetTopLevel(this);
|
||||||
|
var file = await topLevel!.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||||
|
{
|
||||||
|
Title = "CSV-Datei speichern",
|
||||||
|
SuggestedFileType = new FilePickerFileType(".csv-Datei")
|
||||||
|
{
|
||||||
|
Patterns = new[] { "*.csv" }
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
if (file == null) return;
|
||||||
|
|
||||||
|
ExportUtility.ExportToCSV(file.Path.AbsolutePath);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
# SP+
|
# SP+
|
||||||
|
|
||||||
Interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch SuS.
|
Plattformunabhängiger (Windows, Linux, Mac), interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch SuS.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* \+ Import von CSV-Dateien mit Kurswahl
|
* \+ Import von CSV-Dateien mit Kurswahl
|
||||||
* \+ Wahlansicht
|
* \+ Wahlansicht
|
||||||
* \+ Statistiken
|
* \+ Statistiken
|
||||||
* \+ Pflege von Sportkursen (inkl. Kürzel/ alternativen Bezeichnungen)
|
* \+ Pflege von Sportkursen (inkl. Kürzel/ alternativen Bezeichnungen)
|
||||||
|
* \+ CSV-Export
|
||||||
* ~ Fehleransicht für nicht-existente, aber gewählte Kurse
|
* ~ Fehleransicht für nicht-existente, aber gewählte Kurse
|
||||||
|
* ~ PDF-Export
|
||||||
|
|
||||||
\+ Vorhanden, ~ Pending
|
\+ Vorhanden, ~ Pending
|
||||||
|
|
||||||
|
|||||||
255
crafter.cs
255
crafter.cs
@@ -80,8 +80,8 @@ public class CourseCrafter
|
|||||||
}
|
}
|
||||||
GeneratedCourses.Add((semester, inst));
|
GeneratedCourses.Add((semester, inst));
|
||||||
|
|
||||||
MainWindow.Instance.TbResultLog.Text += ($"{semester} -> {inst.Students.Count}\n");
|
//MainWindow.Instance.TbResultLog.Text += ($"{semester} -> {inst.Students.Count}\n");
|
||||||
MainWindow.Instance.TbResultLog.Text += ($"{students_in_semester[0].Count} - {students_in_semester[1].Count} - {students_in_semester[2].Count} - {students_in_semester[3].Count}\n\n");
|
//MainWindow.Instance.TbResultLog.Text += ($"{students_in_semester[0].Count} - {students_in_semester[1].Count} - {students_in_semester[2].Count} - {students_in_semester[3].Count}\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
semeq0: ;
|
semeq0: ;
|
||||||
@@ -120,8 +120,8 @@ public class CourseCrafter
|
|||||||
item.Item2.Remove(s);
|
item.Item2.Remove(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainWindow.Instance.TbResultLog.Text += ($"{ci.Semester} -> {ci.Instance.Students.Count}\n");
|
//MainWindow.Instance.TbResultLog.Text += ($"{ci.Semester} -> {ci.Instance.Students.Count}\n");
|
||||||
MainWindow.Instance.TbResultLog.Text += ($"{students_in_semester[0].Count} - {students_in_semester[1].Count} - {students_in_semester[2].Count} - {students_in_semester[3].Count}\n\n");
|
//MainWindow.Instance.TbResultLog.Text += ($"{students_in_semester[0].Count} - {students_in_semester[1].Count} - {students_in_semester[2].Count} - {students_in_semester[3].Count}\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,25 +193,6 @@ public class CourseCrafter
|
|||||||
|
|
||||||
} while (changed && iteration < maxIterations);
|
} while (changed && iteration < maxIterations);
|
||||||
|
|
||||||
int getSemester()
|
|
||||||
{
|
|
||||||
//int sem = 0;
|
|
||||||
if (GeneratedCourses.Count == 0) return 1; // zunächst im ersten Semester beginnen
|
|
||||||
int[] semcount = new int[4] {0,0,0,0}; // Anzahl der generierten Kurse im jeweiligen Semester
|
|
||||||
foreach (var inst in GeneratedCourses)
|
|
||||||
{
|
|
||||||
semcount[inst.Semester - 1]++; // ...füllen
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i<semcount.Length; i++) // durchlaufen und prüfen
|
|
||||||
{
|
|
||||||
if (semcount[i] < Settings.Instance.NumCoursesPerSemester)
|
|
||||||
{
|
|
||||||
return i+1; // Semester zurückgeben, wenn genug da sind
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isStudentFree(int semester, string studentID)
|
bool isStudentFree(int semester, string studentID)
|
||||||
{
|
{
|
||||||
@@ -244,7 +225,7 @@ public class CourseCrafter
|
|||||||
|
|
||||||
if (low >= initial_sportlist.Count) return true;
|
if (low >= initial_sportlist.Count) return true;
|
||||||
|
|
||||||
if (globalCount >= 12) return true;
|
if (globalCount >= 20) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,35 +234,111 @@ public class CourseCrafter
|
|||||||
MainWindow.Instance.TbResultTextout.Text += $"{tuple.Item1}: {tuple.Item2.Count} remaining\n";
|
MainWindow.Instance.TbResultTextout.Text += $"{tuple.Item1}: {tuple.Item2.Count} remaining\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSemesterForSport(Sport sp)
|
// ...existing code...
|
||||||
|
int getSemesterForSport2(Sport sp)
|
||||||
{
|
{
|
||||||
int[] semcount = new int[4] {0,0,0,0};
|
int[] semcount = new int[4];
|
||||||
|
|
||||||
foreach (var inst in GeneratedCourses)
|
foreach (var inst in GeneratedCourses)
|
||||||
{
|
|
||||||
semcount[inst.Semester - 1]++;
|
semcount[inst.Semester - 1]++;
|
||||||
}
|
|
||||||
|
int bestSem = 0;
|
||||||
|
int minCourses = int.MaxValue;
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
// 1. Ist der Sport in diesem Semester erlaubt?
|
|
||||||
if (sp.Semester[i] == 0) continue;
|
if (sp.Semester[i] == 0) continue;
|
||||||
|
|
||||||
// 2. Ist noch Platz für Kurse?
|
// prüfen, ob für diesen Sport im Semester i schon die maximale Anzahl erreicht ist
|
||||||
if (semcount[i] < Settings.Instance.NumCoursesPerSemester)
|
int sportCoursesInSemester = GeneratedCourses
|
||||||
|
.Count(g => g.Semester == i + 1 && g.Instance.Sport.ID == sp.ID);
|
||||||
|
|
||||||
|
if (sportCoursesInSemester >= sp.Semester[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (semcount[i] < Settings.Instance.NumCoursesPerSemester &&
|
||||||
|
semcount[i] < minCourses)
|
||||||
{
|
{
|
||||||
return i + 1;
|
minCourses = semcount[i];
|
||||||
|
bestSem = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return bestSem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSemesterForSport(Sport sp)
|
||||||
|
{
|
||||||
|
// 1. Zähle alle Kurse pro Semester (egal welche Sportart)
|
||||||
|
int[] totalCoursesPerSemester = new int[4];
|
||||||
|
foreach (var inst in GeneratedCourses)
|
||||||
|
totalCoursesPerSemester[inst.Semester - 1]++;
|
||||||
|
|
||||||
|
int bestSem = 0;
|
||||||
|
int minCourses = int.MaxValue;
|
||||||
|
|
||||||
|
// 2. Kandidaten-Semester durchgehen
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
// a) Sport darf in diesem Semester gar nicht stattfinden?
|
||||||
|
if (sp.Semester[i] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int semesterNumber = i + 1;
|
||||||
|
|
||||||
|
// b) Wie viele Kurse DIESES Sports gibt es schon in diesem Semester?
|
||||||
|
int sportCoursesInThisSemester = GeneratedCourses
|
||||||
|
.Count(g => g.Semester == semesterNumber &&
|
||||||
|
g.Instance.Sport.Name == sp.Name);
|
||||||
|
|
||||||
|
// c) Pro-Sport-Limit erreicht?
|
||||||
|
if (sportCoursesInThisSemester >= sp.Semester[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// d) Globales Limit pro Semester erreicht?
|
||||||
|
if (totalCoursesPerSemester[i] >= Settings.Instance.NumCoursesPerSemester)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// e) Wähle das Semester mit bisher insgesamt den wenigsten Kursen
|
||||||
|
if (totalCoursesPerSemester[i] < minCourses)
|
||||||
|
{
|
||||||
|
minCourses = totalCoursesPerSemester[i];
|
||||||
|
bestSem = semesterNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestSem; // 0, falls kein zulässiges Semester gefunden
|
||||||
|
}
|
||||||
|
|
||||||
|
var errors = ValidateCourses(GeneratedCourses);
|
||||||
|
|
||||||
|
if (errors.Count == 0)
|
||||||
|
{
|
||||||
|
MainWindow.Instance.TbResultLog.Text = "--- Alle generierten Kursen erfüllen die gegebenen Voraussetzungen ---";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainWindow.Instance.TbResultLog.Text = "--- Bei der Generierung sind folgende Fehler aufgetreten: ---\n\n";
|
||||||
|
foreach (var e in errors)
|
||||||
|
MainWindow.Instance.TbResultLog.Text += e + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var course in GeneratedCourses)
|
||||||
|
{
|
||||||
|
foreach (var student in Settings.Instance.Students)
|
||||||
|
{
|
||||||
|
if (course.Instance.Students.Contains(student.ID))
|
||||||
|
{
|
||||||
|
student.Result[course.Semester-1] = course.Instance.Sport.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateStatistics()
|
public static string GenerateStatistics()
|
||||||
{
|
{
|
||||||
|
GeneratedCourses.Sort((x,y) => x.Semester.CompareTo(y.Semester) );
|
||||||
string sb = $"Generierte Kurse: {GeneratedCourses.Count}\n\n";
|
string sb = $"Generierte Kurse: {GeneratedCourses.Count}\n\n";
|
||||||
foreach (var genc in GeneratedCourses)
|
foreach (var genc in GeneratedCourses)
|
||||||
{
|
{
|
||||||
@@ -293,64 +350,106 @@ public class CourseCrafter
|
|||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateStatisticsOld()
|
public static List<string> ValidateCourses(List<(int Semester, CourseInstance Instance)> courses)
|
||||||
{
|
{
|
||||||
var settings = Settings.Instance;
|
List<string> errors = new();
|
||||||
var students = settings.Students;
|
|
||||||
|
|
||||||
if (GeneratedCourses == null || GeneratedCourses.Count == 0)
|
// --- 1. Min/Max + Semester erlaubt ---
|
||||||
return "Keine Kurse generiert.";
|
foreach (var tuple in courses)
|
||||||
|
|
||||||
int semesterCount = students
|
|
||||||
.Where(s => s.Result != null)
|
|
||||||
.Select(s => s.Result!.Count)
|
|
||||||
.DefaultIfEmpty(0)
|
|
||||||
.Max();
|
|
||||||
|
|
||||||
var sb = new System.Text.StringBuilder();
|
|
||||||
|
|
||||||
sb.AppendLine($"Anzahl generierter Kurse: {GeneratedCourses.Count}");
|
|
||||||
sb.AppendLine("Übersicht:");
|
|
||||||
|
|
||||||
// ===== Kursübersicht =====
|
|
||||||
var grouped = GeneratedCourses
|
|
||||||
.GroupBy(g => new { g.Semester, g.Instance.Sport.Name })
|
|
||||||
.OrderBy(g => g.Key.Semester)
|
|
||||||
.ThenBy(g => g.Key.Name);
|
|
||||||
|
|
||||||
foreach (var group in grouped)
|
|
||||||
{
|
{
|
||||||
int counter = 1;
|
int semester = tuple.Semester;
|
||||||
|
var inst = tuple.Instance;
|
||||||
|
var sport = inst.Sport;
|
||||||
|
|
||||||
foreach (var entry in group)
|
if (inst.Students.Count < sport.MinStudents)
|
||||||
{
|
{
|
||||||
int semester = group.Key.Semester + 1;
|
errors.Add($"[Min] {sport.Name} (Sem {semester}): {inst.Students.Count} < {sport.MinStudents}");
|
||||||
string sportName = group.Key.Name;
|
}
|
||||||
string number = counter.ToString("D2");
|
|
||||||
int count = entry.Instance.Students.Count;
|
|
||||||
|
|
||||||
sb.AppendLine(
|
if (inst.Students.Count > sport.MaxStudents)
|
||||||
$"Semester {semester}: {sportName} {number}: {count} Schüler*innen"
|
{
|
||||||
);
|
errors.Add($"[Max] {sport.Name} (Sem {semester}): {inst.Students.Count} > {sport.MaxStudents}");
|
||||||
|
}
|
||||||
|
|
||||||
counter++;
|
if (sport.Semester[semester - 1] == 0)
|
||||||
|
{
|
||||||
|
errors.Add($"[Semester] {sport.Name} darf nicht in Semester {semester} stattfinden");
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- doppelte Schüler im selben Kurs ---
|
||||||
|
for (int i = 0; i < inst.Students.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = i + 1; j < inst.Students.Count; j++)
|
||||||
|
{
|
||||||
|
if (inst.Students[i] == inst.Students[j])
|
||||||
|
{
|
||||||
|
errors.Add($"[Kurs-Duplikat] {inst.Students[i]} mehrfach in {sport.Name} (Sem {semester})");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine();
|
// --- 2. Schüler doppelt im Semester ---
|
||||||
sb.AppendLine("Fehlerübersicht:");
|
for (int sem = 1; sem <= 4; sem++)
|
||||||
|
|
||||||
// ===== Fehler pro Semester =====
|
|
||||||
for (int sem = 0; sem < semesterCount; sem++)
|
|
||||||
{
|
{
|
||||||
int errors = students.Count(st =>
|
List<string> students = new();
|
||||||
st.Result != null &&
|
|
||||||
st.Result.Count > sem &&
|
|
||||||
st.Result[sem] == "Fehler");
|
|
||||||
|
|
||||||
sb.AppendLine($"Semester {sem + 1}: {errors} Fehler");
|
foreach (var tuple in courses)
|
||||||
|
{
|
||||||
|
if (tuple.Semester != sem) continue;
|
||||||
|
|
||||||
|
foreach (var stud in tuple.Instance.Students)
|
||||||
|
{
|
||||||
|
// prüfen ob schon drin
|
||||||
|
bool exists = false;
|
||||||
|
foreach (var s in students)
|
||||||
|
{
|
||||||
|
if (s == stud)
|
||||||
|
{
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
errors.Add($"[Doppelt] Schüler {stud} doppelt in Semester {sem}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
students.Add(stud);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
// --- 3. Sport-Angebote pro Semester zählen ---
|
||||||
|
// (ohne Dictionary: wir iterieren über alle Kurse und zählen jeweils erneut)
|
||||||
|
|
||||||
|
foreach (var tuple in courses)
|
||||||
|
{
|
||||||
|
int semester = tuple.Semester;
|
||||||
|
var sport = tuple.Instance.Sport;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
foreach (var other in courses)
|
||||||
|
{
|
||||||
|
if (other.Semester == semester &&
|
||||||
|
other.Instance.Sport.Name == sport.Name)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int allowed = sport.Semester[semester - 1];
|
||||||
|
|
||||||
|
if (count > allowed)
|
||||||
|
{
|
||||||
|
errors.Add($"[Sport-Semester] {sport.Name} in Sem {semester}: {count} Kurse > erlaubt {allowed}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
exporter.cs
Normal file
19
exporter.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace spplus;
|
||||||
|
|
||||||
|
public static class ExportUtility
|
||||||
|
{
|
||||||
|
public static void ExportToCSV(string filepath)
|
||||||
|
{
|
||||||
|
char separator = ',';
|
||||||
|
string header = $"SchuelerID{separator}Sem1{separator}Sem2{separator}Sem3{separator}Sem4";
|
||||||
|
string output = header + "\n";
|
||||||
|
foreach (var student in Settings.Instance.Students)
|
||||||
|
{
|
||||||
|
output += $"{student.ID}{separator}{student.Result[0]}{separator}{student.Result[1]}{separator}{student.Result[2]}{separator}{student.Result[3]}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(filepath, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,7 +59,7 @@ public class Student
|
|||||||
public string ID { get; set; } = ""; // ID des Schüler (z.B. NolteSeb)
|
public string ID { get; set; } = ""; // ID des Schüler (z.B. NolteSeb)
|
||||||
public string Name { get; set; } = ""; // Name des Schülers
|
public string Name { get; set; } = ""; // Name des Schülers
|
||||||
public List<string> SelectedCourseNames { get; set; } = new();
|
public List<string> SelectedCourseNames { get; set; } = new();
|
||||||
public List<string>? Result { get; set; } = null;
|
public string[] Result { get; set; } = new string[4];
|
||||||
|
|
||||||
public Student()
|
public Student()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user