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

Storyelement #494

Merged
merged 51 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
32afa52
- move unplaced learning elements to bottom container
andreasweishaupt Dec 20, 2023
a42d999
CenterContainer - optimized width
e01118 Jan 12, 2024
75f091a
Full width for ElementFormContainer
e01118 Jan 15, 2024
f477034
Changed display of 3d representation
e01118 Jan 15, 2024
541deca
implemented fully fluid layout and styled UnplacedElementsDropZone.razor
splican Jan 16, 2024
3fc76c8
Merge remote-tracking branch 'origin/issue-448-dialog-windows-arrange…
splican Jan 16, 2024
27b3de2
fixed initial scrollbar behaviour of LearningSpaceLayoutView.razor i…
splican Jan 16, 2024
ebc7912
Refactor Create and Edit element forms to use Enum for mode instead o…
niklasstich Jan 18, 2024
89d592e
Started work on StoryElement dialog
niklasstich Jan 19, 2024
d87c841
Began Refactoring ElementFormModel to contain ContentFormModel instea…
niklasstich Jan 24, 2024
2c6ea2d
- Fixed serialization
niklasstich Jan 29, 2024
d4bd37a
Added slots for StoryElements to LearningSpaceLayout.cs
niklasstich Jan 30, 2024
9743659
Commands for drag-droppping story element into slot (something is sti…
niklasstich Feb 6, 2024
0bb52b6
- StoryElement now draggable into the layout
niklasstich Feb 7, 2024
d1c279b
Added ISpaceStoryJson.cs and sub classes
MarvinHo64 Feb 8, 2024
7f9e54a
Change type of StoryText from string to List<string>
MarvinHo64 Feb 8, 2024
4543d2c
Updated CreateAtf.cs to consider story elements
MarvinHo64 Feb 8, 2024
9febba4
Update unplaced elements component on undo and redo
niklasstich Feb 8, 2024
eb02a42
Fix LearningSpaceLayout memento
niklasstich Feb 8, 2024
85068fd
Adapt forms and validation to StoryContent text as list of strings
niklasstich Feb 8, 2024
3f7de01
Fix bug where clicking story element doesn't open the story element t…
niklasstich Feb 14, 2024
84f65f2
Fix crash when opening ElementModel collapsable but no content is se…
niklasstich Feb 14, 2024
f3db00d
Fixed problem where it was impossible to set 3D representation in Edi…
niklasstich Feb 15, 2024
f584e24
Remove random from story element 3d representation and set it to defa…
niklasstich Feb 19, 2024
0e567d5
Added "create in slot" functionality for story element
niklasstich Feb 19, 2024
6fd7514
Sort 3d representations in story element by theme
niklasstich Feb 19, 2024
58018e0
Added story elements to LearningWorldTreeView.razor
niklasstich Feb 20, 2024
63d61a7
Replaced story icon in MasterLayout and WorldTreeView
niklasstich Feb 20, 2024
2ec6868
Add story icon to drag drop element
niklasstich Feb 20, 2024
8021b64
Fix compilation errors in tests
niklasstich Feb 21, 2024
83fa01d
Fixed CreateElementForm tests
niklasstich Feb 21, 2024
36cb230
Fixed tests
niklasstich Feb 22, 2024
7784372
Merge branch 'main' into issue-449
niklasstich Feb 23, 2024
123ec93
Fixed merge conflicts
niklasstich Feb 23, 2024
1ef8540
Fix story icon
niklasstich Feb 26, 2024
628826a
Extracted LearningWorldTreeViewItem.razor and re-added story elements…
niklasstich Feb 26, 2024
58b7d2d
Implemented right-click delete story in space
niklasstich Feb 26, 2024
278c685
Fixed story drag and drop replace
niklasstich Feb 26, 2024
10a01d9
Fix a bug where after replace dialog unplaced elements don't update
niklasstich Feb 26, 2024
1503647
Fix incorrect default element model for create adaptivity element
niklasstich Feb 26, 2024
8d59112
Expand Changelog
niklasstich Feb 26, 2024
312f835
Added missing localizer strings
niklasstich Feb 27, 2024
7e94b3b
Fixed broken tests
niklasstich Feb 27, 2024
edc2d96
StoryContent entity test
niklasstich Feb 27, 2024
4afcdce
Layout command tests
niklasstich Feb 27, 2024
6ba89ca
Story element commands tests
niklasstich Feb 27, 2024
1db49cf
Optimized the styling of the story element dialog
e01118 Feb 28, 2024
5b6ca2d
Removed dead code from FormDataContainer
niklasstich Feb 28, 2024
23d88d5
ElementCommandFactory tests
niklasstich Feb 28, 2024
a7368d2
Changed SVG of the storyelement
e01118 Feb 28, 2024
aea2855
PresentationLogic story command tests
niklasstich Feb 28, 2024
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
10 changes: 10 additions & 0 deletions AuthoringTool/Mapping/CachingMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,22 @@ private void MapInternal(LearningWorld learningWorldEntity, ILearningWorldViewMo
.Where(kvP =>
learningWorldVm.LearningSpaces.First(s => s.Id == learningSpaceEntity.Id).ContainedLearningElements
.All(l => kvP.Value.Id != l.Id));
var newStoryElementsInSpaceEntity = learningSpaceEntity.LearningSpaceLayout.StoryElements
.Where(kvP =>
learningWorldVm.LearningSpaces.First(s => s.Id == learningSpaceEntity.Id).LearningSpaceLayout
.StoryElements.All(l => kvP.Value.Id != l.Value.Id));
//for all elements in entity that are not in view model, check cache and insert to view model
foreach (var e in newLearningElementsInSpaceEntity.Where(e => _cache.ContainsKey(e.Value.Id)))
{
learningWorldVm.LearningSpaces.First(s => s.Id == learningSpaceEntity.Id).LearningSpaceLayout
.PutElement(e.Key, Get<LearningElementViewModel>(e.Value.Id));
}

foreach (var e in newStoryElementsInSpaceEntity.Where(e => _cache.ContainsKey(e.Value.Id)))
{
learningWorldVm.LearningSpaces.First(s => s.Id == learningSpaceEntity.Id).LearningSpaceLayout
.PutStoryElement(e.Key, Get<LearningElementViewModel>(e.Value.Id));
}
}

_mapper.Map(learningWorldEntity, learningWorldVm);
Expand Down
11 changes: 11 additions & 0 deletions AuthoringTool/Mapping/EntityPersistEntityMappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
using BusinessLogic.Entities.LearningContent.Adaptivity.Trigger;
using BusinessLogic.Entities.LearningContent.FileContent;
using BusinessLogic.Entities.LearningContent.LinkContent;
using BusinessLogic.Entities.LearningContent.Story;
using PersistEntities;
using PersistEntities.LearningContent;
using PersistEntities.LearningContent.Action;
using PersistEntities.LearningContent.Question;
using PersistEntities.LearningContent.Story;
using PersistEntities.LearningContent.Trigger;

namespace AuthoringTool.Mapping;
Expand Down Expand Up @@ -145,14 +147,23 @@ private void CreateLearningContentMap()
.ReverseMap();
CreateMap<LinkContent, LinkContentPe>()
.ReverseMap();
CreateMap<StoryContent, StoryContentPe>()
.ReverseMap();

CreateMap<FileContent, ILearningContentPe>()
.As<FileContentPe>();
CreateMap<LinkContent, ILearningContentPe>()
.As<LinkContentPe>();
CreateMap<StoryContent, ILearningContentPe>()
.As<StoryContentPe>();

CreateMap<FileContentPe, ILearningContent>()
.As<FileContent>();
CreateMap<LinkContentPe, ILearningContent>()
.As<LinkContent>();
CreateMap<StoryContentPe, ILearningContent>()
.As<StoryContent>();

CreateMap<ILearningContent, ILearningContentPe>()
.IncludeAllDerived()
.ReverseMap()
Expand Down
17 changes: 17 additions & 0 deletions AuthoringTool/Mapping/FormModelEntityMappingProfile.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using AutoMapper;
using BusinessLogic.Entities;
using BusinessLogic.Entities.LearningContent;
using BusinessLogic.Entities.LearningContent.Adaptivity;
using BusinessLogic.Entities.LearningContent.Adaptivity.Question;
using BusinessLogic.Entities.LearningContent.FileContent;
using BusinessLogic.Entities.LearningContent.LinkContent;
using BusinessLogic.Entities.LearningContent.Story;
using Presentation.Components.Adaptivity.Dialogues;
using Presentation.Components.Adaptivity.Forms.Models;
using Presentation.Components.Forms.Models;
Expand Down Expand Up @@ -30,7 +33,21 @@ private FormModelEntityMappingProfile()
private void CreateContentMap()
{
CreateMap<LinkContentFormModel, LinkContent>();
CreateMap<FileContentFormModel, FileContent>();
CreateMap<AdaptivityContentFormModel, AdaptivityContent>();
CreateMap<StoryContentFormModel, StoryContent>();

CreateMap<ILearningContentFormModel, ILearningContent>()
.IncludeAllDerived();

CreateMap<LinkContentFormModel, ILearningContent>()
.As<LinkContent>();
CreateMap<FileContentFormModel, ILearningContent>()
.As<FileContent>();
CreateMap<AdaptivityContentFormModel, ILearningContent>()
.As<AdaptivityContent>();
CreateMap<StoryContentFormModel, ILearningContent>()
.As<StoryContent>();
}

private void CreateElementMap()
Expand Down
67 changes: 66 additions & 1 deletion AuthoringTool/Mapping/ViewModelEntityMappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using BusinessLogic.Entities.LearningContent.Adaptivity.Trigger;
using BusinessLogic.Entities.LearningContent.FileContent;
using BusinessLogic.Entities.LearningContent.LinkContent;
using BusinessLogic.Entities.LearningContent.Story;
using Presentation.PresentationLogic;
using Presentation.PresentationLogic.AuthoringToolWorkspace;
using Presentation.PresentationLogic.LearningContent;
Expand All @@ -18,6 +19,7 @@
using Presentation.PresentationLogic.LearningContent.AdaptivityContent.Trigger;
using Presentation.PresentationLogic.LearningContent.FileContent;
using Presentation.PresentationLogic.LearningContent.LinkContent;
using Presentation.PresentationLogic.LearningContent.Story;
using Presentation.PresentationLogic.LearningElement;
using Presentation.PresentationLogic.LearningPathway;
using Presentation.PresentationLogic.LearningSpace;
Expand Down Expand Up @@ -68,7 +70,9 @@ private void CreateLearningSpaceLayoutMap()
.ForMember(x => x.UsedIndices, opt => opt.Ignore())
.ForMember(x => x.ContainedLearningElements, opt => opt.Ignore())
.ForMember(x => x.LearningElements, opt => opt.Ignore())
.AfterMap(MapSpaceLayoutElements);
.ForMember(x => x.StoryElements, opt => opt.Ignore())
.AfterMap(MapSpaceLayoutElements)
.AfterMap(MapSpaceLayoutStoryElements);
CreateMap<ILearningSpaceLayoutViewModel, LearningSpaceLayout>()
.ForMember(x => x.ContainedLearningElements, opt => opt.Ignore());

Expand Down Expand Up @@ -107,25 +111,65 @@ private static void MapSpaceLayoutElements(ILearningSpaceLayout source, Learning
.Union(destination.LearningElements)
.ToDictionary(tup => tup.Key, tup => tup.Value);
}

private static void MapSpaceLayoutStoryElements(ILearningSpaceLayout source, LearningSpaceLayoutViewModel destination,
ResolutionContext ctx)
{
//gather view models for all elements that are in source but not in destination
var sourceNewElementsViewModels = source.StoryElements
.Where(x => !SameIdAtSameIndexStory(destination, x))
.Select(tup =>
new KeyValuePair<int, ILearningElementViewModel>(tup.Key,
ctx.Mapper.Map<LearningElementViewModel>(tup.Value)));

//remove all elements from destination that are not in source
foreach (var (key, _) in destination.StoryElements.Where(x =>
!source.StoryElements.Any(y => y.Key == x.Key && y.Value.Id == x.Value.Id)))
{
destination.StoryElements.Remove(key);
}

//map all elements that are in source and destination already into the respective destination element
foreach (var (key, value) in destination.StoryElements)
{
var entity = source.StoryElements
.First(x => x.Key == key && x.Value.Id == value.Id);
ctx.Mapper.Map(entity.Value, value);
}

destination.StoryElements = sourceNewElementsViewModels
.Union(destination.StoryElements)
.ToDictionary(tup => tup.Key, tup => tup.Value);
}

private static bool SameIdAtSameIndex(ILearningSpaceLayoutViewModel destination,
KeyValuePair<int, ILearningElement> kvp) =>
destination.LearningElements.Any(y => y.Key == kvp.Key && y.Value.Id == kvp.Value.Id);

private static bool SameIdAtSameIndexStory(ILearningSpaceLayoutViewModel destination,
KeyValuePair<int, ILearningElement> kvp) =>
destination.StoryElements.Any(y => y.Key == kvp.Key && y.Value.Id == kvp.Value.Id);

private void CreateLearningContentMap()
{
CreateMap<FileContent, FileContentViewModel>()
.ReverseMap();
CreateMap<LinkContent, LinkContentViewModel>()
.ReverseMap();
CreateMap<StoryContent, StoryContentViewModel>()
.ReverseMap();
CreateMap<FileContent, ILearningContentViewModel>()
.As<FileContentViewModel>();
CreateMap<LinkContent, ILearningContentViewModel>()
.As<LinkContentViewModel>();
CreateMap<StoryContent, ILearningContentViewModel>()
.As<StoryContentViewModel>();
CreateMap<FileContentViewModel, ILearningContent>()
.As<FileContent>();
CreateMap<LinkContentViewModel, ILearningContent>()
.As<LinkContent>();
CreateMap<StoryContentViewModel, ILearningContent>()
.As<StoryContent>();
CreateMap<ILearningContent, ILearningContentViewModel>()
.IncludeAllDerived()
.ReverseMap()
Expand Down Expand Up @@ -246,10 +290,16 @@ private void CreateLearningSpaceMap()
.EqualityComparison((x, y) => x.Id == y.Id)
.AfterMap((_, d) =>
{
//set mapped parent object for learning element
foreach (var element in d.ContainedLearningElements)
{
element.Parent = d;
}
//analogous for story
foreach (var (_, se) in d.LearningSpaceLayout.StoryElements)
{
se.Parent = d;
}
})
.ReverseMap()
.EqualityComparison((x, y) => x.Id == y.Id)
Expand All @@ -262,6 +312,11 @@ private void CreateLearningSpaceMap()
{
element.Parent = d;
}

foreach (var (_, se) in d.LearningSpaceLayout.StoryElements)
{
se.Parent = d;
}
});
CreateMap<ILearningSpaceViewModel, LearningSpace>()
.IncludeBase<IObjectInPathWayViewModel, IObjectInPathWay>()
Expand All @@ -276,6 +331,11 @@ private void CreateLearningSpaceMap()
{
element.Parent = d;
}

