Compare commits

...

18 Commits

Author SHA1 Message Date
1b07d0e2ab [chore:] implemented student view 2026-02-18 15:13:11 +01:00
6a08694753 [chore:] implemented importer call with FilePicker 2026-02-18 14:44:39 +01:00
fabefabe0f [chore:] small type fixes 2026-02-18 14:44:20 +01:00
a572fdf72b [chore:] ListBox got named 2026-02-18 14:43:53 +01:00
a855f0664a [init:] added initial Student-Importer 2026-02-18 14:43:39 +01:00
f8f5140d47 [chore:] better info view (was maximized) 2026-02-18 14:12:57 +01:00
e9c7b61ced [chore:] added student-id 2026-02-18 14:12:42 +01:00
e27a6b88d4 Merge remote-tracking branch 'origin/main' 2026-02-17 09:30:55 +01:00
70c028aee7 [chore:] initial click-handlers 2026-02-17 09:30:40 +01:00
bbfe6299b5 [chore:] added basic ui 2026-02-17 09:30:24 +01:00
d5ff2aeee0 Update README.md 2026-02-17 08:21:46 +00:00
60c8a19a58 Update README.md 2026-02-17 08:21:25 +00:00
dd30ebd516 Update README.md 2026-02-17 08:21:09 +00:00
186a77eacc [chore:] implemented button-click handlers 2026-02-14 17:28:34 +01:00
a7c2b7e5d1 [chore:] added button-click handlers 2026-02-14 17:28:19 +01:00
78050de03f [file:] added MessageBox files from logofclient 2026-02-14 17:27:40 +01:00
f7f482ef30 [chore:] Changed "spplus" to "SP+" in title 2026-02-13 21:37:37 +01:00
ad71f0fd47 [chore:] added fields to structs.cs 2026-02-09 17:44:48 +01:00
7 changed files with 490 additions and 10 deletions

View File

@@ -3,21 +3,21 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="spplus.MainWindow"
Title="spplus">
x:Class="spplus.MainWindow" WindowState="Maximized"
Title="SP+">
<Border>
<Grid RowDefinitions="30,*">
<Menu Background="#50888888">
<MenuItem Header="Datei">
<!-- <MenuItem Click="MnuSettings_OnClick" x:Name="MnuSettings" Header="Einstellungen" /> -->
<!-- <Separator /> -->
<MenuItem x:Name="MnuExpSettings" Header="Einstellungen exportieren" />
<MenuItem x:Name="MnuExit" Header="Beenden" />
<MenuItem x:Name="MnuExpSettings" Header="Einstellungen exportieren" Click="MnuExpSettings_OnClick" />
<MenuItem x:Name="MnuExit" Header="Beenden" Click="MnuExit_OnClick"/>
</MenuItem>
<MenuItem Header="Hilfe">
<MenuItem Header="Onlinehilfe" x:Name="MnuHelp" />
<MenuItem Header="Git" x:Name="MnuGit" />
<MenuItem Header="Über" x:Name="MnuAbout" />
<MenuItem Header="Onlinehilfe" x:Name="MnuHelp" Click="MnuHelp_OnClick"/>
<MenuItem Header="Git" x:Name="MnuGit" Click="MnuGit_OnClick"/>
<MenuItem Header="Über" x:Name="MnuAbout" Click="MnuAbout_OnClick" />
</MenuItem>
</Menu>
<TabControl Grid.Row="1">
@@ -28,7 +28,67 @@
<Label FontSize="20" Content="Planung" VerticalContentAlignment="Center" />
</StackPanel>
</TabItem.Header>
<Grid RowDefinitions="2*,*,*">
<Grid ColumnDefinitions="*,2*" RowDefinitions="*,*">
<Button Grid.RowSpan="2" Margin="0,10,0,0" x:Name="BtnImport" VerticalAlignment="Top" Height="50" HorizontalAlignment="Stretch" Click="BtnImport_OnClick" HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="Import" Width="36" Height="36" />
<Label Content="Importieren..." VerticalContentAlignment="Center" FontSize="15"
FontWeight="Bold" />
</StackPanel>
</Button>
<Button Grid.RowSpan="2" Margin="0,00,0,10" x:Name="BtnCraftCourses" VerticalAlignment="Bottom" Height="50" HorizontalAlignment="Stretch" Click="BtnCraftCourses_OnClick" HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal">
<LucideIcon Kind="Pickaxe" Width="36" Height="36" />
<Label Content="Kurse basteln" VerticalContentAlignment="Center" FontSize="15"
FontWeight="Bold" />
</StackPanel>
</Button>
<ListBox Grid.RowSpan="2" x:Name="LbStudentsImported" SelectionChanged="LbStudentsImported_OnSelectionChanged" Margin="0,70,0,70" Background="MintCream" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></ListBox>
<StackPanel Grid.Column="1" Grid.Row="0" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
<Grid ColumnDefinitions="*,3*">
<Label Content="ID"></Label>
<TextBox Grid.Column="1" x:Name="TbStudentID" TextChanged="TbStudentID_OnTextChanged"></TextBox>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Name"></Label>
<TextBox Grid.Column="1" x:Name="TbStudentName" TextChanged="TbStudentName_OnTextChanged"></TextBox>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Sport 1"></Label>
<Label Grid.Column="1" x:Name="LblSport1"></Label>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Sport 2"></Label>
<Label Grid.Column="1" x:Name="LblSport2"></Label>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Sport 3"></Label>
<Label Grid.Column="1" x:Name="LblSport3"></Label>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Sport 4"></Label>
<Label Grid.Column="1" x:Name="LblSport4"></Label>
</Grid>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="1" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl Einträge"></Label>
<Label Grid.Column="1" x:Name="LblStudentAmount"></Label>
</Grid>
<Grid ColumnDefinitions="*,3*">
<Label Content="Anzahl gewählte Kurse"></Label>
<Label Grid.Column="1" x:Name="LblSelectedAmount"></Label>
</Grid>
</StackPanel>
</Grid>

