Skip to content

Commit

Permalink
lots of lessons for path; show full data in results
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed Jun 17, 2024
1 parent 24201c1 commit 0da51e1
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 23 deletions.
4 changes: 2 additions & 2 deletions LearnJsonEverything.LessonEditor/Controls/Editor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Grid Grid.Column="1" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="3*"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
Expand All @@ -78,7 +78,7 @@
CodeContent="{Binding SelectedLesson.InitialCode, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<local:CodeInput Grid.Row="1" Label="Solution" Margin="0,5,5,5"
CodeContent="{Binding SelectedLesson.Solution, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<local:CodeInput Grid.Row="2" Label="Solution" Margin="0,5,5,0"
<local:CodeInput Grid.Row="2" Label="Output" Margin="0,5,5,0" IsEnabled="False"
CodeContent="{Binding ValidationOutput, ElementName=Self}"/>
<Button Grid.Row="1" Content="Copy from above" Click="CopyInitialToSolution"
HorizontalAlignment="Right" VerticalAlignment="Top"
Expand Down
6 changes: 2 additions & 4 deletions LearnJsonEverything.LessonEditor/Controls/Editor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using System.Text.Json.Nodes;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Json.More;
using LearnJsonEverything.Services;
using LearnJsonEverything.Services.Runners;
using LearnJsonEverything.Services.Hosts;

namespace LearnJsonEverything.LessonEditor.Controls;

Expand Down Expand Up @@ -92,7 +90,7 @@ public string ValidationOutput
}

public static readonly DependencyProperty ValidationOutputProperty =
DependencyProperty.Register(nameof(ValidationOutput), typeof(string), typeof(Editor), new PropertyMetadata(null, LoadFile));
DependencyProperty.Register(nameof(ValidationOutput), typeof(string), typeof(Editor), new PropertyMetadata(null));

private void ValidateSolution(object sender, RoutedEventArgs e)
{
Expand Down
6 changes: 3 additions & 3 deletions LearnJsonEverything.LessonEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:LearnJsonEverything.LessonEditor.Controls"
xmlns:runners="clr-namespace:LearnJsonEverything.Services.Runners;assembly=LearnJsonEverything"
xmlns:hosts="clr-namespace:LearnJsonEverything.Services.Hosts;assembly=LearnJsonEverything"
mc:Ignorable="d"
Title="MainWindow" Height="800" Width="1200"
SnapsToDevicePixels="True"
UseLayoutRounding="True"
TextElement.FontSize="14"
x:Name="Self">
<Window.Resources>
<runners:SchemaHost x:Key="SchemaHost"/>
<runners:PathHost x:Key="PathHost"/>
<hosts:SchemaHost x:Key="SchemaHost"/>
<hosts:PathHost x:Key="PathHost"/>
</Window.Resources>
<TabControl>
<TabItem Header="Schema">
Expand Down
1 change: 0 additions & 1 deletion LearnJsonEverything.LessonEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
using LearnJsonEverything.Services;
using LearnJsonEverything.Services.Runners;

namespace LearnJsonEverything.LessonEditor;

Expand Down
2 changes: 1 addition & 1 deletion LearnJsonEverything.Tests/ProvidedSolutionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using LearnJsonEverything.Services;
using LearnJsonEverything.Services.Runners;
using LearnJsonEverything.Services.Hosts;

namespace LearnJsonEverything.Tests;

Expand Down
2 changes: 1 addition & 1 deletion LearnJsonEverything/Pages/Path.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/json-path"
@using LearnJsonEverything.Services.Runners
@using LearnJsonEverything.Services.Hosts

<Teacher LessonSource="/data/lessons/path.json" Host="@_host"></Teacher>

Expand Down
2 changes: 1 addition & 1 deletion LearnJsonEverything/Pages/Schema.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/json-schema"
@using LearnJsonEverything.Services.Runners
@using LearnJsonEverything.Services.Hosts

<Teacher LessonSource="/data/lessons/schema.json" Host="@_host"></Teacher>

Expand Down
6 changes: 5 additions & 1 deletion LearnJsonEverything/Services/HelpContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use the `json-everything` libraries to their full potential!
provided by one of the libraries. For each lesson, you'll be given some background information,
possibly some links to various documentation, and a coding challenge along with some test
cases. Make all the tests pass to move on to the next lesson.
The site will let you build whatever solution you want, and many of the lessons can be
solved in different ways. If you get stuck, there is a recommended solution that you can
view at any time.
Want to skip ahead and work on a particular lesson? No problem: simply select the lesson
you'd like to work on from the pane on the left. The navigation buttons will activate as
Expand All @@ -23,7 +27,7 @@ either to continue learning or to review the work you've done.
You can click <kbd>Reveal Solution</kbd> at any time to see the recommended solution, or
<kbd>Reset</kbd> to get the template back and clear the lesson state.
---
**This site is 100% client-side. All operations are performed in your browser.**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace LearnJsonEverything.Services.Runners;
namespace LearnJsonEverything.Services.Hosts;

public interface ILessonHost
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Json.More;
using Json.Path;

namespace LearnJsonEverything.Services.Runners;
namespace LearnJsonEverything.Services.Hosts;

public class PathHost : ILessonHost
{
Expand All @@ -20,7 +20,7 @@ public string[] Run(LessonData lesson)
var result = runner.Run(test.AsObject());
var localResult = expectedResult.IsEquivalentTo(result?.Matches?.Select(x => x.Value).ToJsonArray());
correct &= localResult;
results.Add($"{(localResult ? Iconography.SuccessIcon : Iconography.ErrorIcon)} {test["data"]!.Print()}");
results.Add($"{(localResult ? Iconography.SuccessIcon : Iconography.ErrorIcon)} {test.Print()}");
}

lesson.Achieved |= correct;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json;
using Json.Schema;

namespace LearnJsonEverything.Services.Runners;
namespace LearnJsonEverything.Services.Hosts;

public class SchemaHost : ILessonHost
{
Expand All @@ -21,7 +21,7 @@ public string[] Run(LessonData lesson)
var result = runner.Run(test.AsObject());
Console.WriteLine($"Result: {JsonSerializer.Serialize(result, SerializerContext.Default.EvaluationResults)}");
correct &= expectedValidity == result.IsValid;
results.Add($"{(expectedValidity == result.IsValid ? Iconography.SuccessIcon : Iconography.ErrorIcon)} {test["instance"].Print()}");
results.Add($"{(expectedValidity == result.IsValid ? Iconography.SuccessIcon : Iconography.ErrorIcon)} {test.Print()}");
}

lesson.Achieved |= correct;
Expand Down
3 changes: 0 additions & 3 deletions LearnJsonEverything/Shared/Header.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
json-everything
</a>
</div>
<div class="align-items-center">
<span style="color: amber;">⚠</span> This site is still under construction.
</div>
<div class="px-1">
<a class="navbar-brand m-2" href="https://blog.json-everything.net">
blog
Expand Down
2 changes: 1 addition & 1 deletion LearnJsonEverything/Shared/Teacher.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@using System.Text.Encodings.Web
@using System.Text.Json
@using Json.More
@using LearnJsonEverything.Services.Runners
@using LearnJsonEverything.Services.Hosts
@using EditorOptions = LearnJsonEverything.Services.EditorOptions

@inject DataManager DataManager;
Expand Down
Loading

0 comments on commit 0da51e1

Please sign in to comment.