Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0eac4ae95 | |||
| 22e9377062 | |||
| 11e6aab8fd | |||
| 13f313d4a0 | |||
| 64951c579f | |||
| 4130c36335 | |||
| 7f2fc99d0b | |||
| eb640ff749 | |||
| 54a564df04 | |||
| 71dc63f2a2 | |||
| 68f673c8d7 | |||
| d5b7fd7af3 | |||
| 573e7c86e8 | |||
| a1bf573a07 | |||
| 525f3fb4ae | |||
| 9f298d8ce8 | |||
| 11d9c641a6 | |||
| c2f7adc1d0 | |||
| c19f96ea37 | |||
| 9bbde62d70 | |||
| a83f97828c | |||
| 44654dd784 |
+17
-7
@@ -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">
|
||||
@@ -211,13 +212,22 @@
|
||||
</TabItem.Header>
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="50,2*,*">
|
||||
<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">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<LucideIcon Kind="FileText" Width="24" Height="24" />
|
||||
<Label Content="Export (PDF)..." VerticalContentAlignment="Center" FontSize="12"
|
||||
FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<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">
|
||||
<LucideIcon Kind="FileText" Width="24" Height="24" />
|
||||
<Label Content="Export (PDF)..." VerticalContentAlignment="Center" FontSize="12"
|
||||
FontWeight="Bold" />
|
||||
</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">
|
||||
<TextBlock x:Name="TbResultStatistics"></TextBlock>
|
||||
</ScrollViewer>
|
||||
|
||||
+461
-425
@@ -1,426 +1,462 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace spplus;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static MainWindow Instance { get; set; }
|
||||
public static string ApplicationVersion = "v1.1.17";
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Settings.ImportInitial();
|
||||
Instance = this;
|
||||
RefreshCoursesList();
|
||||
try
|
||||
{
|
||||
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
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
|
||||
});
|
||||
}
|
||||
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 {MainWindow.ApplicationVersion}\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;
|
||||
if (file.Count == 0) 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();
|
||||
|
||||
List<(Sport, List<string>)> initial_sportlist = new();
|
||||
foreach (var sp in Settings.Instance.Sports)
|
||||
{
|
||||
initial_sportlist.Add((sp, new()));
|
||||
}
|
||||
foreach (Student s in Settings.Instance.Students)
|
||||
{
|
||||
foreach (var sp in s.SelectedCourseNames)
|
||||
{
|
||||
foreach (var item in initial_sportlist)
|
||||
{
|
||||
if (item.Item1.AlternativeNames.Contains(sp))
|
||||
{
|
||||
item.Item2.Add(s.ID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LblNumVoted.Content = "";
|
||||
foreach (var s in initial_sportlist)
|
||||
{
|
||||
LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
CourseCrafter.Craft();
|
||||
RefreshResultView();
|
||||
TclMainView.SelectedIndex = 2;
|
||||
//TbiResults.Focus();
|
||||
}
|
||||
|
||||
private void RefreshResultView()
|
||||
{
|
||||
LbResult.Items.Clear();
|
||||
foreach (Student s in Settings.Instance.Students)
|
||||
{
|
||||
try
|
||||
{
|
||||
for(int i = 0; i<s.Result.Count;i++)
|
||||
{
|
||||
LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings.ImportInitial();
|
||||
RefreshCoursesList();
|
||||
}
|
||||
|
||||
private void RefreshCoursesList()
|
||||
{
|
||||
LbSportCourses.Items.Clear();
|
||||
foreach (var sp in Settings.Instance.Sports)
|
||||
{
|
||||
LbSportCourses.Items.Add(sp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LbSportCourses.SelectedItem != null)
|
||||
{
|
||||
if (LbSportCourses.SelectedItem is Sport item)
|
||||
{
|
||||
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];
|
||||
NudAmountCoursesSem3.Value = item.Semester[2];
|
||||
NudAmountCoursesSem4.Value = item.Semester[3];
|
||||
// LbAlternativeCourses.Items.Clear();
|
||||
// foreach (var alternative in item.AlternativeCourses)
|
||||
// {
|
||||
// LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
|
||||
// }
|
||||
LbAlternativeNames.Items.Clear();
|
||||
foreach (var alternative in item.AlternativeNames)
|
||||
{
|
||||
LbAlternativeNames.Items.Add(alternative);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||
//TbSportAlternativeCourse.Text = "";
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||
LbAlternativeNames.Items.Add(TbSportAlternativeName.Text);
|
||||
TbSportAlternativeName.Text = "";
|
||||
|
||||
int curr_selected = LbSportCourses.SelectedIndex;
|
||||
RefreshCoursesList();
|
||||
LbSportCourses.SelectedIndex = curr_selected;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem);
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear();
|
||||
foreach (string s in LbAlternativeNames.Items)
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s);
|
||||
}
|
||||
|
||||
int curr_selected = LbSportCourses.SelectedIndex;
|
||||
RefreshCoursesList();
|
||||
LbSportCourses.SelectedIndex = curr_selected;
|
||||
//} catch (Exception ex) {}
|
||||
}
|
||||
|
||||
private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = await MessageBox.Show(this,
|
||||
"Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
|
||||
"Wirklich fortfahren?", MessageBoxButton.YesNo);
|
||||
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 {}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace spplus;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static MainWindow Instance { get; set; }
|
||||
public static string ApplicationVersion = "v1.2.24";
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Settings.ImportInitial();
|
||||
Instance = this;
|
||||
RefreshCoursesList();
|
||||
try
|
||||
{
|
||||
NudSportMaxPerSemester.Value = Settings.Instance.NumCoursesPerSemester;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
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
|
||||
});
|
||||
}
|
||||
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 {MainWindow.ApplicationVersion}\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;
|
||||
if (file.Count == 0) 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();
|
||||
|
||||
List<(Sport, List<string>)> initial_sportlist = new();
|
||||
foreach (var sp in Settings.Instance.Sports)
|
||||
{
|
||||
initial_sportlist.Add((sp, new()));
|
||||
}
|
||||
foreach (Student s in Settings.Instance.Students)
|
||||
{
|
||||
foreach (var sp in s.SelectedCourseNames)
|
||||
{
|
||||
foreach (var item in initial_sportlist)
|
||||
{
|
||||
if (item.Item1.AlternativeNames.Contains(sp))
|
||||
{
|
||||
item.Item2.Add(s.ID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LblNumVoted.Content = "";
|
||||
foreach (var s in initial_sportlist)
|
||||
{
|
||||
LblNumVoted.Content += $"{s.Item1.Name}: {s.Item2.Count}\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BtnCraftCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
CourseCrafter.Craft();
|
||||
RefreshResultView();
|
||||
TclMainView.SelectedIndex = 2;
|
||||
//TbiResults.Focus();
|
||||
}
|
||||
|
||||
private void RefreshResultView()
|
||||
{
|
||||
LbResult.Items.Clear();
|
||||
foreach (Student s in Settings.Instance.Students)
|
||||
{
|
||||
try
|
||||
{
|
||||
for(int i = 0; i<s.Result.Length;i++)
|
||||
{
|
||||
LbResult.Items.Add($"{s.Name} ({s.ID}) - {i+1}. Semester: {s.Result[i]}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
TbResultStatistics.Text = CourseCrafter.GenerateStatistics();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private void TbStudentID_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Student)LbStudentsImported.SelectedItem).ID = TbStudentID.Text;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnImportDefaultCourses_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings.ImportInitial();
|
||||
RefreshCoursesList();
|
||||
}
|
||||
|
||||
private void RefreshCoursesList()
|
||||
{
|
||||
LbSportCourses.Items.Clear();
|
||||
foreach (var sp in Settings.Instance.Sports)
|
||||
{
|
||||
LbSportCourses.Items.Add(sp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LbSportCourses_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LbSportCourses.SelectedItem != null)
|
||||
{
|
||||
if (LbSportCourses.SelectedItem is Sport item)
|
||||
{
|
||||
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];
|
||||
NudAmountCoursesSem3.Value = item.Semester[2];
|
||||
NudAmountCoursesSem4.Value = item.Semester[3];
|
||||
// LbAlternativeCourses.Items.Clear();
|
||||
// foreach (var alternative in item.AlternativeCourses)
|
||||
// {
|
||||
// LbAlternativeCourses.Items.Add(Settings.GetSportNameFromID(alternative));
|
||||
// }
|
||||
LbAlternativeNames.Items.Clear();
|
||||
foreach (var alternative in item.AlternativeNames)
|
||||
{
|
||||
LbAlternativeNames.Items.Add(alternative);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TbSportName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Name = TbSportName.Text;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMaxStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).MaxStudents = Convert.ToInt32(NudSportMaxStudents.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudSportMinStudents_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).MinStudents = Convert.ToInt32(NudSportMinStudents.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem1_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[0] = Convert.ToInt32(NudAmountCoursesSem1.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem2_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[1] = Convert.ToInt32(NudAmountCoursesSem2.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem3_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[2] = Convert.ToInt32(NudAmountCoursesSem3.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void NudAmountCoursesSem4_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).Semester[3] = Convert.ToInt32(NudAmountCoursesSem4.Value);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeCourseAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||
//TbSportAlternativeCourse.Text = "";
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeNameAdd_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(TbSportAlternativeName.Text);
|
||||
LbAlternativeNames.Items.Add(TbSportAlternativeName.Text);
|
||||
TbSportAlternativeName.Text = "";
|
||||
|
||||
int curr_selected = LbSportCourses.SelectedIndex;
|
||||
RefreshCoursesList();
|
||||
LbSportCourses.SelectedIndex = curr_selected;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void BtnAlternativeNameRemove_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
//try
|
||||
//{
|
||||
LbAlternativeNames.Items.Remove(LbAlternativeNames.SelectedItem);
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Clear();
|
||||
foreach (string s in LbAlternativeNames.Items)
|
||||
{
|
||||
((Sport)LbSportCourses.SelectedItem).AlternativeNames.Add(s);
|
||||
}
|
||||
|
||||
int curr_selected = LbSportCourses.SelectedIndex;
|
||||
RefreshCoursesList();
|
||||
LbSportCourses.SelectedIndex = curr_selected;
|
||||
//} catch (Exception ex) {}
|
||||
}
|
||||
|
||||
private async void BtnClearCourseList_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = await MessageBox.Show(this,
|
||||
"Möchten Sie wirklich alle Kurse löschen?\n Dies kann nicht rückgängig gemacht werden.",
|
||||
"Wirklich fortfahren?", MessageBoxButton.YesNo);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
# 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
|
||||
* \+ Import von CSV-Dateien mit Kurswahl
|
||||
* \+ Wahlansicht
|
||||
* \+ Statistiken
|
||||
* \+ Pflege von Sportkursen (inkl. Kürzel/ alternativen Bezeichnungen)
|
||||
* \+ CSV-Export
|
||||
* ~ Fehleransicht für nicht-existente, aber gewählte Kurse
|
||||
* ~ PDF-Export
|
||||
|
||||
\+ 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
|
||||
* Linux/MacOS evl.: `chmod +x spplus`
|
||||
|
||||
|
||||

|
||||
+719
-332
File diff suppressed because it is too large
Load Diff
+19
@@ -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 |
@@ -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: 67 KiB |
+2
-2
@@ -59,7 +59,7 @@ 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 List<string> SelectedCourseNames { get; set; } = new();
|
||||
public List<string>? Result { get; set; } = null;
|
||||
public string[] Result { get; set; } = new string[4];
|
||||
|
||||
public Student()
|
||||
{
|
||||
@@ -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; // Exact Amount of courses, not a maximum
|
||||
|
||||
public Settings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user