From 4533c8fe62c37595bb1589b1a8e0e6a1e2bc70b4 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Mon, 8 Jul 2024 00:03:05 -0700 Subject: [PATCH] Add syllabus enumeration --- src/swarm-scenario/Swarm/Game/Scenario.hs | 7 +++++ .../Swarm/Game/Scenario/Coach.hs | 29 +++++++++++++++++++ swarm.cabal | 1 + 3 files changed, 37 insertions(+) create mode 100644 src/swarm-scenario/Swarm/Game/Scenario/Coach.hs diff --git a/src/swarm-scenario/Swarm/Game/Scenario.hs b/src/swarm-scenario/Swarm/Game/Scenario.hs index 808026502f..861c6370a5 100644 --- a/src/swarm-scenario/Swarm/Game/Scenario.hs +++ b/src/swarm-scenario/Swarm/Game/Scenario.hs @@ -35,6 +35,7 @@ module Swarm.Game.Scenario ( scenarioVersion, scenarioName, scenarioAuthor, + scenarioPedagogy, scenarioDescription, scenarioCreative, scenarioSeed, @@ -90,6 +91,7 @@ import Swarm.Game.Location import Swarm.Game.Recipe import Swarm.Game.ResourceLoading (getDataFileNameSafe) import Swarm.Game.Robot (TRobot, trobotLocation, trobotName) +import Swarm.Game.Scenario.Coach import Swarm.Game.Scenario.Objective import Swarm.Game.Scenario.Objective.Validation import Swarm.Game.Scenario.RobotLookup @@ -142,6 +144,7 @@ data ScenarioMetadata = ScenarioMetadata { _scenarioVersion :: Int , _scenarioName :: Text , _scenarioAuthor :: Maybe Text + , _scenarioPedagogy :: Maybe Pedagogy } deriving (Show, Generic) @@ -166,6 +169,9 @@ scenarioName :: Lens' ScenarioMetadata Text -- | The author of the scenario. scenarioAuthor :: Lens' ScenarioMetadata (Maybe Text) +-- | Pedagogical information about the scenario. +scenarioPedagogy :: Lens' ScenarioMetadata (Maybe Pedagogy) + -- | Non-structural gameplay content of the scenario; -- how it is to be played. data ScenarioOperation = ScenarioOperation @@ -404,6 +410,7 @@ instance FromJSONE ScenarioInputs Scenario where <$> liftE (v .: "version") <*> liftE (v .: "name") <*> liftE (v .:? "author") + <*> liftE (v .:? "pedagogy") playInfo <- ScenarioOperation diff --git a/src/swarm-scenario/Swarm/Game/Scenario/Coach.hs b/src/swarm-scenario/Swarm/Game/Scenario/Coach.hs new file mode 100644 index 0000000000..367bb2d069 --- /dev/null +++ b/src/swarm-scenario/Swarm/Game/Scenario/Coach.hs @@ -0,0 +1,29 @@ +-- | +-- SPDX-License-Identifier: BSD-3-Clause +module Swarm.Game.Scenario.Coach where + +import Data.Aeson +import Data.Set (Set) +import GHC.Generics (Generic) + +data TutorialConcept + = Sensing + | ErrorHandling + | Recursion + | CodeReuse + | Movement + | EntityManagement + | BuildingRobots + deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON) + +-- | +-- Intended primarily for Tutorials, though other challenge scenarios +-- may also supply these annotations. +-- This record might eventually contain other metadata like +-- "difficulty" or "par time". + +{- HLINT ignore "Use newtype instead of data" -} +data Pedagogy = Pedagogy + { concepts :: Set TutorialConcept + } + deriving (Show, Generic, FromJSON, ToJSON) diff --git a/swarm.cabal b/swarm.cabal index 2961803985..32d630ba33 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -275,6 +275,7 @@ library swarm-scenario Swarm.Game.Robot Swarm.Game.Robot.Walk Swarm.Game.Scenario + Swarm.Game.Scenario.Coach Swarm.Game.Scenario.Objective Swarm.Game.Scenario.Objective.Graph Swarm.Game.Scenario.Objective.Logic