28 Commits

Author SHA1 Message Date
fierke a0eac4ae95 Merge pull request '[chore:] better crafting' (#5) from bettercrafting into main
Reviewed-on: #5
2026-05-30 11:33:11 +00:00
fierke 22e9377062 [chore:] better crafting 2026-05-29 12:52:02 +02:00
fierke 11e6aab8fd [fix:] removed triple-calling of OptimizeStudentWishCoverage() 2026-04-22 07:25:46 +02:00
fierke 13f313d4a0 Merge remote-tracking branch 'origin/main' 2026-04-21 14:14:07 +02:00
fierke 64951c579f [fix:] massive bug that prevented correct course crafting (sports's id was always 0) 2026-04-21 14:13:54 +02:00
fierke 4130c36335 [chore:] import function that won't be called 2026-04-21 14:13:14 +02:00
fierke 7f2fc99d0b [gui:] import-button in the menu 2026-04-21 14:12:54 +02:00
fierke eb640ff749 [chore:] file picker, but currently not using the file itself 2026-04-21 14:12:40 +02:00
fierke 54a564df04 [chore:] tiny little comment to prevent confusion 2026-04-21 14:11:51 +02:00
fierke 71dc63f2a2 [file:] added logo 2026-04-18 16:04:14 +02:00
fierke 68f673c8d7 Update README.md 2026-04-15 11:48:44 +00:00
fierke d5b7fd7af3 [file:] uploaded app-screenshots 2026-04-15 13:45:37 +02:00
fierke 573e7c86e8 [fix:] course amount per semester synchronized with NumCoursesPerSemester, fixing #1 2026-04-15 13:22:12 +02:00
fierke a1bf573a07 [chore:] updated version 2026-03-19 08:53:53 +01:00
fierke 525f3fb4ae Update README.md 2026-03-19 07:52:11 +00:00
fierke 9f298d8ce8 [chore:] implemented csv-export access from gui 2026-03-19 08:49:03 +01:00
fierke 11d9c641a6 [chore:] cleanup 2026-03-19 08:48:51 +01:00
fierke c2f7adc1d0 [fix:] typo 2026-03-19 08:48:34 +01:00
fierke c19f96ea37 [chore:] added results to Student.Result 2026-03-19 08:48:24 +01:00
fierke 9bbde62d70 [feat:] csv-exporter (basic implementation) 2026-03-19 08:48:01 +01:00
fierke a83f97828c [chore:] changed Student.Result-Field-Type to array 2026-03-19 08:47:38 +01:00
fierke 44654dd784 [gui:] added csv-export placeholder button 2026-03-18 14:37:23 +01:00
fierke 410055c9f2 [chore:] tiny improvements for ux 2026-03-18 14:33:45 +01:00
fierke ce75d8aa0b [gui:] re-renamed to spplus since it looks better :D 2026-03-18 14:33:33 +01:00
fierke be436f1b1c [feat:] voting numbers (total count) visible after importing 2026-03-18 14:24:49 +01:00
fierke 14c11b81b6 [gui:] added label for voting numbers 2026-03-18 14:24:31 +01:00
fierke dd38b91d68 [fix:] inconsistent gui 2026-03-18 14:19:12 +01:00
fierke 987f27fcbc [fix]: inconsistent course creation when changing NumCoursePerSemester 2026-03-18 14:13:16 +01:00
10 changed files with 1362 additions and 664 deletions
+25 -10
View File
@@ -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">
@@ -12,6 +12,7 @@
<!-- <MenuItem Click="MnuSettings_OnClick" x:Name="MnuSettings" Header="Einstellungen" /> --> <!-- <MenuItem Click="MnuSettings_OnClick" x:Name="MnuSettings" Header="Einstellungen" /> -->
<!-- <Separator /> --> <!-- <Separator /> -->
<MenuItem x:Name="MnuExpSettings" Header="Einstellungen exportieren" Click="MnuExpSettings_OnClick" /> <MenuItem x:Name="MnuExpSettings" Header="Einstellungen exportieren" Click="MnuExpSettings_OnClick" />
<MenuItem x:Name="MnuImpResult" Header="Berechnung importieren" Click="MnuImpResult_OnClick" />
<MenuItem x:Name="MnuExit" Header="Beenden" Click="MnuExit_OnClick"/> <MenuItem x:Name="MnuExit" Header="Beenden" Click="MnuExit_OnClick"/>
</MenuItem> </MenuItem>
<MenuItem Header="Hilfe"> <MenuItem Header="Hilfe">
@@ -20,7 +21,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 +89,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>
@@ -205,14 +211,23 @@
</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>
+461 -398
View File
@@ -1,399 +1,462 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
namespace spplus; 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 MainWindow() public static string ApplicationVersion = "v1.2.24";
{ public MainWindow()
InitializeComponent(); {
Settings.ImportInitial(); InitializeComponent();
Instance = this; Settings.ImportInitial();
RefreshCoursesList(); Instance = this;
try RefreshCoursesList();
{ try
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester; {
} catch {} NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
} } catch {}
}
private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
{ private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
var res = MessageBox.Show(this, "Dieses Feature ist noch nicht implementiert", "Fehlend"); {
} var res = MessageBox.Show(this, "Dieses Feature ist noch nicht implementiert", "Fehlend");
}
private void MnuExit_OnClick(object? sender, RoutedEventArgs e)
{ private void MnuExit_OnClick(object? sender, RoutedEventArgs e)
Environment.Exit(0); {
} Environment.Exit(0);
}
private void MnuHelp_OnClick(object? sender, RoutedEventArgs e)
{ private void MnuHelp_OnClick(object? sender, RoutedEventArgs e)
try {
{ try
Process.Start(new ProcessStartInfo {
{ Process.Start(new ProcessStartInfo
FileName = "https://git.mypapercloud.de/fierke/spplus/wiki", {
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen FileName = "https://git.mypapercloud.de/fierke/spplus/wiki",
}); UseShellExecute = true
} });
catch (Exception ex) }
{ catch (Exception ex)
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}"); {
} Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
} }
}
private void MnuGit_OnClick(object? sender, RoutedEventArgs e)
{ private void MnuGit_OnClick(object? sender, RoutedEventArgs e)
try {
{ try
Process.Start(new ProcessStartInfo {
{ Process.Start(new ProcessStartInfo
FileName = "https://git.mypapercloud.de/fierke/spplus", {
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen FileName = "https://git.mypapercloud.de/fierke/spplus",
}); UseShellExecute = true
} });
catch (Exception ex) }
{ catch (Exception ex)
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}"); {
} Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
} }
}
private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
{ private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
Window w = new(); {
w.WindowState = WindowState.Normal; Window w = new();
w.WindowStartupLocation = WindowStartupLocation.CenterScreen; w.WindowState = WindowState.Normal;
w.Width = 300; w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
w.Height = 120; w.Width = 300;
Grid g = new(); w.Height = 120;
TextBlock tb = new() Grid g = 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); };
w.Content = g; g.Children.Add(tb);
w.Show(); w.Content = g;
} w.Show();
}
private async void BtnImport_OnClick(object? sender, RoutedEventArgs e)
{ private async void BtnImport_OnClick(object? sender, RoutedEventArgs e)
var topLevel = GetTopLevel(this); {
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions var topLevel = GetTopLevel(this);
{ var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
Title = "CSV-Datei auswählen", {
AllowMultiple = false, Title = "CSV-Datei auswählen",
FileTypeFilter = new[] AllowMultiple = false,
{ FileTypeFilter = new[]
new FilePickerFileType(".csv-Datei") {
{ new FilePickerFileType(".csv-Datei")
Patterns = new[] { "*.csv" } {
} Patterns = new[] { "*.csv" }
} }
}); }
});
if (file == null) return;
if (file.Count == 0) return; if (file == null) return;
if (file.Count == 0) return;
var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
foreach (var s in imported_students) var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
{ foreach (var s in imported_students)
Settings.Instance.Students.Add(s); {
} Settings.Instance.Students.Add(s);
RefreshImportedStudentList(); }
RefreshImportedStudentList();
}
}
private void RefreshImportedStudentList()
{ private void RefreshImportedStudentList()
LbStudentsImported.Items.Clear(); {
int count_selected = 0; LbStudentsImported.Items.Clear();
foreach (var s in Settings.Instance.Students) int count_selected = 0;
{ foreach (var s in Settings.Instance.Students)
LbStudentsImported.Items.Add(s); {
count_selected += s.SelectedCourseNames.Count; LbStudentsImported.Items.Add(s);
} count_selected += s.SelectedCourseNames.Count;
LblStudentAmount.Content = Settings.Instance.Students.Count.ToString(); }
LblSelectedAmount.Content = count_selected.ToString(); LblStudentAmount.Content = Settings.Instance.Students.Count.ToString();
LblSelectedAmount.Content = count_selected.ToString();
}
List<(Sport, List<string>)> initial_sportlist = new();
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e) foreach (var sp in Settings.Instance.Sports)
{ {
// Craft courses here / call course-crafter initial_sportlist.Add((sp, new()));
CourseCrafter.Craft(); }
RefreshResultView(); foreach (Student s in Settings.Instance.Students)
TbiResults.Focus(); {
} foreach (var sp in s.SelectedCourseNames)
{
private void RefreshResultView() foreach (var item in initial_sportlist)
{ {
LbResult.Items.Clear(); if (item.Item1.AlternativeNames.Contains(sp))
foreach (Student s in Settings.Instance.Students) {
{ item.Item2.Add(s.ID);
try break;
{ }
for(int i = 0; i<s.Result.Count;i++) }
{ }
LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}"); }
}
} LblNumVoted.Content = "";
catch (Exception ex) foreach (var s in initial_sportlist)
{ {
Console.WriteLine(ex.StackTrace); LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n";
} }
}
}
TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
} private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
{
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) CourseCrafter.Craft();
{ RefreshResultView();
Prepare(); TclMainView.SelectedIndex = 2;
var stud = (Student)LbStudentsImported.SelectedItem; //TbiResults.Focus();
if (stud == null) }
{
TbStudentName.Text = string.Empty; private void RefreshResultView()
TbStudentID.Text = string.Empty; {
SetEmpty(); LbResult.Items.Clear();
return; foreach (Student s in Settings.Instance.Students)
}; {
try
try {
{ for(int i = 0; i<s.Result.Length;i++)
TbStudentName.Text = stud.Name; {
TbStudentID.Text = stud.ID; LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}");
LblSport1.Content = stud.SelectedCourseNames[0]; }
LblSport2.Content = stud.SelectedCourseNames[1]; }
LblSport3.Content = stud.SelectedCourseNames[2]; catch (Exception ex)
LblSport4.Content = stud.SelectedCourseNames[3]; {
} Console.WriteLine(ex.StackTrace);
catch }
{ }
SetEmpty();
} TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
}
return;
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
void SetEmpty() {
{ Prepare();
if(LblSport1.Content == "null") LblSport1.Content = "ungewählt"; var stud = (Student)LbStudentsImported.SelectedItem;
if(LblSport2.Content == "null") LblSport2.Content = "ungewählt"; if (stud == null)
if(LblSport3.Content == "null") LblSport3.Content = "ungewählt"; {
if(LblSport4.Content == "null") LblSport4.Content = "ungewählt"; TbStudentName.Text = string.Empty;
} TbStudentID.Text = string.Empty;
SetEmpty();
void Prepare() return;
{ };
LblSport1.Content = "null";
LblSport2.Content = "null"; try
LblSport3.Content = "null"; {
LblSport4.Content = "null"; TbStudentName.Text = stud.Name;
} TbStudentID.Text = stud.ID;
LblSport1.Content = stud.SelectedCourseNames[0];
} LblSport2.Content = stud.SelectedCourseNames[1];
LblSport3.Content = stud.SelectedCourseNames[2];
private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e) LblSport4.Content = stud.SelectedCourseNames[3];
{ }
try catch
{ {
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text; SetEmpty();
} }
catch
{ return;
} void SetEmpty()
} {
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e) if(LblSport1.Content == "null") LblSport1.Content = "ungewählt";
{ if(LblSport2.Content == "null") LblSport2.Content = "ungewählt";
try if(LblSport3.Content == "null") LblSport3.Content = "ungewählt";
{ if(LblSport4.Content == "null") LblSport4.Content = "ungewählt";
((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text; }
}
catch void Prepare()
{ {
LblSport1.Content = "null";
} LblSport2.Content = "null";
} LblSport3.Content = "null";
LblSport4.Content = "null";
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e) }
{
Settings.ImportInitial(); }
RefreshCoursesList();
} private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e)
{
private void RefreshCoursesList() try
{ {
LbSportCourses.Items.Clear(); ((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
foreach (var sp in Settings.Instance.Sports) }
{ catch
LbSportCourses.Items.Add(sp); {
}
} }
}
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) {
{ try
if (LbSportCourses.SelectedItem != null) {
{ ((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text;
if (LbSportCourses.SelectedItem is Sport item) }
{ catch
LblSportID.Content = item.ID; {
TbSportName.Text = item.Name;
NudSportMaxStudents.Value = item.MaxStudents; }
NudSportMinStudents.Value = item.MinStudents; }
NudAmountCoursesSem1.Value = item.Semester[0];
NudAmountCoursesSem2.Value = item.Semester[1]; private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
NudAmountCoursesSem3.Value = item.Semester[2]; {
NudAmountCoursesSem4.Value = item.Semester[3]; Settings.ImportInitial();
// LbAlternativeCourses.Items.Clear(); RefreshCoursesList();
// foreach (var alternative in item.AlternativeCourses) }
// {
// LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative)); private void RefreshCoursesList()
// } {
LbAlternativeNames.Items.Clear(); LbSportCourses.Items.Clear();
foreach (var alternative in item.AlternativeNames) foreach (var sp in Settings.Instance.Sports)
{ {
LbAlternativeNames.Items.Add(alternative); LbSportCourses.Items.Add(sp);
} }
} }
}
}
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e) {
{ if (LbSportCourses.SelectedItem != null)
try {
{ if (LbSportCourses.SelectedItem is Sport item)
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text; {
} catch {} LblSportID.Content = item.ID;
} TbSportName.Text = item.Name;
NudSportMaxStudents.Value = item.MaxStudents;
private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) NudSportMinStudents.Value = item.MinStudents;
{ NudAmountCoursesSem1.Value = item.Semester[0];
try NudAmountCoursesSem2.Value = item.Semester[1];
{ NudAmountCoursesSem3.Value = item.Semester[2];
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value); NudAmountCoursesSem4.Value = item.Semester[3];
} catch {} // LbAlternativeCourses.Items.Clear();
} // foreach (var alternative in item.AlternativeCourses)
// {
private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) // LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
{ // }
try LbAlternativeNames.Items.Clear();
{ foreach (var alternative in item.AlternativeNames)
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value); {
} catch {} LbAlternativeNames.Items.Add(alternative);
} }
}
private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) }
{ }
try
{ private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e)
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value); {
} catch {} try
} {
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) } catch {}
{ }
try
{ private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value); {
} catch {} try
} {
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value);
private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) } catch {}
{ }
try
{ private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value); {
} catch {} try
} {
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value);
private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) } catch {}
{ }
try
{ private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value); {
} catch {} try
} {
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value);
private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e) } catch {}
{ }
try
{ private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
//((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text); {
//TbSportAlternativeCourse.Text = ""; try
} catch {} {
} ((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value);
} catch {}
private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e) }
{
try private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
{ {
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text); try
LbAlternativeNames.Items.Add(TbSportAlternativeName.Text); {
TbSportAlternativeName.Text = ""; ((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value);
} catch {}
int curr_selected = LbSportCourses.SelectedIndex; }
RefreshCoursesList();
LbSportCourses.SelectedIndex = curr_selected; private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
} catch {} {
} try
{
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e) ((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value);
{ } catch {}
//try }
//{
LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem); private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e)
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear(); {
foreach (string s in LbAlternativeNames.Items) try
{ {
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s); //((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
} //TbSportAlternativeCourse.Text = "";
} catch {}
int curr_selected = LbSportCourses.SelectedIndex; }
RefreshCoursesList();
LbSportCourses.SelectedIndex = curr_selected; private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e)
//} catch (Exception ex) {} {
} try
{
private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e) ((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
{ LbAlternativeNames.Items.Add(TbSportAlternativeName.Text);
var result = await MessageBox.Show(this, TbSportAlternativeName.Text = "";
"Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
"Wirklich fortfahren?", MessageBoxButton.YesNo); int curr_selected = LbSportCourses.SelectedIndex;
if (result == MessageBoxResult.Yes) RefreshCoursesList();
{ LbSportCourses.SelectedIndex = curr_selected;
Settings.Instance.Sports.Clear(); } catch {}
RefreshCoursesList(); }
}
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e)
} {
//try
private void BtnDeleteSinleCourse_OnClick(object? sender, RoutedEventArgs e) //{
{ LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem);
try ((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear();
{ foreach (string s in LbAlternativeNames.Items)
Settings.Instance.Sports.Remove(LbSportCourses.SelectedItem as Sport); {
RefreshCoursesList(); ((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s);
} catch (Exception ex){} }
}
int curr_selected = LbSportCourses.SelectedIndex;
private void BtnExportCoursePDF_OnClick(object? sender, RoutedEventArgs e) RefreshCoursesList();
{ LbSportCourses.SelectedIndex = curr_selected;
// Export as PDF //} catch (Exception ex) {}
} }
private void NudSportMaxPerSemester_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e) private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e)
{ {
try var result = await MessageBox.Show(this,
{ "Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
Settings.Instance.NumCoursesPerSemester = Convert.ToInt32(NudSportMaxPerSemester.Value); "Wirklich fortfahren?", MessageBoxButton.YesNo);
} catch {} if (result == MessageBoxResult.Yes)
} {
Settings.Instance.Sports.Clear();
RefreshCoursesList();
}
}
private void BtnDeleteSinleCourse_OnClick(object? sender, RoutedEventArgs e)
{
try
{
Settings.Instance.Sports.Remove(LbSportCourses.SelectedItem as Sport);
RefreshCoursesList();
} catch (Exception ex){}
}
private void BtnExportCoursePDF_OnClick(object? sender, RoutedEventArgs e)
{
// 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);
}
private async void MnuImpResult_OnClick(object? sender, RoutedEventArgs e)
{
// Hier importieren
var topLevel = GetTopLevel(this);
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
Title = "CSV-Datei laden",
SuggestedFileType = new FilePickerFileType(".csv-Datei")
{
Patterns = new[] { "*.csv" }
}
});
if (file == null) return;
}
} }
+7 -1
View File
@@ -1,13 +1,17 @@
# 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.
![spplus-Hauptbildschirm](img/spplus_planung.png)
## 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
@@ -19,3 +23,5 @@ Interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch
* Suche `spplus` bzw. `spplus.exe` und führe aus * Suche `spplus` bzw. `spplus.exe` und führe aus
* Linux/MacOS evl.: `chmod +x spplus` * Linux/MacOS evl.: `chmod +x spplus`
![spplus-Sportkursübersicht](img/spplus_sport.png)
+807 -253
View File
File diff suppressed because it is too large Load Diff
+19
View 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);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

