Add shared export infrastructure
This commit is contained in:
@@ -3,9 +3,9 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Groups;
|
||||
|
||||
@@ -195,27 +195,27 @@ public partial class ExamEvaluationDialogViewModel : ObservableObject
|
||||
|
||||
public string ExportCsv()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"Klausur;{_exam.Title}");
|
||||
sb.AppendLine($"Datum;{_exam.Date:dd.MM.yyyy}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("Notenspiegel");
|
||||
sb.AppendLine("Note;Anzahl;Anteil");
|
||||
var csv = new CsvBuilder()
|
||||
.AddRow("Klausur", _exam.Title)
|
||||
.AddRow("Datum", _exam.Date.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture))
|
||||
.AddBlankRow()
|
||||
.AddRow("Notenspiegel")
|
||||
.AddRow("Note", "Anzahl", "Anteil");
|
||||
foreach (var g in GradeDistribution)
|
||||
sb.AppendLine($"{g.Grade};{g.Count};{Percent(g.Count, GradedCount)}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"Durchschnitt;{AverageDisplay}");
|
||||
sb.AppendLine($"Median;{MedianDisplay}");
|
||||
if (!string.IsNullOrEmpty(BelowThresholdLabel1)) sb.AppendLine($"{BelowThresholdLabel1};{BelowThresholdDisplay1}");
|
||||
if (!string.IsNullOrEmpty(BelowThresholdLabel2)) sb.AppendLine($"{BelowThresholdLabel2};{BelowThresholdDisplay2}");
|
||||
sb.AppendLine($"Bewertet;{GradedCount}");
|
||||
sb.AppendLine($"Abwesend;{AbsentCount}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("Aufgabenanalyse");
|
||||
sb.AppendLine("Aufgabe;Ø Erfüllungsgrad;Auffällig schwach");
|
||||
csv.AddRow(g.Grade, g.Count, Percent(g.Count, GradedCount));
|
||||
csv.AddBlankRow()
|
||||
.AddRow("Durchschnitt", AverageDisplay)
|
||||
.AddRow("Median", MedianDisplay);
|
||||
if (!string.IsNullOrEmpty(BelowThresholdLabel1)) csv.AddRow(BelowThresholdLabel1, BelowThresholdDisplay1);
|
||||
if (!string.IsNullOrEmpty(BelowThresholdLabel2)) csv.AddRow(BelowThresholdLabel2, BelowThresholdDisplay2);
|
||||
csv.AddRow("Bewertet", GradedCount)
|
||||
.AddRow("Abwesend", AbsentCount)
|
||||
.AddBlankRow()
|
||||
.AddRow("Aufgabenanalyse")
|
||||
.AddRow("Aufgabe", "Ø Erfüllungsgrad", "Auffällig schwach");
|
||||
foreach (var t in TaskAnalysis)
|
||||
sb.AppendLine($"{t.Label};{t.AvgPercentDisplay};{(t.IsWeak ? "ja" : "")}");
|
||||
return sb.ToString();
|
||||
csv.AddRow(t.Label, t.AvgPercentDisplay, t.IsWeak ? "ja" : "");
|
||||
return csv.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user