View File

@@ -1,4 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace spplus;
@@ -8,4 +13,185 @@ public partial class MainWindow : Window
{
InitializeComponent();
}
private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
{
var res = MessageBox.Show(this, "Dieses Feature ist noch nicht implementiert", "Fehlend");
}
private void MnuExit_OnClick(object? sender, RoutedEventArgs e)
{
Environment.Exit(0);
}
private void MnuHelp_OnClick(object? sender, RoutedEventArgs e)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "https://git.mypapercloud.de/fierke/spplus/wiki",
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
});
}
catch (Exception ex)
{
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
}
}
private void MnuGit_OnClick(object? sender, RoutedEventArgs e)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "https://git.mypapercloud.de/fierke/spplus",
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
});
}
catch (Exception ex)
{
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
}
}
private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
{
Window w = new();
w.WindowState = WindowState.Normal;
w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
w.Width = 300;
w.Height = 120;
Grid g = new();
TextBlock tb = new()
{
Text = "spplus v1.0.0\n(c)2026 MyPapertown, Elias Fierke"
};
g.Children.Add(tb);
w.Content = g;
w.Show();
}
private async void BtnImport_OnClick(object? sender, RoutedEventArgs e)
{
var topLevel = GetTopLevel(this);
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
Title = "CSV-Datei auswählen",
AllowMultiple = false,
FileTypeFilter = new[]
{
new FilePickerFileType(".csv-Datei")
{
Patterns = new[] { "*.csv" }
}
}
});
if (file == null) return;
var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
foreach (var s in imported_students)
{
Settings.Instance.Students.Add(s);
}
RefreshImportedStudentList();
}
private void RefreshImportedStudentList()
{
LbStudentsImported.Items.Clear();
int count_selected = 0;
foreach (var s in Settings.Instance.Students)
{
LbStudentsImported.Items.Add(s);
count_selected += s.SelectedCourseNames.Count;
}
LblStudentAmount.Content = Settings.Instance.Students.Count.ToString();
LblSelectedAmount.Content = count_selected.ToString();
}
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
{
// Craft courses here / call course-crafter
}
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
Prepare();
var stud = (Student)LbStudentsImported.SelectedItem;
if (stud == null)
{
TbStudentName.Text = string.Empty;
TbStudentID.Text = string.Empty;
SetEmpty();
return;
};
try
{
TbStudentName.Text = stud.Name;
TbStudentID.Text = stud.ID;
LblSport1.Content = stud.SelectedCourseNames[0];
LblSport2.Content = stud.SelectedCourseNames[1];
LblSport3.Content = stud.SelectedCourseNames[2];
LblSport4.Content = stud.SelectedCourseNames[3];
}
catch
{
SetEmpty();
}
return;
void SetEmpty()
{
if(LblSport1.Content == "null") LblSport1.Content = "ungewählt";
if(LblSport2.Content == "null") LblSport2.Content = "ungewählt";
if(LblSport3.Content == "null") LblSport3.Content = "ungewählt";
if(LblSport4.Content == "null") LblSport4.Content = "ungewählt";
}
void Prepare()
{
LblSport1.Content = "null";
LblSport2.Content = "null";
LblSport3.Content = "null";
LblSport4.Content = "null";
}
}
private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e)
{
try
{
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
//int current = LbStudentsImported.SelectedIndex;
//RefreshImportedStudentList();
//LbStudentsImported.SelectedIndex = current;
}
catch
{
}
}
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
{
try
{
((Student)LbStudentsImported.SelectedItem).Name = TbStudentID.Text;
//int current = LbStudentsImported.SelectedIndex;
//RefreshImportedStudentList();
//LbStudentsImported.SelectedIndex = current;
}
catch
{
}
}
}

18
MessageBox.axaml Normal file
View File

