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

Beta enhancements #20

Merged
merged 35 commits into from
Jun 21, 2022
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
af97e67
Change input format to lower case to disable case sensitivity
Typiqally Jun 9, 2022
3692ab5
Cleanup code
Typiqally Jun 9, 2022
979acb8
Log supported formats when exporter could not be determined
Typiqally Jun 9, 2022
8b06666
Add extra formats to excel module exporter
Typiqally Jun 9, 2022
e4a03d2
Fix outcomes being capped at 100
i404788 Jun 14, 2022
fa75ccc
Remove inappropriate try catch
Typiqally Jun 14, 2022
0d8bbbf
Remove obsolete this reference
Typiqally Jun 14, 2022
9261978
Add score property to outcome result
Typiqally Jun 14, 2022
250da5c
Add rubric assessment and rating data models
Typiqally Jun 14, 2022
49e5746
Add submission data model
Typiqally Jun 14, 2022
32bbb3c
Add submissions to module data model
Typiqally Jun 14, 2022
0864f60
Add submission service
Typiqally Jun 14, 2022
af7aa0c
Remove loggers from canvas services
Typiqally Jun 14, 2022
2c34536
Replace assignments list with submission list for core logic
Typiqally Jun 14, 2022
8b7a201
Cleanup startup and remove try catch
Typiqally Jun 14, 2022
393ae22
Merge branch 'feat/beta-enhancements' into master
Typiqally Jun 14, 2022
95fdf49
Fix build errors
Typiqally Jun 14, 2022
061f255
Merge pull request #21 from i404788/master
Typiqally Jun 14, 2022
01c78d4
Replace argument exceptions with validation results
Typiqally Jun 15, 2022
8ced417
Rename data namespace to model
Typiqally Jun 15, 2022
6c23432
Remove unused properties
Typiqally Jun 15, 2022
92cbf13
Rename services namespace for consistency
Typiqally Jun 15, 2022
fdca9b6
Rename count to limit for consistency
Typiqally Jun 15, 2022
288bd9d
Merge remote-tracking branch 'origin/feat/beta-enhancements' into fea…
Typiqally Jun 15, 2022
ffa3f1b
Cleanup code from pagination implementation
Typiqally Jun 15, 2022
2122c65
Add outcome description to excel export
Typiqally Jun 16, 2022
cc7a961
Trim excessive spaces
Typiqally Jun 16, 2022
57df77d
Modify column widths to show content clearer
Typiqally Jun 16, 2022
88e0f8a
Remove unused using directives
Typiqally Jun 16, 2022
7b27410
Update application demo gif
Typiqally Jun 16, 2022
f6d5661
Adding functionality for a short outcome description.
NealGeilen Jun 18, 2022
70156ca
Replace multiple endpoints with one single-purpose endpoint
Typiqally Jun 21, 2022
d4eeb8d
Added score to xls export
NealGeilen Jun 21, 2022
2a2c750
Added score to xls export
NealGeilen Jun 21, 2022
054df8d
Merge branch 'master' into feat/beta-enhancements
NealGeilen Jun 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix outcomes being capped at 100
i404788 committed Jun 14, 2022
commit e4a03d205e7ef0b817acb99bd1fd06eecf0a8642
64 changes: 64 additions & 0 deletions Epsilon.Canvas.Abstractions/Data/LinkHeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System.Text.RegularExpressions;

public class LinkHeader
{
public string FirstLink { get; set; }
public string PrevLink { get; set; }
public string NextLink { get; set; }
public string LastLink { get; set; }

public static LinkHeader LinksFromHeader(HttpResponseMessage httpResponseMessage)
{
if (httpResponseMessage.Headers.Contains("Link"))
{
return LinkHeader.LinksFromHeader(httpResponseMessage.Headers.GetValues("Link").FirstOrDefault());
}

return null;
}

public static LinkHeader LinksFromHeader(string linkHeaderStr)
{
LinkHeader linkHeader = null;

if (!string.IsNullOrWhiteSpace(linkHeaderStr))
{
string[] linkStrings = linkHeaderStr.Split(',');

if (linkStrings != null && linkStrings.Any())
{
linkHeader = new LinkHeader();

foreach (string linkString in linkStrings)
{
var relMatch = Regex.Match(linkString, "(?<=rel=\").+?(?=\")", RegexOptions.IgnoreCase);
var linkMatch = Regex.Match(linkString, "(?<=<).+?(?=>)", RegexOptions.IgnoreCase);

if (relMatch.Success && linkMatch.Success)
{
string rel = relMatch.Value.ToUpper();
string link = linkMatch.Value;

switch (rel)
{
case "FIRST":
linkHeader.FirstLink = link;
break;
case "PREV":
linkHeader.PrevLink = link;
break;
case "NEXT":
linkHeader.NextLink = link;
break;
case "LAST":
linkHeader.LastLink = link;
break;
}
}
}
}
}

return linkHeader;
}
}
2 changes: 1 addition & 1 deletion Epsilon.Canvas/Response/OutcomeResultResponse.cs
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ namespace Epsilon.Canvas.Response;

public record OutcomeResultResponse(
[property: JsonPropertyName("outcome_results")] IEnumerable<OutcomeResult> OutcomeResults
);
);
21 changes: 17 additions & 4 deletions Epsilon.Canvas/Service/OutcomeService.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using Epsilon.Http.Abstractions;
using Epsilon.Http.Abstractions.Json;
using Microsoft.Extensions.Logging;
using System.Text.Json;

namespace Epsilon.Canvas.Service;

@@ -28,11 +29,23 @@ public OutcomeService(HttpClient client, ILogger<OutcomeService> logger) : base(

public async Task<IEnumerable<OutcomeResult>?> AllResults(int courseId, int count = 1000)
{
var request = new HttpRequestMessage(HttpMethod.Get, $"v1/courses/{courseId}/outcome_results?per_page={count}");
var (response, value) = await Client.SendAsync<OutcomeResultResponse>(request);
IEnumerable<OutcomeResult>? res = null;
var page = 1;
do {
var request = new HttpRequestMessage(HttpMethod.Get, $"v1/courses/{courseId}/outcome_results?per_page={count}&offset={res?.Count() ?? 0}&page={page}");
var (response, value) = await Client.SendAsync<OutcomeResultResponse>(request);
var links = LinkHeader.LinksFromHeader(response);

_logger.LogDebug("Fetching outcome results from course #{res} #{len} #{links}", JsonSerializer.Serialize(value?.OutcomeResults), value?.OutcomeResults.Count(), links.NextLink);
res = res == null ? value?.OutcomeResults : res.Concat(value.OutcomeResults);
if (links.NextLink == null)
break;
page += 1;

} while(res.Count() % 100 == 0);

_logger.LogDebug("Fetching outcome results from course #{CourseId}", courseId);

return value?.OutcomeResults;
return res;
}
}
}