foreach (var (_, se) in d.LearningSpaceLayout.StoryElements)
{
se.Parent = d;
}
});
CreateMap<ILearningSpace, LearningSpaceViewModel>()
.ForMember(x => x.InBoundObjects, opt => opt.Ignore())
Expand All @@ -291,6 +351,11 @@ private void CreateLearningSpaceMap()
{
element.Parent = d;
}

foreach (var (_, se) in d.LearningSpaceLayout.StoryElements)
{
se.Parent = d;
}
});
}

Expand Down
42 changes: 41 additions & 1 deletion AuthoringTool/Mapping/ViewModelFormModelMappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using Presentation.Components.Adaptivity.Dialogues;
using Presentation.Components.Adaptivity.Forms.Models;
using Presentation.Components.Forms.Models;
using Presentation.PresentationLogic.LearningContent;
using Presentation.PresentationLogic.LearningContent.AdaptivityContent;
using Presentation.PresentationLogic.LearningContent.AdaptivityContent.Question;
using Presentation.PresentationLogic.LearningContent.FileContent;
using Presentation.PresentationLogic.LearningContent.LinkContent;
using Presentation.PresentationLogic.LearningContent.Story;
using Presentation.PresentationLogic.LearningElement;
using Presentation.PresentationLogic.LearningSpace;
using Presentation.PresentationLogic.LearningWorld;
Expand Down Expand Up @@ -33,13 +36,50 @@ private void CreateContentMap()
{
CreateMap<LinkContentViewModel, LinkContentFormModel>()
.ReverseMap();
CreateMap<AdaptivityContentViewModel, AdaptivityContentFormModel>();
CreateMap<AdaptivityContentViewModel, AdaptivityContentFormModel>()
.ReverseMap();
CreateMap<FileContentViewModel, FileContentFormModel>()
.ReverseMap();
CreateMap<StoryContentViewModel, StoryContentFormModel>()
.ReverseMap();

CreateMap<ILearningContentViewModel, ILearningContentFormModel>()
.IncludeAllDerived()
.ReverseMap()
.IncludeAllDerived();

CreateMap<LinkContentViewModel, ILearningContentFormModel>()
.As<LinkContentFormModel>();
CreateMap<FileContentViewModel, ILearningContentFormModel>()
.As<FileContentFormModel>();
CreateMap<AdaptivityContentViewModel, ILearningContentFormModel>()
.As<AdaptivityContentFormModel>();
CreateMap<StoryContentViewModel, ILearningContentFormModel>()
.As<StoryContentFormModel>();

CreateMap<LinkContentFormModel, ILearningContentViewModel>()
.As<LinkContentViewModel>();
CreateMap<FileContentFormModel, ILearningContentViewModel>()
.As<FileContentViewModel>();
CreateMap<AdaptivityContentFormModel, ILearningContentViewModel>()
.As<AdaptivityContentViewModel>();
CreateMap<StoryContentFormModel, ILearningContentViewModel>()
.As<StoryContentViewModel>();
}

