Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 538 #586

Merged
merged 10 commits into from
Aug 1, 2024
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Changed
- Improved the filter search field in unplaced learning elements to be case-insensitive.
- Changed the order of learning elements in 13- and 15-slot floor plan

### Deprecated

Expand All @@ -19,6 +20,7 @@
- Fixed a bug where the program crashed after deleting two learning elements in a row using the right click menu.
- Fixed a bug where the list of unplaced elements was not updated after changing the floor plan.
- Fixed a bug where a story slot was not made active after undoing the creation of a story element.
- Fixed the order of learning elements in learning world tree view
- Fixed a bug in adaptivity element question preview, where long comments exceeded the viewport.

### Security
Expand Down
17 changes: 6 additions & 11 deletions Generator/ATF/ReadAtf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void ReadLearningWorld(string atfPath, DocumentRootJson? rootJsonForTest
else
{
var jsonString = _fileSystem.File.ReadAllText(atfPath);
var options = new JsonSerializerOptions {WriteIndented = true, PropertyNameCaseInsensitive = true};
var options = new JsonSerializerOptions { WriteIndented = true, PropertyNameCaseInsensitive = true };
_rootJson = JsonSerializer.Deserialize<DocumentRootJson>(jsonString, options) ??
throw new InvalidOperationException("Could not deserialize ATF_Document");
}
Expand Down Expand Up @@ -150,7 +150,7 @@ private void GetH5PElements(IDocumentRootJson documentRootJson)
{
if (element.ElementFileType is "h5p" or "primitiveH5P")
{
_listH5PElements.Add((ILearningElementJson) element);
_listH5PElements.Add((ILearningElementJson)element);
}
}

Expand All @@ -168,7 +168,7 @@ private void GetResourceElements(IDocumentRootJson documentRootJson)
or "c"
or "h" or "cpp" or "cc" or "c++" or "py" or "cs" or "js" or "php" or "html" or "css")
{
_listResourceElements.Add((ILearningElementJson) resource);
_listResourceElements.Add((ILearningElementJson)resource);
}
}

Expand Down Expand Up @@ -204,11 +204,6 @@ private void GetWorldAttributes(IDocumentRootJson documentRootJson)
private void GetSpaces(IDocumentRootJson rootJson)
{
_listSpaces = rootJson.World.Spaces;
foreach (var space in _listSpaces)
{
space.SpaceSlotContents = FloorPlanElementSorter.GetListInOrder(space.SpaceSlotContents,
Enum.Parse<FloorPlanEnum>(space.SpaceTemplate));
}
}

/// <summary>
Expand All @@ -220,7 +215,7 @@ private void GetUrlElements(IDocumentRootJson documentRootJson)
{
if (url.ElementFileType is "url")
{
_listUrlElements.Add((ILearningElementJson) url);
_listUrlElements.Add((ILearningElementJson)url);
}
}

Expand All @@ -235,7 +230,7 @@ private void GetAdaptivityElements(IDocumentRootJson documentRootJson)
foreach (var element in documentRootJson.World.Elements.Where(
element => element.ElementFileType is "adaptivity"))
{
_listAdaptivityElements.Add((IAdaptivityElementJson) element);
_listAdaptivityElements.Add((IAdaptivityElementJson)element);
}
}

