Skip to content

Commit 6a7ef1e

Browse files
committed
Adding more restrictions to learning objectives json schema
1 parent cffae05 commit 6a7ef1e

File tree

4 files changed

+282
-44
lines changed

4 files changed

+282
-44
lines changed

js/LearningObjectives.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ export const SCHEMA = {
1010
"description": "Schema for Learning Objectives mapping",
1111
"additionalProperties": false,
1212
"definitions": {
13-
"learning_objective_id": {
13+
"uuid": {
1414
"type": "string",
15+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
16+
"description": "A unique identifier in the form of a UUID v4"
17+
},
18+
"learning_objective_id": {
19+
"$ref": "#/definitions/uuid",
1520
"description": "Unique identifier for the Learning Objective"
1621
}
1722
},
@@ -28,6 +33,8 @@ export const SCHEMA = {
2833
},
2934
"text": {
3035
"type": "string",
36+
"minLength": 1,
37+
"pattern": "^\\s*\\S[\\s\\S]*$",
3138
"description": "Human-readable text describing the Learning Objective"
3239
},
3340
"metadata": {
@@ -42,21 +49,27 @@ export const SCHEMA = {
4249
"type": "object",
4350
"description": "Mapping of assessment question IDs to Learning Objective IDs",
4451
"minProperties": 1,
52+
"additionalProperties": false,
4553
"patternProperties": {
46-
"^.*$": {
54+
"^[0-9a-f]{32}:.+$": {
4755
"type": "array",
48-
"items": { "$ref": "#/definitions/learning_objective_id" }
56+
"items": {
57+
"$ref": "#/definitions/learning_objective_id"
58+
}
4959
}
5060
}
5161
},
5262
"lesson_objectives": {
5363
"type": "object",
54-
"description": "Mapping of lesson content node IDs to Learning Objective IDs",
64+
"description": "Mapping of lesson IDs to Learning Objective IDs",
5565
"minProperties": 1,
66+
"additionalProperties": false,
5667
"patternProperties": {
57-
"^.*$": {
68+
"^[0-9a-f]{32}$": {
5869
"type": "array",
59-
"items": { "$ref": "#/definitions/learning_objective_id" }
70+
"items": {
71+
"$ref": "#/definitions/learning_objective_id"
72+
}
6073
}
6174
}
6275
}

le_utils/constants/learning_objectives.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
"description": "Schema for Learning Objectives mapping",
1717
"additionalProperties": False,
1818
"definitions": {
19-
"learning_objective_id": {
19+
"uuid": {
2020
"type": "string",
21+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
22+
"description": "A unique identifier in the form of a UUID v4",
23+
},
24+
"learning_objective_id": {
25+
"$ref": "#/definitions/uuid",
2126
"description": "Unique identifier for the Learning Objective",
22-
}
27+
},
2328
},
2429
"properties": {
2530
"learning_objectives": {
@@ -32,6 +37,8 @@
3237
"id": {"$ref": "#/definitions/learning_objective_id"},
3338
"text": {
3439
"type": "string",
40+
"minLength": 1,
41+
"pattern": "^\\s*\\S[\\s\\S]*$",
3542
"description": "Human-readable text describing the Learning Objective",
3643
},
3744
"metadata": {
@@ -46,19 +53,21 @@
4653
"type": "object",
4754
"description": "Mapping of assessment question IDs to Learning Objective IDs",
4855
"minProperties": 1,
56+
"additionalProperties": False,
4957
"patternProperties": {
50-
"^.*$": {
58+
"^[0-9a-f]{32}:.+$": {
5159
"type": "array",
5260
"items": {"$ref": "#/definitions/learning_objective_id"},
5361
}
5462
},
5563
},
5664
"lesson_objectives": {
5765
"type": "object",
58-
"description": "Mapping of lesson content node IDs to Learning Objective IDs",
66+
"description": "Mapping of lesson IDs to Learning Objective IDs",
5967
"minProperties": 1,
68+
"additionalProperties": False,
6069
"patternProperties": {
61-
"^.*$": {
70+
"^[0-9a-f]{32}$": {
6271
"type": "array",
6372
"items": {"$ref": "#/definitions/learning_objective_id"},
6473
}

spec/schema-learning_objectives.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
"description": "Schema for Learning Objectives mapping",
66
"additionalProperties": false,
77
"definitions": {
8-
"learning_objective_id": {
8+
"uuid": {
99
"type": "string",
10+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
11+
"description": "A unique identifier in the form of a UUID v4"
12+
},
13+
"learning_objective_id": {
14+
"$ref": "#/definitions/uuid",
1015
"description": "Unique identifier for the Learning Objective"
1116
}
1217
},
@@ -23,6 +28,8 @@
2328
},
2429
"text": {
2530
"type": "string",
31+
"minLength": 1,
32+
"pattern": "^\\s*\\S[\\s\\S]*$",
2633
"description": "Human-readable text describing the Learning Objective"
2734
},
2835
"metadata": {
@@ -37,21 +44,27 @@
3744
"type": "object",
3845
"description": "Mapping of assessment question IDs to Learning Objective IDs",
3946
"minProperties": 1,
47+
"additionalProperties": false,
4048
"patternProperties": {
41-
"^.*$": {
49+
"^[0-9a-f]{32}:.+$": {
4250
"type": "array",
43-
"items": { "$ref": "#/definitions/learning_objective_id" }
51+
"items": {
52+
"$ref": "#/definitions/learning_objective_id"
53+
}
4454
}
4555
}
4656
},
4757
"lesson_objectives": {
4858
"type": "object",
49-
"description": "Mapping of lesson content node IDs to Learning Objective IDs",
59+
"description": "Mapping of lesson IDs to Learning Objective IDs",
5060
"minProperties": 1,
61+
"additionalProperties": false,
5162
"patternProperties": {
52-
"^.*$": {
63+
"^[0-9a-f]{32}$": {
5364
"type": "array",
54-
"items": { "$ref": "#/definitions/learning_objective_id" }
65+
"items": {
66+
"$ref": "#/definitions/learning_objective_id"
67+
}
5568
}
5669
}
5770
}

0 commit comments

Comments
 (0)