Skip to content

Commit

Permalink
Resolved requested changes
Browse files Browse the repository at this point in the history
'?' behind each 'body' element.

Added RunProperties (underline) to each submission hyperlink.

Want to add a color to each hyperlink, but this makes the grading icons the same color as the text. So it makes you unable to know what each icon means.
  • Loading branch information
Bash-04 committed Jan 9, 2024
1 parent db6db55 commit 1aa849b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ protected AbstractCompetenceComponent(IAsyncEnumerable<LearningDomainSubmission>
protected IAsyncEnumerable<LearningDomainSubmission> Submissions { get; set; }
protected IEnumerable<LearningDomain?> Domains { get; set; }

public abstract Task<Body> AddToWordDocument(MainDocumentPart mainDocumentPart);
public abstract Task<Body?> AddToWordDocument(MainDocumentPart mainDocumentPart);

Check warning on line 17 in Epsilon.Abstractions/Components/AbstractCompetenceComponent.cs

View workflow job for this annotation

GitHub Actions / Build .NET solution

Nullability of reference types in return type of 'Task<Body?> AbstractCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)' doesn't match implicitly implemented member 'Task<Body> IWordCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)'.

Check warning on line 17 in Epsilon.Abstractions/Components/AbstractCompetenceComponent.cs

View workflow job for this annotation

GitHub Actions / Build .NET solution

Nullability of reference types in return type of 'Task<Body?> AbstractCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)' doesn't match implicitly implemented member 'Task<Body> IWordCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)'.

Check warning on line 17 in Epsilon.Abstractions/Components/AbstractCompetenceComponent.cs

View workflow job for this annotation

GitHub Actions / Unit testing

Nullability of reference types in return type of 'Task<Body?> AbstractCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)' doesn't match implicitly implemented member 'Task<Body> IWordCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)'.

Check warning on line 17 in Epsilon.Abstractions/Components/AbstractCompetenceComponent.cs

View workflow job for this annotation

GitHub Actions / Unit testing

Nullability of reference types in return type of 'Task<Body?> AbstractCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)' doesn't match implicitly implemented member 'Task<Body> IWordCompetenceComponent.AddToWordDocument(MainDocumentPart mainDocumentPart)'.
}
8 changes: 4 additions & 4 deletions Epsilon/Components/CompetenceProfileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace Epsilon.Components;

public class CompetenceProfileComponent : AbstractCompetenceComponent
{
public override async Task<Body> AddToWordDocument(MainDocumentPart mainDocumentPart)
public override async Task<Body?> AddToWordDocument(MainDocumentPart mainDocumentPart)
{
var body = mainDocumentPart.Document.Body;

body!.Append(new Paragraph(new Run(new Text("Hello World!"))));
body?.Append(new Paragraph(new Run(new Text("Hello World!"))));
// toDo: Add the table with realised outcomes, like the performance dashboard.

var count = await Submissions.CountAsync();
body.Append(new Paragraph(new Run(new Text(count.ToString(CultureInfo.InvariantCulture)))));
body?.Append(new Paragraph(new Run(new Text(count.ToString(CultureInfo.InvariantCulture)))));
await foreach (var sub in Submissions)
{
body.Append(new Paragraph(new Run(new Text(sub.Assignment ?? "We tried"))));
body?.Append(new Paragraph(new Run(new Text(sub.Assignment ?? "We tried"))));
}

return body;
Expand Down
24 changes: 12 additions & 12 deletions Epsilon/Components/KpiTableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Epsilon.Components;

public class KpiTableComponent : AbstractCompetenceComponent
{
public override async Task<Body> AddToWordDocument(MainDocumentPart mainDocumentPart)
public override async Task<Body?> AddToWordDocument(MainDocumentPart mainDocumentPart)
{
var body = mainDocumentPart.Document.Body;

Expand Down Expand Up @@ -41,26 +41,26 @@ public override async Task<Body> AddToWordDocument(MainDocumentPart mainDocument
// Create the header cells
foreach (var columnHeader in columnsHeaders)
{
headerRow.AppendChild(CreateTableCellWithBorders(columnHeader.Value, new Paragraph(new Run(new Text(columnHeader.Key)))));
headerRow.AppendChild(CreateTableCell(columnHeader.Value, new Paragraph(new Run(new Text(columnHeader.Key)))));
}

// Add the header row to the table
table.AppendChild(headerRow);


// Get allOutcomes
var allOutcomes = Submissions
.SelectMany(static e => e.Results
.Select(static result => result.Outcome)
.ToAsyncEnumerable());

// Create the table body rows and cells
await foreach (var outcome in allOutcomes
.OrderBy(static e => e.Value.Order)
.Distinct())
{
var tableRow = new TableRow();

// Outcome (KPI) column
tableRow.AppendChild(CreateTableCellWithBorders("3000", new Paragraph(new Run(new Text(outcome.Name)))));
tableRow.AppendChild(CreateTableCell("3000", new Paragraph(new Run(new Text(outcome.Name)))));

// Assignments column
var assignmentsParagraph = new Paragraph();
Expand All @@ -77,7 +77,7 @@ public override async Task<Body> AddToWordDocument(MainDocumentPart mainDocument
var rel = mainDocumentPart.AddHyperlinkRelationship(new Uri(submission.AssignmentUrl!.ToString()), true);
var relationshipId = rel.Id;

var hyperlink = new Hyperlink(new Run(new Text(submission.Assignment!))) { Id = relationshipId, };
var hyperlink = new Hyperlink(new Run(new RunProperties(new Underline { Val = UnderlineValues.Single, }), new Text(submission.Assignment!))) { Id = relationshipId, };

assignmentsParagraph.AppendChild(hyperlink);
assignmentsParagraph.AppendChild(new Run(new Break()));
Expand All @@ -90,23 +90,23 @@ public override async Task<Body> AddToWordDocument(MainDocumentPart mainDocument
}
}

tableRow.AppendChild(CreateTableCellWithBorders("5000", assignmentsParagraph));
tableRow.AppendChild(CreateTableCellWithBorders("1000", gradesParagraph));
tableRow.AppendChild(CreateTableCell("5000", assignmentsParagraph));
tableRow.AppendChild(CreateTableCell("1000", gradesParagraph));

// Add the row to the table
table.AppendChild(tableRow);
}

// Newline to separate the table from the rest of the document
body.Append(new Paragraph(new Run(new Text(""))));
body?.Append(new Paragraph(new Run(new Text(""))));

// Add the table to the document
body.AppendChild(table);
body?.AppendChild(table);

return null;
return body;
}

private static TableCell CreateTableCellWithBorders(string? width, params OpenXmlElement[] elements)
private static TableCell CreateTableCell(string? width, params OpenXmlElement[] elements)
{
var cell = new TableCell();
var cellProperties = new TableCellProperties();
Expand Down

0 comments on commit 1aa849b

Please sign in to comment.