Quelques tests visant à intégrer la syntaxe des fichiers de contenu Json de H5P

pull/1/head
Jean-Christophe Jameux 3 years ago
parent 2c73fb0eb4
commit 04dc7226e9
  1. 5
      elm.json
  2. 146
      src/GenerateurH5P.elm

@ -6,12 +6,14 @@
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"alexkorban/json-to-elm": "1.1.0",
"avh4/elm-color": "1.0.0",
"dmy/elm-pratt-parser": "2.0.0",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/file": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/random": "1.0.0",
"elm/svg": "1.0.1",
@ -29,7 +31,6 @@
"andre-dietrich/parser-combinators": "3.2.0",
"elm/bytes": "1.0.8",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.2",
@ -37,8 +38,10 @@
"elm-community/list-extra": "8.5.1",
"elm-community/maybe-extra": "5.2.1",
"elm-community/result-extra": "2.4.0",
"elm-community/string-extra": "4.0.1",
"erlandsona/assoc-set": "1.1.0",
"fredcy/elm-parseint": "2.0.1",
"hrldcpr/elm-cons": "3.1.0",
"miniBill/elm-unicode": "1.0.2",
"pablohirafuji/elm-syntax-highlight": "3.4.1",
"pilatch/flip": "1.0.0",

@ -7,9 +7,12 @@ import Element.Border as Border
import Element.Events exposing (..)
import Element.Font as Font
import Element.Input as Input
import ElmCodeGenerator
import File.Download
import Fraction as F exposing (Fraction)
import Html exposing (Attribute, Html, button, div, iframe, input, p, section, textarea)
import Json.Decode
import Json.Encode
import List as L
import Parser as P exposing (..)
import ParserExpressionMathematique as Pem
@ -181,14 +184,141 @@ view model =
{-
'########:::::'###::::'########:::'######::'########:'########::
##.... ##:::'## ##::: ##.... ##:'##... ##: ##.....:: ##.... ##:
##:::: ##::'##:. ##:: ##:::: ##: ##:::..:: ##::::::: ##:::: ##:
########::'##:::. ##: ########::. ######:: ######::: ########::
##.....::: #########: ##.. ##::::..... ##: ##...:::: ##.. ##:::
##:::::::: ##.... ##: ##::. ##::'##::: ##: ##::::::: ##::. ##::
##:::::::: ##:::: ##: ##:::. ##:. ######:: ########: ##:::. ##:
..:::::::::..:::::..::..:::::..:::......:::........::..:::::..::
-}
type H5P branchingScenarioComposable
= BranchingScenario
{ endScreens :
List
{ endScreenTitle : String
, endScreenSubtitle : String
, contentId : Int
, endScreenScore : Int
}
, scoringOptionGroup :
{ scoringOption : ScoringOption
, includeInteractionsScores : Bool
}
, startScreen :
{ startScreenTitle : String
, startScreenSubtitle : String
}
, behaviour :
{ enableBackwardsNavigation : Bool
, forceContentFinished : Bool
}
, l10n :
{ startScreenButtonText : String
, endScreenButtonText : String
, backButtonText : String
, proceedButtonText : String
, disableProceedButtonText : String
, replayButtonText : String
, scoreText : String
, fullscreenAria : String
}
, content : List (H5P BranchingScenarioComposable)
}
nouveauBranchingScenario =
BranchingScenario
{ endScreens =
[ { endScreenTitle = "Fin du parcours personnalisé"
, endScreenSubtitle = "Fin du parcours personnalisé"
, contentId = -1
, endScreenScore = 0
}
]
, scoringOptionGroup =
{ scoringOption = NoScore
, includeInteractionsScores = True
}
, startScreen =
{ startScreenTitle = "<p>Préliminaires</p>\n"
, startScreenSubtitle = "<p>Le langage et les règles du jeux mathématiques</p>\n"
}
, behaviour =
{ enableBackwardsNavigation = True
, forceContentFinished = False
}
, l10n =
{ startScreenButtonText = "Commencer le cours"
, endScreenButtonText = "Recommencer le cours"
, backButtonText = "Revenir en arrière"
, proceedButtonText = "Continuer"
, disableProceedButtonText = "Jouer la vidéo de nouveau"
, replayButtonText = "Votre note:"
, scoreText = "Votre note:"
, fullscreenAria = "Plein écran"
}
, content = []
}
test =
ElmCodeGenerator.fromJsonSample
{ rootTypeName = "Test"
, decodeImport = { importAlias = "Json.Decode", exposingSpec = ElmCodeGenerator.ExposingNone }
, encodeImport = { importAlias = "Json.Encode", exposingSpec = ElmCodeGenerator.ExposingNone }
, decoderStyle = ElmCodeGenerator.PlainDecoders
, namingStyle = ElmCodeGenerator.NounNaming
}
"""{"a": 1, "b": "str"}"""
testOutput =
{ decoders = [ """testDecoder : Json.Decode.Decoder Test
testDecoder =
Json.Decode.map2 Test
(Json.Decode.field "a" Json.Decode.int)
(Json.Decode.field "b" Json.Decode.string)
""" ]
, encoders =
[ """
encodedTest : Test -> Json.Encode.Value
encodedTest test =
Json.Encode.object
[ ( "a", Json.Encode.int test.a )
, ( "b", Json.Encode.string test.b )
]
"""
]
, imports = [ "import Json.Decode", "import Json.Encode", "\n", "-- Required packages:", "-- * elm/json" ]
, types =
[ """
type alias Test =
{ a : Int
, b : String
}
"""
]
}
type ScoringOption
= NoScore
type BranchingScenarioComposable
= BranchingScenarioComposable
{-
-}

Loading…
Cancel
Save