before i get in a deeper hole

This commit is contained in:
2023-08-04 11:17:55 -06:00
parent a921fd6f90
commit 9d96b7f23f
19 changed files with 218 additions and 242 deletions

View File

@@ -1 +0,0 @@
*.feature.cs

View File

@@ -1,9 +0,0 @@
using System;
namespace Management.Gherkin.Drivers
{
public class Driver
{
}
}

View File

@@ -1,13 +0,0 @@
Feature: Calculator
![Calculator](https://specflow.org/wp-content/uploads/2020/09/calculator.png)
Simple calculator for adding **two** numbers
Link to a feature: [Calculator]($projectname$/Features/Calculator.feature)
***Further read***: **[Learn more about how to generate Living Documentation](https://docs.specflow.org/projects/specflow-livingdoc/en/latest/LivingDocGenerator/Generating-Documentation.html)**
@mytag
Scenario: Add two numbers
Given the first number is 50
And the second number is 70
When the two numbers are added
Then the result should be 120

View File

@@ -1,11 +0,0 @@
using System;
using TechTalk.SpecFlow;
namespace Management.Gherkin.Hooks
{
[Binding]
public class Hooks
{
}
}

View File

@@ -1,16 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.*" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
</ItemGroup>
</Project>

View File

@@ -1,58 +0,0 @@
using TechTalk.SpecFlow;
namespace Management.Gherkin.Steps
{
[Binding]
public sealed class CalculatorStepDefinitions
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
public CalculatorStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(int number)
{
//TODO: implement arrange (precondition) logic
// For storing and retrieving scenario-specific data see https://go.specflow.org/doc-sharingdata
// To use the multiline text or the table argument of the scenario,
// additional string/Table parameters can be defined on the step definition
// method.
_scenarioContext.Pending();
}
[Given("the second number is (.*)")]
public void GivenTheSecondNumberIs(int number)
{
//TODO: implement arrange (precondition) logic
// For storing and retrieving scenario-specific data see https://go.specflow.org/doc-sharingdata
// To use the multiline text or the table argument of the scenario,
// additional string/Table parameters can be defined on the step definition
// method.
_scenarioContext.Pending();
}
[When("the two numbers are added")]
public void WhenTheTwoNumbersAreAdded()
{
//TODO: implement act (action) logic
_scenarioContext.Pending();
}
[Then("the result should be (.*)")]
public void ThenTheResultShouldBe(int result)
{
//TODO: implement assert (verification) logic
_scenarioContext.Pending();
}
}
}

View File

@@ -28,8 +28,6 @@
}
}
private void reload()
{
this.InvokeAsync(this.StateHasChanged);

View File

@@ -25,7 +25,6 @@
{
planner.StateHasChanged -= reload;
}
private Modal? assignmentEditorModal { get; set; }
private bool showAll { get; set; } = false;
private void dropOnDate(DateTime dropDate)
@@ -134,18 +133,15 @@
role="button"
>
<div class="card">
<div class="card-body">
<div class="card-title">
<div class="row">
<div class="col">
</div>
<div class="col-8">
<h4 class="text-center">
<div class="card-body p-0">
<div class="card-title pt-2 px-2 m-0">
<div class="row mx-1">
<div class="col offset-2 offset-lg-1 ">
<h4 class="text-center m-0">
@Assignment.name
</h4>
</div>
<div class="col text-end">
<div class="col-2 col-lg-1 text-end">
@if(isSyncedWithCanvas)
{
@if(planner.LocalCourse != null
@@ -167,23 +163,15 @@
}
else
{
<div>Not Synced with Canvas</div>
<SyncIcon />
}
</div>
</div>
</div>
@if(!showAll)
{
<div class="card-text overflow-hidden" style="max-height: 5rem;">
@* @if(Assignment.use_template)
{
var html = Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates);
@((MarkupString) html)
}
else
{
@Assignment.description
} *@
<div class="card-text overflow-hidden p-2" style="max-height: 5rem;">
<div>Points: @Assignment.points_possible</div>
<div>Due At: @Assignment.due_at</div>
</div>
@@ -191,36 +179,15 @@
else
{
<div class="card-text">
@if(Assignment.use_template)
{
var html = Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates);
@((MarkupString) html)
}
else
{
@Assignment.description
}
<div class="px-3 py-1 bg-dark-subtle my-1">
<hr>
@((MarkupString) @Assignment.GetDescriptionHtml(planner.LocalCourse?.AssignmentTemplates))
</div>
<section class="px-3">
<div>Points: @Assignment.points_possible</div>
<div>Due At: @Assignment.due_at</div>
<div>Lock At: @Assignment.lock_at</div>
<br>
<h5>
Rubric
</h5>
@foreach(var rubricItem in Assignment.rubric)
{
<div class="row m-0">
<div class="col border-end my-auto">
@rubricItem.Label
</div>
<div class="col-2 my-auto">
@rubricItem.Points
</div>
</div>
}
<br>
<div>Submission Types:</div>
<ul>
@foreach(var type in Assignment.submission_types)
@@ -230,6 +197,7 @@
</li>
}
</ul>
</section>
</div>
}
@@ -237,25 +205,45 @@
@if(!showAll)
{
<div
class="text-center"
class="text-center fs-3 fw-bold lh-1 text-primary"
role="button"
@onclick:preventDefault="true"
@onclick:stopPropagation="true"
@onclick="() => showAll = true"
>
...
<svg
width="30"
height="30"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6 10a2 2 0 11-4.001-.001A2 2 0 016 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0112 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0118 10z"
fill="var(--bs-primary)"
/>
</svg>
</div>
}
else
{
<div
class="text-center"
class="text-center fs-3 fw-bold lh-1 text-primary"
role="button"
@onclick:preventDefault="true"
@onclick:stopPropagation="true"
@onclick="() => showAll = false"
>
...
<svg
width="30"
height="30"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6 10a2 2 0 11-4.001-.001A2 2 0 016 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0112 10zm6 0a2 2 0 11-4.001-.001A2 2 0 0118 10z"
fill="var(--bs-primary)"
/>
</svg>
</div>
}
@@ -267,5 +255,4 @@
Assignment="Assignment"
Show="showUpdateForm"
OnHide="@(() => showUpdateForm = false)"
Module="Module"
/>

