This repository has been archived by the owner on Sep 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstracted format logic from exporters to main logic (#62)
* Abstracted format logic from exporters to main logic * Remove typo * Remove unused variable * Renamed Course- prefix to Module, Kpi and Assignment class & Renamed Kpi to Outcome * Renamed ModuleExporterDataCollection to ModuleDataPackager * Resolved GetExportData List/IAsyncEnumerable type conflict * Added generic data model for exporters * Rename ModuleData to ExportData
- Loading branch information
1 parent
a5e6270
commit 3dc1593
Showing
13 changed files
with
169 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using Epsilon.Canvas.Abstractions.Model; | ||
using Epsilon.Abstractions.Model; | ||
|
||
namespace Epsilon.Abstractions.Export; | ||
|
||
public interface ICanvasModuleExporter : IExporter<IAsyncEnumerable<ModuleOutcomeResultCollection>> | ||
public interface ICanvasModuleExporter : IExporter<ExportData> | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Epsilon.Abstractions.Model; | ||
using Epsilon.Canvas.Abstractions.Model; | ||
|
||
namespace Epsilon.Abstractions.Export; | ||
|
||
public interface IExportDataPackager | ||
{ | ||
public Task<ExportData> GetExportData(IAsyncEnumerable<ModuleOutcomeResultCollection> data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Epsilon.Abstractions.Model | ||
{ | ||
public class CourseAssignment | ||
{ | ||
public string Name { get; set; } | ||
public string Score { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Epsilon.Abstractions.Model | ||
{ | ||
public class CourseModule | ||
{ | ||
public string Name { get; set; } | ||
public IEnumerable<CourseOutcome> Kpis { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Epsilon.Abstractions.Model | ||
{ | ||
public class CourseOutcome | ||
{ | ||
public string Name { get; set; } | ||
public IEnumerable<CourseAssignment> Assignments { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Epsilon.Abstractions.Model | ||
{ | ||
public class ExportData | ||
{ | ||
public IEnumerable<CourseModule> CourseModules { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Diagnostics; | ||
using Epsilon.Abstractions.Export; | ||
using Epsilon.Abstractions.Model; | ||
using Epsilon.Canvas.Abstractions.Model; | ||
|
||
namespace Epsilon.Export; | ||
|
||
public class ExportDataPackager : IExportDataPackager | ||
{ | ||
public async Task<ExportData> GetExportData(IAsyncEnumerable<ModuleOutcomeResultCollection> data) | ||
{ | ||
var output = new List<CourseModule>(); | ||
|
||
await foreach (var item in data.Where(m => m.Collection.OutcomeResults.Any())) | ||
{ | ||
var module = new CourseModule { Name = item.Module.Name }; | ||
var links = item.Collection.Links; | ||
|
||
Debug.Assert(links != null, nameof(links) + " != null"); | ||
|
||
var alignments = links.AlignmentsDictionary; | ||
var outcomes = links.OutcomesDictionary; | ||
|
||
var moduleKpis = new List<CourseOutcome>(); | ||
|
||
foreach (var (outcomeId, outcome) in outcomes) | ||
{ | ||
var assignmentIds = item.Collection.OutcomeResults | ||
.Where(o => o.Link.Outcome == outcomeId && o.Grade() != null) | ||
.Select(o => o.Link.Assignment); | ||
|
||
if (assignmentIds.Any()) | ||
{ | ||
var assignments = assignmentIds | ||
.Select(assignmentId => new CourseAssignment | ||
{ | ||
Name = alignments[assignmentId].Name + " | " + alignments[assignmentId].Url, | ||
Score = item.Collection.OutcomeResults | ||
.First(o => o.Link.Outcome == outcomeId && o.Link.Assignment == assignmentId) | ||
.Grade() ?? "N/A" | ||
}) | ||
.ToList(); | ||
|
||
moduleKpis.Add(new CourseOutcome | ||
{ | ||
Name = outcome.Title + " " + outcome.ShortDescription(), | ||
Assignments = assignments, | ||
}); | ||
} | ||
} | ||
|
||
module.Kpis = moduleKpis; | ||
|
||
output.Add(module); | ||
} | ||
|
||
return new ExportData { CourseModules = output }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.