+41
View File
@@ -47,4 +47,45 @@ public static class import
return result; return result;
} }
public static List<Student> ImportResultFromFile(string path)
{
var dict = new Dictionary<string, (string Name, List<string> Courses)>();
foreach (var line in File.ReadLines(path).Skip(1)) // Header überspringen
{
if (string.IsNullOrWhiteSpace(line))
continue;
var parts = line.Split(',');
if (parts.Length < 3)
continue;
string nameWithId = parts[0].Trim();
string course = parts[2].Replace("(2)", "").Replace("(3)", "").Replace("(4)", "").Trim();
int open = nameWithId.LastIndexOf('(');
int close = nameWithId.LastIndexOf(')');
if (open < 0 || close < 0 || close <= open)
continue;
string name = nameWithId[..open].Trim();
string id = nameWithId[(open + 1)..close].Trim();
if (!dict.ContainsKey(id))
dict[id] = (name, new List<string>());
dict[id].Courses.Add(course);
}
var result = new List<Student>();
foreach (var (id, data) in dict)
{
var student = new Student(id, data.Name, data.Courses);
result.Add(student);
}
return result;
}
} }
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

+2 -2
View File
@@ -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()
{ {
@@ -85,7 +85,7 @@ public class Settings
public List<Student> Students { get; set; } = []; public List<Student> Students { get; set; } = [];
public List<Sport> Sports { get; set; } = []; public List<Sport> Sports { get; set; } = [];
public int NumCoursesPerSemester { get; set; } = 10; public int NumCoursesPerSemester { get; set; } = 10; // Exact Amount of courses, not a maximum
public Settings() public Settings()
{ {