View File

@@ -1,3 +1,4 @@
@using Markdig
@inject CoursePlanner planner
@@ -29,6 +30,7 @@
.LocalCourse?
.AssignmentTemplates
.FirstOrDefault(t => t.Id == TemplateId);
public string Preview => Markdown.ToHtml(Description);
}
@@ -109,17 +111,35 @@
}
else
{
<div class="row">
<div class="col">
<label
for="description"
class="form-label"
>
Description
</label>
</div>
<div class="col">
HTML Preview
</div>
</div>
<div class="row">
<div class="col">
<textarea
id="description"
class="form-control"
value="@Description"
rows=12
@oninput="async (e) =>
await DescriptionChanged.InvokeAsync(e.Value?.ToString() ?? String.Empty)"
/>
</div>
<div class="col">
@((MarkupString) Preview)
</div>
</div>
}

View File

@@ -3,8 +3,6 @@
@inject CoursePlanner planner
@code {
[Parameter]
[EditorRequired]
public LocalModule Module { get; set; } = default!;
[Parameter]
@@ -94,6 +92,11 @@
rubric = newRubric;
StateHasChanged();
}
private void SetTypes(IEnumerable<string> newTypes)
{
submissionTypes = newTypes;
StateHasChanged();
}
}
<Modal @ref="AssignmentModal" OnHide="@(() => OnHide())">
@@ -139,7 +142,7 @@
<RubricEditor Rubric="rubric" SetRubric="updateRubric" />
<SubmissionTypeSelector
Types="submissionTypes"
SetTypes="(newTypes) => submissionTypes = newTypes"
SetTypes="SetTypes"
/>
</form>
</Body>

View File

