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

Release v1.0.0-beta3 #32

Merged
merged 14 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
39 changes: 39 additions & 0 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Code analysis"

on:
push:
branches: [ "master", develop ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '22 18 * * 5'

jobs:
analyze:
name: Analyze code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
3 changes: 1 addition & 2 deletions Epsilon.Canvas.Abstractions/Model/ModuleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Epsilon.Canvas.Abstractions.Model;
public record ModuleItem(
[property: JsonPropertyName("id")] int Id,
[property: JsonPropertyName("title")] string Title,
[property: JsonPropertyName("type"), JsonConverter(typeof(JsonStringEnumConverter))]
ModuleItemType? Type,
[property: JsonPropertyName("type")] ModuleItemType? Type,
[property: JsonPropertyName("content_id")] int? ContentId
);
12 changes: 9 additions & 3 deletions Epsilon.Canvas.Abstractions/Model/ModuleItemType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace Epsilon.Canvas.Abstractions.Model;
using System.Text.Json.Serialization;

namespace Epsilon.Canvas.Abstractions.Model;

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ModuleItemType
{
Unknown,
File,
Page,
Discussion,
Assignment,
Quiz,
SubHeader,
File,
ExternalUrl,
ExternalTool,
}
21 changes: 17 additions & 4 deletions Epsilon.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@ IHostBuilder CreateHostBuilder(string[] args)
});
}

await CreateHostBuilder(args)
.UseSerilog()
.Build()
.RunAsync();
try
{
Log.Information("Starting up");

await CreateHostBuilder(args)
.UseSerilog()
.Build()
.RunAsync();
}
catch (Exception ex)

Check notice

Code scanning / CodeQL

Extraction error

Unexpected C# extractor error: TagStack unexpectedly empty

Check notice

Code scanning / CodeQL

Extraction message

Error was generated by C# extractor: TagStack unexpectedly empty
{
Log.Fatal(ex, "Application was unable to start due to fatal error");
}
Comment on lines +37 to +40

Check notice

Code scanning / CodeQL

Generic catch clause

Generic catch clause.
finally
{
Log.CloseAndFlush();
}
43 changes: 27 additions & 16 deletions Epsilon.Cli/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,42 @@ public Task StopAsync(CancellationToken cancellationToken)

private async Task ExecuteAsync()
{
var results = Validate(_canvasSettings).ToArray();
if (results.Any())
try
{
foreach (var validationResult in results)
var results = Validate(_canvasSettings).ToArray();
if (results.Any())
{
_logger.LogError("Error: {Message}", validationResult.ErrorMessage);
foreach (var validationResult in results)
{
_logger.LogError("Error: {Message}", validationResult.ErrorMessage);
}

_lifetime.StopApplication();
return;
}

_lifetime.StopApplication();
return;
}
_logger.LogInformation("Targeting Canvas course: {CourseId}, at {Url}", _canvasSettings.CourseId, _canvasSettings.ApiUrl);
var modules = await _collectionFetcher.GetAll(_canvasSettings.CourseId);

_logger.LogInformation("Targeting Canvas course: {CourseId}, at {Url}", _canvasSettings.CourseId, _canvasSettings.ApiUrl);
var modules = await _collectionFetcher.GetAll(_canvasSettings.CourseId);
var formats = _exportOptions.Formats.Split(",");
var exporters = _exporterCollection.DetermineExporters(formats).ToArray();

_logger.LogInformation("Attempting to use following formats: {Formats}", string.Join(", ", _exportOptions.Formats));
var exporters = _exporterCollection.DetermineExporters(_exportOptions.Formats).ToArray();
_logger.LogInformation("Attempting to use following formats: {Formats}", string.Join(", ", formats));

foreach (var (format, exporter) in exporters)
foreach (var (format, exporter) in exporters)
{
_logger.LogInformation("Exporting to {Format} using {Exporter}...", format, exporter.GetType().Name);
exporter.Export(modules, format);
}
}
catch (Exception ex)
{
_logger.LogInformation("Exporting to {Format} using {Exporter}...", format, exporter.GetType().Name);
exporter.Export(modules, format);
_logger.LogError(ex, "Error occured:");
}
Comment on lines +79 to +82

Check notice

Code scanning / CodeQL

Generic catch clause

Generic catch clause.
finally
{
_lifetime.StopApplication();
}

_lifetime.StopApplication();
}

private static IEnumerable<ValidationResult> Validate(object model)
Expand Down
13 changes: 1 addition & 12 deletions Epsilon.Cli/appsettings.example.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "None",
"Microsoft": "None"
}
},
"Serilog": {
"Using": [
"Serilog.Sinks.Console"
],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Error",
"System": "Error"
}
"Default": "Debug"
},
"WriteTo": [
{
Expand Down
2 changes: 1 addition & 1 deletion Epsilon/Export/ExportOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class ExportOptions
{
public string OutputName { get; set; } = "Epsilon-Export-{DateTime}";

public List<string> Formats { get; } = new();
public string Formats { get; set; } = "console";

public string FormattedOutputName => OutputName
.Replace("{DateTime}", DateTime.Now.ToString("ddMMyyyyHHmmss"));
Expand Down
2 changes: 1 addition & 1 deletion Epsilon/Extensions/CoreServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class CoreServiceCollectionExtensions
public static IServiceCollection AddCore(this IServiceCollection services, IConfiguration config)
{
services.AddCanvas(config.GetSection("Canvas"));
services.AddExport(config.GetSection("Export"));
services.AddExport(config);

return services;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ These students usually have a personal course within Canvas (from Instructure),
During each semester, it is requested to take note of all KPI's which have been proven.
To aid in these efforts, this application will gather all your mastered/proven [KPI's](https://hbo-i.nl/domeinbeschrijving/) and export your KPI's to a file format (e.g., JSON, Exel, CSV).

![Application demo](https://i.imgur.com/nd4zKAT.gif)
![Application demo](https://user-images.githubusercontent.com/12190745/176268592-e863e4c3-47b4-4af5-aeca-298d53a37c33.gif)

## Usage
Read how to use the application in our Wiki located [here](https://github.com/Typiqally/epsilon/wiki/How-to-use).
Expand Down