private void CreateElementMap()
{
CreateMap<LearningElementViewModel, LearningElementFormModel>()
.ForMember(x => x.LearningContent, opt => opt.Ignore())
.AfterMap(MapContent)
.ReverseMap();
return;

void MapContent(LearningElementViewModel source, LearningElementFormModel dest, ResolutionContext ctx)
{
dest.LearningContent =
ctx.Mapper.Map<ILearningContentFormModel>(source.LearningContent);
}
}

private void CreateSpaceMap()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions AuthoringToolTest/AuthoringToolTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AgileObjects.ReadableExpressions" Version="4.1.1" />
<PackageReference Include="AutoMapper" Version="11.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="bunit" Version="1.23.9" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public void MapLearningSpaceAndLearningSpacePersistEntity_WithLearningElement_Te
{
var systemUnderTest = CreateTestableMapper();
var source = new LearningSpace(Name, Description, Goals, RequiredPoints, Theme.Campus,
new LearningSpaceLayout(new Dictionary<int, ILearningElement>(), FloorPlanEnum.R_20X30_8L),
new LearningSpaceLayout(new Dictionary<int, ILearningElement>(), new Dictionary<int, ILearningElement>(),
FloorPlanEnum.R_20X30_8L),
positionX: PositionX, positionY: PositionY, inBoundSpaces: new List<IObjectInPathWay>(),
outBoundSpaces: new List<IObjectInPathWay>());
source.LearningSpaceLayout.LearningElements[0] = GetTestableElementWithParent(source);
Expand Down Expand Up @@ -520,7 +521,8 @@ private static LearningElementPe GetTestableElementPersistEntity()
private static LearningSpace GetTestableSpace()
{
var space = new LearningSpace(Name, Description, Goals, RequiredPoints, Theme.Campus,
new LearningSpaceLayout(new Dictionary<int, ILearningElement>(), FloorPlanEnum.R_20X30_8L),
new LearningSpaceLayout(new Dictionary<int, ILearningElement>(), new Dictionary<int, ILearningElement>(),
FloorPlanEnum.R_20X30_8L),
positionX: PositionX, positionY: PositionY);
var element = GetTestableElementWithParent(space);
space.LearningSpaceLayout.LearningElements[0] = element;
Expand All @@ -538,6 +540,7 @@ private static LearningSpacePe GetTestableNewSpacePersistEntity()
GetTestableElementPersistEntity()
}
},
new Dictionary<int, ILearningElementPe>(),
FloorPlanEnum.R_20X30_8L), positionX: NewPositionX, positionY: NewPositionY);
}