@@ -22,6 +22,13 @@
);
StateHasChanged();
}
private void removeItem()
{
SetRubric(
Rubric.Take(Rubric.Count() - 1)
);
StateHasChanged();
}
private void editItem(RubricItem newItem)
{
var newRubric = Rubric.Select(i => i.Id == newItem.Id ? newItem : i);
@@ -71,6 +78,14 @@
</ul>
<div class="text-end my-1">
<button
@onclick:preventDefault="true"
@onclick="removeItem"
type="button"
class="btn btn-outline-danger"
>
- rubric item
</button>
<button
@onclick:preventDefault="true"
@onclick="addItem"

View File

@@ -2,8 +2,16 @@
@code
{
private IEnumerable<string> _types { get; set; } = Enumerable.Empty<string>();
[Parameter, EditorRequired]
public IEnumerable<string> Types { get; set; } = Enumerable.Empty<string>();
public IEnumerable<string> Types {
get => _types;
set
{
_types = value;
renderKey++;
}
}
[Parameter, EditorRequired]
public Action<IEnumerable<string>> SetTypes { get; set; } = (_) => {};
@@ -11,13 +19,23 @@
{
return type.ToString().Replace("_", "") + "switch";
}
private bool discussionIsSelected
{
get => Types.FirstOrDefault(
t => t == SubmissionType.discussion_topic
) != null;
}
private int renderKey {get; set; } = 1;
}
<h5>Submission Types</h5>
<div class="row">
<div class="row" @key="Types">
@foreach (var submissionType in SubmissionType.AllTypes)
{
var isDiscussion = submissionType == SubmissionType.discussion_topic;
var allowedToBeChecked = !discussionIsSelected || isDiscussion;
<div class="col-4">
<div class="form-check form-switch">
<input
@@ -25,7 +43,7 @@
type="checkbox"
role="switch"
id="@getLabel(submissionType)"
checked="@Types.Contains(submissionType)"
checked="@(Types.Contains(submissionType) && allowedToBeChecked)"
@onchange="(e) => {
var isChecked = (bool)(e.Value ?? false);
if(isChecked)
@@ -33,6 +51,7 @@
else
SetTypes(Types.Where(t => t != submissionType));
}"
disabled="@(discussionIsSelected && !isDiscussion)"
>
<label
class="form-check-label"

View File

@@ -26,6 +26,7 @@
planner.StateHasChanged -= reload;
}
private IEnumerable<LocalAssignment> TodaysAssignments {
get
{
@@ -53,8 +54,8 @@
var isClassDay = planner.LocalCourse?.DaysOfWeek.Contains(notNullDay) ?? false;
var dayInSemester =
isClassDay
&& date < planner.LocalCourse?.EndDate
&& date > planner.LocalCourse.StartDate;
&& date <= planner.LocalCourse?.EndDate
&& date >= planner.LocalCourse?.StartDate;
var totalClasses = dayInSemester
? "bg-light-subtle text-light " + baseClasses

View File

@@ -92,6 +92,8 @@ public class CoursePlanner
StateHasChanged?.Invoke();
var (canvasAssignments, canvasModules, canvasModuleItems) = await LoadCanvasData();
LoadingCanvasData = true;
StateHasChanged?.Invoke();
LocalCourse = LocalCourse.deleteCanvasIdsThatNoLongerExist(canvasModules, canvasAssignments);
var canvasId =
@@ -105,7 +107,7 @@ public class CoursePlanner
LocalCourse = await LocalCourse.SyncModulesWithCanvasData(canvasId, CanvasModules, canvas);
await LocalCourse.SyncAssignmentsWithCanvas(canvasId, CanvasAssignments, canvas);
LocalCourse = await LocalCourse.SyncAssignmentsWithCanvas(canvasId, CanvasAssignments, canvas);
CanvasAssignments = await canvas.Assignments.GetAll(canvasId);
await syncModuleItemsWithCanvas(canvasId);

View File

@@ -111,7 +111,7 @@ public static class CoursePlannerSyncronizationExtensions
var canvasHtmlDescription = canvasAssignment.Description;
canvasHtmlDescription = Regex.Replace(canvasHtmlDescription, "<script.*script>", "");
canvasHtmlDescription = Regex.Replace(canvasHtmlDescription, "<link .*\">", "");
canvasHtmlDescription = Regex.Replace(canvasHtmlDescription, "<link\\s+rel=\"[^\"]*\"\\s+href=\"[^\"]*\"[^>]*>", "");
var dueDatesSame = canvasAssignment.DueAt == localAssignment.due_at;
var descriptionSame = canvasHtmlDescription == localHtmlDescription;
@@ -131,11 +131,21 @@ public static class CoursePlannerSyncronizationExtensions
if (!descriptionSame)
{
Console.WriteLine();
Console.WriteLine($"descriptions different for {localAssignment.name}");
Console.WriteLine();
Console.WriteLine("Local Description:");
Console.WriteLine(localHtmlDescription);
Console.WriteLine();
Console.WriteLine("Canvas Description: ");
Console.WriteLine(canvasHtmlDescription);
Console.WriteLine();
Console.WriteLine("Canvas Raw Description: ");
Console.WriteLine(canvasAssignment.Description);
Console.WriteLine();
}
if (!nameSame)

View File

@@ -8,17 +8,33 @@ public static class CoursePlannerExtensions
{
public static LocalCourse GeneralCourseCleanup(this LocalCourse incomingCourse)
{
var modulesWithUniqueAssignments = incomingCourse.Modules.Select(
var cleanModules = incomingCourse.Modules.Select(
module =>
module with
{
Assignments = module.Assignments.OrderBy(a => a.due_at).DistinctBy(a => a.id)
Assignments = module.Assignments
.OrderBy(a => a.due_at)
.DistinctBy(a => a.id)
.Select(a => a.validateSubmissionTypes())
}
);
var cleanStartDay = new DateTime(
incomingCourse.StartDate.Year,
incomingCourse.StartDate.Month,
incomingCourse.StartDate.Day
);
var cleanEndDay = new DateTime(
incomingCourse.EndDate.Year,
incomingCourse.EndDate.Month,
incomingCourse.EndDate.Day
);
return incomingCourse with
{
Modules = modulesWithUniqueAssignments
Modules = cleanModules,
StartDate = cleanStartDay,
EndDate = cleanEndDay,
};
}
@@ -80,4 +96,17 @@ public static class CoursePlannerExtensions
}
return assignment;
}
public static LocalAssignment validateSubmissionTypes(this LocalAssignment assignment)
{
var containsDiscussion =
assignment.submission_types.FirstOrDefault(t => t == SubmissionType.discussion_topic) != null;
if (containsDiscussion)
return assignment with
{
submission_types = new string[] { SubmissionType.discussion_topic }
};
return assignment;
}
}

View File

@@ -40,7 +40,7 @@ public class CanvasAssignmentService
{
name = localAssignment.name,
submission_types = localAssignment.submission_types.Select(t => t.ToString()),
description = localAssignment.description ?? "",
description = htmlDescription,
due_at = localAssignment.due_at,
lock_at = localAssignment.lock_at,
points_possible = localAssignment.points_possible

View File

@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management", "Management\Management.csproj", "{35B6CD41-4B43-42F4-929C-32694D1607EA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management", "Management\Management.csproj", "{FC5771C2-8752-4871-B0CA-A9C9AC5E4CA5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management.Test", "Management.Test\Management.Test.csproj", "{70AD8D71-7696-48A3-ACA6-C8D2081693F1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management.Test", "Management.Test\Management.Test.csproj", "{1C1D51D9-FE2F-47E9-B60F-BAAFBA0808C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management.Web", "Management.Web\Management.Web.csproj", "{1BDBA09F-5CD1-461F-AD2F-2B25CA2CD454}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management.Web", "Management.Web\Management.Web.csproj", "{8828A70D-8DAD-4FD0-870A-6437595BCE8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -18,17 +18,17 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{35B6CD41-4B43-42F4-929C-32694D1607EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35B6CD41-4B43-42F4-929C-32694D1607EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35B6CD41-4B43-42F4-929C-32694D1607EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35B6CD41-4B43-42F4-929C-32694D1607EA}.Release|Any CPU.Build.0 = Release|Any CPU
{70AD8D71-7696-48A3-ACA6-C8D2081693F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70AD8D71-7696-48A3-ACA6-C8D2081693F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70AD8D71-7696-48A3-ACA6-C8D2081693F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70AD8D71-7696-48A3-ACA6-C8D2081693F1}.Release|Any CPU.Build.0 = Release|Any CPU
{1BDBA09F-5CD1-461F-AD2F-2B25CA2CD454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BDBA09F-5CD1-461F-AD2F-2B25CA2CD454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BDBA09F-5CD1-461F-AD2F-2B25CA2CD454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BDBA09F-5CD1-461F-AD2F-2B25CA2CD454}.Release|Any CPU.Build.0 = Release|Any CPU
{FC5771C2-8752-4871-B0CA-A9C9AC5E4CA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC5771C2-8752-4871-B0CA-A9C9AC5E4CA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC5771C2-8752-4871-B0CA-A9C9AC5E4CA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC5771C2-8752-4871-B0CA-A9C9AC5E4CA5}.Release|Any CPU.Build.0 = Release|Any CPU
{1C1D51D9-FE2F-47E9-B60F-BAAFBA0808C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C1D51D9-FE2F-47E9-B60F-BAAFBA0808C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C1D51D9-FE2F-47E9-B60F-BAAFBA0808C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C1D51D9-FE2F-47E9-B60F-BAAFBA0808C0}.Release|Any CPU.Build.0 = Release|Any CPU
{8828A70D-8DAD-4FD0-870A-6437595BCE8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8828A70D-8DAD-4FD0-870A-6437595BCE8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8828A70D-8DAD-4FD0-870A-6437595BCE8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8828A70D-8DAD-4FD0-870A-6437595BCE8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal