Compare commits
9 Commits
410055c9f2
...
spplus1.2.
| Author | SHA1 | Date | |
|---|---|---|---|
| a1bf573a07 | |||
| 525f3fb4ae | |||
| 9f298d8ce8 | |||
| 11d9c641a6 | |||
| c2f7adc1d0 | |||
| c19f96ea37 | |||
| 9bbde62d70 | |||
| a83f97828c | |||
| 44654dd784 |
@@ -211,13 +211,22 @@
|
|||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid ColumnDefinitions="*,*" RowDefinitions="50,2*,*">
|
<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"></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>
|
||||||
|
|||||||
@@ -1,426 +1,445 @@
|
|||||||
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 static string ApplicationVersion = "v1.1.17";
|
public static string ApplicationVersion = "v1.2.24";
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Settings.ImportInitial();
|
Settings.ImportInitial();
|
||||||
Instance = this;
|
Instance = this;
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
||||||
} catch {}
|
} 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",
|
FileName = "https://git.mypapercloud.de/fierke/spplus/wiki",
|
||||||
UseShellExecute = true
|
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",
|
FileName = "https://git.mypapercloud.de/fierke/spplus",
|
||||||
UseShellExecute = true
|
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();
|
Window w = new();
|
||||||
w.WindowState = WindowState.Normal;
|
w.WindowState = WindowState.Normal;
|
||||||
w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
w.Width = 300;
|
w.Width = 300;
|
||||||
w.Height = 120;
|
w.Height = 120;
|
||||||
Grid g = new();
|
Grid g = new();
|
||||||
TextBlock tb = new()
|
TextBlock tb = new()
|
||||||
{
|
{
|
||||||
Text = $"spplus {MainWindow.ApplicationVersion}\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;
|
||||||
w.Show();
|
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 topLevel = GetTopLevel(this);
|
||||||
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||||
{
|
{
|
||||||
Title = "CSV-Datei auswählen",
|
Title = "CSV-Datei auswählen",
|
||||||
AllowMultiple = false,
|
AllowMultiple = false,
|
||||||
FileTypeFilter = new[]
|
FileTypeFilter = new[]
|
||||||
{
|
{
|
||||||
new FilePickerFileType(".csv-Datei")
|
new FilePickerFileType(".csv-Datei")
|
||||||
{
|
{
|
||||||
Patterns = new[] { "*.csv" }
|
Patterns = new[] { "*.csv" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (file == null) return;
|
if (file == null) return;
|
||||||
if (file.Count == 0) return;
|
if (file.Count == 0) return;
|
||||||
|
|
||||||
var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
|
var imported_students = import.ImportStudentsFromFile(file[0].Path.LocalPath.ToString());
|
||||||
foreach (var s in imported_students)
|
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();
|
LbStudentsImported.Items.Clear();
|
||||||
int count_selected = 0;
|
int count_selected = 0;
|
||||||
foreach (var s in Settings.Instance.Students)
|
foreach (var s in Settings.Instance.Students)
|
||||||
{
|
{
|
||||||
LbStudentsImported.Items.Add(s);
|
LbStudentsImported.Items.Add(s);
|
||||||
count_selected += s.SelectedCourseNames.Count;
|
count_selected += s.SelectedCourseNames.Count;
|
||||||
}
|
}
|
||||||
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();
|
List<(Sport, List<string>)> initial_sportlist = new();
|
||||||
foreach (var sp in Settings.Instance.Sports)
|
foreach (var sp in Settings.Instance.Sports)
|
||||||
{
|
{
|
||||||
initial_sportlist.Add((sp, new()));
|
initial_sportlist.Add((sp, new()));
|
||||||
}
|
}
|
||||||
foreach (Student s in Settings.Instance.Students)
|
foreach (Student s in Settings.Instance.Students)
|
||||||
{
|
{
|
||||||
foreach (var sp in s.SelectedCourseNames)
|
foreach (var sp in s.SelectedCourseNames)
|
||||||
{
|
{
|
||||||
foreach (var item in initial_sportlist)
|
foreach (var item in initial_sportlist)
|
||||||
{
|
{
|
||||||
if (item.Item1.AlternativeNames.Contains(sp))
|
if (item.Item1.AlternativeNames.Contains(sp))
|
||||||
{
|
{
|
||||||
item.Item2.Add(s.ID);
|
item.Item2.Add(s.ID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LblNumVoted.Content = "";
|
LblNumVoted.Content = "";
|
||||||
foreach (var s in initial_sportlist)
|
foreach (var s in initial_sportlist)
|
||||||
{
|
{
|
||||||
LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n";
|
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)
|
||||||
{
|
{
|
||||||
CourseCrafter.Craft();
|
CourseCrafter.Craft();
|
||||||
RefreshResultView();
|
RefreshResultView();
|
||||||
TclMainView.SelectedIndex = 2;
|
TclMainView.SelectedIndex = 2;
|
||||||
//TbiResults.Focus();
|
//TbiResults.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshResultView()
|
private void RefreshResultView()
|
||||||
{
|
{
|
||||||
LbResult.Items.Clear();
|
LbResult.Items.Clear();
|
||||||
foreach (Student s in Settings.Instance.Students)
|
foreach (Student s in Settings.Instance.Students)
|
||||||
{
|
{
|
||||||
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]}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.StackTrace);
|
Console.WriteLine(ex.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
|
TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
private void LbStudentsImported_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
Prepare();
|
Prepare();
|
||||||
var stud = (Student)LbStudentsImported.SelectedItem;
|
var stud = (Student)LbStudentsImported.SelectedItem;
|
||||||
if (stud == null)
|
if (stud == null)
|
||||||
{
|
{
|
||||||
TbStudentName.Text = string.Empty;
|
TbStudentName.Text = string.Empty;
|
||||||
TbStudentID.Text = string.Empty;
|
TbStudentID.Text = string.Empty;
|
||||||
SetEmpty();
|
SetEmpty();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TbStudentName.Text = stud.Name;
|
TbStudentName.Text = stud.Name;
|
||||||
TbStudentID.Text = stud.ID;
|
TbStudentID.Text = stud.ID;
|
||||||
LblSport1.Content = stud.SelectedCourseNames[0];
|
LblSport1.Content = stud.SelectedCourseNames[0];
|
||||||
LblSport2.Content = stud.SelectedCourseNames[1];
|
LblSport2.Content = stud.SelectedCourseNames[1];
|
||||||
LblSport3.Content = stud.SelectedCourseNames[2];
|
LblSport3.Content = stud.SelectedCourseNames[2];
|
||||||
LblSport4.Content = stud.SelectedCourseNames[3];
|
LblSport4.Content = stud.SelectedCourseNames[3];
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
SetEmpty();
|
SetEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
void SetEmpty()
|
void SetEmpty()
|
||||||
{
|
{
|
||||||
if(LblSport1.Content == "null") LblSport1.Content = "ungewählt";
|
if(LblSport1.Content == "null") LblSport1.Content = "ungewählt";
|
||||||
if(LblSport2.Content == "null") LblSport2.Content = "ungewählt";
|
if(LblSport2.Content == "null") LblSport2.Content = "ungewählt";
|
||||||
if(LblSport3.Content == "null") LblSport3.Content = "ungewählt";
|
if(LblSport3.Content == "null") LblSport3.Content = "ungewählt";
|
||||||
if(LblSport4.Content == "null") LblSport4.Content = "ungewählt";
|
if(LblSport4.Content == "null") LblSport4.Content = "ungewählt";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prepare()
|
void Prepare()
|
||||||
{
|
{
|
||||||
LblSport1.Content = "null";
|
LblSport1.Content = "null";
|
||||||
LblSport2.Content = "null";
|
LblSport2.Content = "null";
|
||||||
LblSport3.Content = "null";
|
LblSport3.Content = "null";
|
||||||
LblSport4.Content = "null";
|
LblSport4.Content = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
private void TbStudentName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
|
((Student)LbStudentsImported.SelectedItem).Name = TbStudentName.Text;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
|
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text;
|
((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Settings.ImportInitial();
|
Settings.ImportInitial();
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshCoursesList()
|
private void RefreshCoursesList()
|
||||||
{
|
{
|
||||||
LbSportCourses.Items.Clear();
|
LbSportCourses.Items.Clear();
|
||||||
foreach (var sp in Settings.Instance.Sports)
|
foreach (var sp in Settings.Instance.Sports)
|
||||||
{
|
{
|
||||||
LbSportCourses.Items.Add(sp);
|
LbSportCourses.Items.Add(sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (LbSportCourses.SelectedItem != null)
|
if (LbSportCourses.SelectedItem != null)
|
||||||
{
|
{
|
||||||
if (LbSportCourses.SelectedItem is Sport item)
|
if (LbSportCourses.SelectedItem is Sport item)
|
||||||
{
|
{
|
||||||
LblSportID.Content = item.ID;
|
LblSportID.Content = item.ID;
|
||||||
TbSportName.Text = item.Name;
|
TbSportName.Text = item.Name;
|
||||||
NudSportMaxStudents.Value = item.MaxStudents;
|
NudSportMaxStudents.Value = item.MaxStudents;
|
||||||
NudSportMinStudents.Value = item.MinStudents;
|
NudSportMinStudents.Value = item.MinStudents;
|
||||||
NudAmountCoursesSem1.Value = item.Semester[0];
|
NudAmountCoursesSem1.Value = item.Semester[0];
|
||||||
NudAmountCoursesSem2.Value = item.Semester[1];
|
NudAmountCoursesSem2.Value = item.Semester[1];
|
||||||
NudAmountCoursesSem3.Value = item.Semester[2];
|
NudAmountCoursesSem3.Value = item.Semester[2];
|
||||||
NudAmountCoursesSem4.Value = item.Semester[3];
|
NudAmountCoursesSem4.Value = item.Semester[3];
|
||||||
// LbAlternativeCourses.Items.Clear();
|
// LbAlternativeCourses.Items.Clear();
|
||||||
// foreach (var alternative in item.AlternativeCourses)
|
// foreach (var alternative in item.AlternativeCourses)
|
||||||
// {
|
// {
|
||||||
// LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
|
// LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
|
||||||
// }
|
// }
|
||||||
LbAlternativeNames.Items.Clear();
|
LbAlternativeNames.Items.Clear();
|
||||||
foreach (var alternative in item.AlternativeNames)
|
foreach (var alternative in item.AlternativeNames)
|
||||||
{
|
{
|
||||||
LbAlternativeNames.Items.Add(alternative);
|
LbAlternativeNames.Items.Add(alternative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
|
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value);
|
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value);
|
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value);
|
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value);
|
((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value);
|
((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value);
|
((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
//((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||||
//TbSportAlternativeCourse.Text = "";
|
//TbSportAlternativeCourse.Text = "";
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||||
LbAlternativeNames.Items.Add(TbSportAlternativeName.Text);
|
LbAlternativeNames.Items.Add(TbSportAlternativeName.Text);
|
||||||
TbSportAlternativeName.Text = "";
|
TbSportAlternativeName.Text = "";
|
||||||
|
|
||||||
int curr_selected = LbSportCourses.SelectedIndex;
|
int curr_selected = LbSportCourses.SelectedIndex;
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
LbSportCourses.SelectedIndex = curr_selected;
|
LbSportCourses.SelectedIndex = curr_selected;
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem);
|
LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem);
|
||||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear();
|
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear();
|
||||||
foreach (string s in LbAlternativeNames.Items)
|
foreach (string s in LbAlternativeNames.Items)
|
||||||
{
|
{
|
||||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s);
|
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
int curr_selected = LbSportCourses.SelectedIndex;
|
int curr_selected = LbSportCourses.SelectedIndex;
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
LbSportCourses.SelectedIndex = curr_selected;
|
LbSportCourses.SelectedIndex = curr_selected;
|
||||||
//} catch (Exception ex) {}
|
//} catch (Exception ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e)
|
private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var result = await MessageBox.Show(this,
|
var result = await MessageBox.Show(this,
|
||||||
"Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
|
"Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
|
||||||
"Wirklich fortfahren?", MessageBoxButton.YesNo);
|
"Wirklich fortfahren?", MessageBoxButton.YesNo);
|
||||||
if (result == MessageBoxResult.Yes)
|
if (result == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
Settings.Instance.Sports.Clear();
|
Settings.Instance.Sports.Clear();
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnDeleteSinleCourse_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnDeleteSinleCourse_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Settings.Instance.Sports.Remove(LbSportCourses.SelectedItem as Sport);
|
Settings.Instance.Sports.Remove(LbSportCourses.SelectedItem as Sport);
|
||||||
RefreshCoursesList();
|
RefreshCoursesList();
|
||||||
} catch (Exception ex){}
|
} catch (Exception ex){}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnExportCoursePDF_OnClick(object? sender, RoutedEventArgs e)
|
private void BtnExportCoursePDF_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Export as PDF
|
// Export as PDF
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NudSportMaxPerSemester_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
private void NudSportMaxPerSemester_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Settings.Instance.NumCoursesPerSemester = Convert.ToInt32(NudSportMaxPerSemester.Value);
|
Settings.Instance.NumCoursesPerSemester = Convert.ToInt32(NudSportMaxPerSemester.Value);
|
||||||
} catch {}
|
} 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
|
||||||
|
|
||||||
|
|||||||
74
crafter.cs
74
crafter.cs
@@ -314,7 +314,7 @@ public class CourseCrafter
|
|||||||
|
|
||||||
if (errors.Count == 0)
|
if (errors.Count == 0)
|
||||||
{
|
{
|
||||||
MainWindow.Instance.TbResultLog.Text = "Alles generierten Kursen erfüllen die gegebenen Voraussetzungen.";
|
MainWindow.Instance.TbResultLog.Text = "--- Alle generierten Kursen erfüllen die gegebenen Voraussetzungen ---";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -323,6 +323,17 @@ public class CourseCrafter
|
|||||||
MainWindow.Instance.TbResultLog.Text += e + "\n";
|
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()
|
||||||
@@ -339,67 +350,6 @@ public class CourseCrafter
|
|||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateStatisticsOld()
|
|
||||||
{
|
|
||||||
var settings = Settings.Instance;
|
|
||||||
var students = settings.Students;
|
|
||||||
|
|
||||||
if (GeneratedCourses == null || GeneratedCourses.Count == 0)
|
|
||||||
return "Keine Kurse generiert.";
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
foreach (var entry in group)
|
|
||||||
{
|
|
||||||
int semester = group.Key.Semester + 1;
|
|
||||||
string sportName = group.Key.Name;
|
|
||||||
string number = counter.ToString("D2");
|
|
||||||
int count = entry.Instance.Students.Count;
|
|
||||||
|
|
||||||
sb.AppendLine(
|
|
||||||
$"Semester {semester}: {sportName} {number}: {count} Schüler*innen"
|
|
||||||
);
|
|
||||||
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.AppendLine();
|
|
||||||
sb.AppendLine("Fehlerübersicht:");
|
|
||||||
|
|
||||||
// ===== Fehler pro Semester =====
|
|
||||||
for (int sem = 0; sem < semesterCount; sem++)
|
|
||||||
{
|
|
||||||
int errors = students.Count(st =>
|
|
||||||
st.Result != null &&
|
|
||||||
st.Result.Count > sem &&
|
|
||||||
st.Result[sem] == "Fehler");
|
|
||||||
|
|
||||||
sb.AppendLine($"Semester {sem + 1}: {errors} Fehler");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<string> ValidateCourses(List<(int Semester, CourseInstance Instance)> courses)
|
public static List<string> ValidateCourses(List<(int Semester, CourseInstance Instance)> courses)
|
||||||
{
|
{
|
||||||
List<string> errors = new();
|
List<string> errors = new();
|
||||||
|
|||||||
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