Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c5be9d2c6e | |||
| c46417c56d | |||
| 895c55a52f | |||
| e54e2e7840 | |||
| 0a710bea8b | |||
| d4de543d71 | |||
| a0eac4ae95 | |||
| 22e9377062 | |||
| 11e6aab8fd | |||
| 13f313d4a0 | |||
| 64951c579f | |||
| 4130c36335 | |||
| 7f2fc99d0b | |||
| eb640ff749 | |||
| 54a564df04 | |||
| 71dc63f2a2 | |||
| 68f673c8d7 | |||
| d5b7fd7af3 |
+23
-4
@@ -3,7 +3,7 @@
|
||||
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" WindowState="Maximized"
|
||||
x:Class="spplus.MainWindow" WindowState="Maximized" Icon="res/logo.ico"
|
||||
Title="spplus">
|
||||
<Border>
|
||||
<Grid RowDefinitions="30,*">
|
||||
@@ -12,6 +12,7 @@
|
||||
<!-- <MenuItem Click="MnuSettings_OnClick" x:Name="MnuSettings" Header="Einstellungen" /> -->
|
||||
<!-- <Separator /> -->
|
||||
<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>
|
||||
<MenuItem Header="Hilfe">
|
||||
@@ -195,8 +196,20 @@
|
||||
</Grid>
|
||||
<Line />
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Maximale Sportkursanzahl pro Semester"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester" ValueChanged="NudSportMaxPerSemester_OnValueChanged"></NumericUpDown>
|
||||
<Label Content="Maximale Sportkursanzahl Semester 1"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester1" ValueChanged="NudSportMaxPerSemester1_OnValueChanged"></NumericUpDown>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Maximale Sportkursanzahl Semester 2"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester2" ValueChanged="NudSportMaxPerSemester2_OnValueChanged"></NumericUpDown>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Maximale Sportkursanzahl Semester 3"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester3" ValueChanged="NudSportMaxPerSemester3_OnValueChanged"></NumericUpDown>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Maximale Sportkursanzahl Semester 4"></Label>
|
||||
<NumericUpDown Grid.Column="1" x:Name="NudSportMaxPerSemester4" ValueChanged="NudSportMaxPerSemester4_OnValueChanged"></NumericUpDown>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -210,7 +223,13 @@
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="50,2*,*">
|
||||
<ListBox Grid.RowSpan="2" x:Name="LbResult" Margin="0,10,10,10"></ListBox>
|
||||
<ListBox Grid.RowSpan="2" x:Name="LbResult" Margin="0,10,10,10" PointerPressed="LbResult_OnPointerPressed">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Ändern" x:Name="MnuChange" />
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
</ListBox>
|
||||
<Grid Grid.Row="0" Grid.Column="1" Grid.ColumnDefinitions="*,*">
|
||||
<Button Grid.Column="0" Margin="0,10,0,0" x:Name="BtnExportCoursePDF" VerticalAlignment="Top" Height="35" HorizontalAlignment="Stretch" Click="BtnExportCoursePDF_OnClick" HorizontalContentAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
+182
-5
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -12,6 +13,26 @@ public partial class MainWindow : Window
|
||||
{
|
||||
public static MainWindow Instance { get; set; }
|
||||
public static string ApplicationVersion = "v1.2.24";
|
||||
|
||||
private sealed class ResultEntry
|
||||
{
|
||||
public Student Student { get; }
|
||||
public int Semester { get; }
|
||||
public string CourseName { get; }
|
||||
|
||||
public ResultEntry(Student student, int semester, string? courseName)
|
||||
{
|
||||
Student = student;
|
||||
Semester = semester;
|
||||
CourseName = courseName ?? string.Empty;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Student.Name} ({Student.ID}) - {Semester}. Semester: {CourseName}";
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -20,10 +41,108 @@ public partial class MainWindow : Window
|
||||
RefreshCoursesList();
|
||||
try
|
||||
{
|
||||
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
||||
NudSportMaxPerSemester1.Value = Settings.Instance.NumCoursesPerSemester[0];
|
||||
NudSportMaxPerSemester2.Value = Settings.Instance.NumCoursesPerSemester[1];
|
||||
NudSportMaxPerSemester3.Value = Settings.Instance.NumCoursesPerSemester[2];
|
||||
NudSportMaxPerSemester4.Value = Settings.Instance.NumCoursesPerSemester[3];
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void RegenerateContextMenu()
|
||||
{
|
||||
MnuChange.Items.Clear();
|
||||
foreach (var sport in Settings.Instance.Sports)
|
||||
{
|
||||
var item = new MenuItem { Header = sport.Name };
|
||||
item.Click += (_, _) => ChangeStudentCourse(sport);
|
||||
MnuChange.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeStudentCourse(Sport targetSport)
|
||||
{
|
||||
if (LbResult.SelectedItem is not ResultEntry selectedEntry)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (ApplyStudentCourseChange(selectedEntry.Student, selectedEntry.Semester, targetSport))
|
||||
{
|
||||
CourseCrafter.ReloadResult();
|
||||
RefreshResultView();
|
||||
RegenerateContextMenu();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ApplyStudentCourseChange(Student student, int semester, Sport targetSport)
|
||||
{
|
||||
if (semester < 1 || semester > 4)
|
||||
return false;
|
||||
|
||||
var semesterCourses = CourseCrafter.GeneratedCourses
|
||||
.Where(course => course.Semester == semester)
|
||||
.ToList();
|
||||
|
||||
var currentCourses = semesterCourses
|
||||
.Where(course => course.Instance.Students.Contains(student.ID))
|
||||
.ToList();
|
||||
|
||||
CourseCrafter.CourseInstance? targetCourse = currentCourses
|
||||
.FirstOrDefault(course => course.Instance.Sport.Name == targetSport.Name)
|
||||
.Instance;
|
||||
|
||||
if (targetCourse == null)
|
||||
{
|
||||
targetCourse = semesterCourses
|
||||
.Where(course => course.Instance.Sport.Name == targetSport.Name)
|
||||
.OrderBy(course => course.Instance.Students.Count)
|
||||
.Select(course => course.Instance)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
foreach (var course in currentCourses)
|
||||
{
|
||||
if (targetCourse != null && ReferenceEquals(course.Instance, targetCourse))
|
||||
continue;
|
||||
|
||||
if (course.Instance.Students.Remove(student.ID))
|
||||
changed = true;
|
||||
}
|
||||
|
||||
int removedEmptyCourses = CourseCrafter.GeneratedCourses.RemoveAll(course =>
|
||||
course.Semester == semester &&
|
||||
course.Instance.Students.Count == 0 &&
|
||||
!ReferenceEquals(course.Instance, targetCourse));
|
||||
if (removedEmptyCourses > 0)
|
||||
changed = true;
|
||||
|
||||
if (targetCourse == null)
|
||||
{
|
||||
var newCourse = new CourseCrafter.CourseInstance
|
||||
{
|
||||
Sport = targetSport,
|
||||
Students = new List<string> { student.ID }
|
||||
};
|
||||
|
||||
CourseCrafter.GeneratedCourses.Add((semester, newCourse));
|
||||
changed = true;
|
||||
}
|
||||
else if (!targetCourse.Students.Contains(student.ID))
|
||||
{
|
||||
targetCourse.Students.Add(student.ID);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void MnuExpSettings_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var res = MessageBox.Show(this, "Dieses Feature ist noch nicht implementiert", "Fehlend");
|
||||
@@ -159,6 +278,21 @@ public partial class MainWindow : Window
|
||||
//TbiResults.Focus();
|
||||
}
|
||||
|
||||
private void LbResult_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (!e.GetCurrentPoint(LbResult).Properties.IsRightButtonPressed)
|
||||
return;
|
||||
|
||||
if (e.Source is Control control && control.DataContext is ResultEntry entry)
|
||||
{
|
||||
LbResult.SelectedItem = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
LbResult.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshResultView()
|
||||
{
|
||||
LbResult.Items.Clear();
|
||||
@@ -168,7 +302,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
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(new ResultEntry(s, i + 1, s.Result[i]));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -262,6 +396,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
LbSportCourses.Items.Add(sp);
|
||||
}
|
||||
RegenerateContextMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +433,7 @@ public partial class MainWindow : Window
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
|
||||
RegenerateContextMenu();
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -416,11 +552,35 @@ public partial class MainWindow : Window
|
||||
// Export as PDF
|
||||
}
|
||||
|
||||
private void NudSportMaxPerSemester_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
private void NudSportMaxPerSemester1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Instance.NumCoursesPerSemester = Convert.ToInt32(NudSportMaxPerSemester.Value);
|
||||
Settings.Instance.NumCoursesPerSemester[0] = Convert.ToInt32(NudSportMaxPerSemester1.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMaxPerSemester2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Instance.NumCoursesPerSemester[1] = Convert.ToInt32(NudSportMaxPerSemester2.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMaxPerSemester3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Instance.NumCoursesPerSemester[2] = Convert.ToInt32(NudSportMaxPerSemester3.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMaxPerSemester4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.Instance.NumCoursesPerSemester[3] = Convert.ToInt32(NudSportMaxPerSemester4.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -442,4 +602,21 @@ public partial class MainWindow : Window
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
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"
|
||||
mc:Ignorable="d" SizeToContent="WidthAndHeight" Icon="res/logo.ico"
|
||||
x:Class="spplus.MessageBox" WindowStartupLocation="CenterScreen"
|
||||
Title="MessageBox">
|
||||
<StackPanel>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Plattformunabhängiger (Windows, Linux, Mac), interaktiver Sportkursplaner für Oberstufen auf Basis einer Sportkurswahl durch SuS.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
* \+ Import von CSV-Dateien mit Kurswahl
|
||||
* \+ Wahlansicht
|
||||
@@ -21,3 +23,5 @@ Plattformunabhängiger (Windows, Linux, Mac), interaktiver Sportkursplaner für
|
||||
* Suche `spplus` bzw. `spplus.exe` und führe aus
|
||||
* Linux/MacOS evl.: `chmod +x spplus`
|
||||
|
||||
|
||||

|
||||
+652
-334
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
@@ -47,4 +47,45 @@ public static class import
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 106 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
@@ -5,6 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
<ApplicationIcon>res/logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -19,4 +20,16 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Lucide.Avalonia" Version="0.1.35"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="res\logo.ico"/>
|
||||
<AvaloniaResource Include="res\logo.ico">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AvaloniaResource>
|
||||
<None Remove="res\logo.png"/>
|
||||
<AvaloniaResource Include="res\logo.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</AvaloniaResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class Settings
|
||||
|
||||
public List<Student> Students { get; set; } = [];
|
||||
public List<Sport> Sports { get; set; } = [];
|
||||
public int NumCoursesPerSemester { get; set; } = 10;
|
||||
public int[] NumCoursesPerSemester { get; set; } = [10,10,11,11]; // Exact Amount of courses, not a maximum
|
||||
|
||||
public Settings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user