Skip to content

Commit

Permalink
added missing files from editor branch
Browse files Browse the repository at this point in the history
  • Loading branch information
poef committed Sep 27, 2023
1 parent 1640acc commit 2e553d8
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
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
2 changes: 2 additions & 0 deletions README.md
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)
1 change: 1 addition & 0 deletions curriculum-basis
Submodule curriculum-basis added at ce330e
17 changes: 17 additions & 0 deletions package.json
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"
}
}
34 changes: 34 additions & 0 deletions schema.jsonld
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"
}
}
}
46 changes: 46 additions & 0 deletions test/repl.mjs
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()
23 changes: 23 additions & 0 deletions test/test.mjs
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();

0 comments on commit 2e553d8

Please sign in to comment.