-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing files from editor branch
- Loading branch information
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "curriculum-basis"] | ||
path = curriculum-basis | ||
url = https://github.com/slonl/curriculum-basis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# curriculum-fo | ||
SLO Wettelijk Curriculum FO (Kerndoelen en Examenprogramma's Funderend onderwijs) |
Submodule curriculum-basis
added at
ce330e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "curriculum-fo", | ||
"description": "Curriculum Context: SLO Wettelijk Curriculum FO (Kerndoelen en Examenprogramma's Funderend onderwijs)", | ||
"main": "context.json", | ||
"scripts": { | ||
"test": "node test/test.mjs", | ||
"repl": "NODE_REPL_HISTORY=.repl_history && node test/repl.mjs" | ||
}, | ||
"author": "SLO", | ||
"license": "MIT", | ||
"dependencies": { | ||
"ajv": "^6.5.5", | ||
"curriculum-js": "^0.3.7", | ||
"jsondiffpatch": "^0.3.11", | ||
"uuid": "^3.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"@context": { | ||
"fo": "http://opendata.slo.nl/curriculum/schemas/fo.jsonld", | ||
"id": { | ||
"@id": "@id" | ||
}, | ||
"title": { | ||
"@id": "http://purl.org/dc/terms/title", | ||
"@type": "@id" | ||
}, | ||
"description": { | ||
"@id": "http://purl.org/dc/terms/description", | ||
"@type": "@id" | ||
}, | ||
"fo_domein": { | ||
"@id": "fo:#fo_domein" | ||
}, | ||
"fo_subdomein": { | ||
"@id": "fo:#fo_subdomein" | ||
}, | ||
"fo_doelzin": { | ||
"@id": "fo:#fo_doelzin" | ||
}, | ||
"fo_toelichting": { | ||
"@id": "fo:#fo_toelichting" | ||
}, | ||
"fo_uitwerking": { | ||
"@id": "fo:#fo_uitwerking" | ||
}, | ||
"deprecated": { | ||
"@id": "fo:#Deprecated" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// load the curriculum-js library | ||
import Curriculum from 'curriculum-js' | ||
// load node filesystem support | ||
import fs from 'fs' | ||
import repl from 'repl'; | ||
|
||
// create an async function, so we can use await inside it | ||
async function main() { | ||
|
||
// create new curriculum instance | ||
const curriculum = new Curriculum() | ||
|
||
// read the list of all contexts from the file /curriculum-contexts.txt | ||
const schemas = fs.readFileSync('curriculum-contexts.txt','utf8') | ||
.split(/\n/g) // split the file on newlines | ||
.map(line => line.trim()) // remove leading and trailing whitespace | ||
.filter(Boolean) // filter empty lines | ||
|
||
// load all contexts from the editor/ and master/ folders | ||
let loadedSchemas = schemas.map( | ||
schema => curriculum.loadContextFromFile(schema, schema+'/context.json') | ||
).concat( | ||
curriculum.loadContextFromFile('curriculum-fo', 'context.json') | ||
) | ||
|
||
// wait untill all contexts have been loaded, and return the promise values as schemas | ||
Promise.allSettled(loadedSchemas).then((settledSchemas) => { | ||
loadedSchemas = settledSchemas.map(promise => promise.value) | ||
}) | ||
.then(() => { | ||
|
||
var server = repl.start({ | ||
ignoreUndefined: true | ||
}); | ||
|
||
server.context.curriculum = curriculum; | ||
if (process.env.NODE_REPL_HISTORY) { | ||
server.setupHistory(process.env.NODE_REPL_HISTORY, (e) => { if (e) console.log(e); } ); | ||
} else { | ||
console.log('Set environment variable NODE_REPL_HISTORY=.repl_history to enable persistent REPL history'); | ||
} | ||
|
||
}) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Curriculum from "curriculum-js"; | ||
|
||
async function validate() { | ||
var curriculum = new Curriculum(); | ||
var schema = await curriculum.loadContextFromFile( | ||
"curriculum-fo", | ||
"context.json" | ||
); | ||
await curriculum.loadContextFromFile( | ||
"curriculum-fo", | ||
"curriculum-basis/context.json" | ||
); | ||
try { | ||
await curriculum.validate(schema); | ||
console.log("Data is valid!"); | ||
} catch (error) { | ||
error.validationErrors.forEach((error) => { | ||
console.log(error.instancePath + ": " + error.message); | ||
}); | ||
} | ||
} | ||
|
||
validate(); |