Expand All @@ -251,7 +246,7 @@ private void GetElementsOrdered(IDocumentRootJson? documentRootJson)
foreach (var elementInSpace in space.SpaceSlotContents)
{
if (elementInSpace != null)
_listAllElementsOrdered.Add(documentRootJson.World.Elements[(int) elementInSpace - 1]);
_listAllElementsOrdered.Add(documentRootJson.World.Elements[(int)elementInSpace - 1]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion GeneratorTest/ATF/ReadAtfUt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void ReadATF_ReadLearningWorld_ATFDocumentRead()

Assert.That(listSpace.Count, Is.EqualTo(2));
Assert.That(listSpace[0].SpaceSlotContents,
Is.EqualTo(new List<int?> { 1, 2, null, 3, null, 4 })); // R_20X20_6L sort order is 0, 1, 2, 3, 5, 4
Is.EqualTo(new List<int?> { 1, 2, null, 3, 4, null }));
Assert.That(listSpace[1].SpaceSlotContents, Is.EqualTo(new List<int?> { 5, null, null, null, null, null }));

Assert.That(getUrlList, Has.Count.EqualTo(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class D40X3715LViewModel : IFloorPlanViewModel

public IList<Point> ElementSlotPositions { get; } = new List<Point>
{
new() { X = 4, Y = 33 },
new() { X = 4, Y = 29 },
new() { X = 4, Y = 22 },
new() { X = 4, Y = 17 },
new() { X = 4, Y = 10 },
new() { X = 4, Y = 5 },
new() { X = 10, Y = 5 },
new() { X = 16, Y = 5 },
Expand All @@ -44,12 +49,7 @@ public class D40X3715LViewModel : IFloorPlanViewModel
new() { X = 31, Y = 24 },
new() { X = 27, Y = 30 },
new() { X = 20, Y = 33 },
new() { X = 15, Y = 33 },
new() { X = 4, Y = 33 },
new() { X = 4, Y = 29 },
new() { X = 4, Y = 22 },
new() { X = 4, Y = 17 },
new() { X = 4, Y = 10 }
new() { X = 15, Y = 33 }
};

public IList<Point> StoryElementSlotPositions { get; } = new List<Point>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ public class T40X3213LViewModel : IFloorPlanViewModel
new() { X = 5, Y = 5 },
new() { X = 11, Y = 5 },
new() { X = 17, Y = 5 },
new() { X = 5, Y = 16 },
new() { X = 11, Y = 16 },
new() { X = 30, Y = 12 },
new() { X = 17, Y = 19 },
new() { X = 30, Y = 26 },
new() { X = 17, Y = 33 },
new() { X = 11, Y = 33 },
new() { X = 5, Y = 33 },
new() { X = 5, Y = 22 },
new() { X = 11, Y = 22 }
new() { X = 11, Y = 22 },
new() { X = 17, Y = 19 },
new() { X = 11, Y = 16 },
new() { X = 5, Y = 16 }
};

public IList<Point> StoryElementSlotPositions { get; } = new List<Point>
Expand Down
15 changes: 8 additions & 7 deletions Presentation/View/LearningWorld/LearningWorldTreeView.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@using Presentation.PresentationLogic.LearningWorld
@using Presentation.PresentationLogic.Mediator
@using Presentation.PresentationLogic.SelectedViewModels
@using System.ComponentModel
@using System.Diagnostics.CodeAnalysis
@using Microsoft.Extensions.Localization
@using MudBlazor.Utilities
@using Presentation.Components
@using Presentation.Components.Forms
@using Presentation.PresentationLogic
@using Presentation.PresentationLogic.LearningElement
@using Presentation.PresentationLogic.LearningSpace
@using System.ComponentModel
@using System.Diagnostics.CodeAnalysis
@using MudBlazor.Utilities
@using Presentation.PresentationLogic.LearningWorld
@using Presentation.PresentationLogic.Mediator
@using Presentation.PresentationLogic.SelectedViewModels
@using Shared.Command
@using Shared.Extensions
@implements IDisposable
Expand Down Expand Up @@ -54,8 +54,9 @@
IsSelected="@IsLearningElementSelected(entranceElement)"
OnSelect="@(ele => OnLearningElementClicked(ele))"/>
}
@foreach (var learningElement in learningSpace.ContainedLearningElements)
@foreach (var key in learningSpace.LearningSpaceLayout.LearningElements.Keys.OrderBy(key => key))
{
var learningElement = learningSpace.LearningSpaceLayout.LearningElements[key];
<LearningWorldTreeViewItem @key="learningElement" LearningElement="@learningElement"
IsSelected="@IsLearningElementSelected(learningElement)"
OnSelect="@(ele => OnLearningElementClicked(ele))"/>
Expand Down
13 changes: 5 additions & 8 deletions Presentation/View/LearningWorld/LearningWorldTreeViewItem.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@using Presentation.PresentationLogic.LearningElement
@using System.Diagnostics.CodeAnalysis
@using MudBlazor.Utilities
@using Presentation.Components
@using Presentation.PresentationLogic.LearningContent.AdaptivityContent
@using Presentation.PresentationLogic.LearningContent.FileContent
@using Presentation.PresentationLogic.LearningContent.LinkContent
@using System.Diagnostics.CodeAnalysis
@using Presentation.PresentationLogic.LearningContent.Story
@using Presentation.PresentationLogic.LearningElement
<div @onclick="@(e => OnSelect.InvokeAsync(LearningElement))"
class="@GetElementDivCss()">
<div class="flex flex-row gap-2 items-center p-2 ml-14">
Expand All @@ -15,12 +15,9 @@
</div>

@code {
[Parameter, EditorRequired, AllowNull]
public ILearningElementViewModel LearningElement { get; set; }
[Parameter, EditorRequired]
public EventCallback<ILearningElementViewModel> OnSelect { get; set; }
[Parameter, EditorRequired]
public bool IsSelected { get; set; }
[Parameter, EditorRequired, AllowNull] public ILearningElementViewModel LearningElement { get; set; }
[Parameter, EditorRequired] public EventCallback<ILearningElementViewModel> OnSelect { get; set; }
[Parameter, EditorRequired] public bool IsSelected { get; set; }

private string GetElementDivCss()
{
Expand Down
50 changes: 0 additions & 50 deletions Shared/FloorPlanElementSorter.cs

This file was deleted.

81 changes: 0 additions & 81 deletions SharedTest/FloorPlanElementSorterUt.cs

This file was deleted.

Loading