@@ -0,0 +1,18 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" SizeToContent="WidthAndHeight"
x:Class="spplus.MessageBox"
Title="MessageBox">
<StackPanel>
<TextBlock Name="Text" Margin="10" TextWrapping="Wrap" />
<StackPanel HorizontalAlignment="Right" Margin="5" Orientation="Horizontal" Name="Buttons">
<StackPanel.Styles>
<Style Selector="Button">
<Setter Property="Margin" Value="5" />
</Style>
</StackPanel.Styles>
</StackPanel>
</StackPanel>
</Window>

85
MessageBox.axaml.cs Normal file
View File

@@ -0,0 +1,85 @@
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace spplus;
public partial class MessageBox : Window
{
public MessageBox()
{
AvaloniaXamlLoader.Load(this);
}
public static Task<MessageBoxResult> Show(Window parent, string text, string title,
MessageBoxButton buttons = MessageBoxButton.Ok)
{
try
{
var msgbox = new MessageBox
{
Title = title
};
msgbox.FindControl<TextBlock>("Text").Text = text;
var buttonPanel = msgbox.FindControl<StackPanel>("Buttons");
var res = MessageBoxResult.Ok;
void AddButton(string caption, MessageBoxResult r, bool def = false)
{
var btn = new Button { Content = caption };
btn.Click += (_, __) =>
{
res = r;
msgbox.Close();
};
buttonPanel.Children.Add(btn);
if (def)
res = r;
}
if (buttons == MessageBoxButton.Ok || buttons == MessageBoxButton.OkCancel)
AddButton("Ok", MessageBoxResult.Ok, true);
if (buttons == MessageBoxButton.YesNo || buttons == MessageBoxButton.YesNoCancel)
{
AddButton("Yes", MessageBoxResult.Yes);
AddButton("No", MessageBoxResult.No, true);
}
if (buttons == MessageBoxButton.OkCancel || buttons == MessageBoxButton.YesNoCancel)
AddButton("Cancel", MessageBoxResult.Cancel, true);
var tcs = new TaskCompletionSource<MessageBoxResult>();
msgbox.Closed += delegate { tcs.TrySetResult(res); };
if (parent != null)
msgbox.ShowDialog(parent);
else msgbox.Show();
return tcs.Task;
}
catch (Exception ex)
{
Console.WriteLine("Error while showing messagebox: " + ex.Message);
return Task.FromResult(MessageBoxResult.Error);
}
}
}
public enum MessageBoxButton
{
Ok,
OkCancel,
YesNo,
YesNoCancel
}
public enum MessageBoxResult
{
Ok,
Cancel,
Yes,
No,
Error
}

View File

@@ -1,3 +1,19 @@
# spplus
# SP+
Interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch SuS.
## (future) Features
* Import von CSV-Dateien mit Kurswahl
* Wahlansicht
* Statistiken
* Pflege von Sportkursen (inkl. Kürzel/ alternativen Bezeichnungen)
* Fehleransicht für nicht-existente, aber gewählte Kurse
## Nutzung
* Build from source:
* Benötigt .NET-SDK 9.0
* Im Projektordner: `dotnet run`
* Release:
* Suche `spplus` bzw. `spplus.exe` und führe aus
* Linux/MacOS evl.: `chmod +x spplus`
Interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch SuS.

50
import.cs Normal file
View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace spplus;
public static class import
{
public static List<Student> ImportStudentsFromFile(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;
}
}

View File

@@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace spplus;
public class Sport
@@ -7,4 +9,67 @@ public class Sport
public int MaxStudents { get; set; } = 20; // Maximale Anzahl an Schülern pro Kurs
public int MinStudents { get; set; } = 5; // Minimale Anzahl an Schülern pro Kurs
public int[] Semester { get; set; } = [1, 2, 3, 4]; // Angebot in diesen Semestern
protected Sport()
{
}
protected Sport(string name)
{
Name = name;
}
protected Sport(string name, int maxCoursesPerSemester, int maxStudents, int minStudents, int[] semester)
{
Name = name;
MaxCoursesPerSemester = maxCoursesPerSemester;
MaxStudents = maxStudents;
MinStudents = minStudents;
Semester = semester;
}
}
public class Student
{
public string ID { get; set; } = ""; // ID des Schüler (z.B. NolteSeb)
public string Name { get; set; } = ""; // Name des Schülers
public Sport[] SelectedCourses { get; set; } = new Sport[4]; // Kurswahl
public List<string> SelectedCourseNames { get; set; } = new();
public List<string>? Result { get; set; } = null;
public Student()
{
}
public override string ToString()
{
return $"{Name} ({ID})";
}
public Student(string id, string name, List<string> selectedCoursesNames)
{
ID = id;
Name = name;
SelectedCourseNames = selectedCoursesNames;
}
}
public class Settings
{
public static Settings Instance = new Settings();
public List<Student> Students { get; set; } = [];
public List<Sport> Sports { get; set; } = [];
public Settings()
{
}
public static void Import(string path)
{
// Hier importieren...
}
}