Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Fix module filter not returning empty list when option is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Typiqally committed May 26, 2023
1 parent 23df346 commit 3341acf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace Epsilon.Canvas.Abstractions;

public interface ICanvasModuleCollectionFetcher
{
public IAsyncEnumerable<ModuleOutcomeResultCollection> GetAll(int courseId, String[] allowedModules);
public IAsyncEnumerable<ModuleOutcomeResultCollection> GetAll(int courseId, IEnumerable<string>? allowedModules);
}
4 changes: 2 additions & 2 deletions Epsilon.Canvas/CanvasModuleCollectionFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ IOutcomeHttpService outcomeService
_outcomeService = outcomeService;
}

public async IAsyncEnumerable<ModuleOutcomeResultCollection> GetAll(int courseId, string[] allowedModules)
public async IAsyncEnumerable<ModuleOutcomeResultCollection> GetAll(int courseId, IEnumerable<string>? allowedModules)
{
var response = await _outcomeService.GetResults(courseId, new[] { "outcomes", "alignments" });
var modules = await _moduleService.GetAll(courseId, new[] { "items" });
Expand All @@ -31,7 +31,7 @@ public async IAsyncEnumerable<ModuleOutcomeResultCollection> GetAll(int courseId

foreach (var module in modules.ToArray())
{
if (allowedModules.Length == 0 || allowedModules.Contains(module.Name))
if (allowedModules == null || !allowedModules.Any() || allowedModules.Contains(module.Name))
{
Debug.Assert(module.Items != null, "module.Items != null");

Expand Down
2 changes: 1 addition & 1 deletion Epsilon.Cli/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private async Task ExecuteAsync()
return;
}

var modules = _exportOptions.Modules.Split(",");
var modules = _exportOptions.Modules?.Split(",");
_logger.LogInformation("Targeting Canvas course: {CourseId}, at {Url}", _canvasSettings.CourseId,
_canvasSettings.ApiUrl);
_logger.LogInformation("Downloading results, this may take a few seconds...");
Expand Down
4 changes: 2 additions & 2 deletions Epsilon/Export/ExportOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class ExportOptions
public string OutputName { get; set; } = $"{Constants.ProjectName}-Export-{{DateTime}}";

public string Formats { get; set; } = "console";
public string Modules { get; set; } = "";

public string? Modules { get; set; } = null;

public string FormattedOutputName => OutputName
.Replace("{DateTime}", DateTime.Now.ToString("ddMMyyyyHHmmss"));
Expand Down

0 comments on commit 3341acf

Please sign in to comment.