Expand Down
30 changes: 30 additions & 0 deletions AuthoringToolTest/Mapping/FormModelEntityMappingProfileUt.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using AgileObjects.ReadableExpressions;
using AuthoringTool.Mapping;
using AutoMapper;
using BusinessLogic.Entities;
using BusinessLogic.Entities.LearningContent.Adaptivity.Question;
using NUnit.Framework;
using Presentation.Components.Forms.Models;
using Presentation.PresentationLogic.LearningContent.AdaptivityContent.Question;
using Presentation.PresentationLogic.LearningElement;
using TestHelpers;

namespace AuthoringToolTest.Mapping;
Expand All @@ -13,6 +17,32 @@ public class FormModelEntityMappingProfileUt
private const string QuestionText = "questionText";
private const int ExpectedCompletionTime = 10;

// [Test]
// public void Constructor_TestConfigurationisValid()
// {
// var mapper = new MapperConfiguration(cfg =>
// {
// FormModelEntityMappingProfile.Configure(cfg);
// cfg.AddCollectionMappersOnce();
// });
//
// Assert.That(() => mapper.AssertConfigurationIsValid(), Throws.Nothing);
// }

[Test]
public void Debug()
{
var mapper = new MapperConfiguration(cfg =>
{
FormModelEntityMappingProfile.Configure(cfg);
ViewModelFormModelMappingProfile.Configure(cfg);
cfg.AddCollectionMappersOnce();
});

var executionPlan = mapper.BuildExecutionPlan(typeof(LearningElementFormModel), typeof(LearningElement));
var plan = executionPlan.ToReadableString();
}

[Test]
public void MultipleChoiceQuestion_SingleResponse_TestMappingIsValid()
{
Expand Down
Loading
Loading