Compare commits
6 Commits
f8f5140d47
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b0703f25e | |||
| 1b07d0e2ab | |||
| 6a08694753 | |||
| fabefabe0f | |||
| a572fdf72b | |||
| a855f0664a |
@@ -28,8 +28,8 @@
|
||||
<Label FontSize="20" Content="Planung" VerticalContentAlignment="Center" />
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<Grid ColumnDefinitions="*,2*">
|
||||
<Button Margin="0,10,0,0" x:Name="BtnImport" VerticalAlignment="Top" Height="50" HorizontalAlignment="Stretch" Click="BtnImport_OnClick" HorizontalContentAlignment="Center">
|
||||
<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"
|
||||
@@ -37,7 +37,7 @@
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button Margin="0,00,0,10" x:Name="BtnCraftCourses" VerticalAlignment="Bottom" Height="50" HorizontalAlignment="Stretch" Click="BtnCraftCourses_OnClick" HorizontalContentAlignment="Center">
|
||||
<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"
|
||||
@@ -45,34 +45,49 @@
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<ListBox Margin="0,70,0,70" Background="MintCream" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></ListBox>
|
||||
<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" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
|
||||
<StackPanel Grid.Column="1" Grid.Row="0" Margin="10,10,10,10" Orientation="Vertical" Spacing="10">
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Name"></Label>
|
||||
<TextBox Grid.Column="1" x:Name="TbStudentName"></TextBox>
|
||||
<Label Content="ID"></Label>
|
||||
<TextBox Grid.Column="1" x:Name="TbStudentID" TextChanged="TbStudentID_OnTextChanged"></TextBox>
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*,2*">
|
||||
<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="*,2*">
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Sport 2"></Label>
|
||||
<Label Grid.Column="1" x:Name="LblSport2"></Label>
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*,2*">
|
||||
<Grid ColumnDefinitions="*,3*">
|
||||
<Label Content="Sport 3"></Label>
|
||||
<Label Grid.Column="1" x:Name="LblSport3"></Label>
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*,2*">
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace spplus;
|
||||
|
||||
@@ -71,13 +73,125 @@ public partial class MainWindow : Window
|
||||
w.Show();
|
||||
}
|
||||
|
||||
private void BtnImport_OnClick(object? sender, RoutedEventArgs e)
|
||||
private async void BtnImport_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
// CSV Import
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
14
README.md
14
README.md
@@ -2,12 +2,14 @@
|
||||
|
||||
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
|
||||
## 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
|
||||
|
||||
\+ Vorhanden, ~ Pending
|
||||
|
||||
## Nutzung
|
||||
* Build from source:
|
||||
|
||||
50
import.cs
Normal file
50
import.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
16
structs.cs
16
structs.cs
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace spplus;
|
||||
|
||||
public abstract class Sport
|
||||
public class Sport
|
||||
{
|
||||
public string Name { get; set; } = "Neuer Kurs"; // Kursname
|
||||
public int MaxCoursesPerSemester { get; set; } = 1; // Maximale Anzahl an Kursen pro Semester
|
||||
@@ -30,23 +30,29 @@ public abstract class Sport
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Student
|
||||
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;
|
||||
|
||||
protected Student()
|
||||
public Student()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Name} ({ID})";
|
||||
}
|
||||
|
||||
protected Student(string id, string name, Sport[] selectedCourses)
|
||||
public Student(string id, string name, List<string> selectedCoursesNames)
|
||||
{
|
||||
ID = id;
|
||||
Name = name;
|
||||
SelectedCourses = selectedCourses;
|
||||
SelectedCourseNames = selectedCoursesNames;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user