Skip to content

Commit 9104ece

Browse files
Merge pull request #193 from akolson/pre-post-tests-updates
Makes pre/post test updates on schema and model
2 parents 92c6731 + 89aa6b6 commit 9104ece

File tree

5 files changed

+205
-3
lines changed

5 files changed

+205
-3
lines changed

js/MasteryCriteria.js

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default {
99
NUM_CORRECT_IN_A_ROW_2: "num_correct_in_a_row_2",
1010
NUM_CORRECT_IN_A_ROW_3: "num_correct_in_a_row_3",
1111
NUM_CORRECT_IN_A_ROW_5: "num_correct_in_a_row_5",
12+
PRE_POST_TEST: "pre_post_test",
1213
};
1314

1415
export const SCHEMA = {
@@ -28,7 +29,47 @@ export const SCHEMA = {
2829
"num_correct_in_a_row_2",
2930
"num_correct_in_a_row_3",
3031
"num_correct_in_a_row_5",
31-
"num_correct_in_a_row_10"
32+
"num_correct_in_a_row_10",
33+
"pre_post_test"
34+
]
35+
},
36+
"pre_post_test": {
37+
"type": "object",
38+
"description": "Definition for pre/post test",
39+
"additionalProperties": false,
40+
"properties": {
41+
"assessment_item_ids": {
42+
"type": "array",
43+
"minItems": 2,
44+
"items": {
45+
"type": "string",
46+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
47+
},
48+
"description": "List of assessment item UUIDs for version A and B of the pre/post test"
49+
},
50+
"version_a_item_ids": {
51+
"type": "array",
52+
"minItems": 1,
53+
"items": {
54+
"type": "string",
55+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
56+
},
57+
"description": "List of assessment item UUIDs for version A of the pre/post test"
58+
},
59+
"version_b_item_ids": {
60+
"type": "array",
61+
"minItems": 1,
62+
"items": {
63+
"type": "string",
64+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
65+
},
66+
"description": "List of assessment item UUIDs for version B of the pre/post test"
67+
}
68+
},
69+
"required": [
70+
"assessment_item_ids",
71+
"version_a_item_ids",
72+
"version_b_item_ids"
3273
]
3374
}
3475
},
@@ -37,6 +78,9 @@ export const SCHEMA = {
3778
"n": true,
3879
"mastery_model": {
3980
"$ref": "#/definitions/mastery_model"
81+
},
82+
"pre_post_test": {
83+
"$ref": "#/definitions/pre_post_test"
4084
}
4185
},
4286
"anyOf": [
@@ -66,6 +110,14 @@ export const SCHEMA = {
66110
"type": "null"
67111
}
68112
}
113+
},
114+
{
115+
"properties": {
116+
"mastery_model": {
117+
"const": "pre_post_test"
118+
}
119+
},
120+
"required": ["pre_post_test"]
69121
}
70122
]
71123
};

le_utils/constants/exercises.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
SKILL_CHECK = "skill_check"
99
M_OF_N = "m_of_n"
1010
QUIZ = "quiz"
11+
PRE_POST_TEST = "pre_post_test"
1112

1213
MASTERY_MODELS = (
1314
(DO_ALL, "Do all"),
@@ -18,6 +19,7 @@
1819
(SKILL_CHECK, "Skill check"),
1920
(M_OF_N, "M out of N"),
2021
(QUIZ, "Quiz"),
22+
(PRE_POST_TEST, "Pre/Post Test"),
2123
)
2224

2325
IMG_PLACEHOLDER = "{☣ LOCALPATH}"

le_utils/constants/mastery_criteria.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
NUM_CORRECT_IN_A_ROW_2 = "num_correct_in_a_row_2"
1111
NUM_CORRECT_IN_A_ROW_3 = "num_correct_in_a_row_3"
1212
NUM_CORRECT_IN_A_ROW_5 = "num_correct_in_a_row_5"
13+
PRE_POST_TEST = "pre_post_test"
1314

1415
choices = (
1516
(DO_ALL, "Do All"),
@@ -18,6 +19,7 @@
1819
(NUM_CORRECT_IN_A_ROW_2, "Num Correct In A Row 2"),
1920
(NUM_CORRECT_IN_A_ROW_3, "Num Correct In A Row 3"),
2021
(NUM_CORRECT_IN_A_ROW_5, "Num Correct In A Row 5"),
22+
(PRE_POST_TEST, "Pre Post Test"),
2123
)
2224

2325
MASTERYCRITERIALIST = [
@@ -27,6 +29,7 @@
2729
NUM_CORRECT_IN_A_ROW_2,
2830
NUM_CORRECT_IN_A_ROW_3,
2931
NUM_CORRECT_IN_A_ROW_5,
32+
PRE_POST_TEST,
3033
]
3134

3235
SCHEMA = {
@@ -47,13 +50,54 @@
4750
"num_correct_in_a_row_3",
4851
"num_correct_in_a_row_5",
4952
"num_correct_in_a_row_10",
53+
"pre_post_test",
5054
],
51-
}
55+
},
56+
"pre_post_test": {
57+
"type": "object",
58+
"description": "Definition for pre/post test",
59+
"additionalProperties": False,
60+
"properties": {
61+
"assessment_item_ids": {
62+
"type": "array",
63+
"minItems": 2,
64+
"items": {
65+
"type": "string",
66+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
67+
},
68+
"description": "List of assessment item UUIDs for version A and B of the pre/post test",
69+
},
70+
"version_a_item_ids": {
71+
"type": "array",
72+
"minItems": 1,
73+
"items": {
74+
"type": "string",
75+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
76+
},
77+
"description": "List of assessment item UUIDs for version A of the pre/post test",
78+
},
79+
"version_b_item_ids": {
80+
"type": "array",
81+
"minItems": 1,
82+
"items": {
83+
"type": "string",
84+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
85+
},
86+
"description": "List of assessment item UUIDs for version B of the pre/post test",
87+
},
88+
},
89+
"required": [
90+
"assessment_item_ids",
91+
"version_a_item_ids",
92+
"version_b_item_ids",
93+
],
94+
},
5295
},
5396
"properties": {
5497
"m": True,
5598
"n": True,
5699
"mastery_model": {"$ref": "#/definitions/mastery_model"},
100+
"pre_post_test": {"$ref": "#/definitions/pre_post_test"},
57101
},
58102
"anyOf": [
59103
{"properties": {"mastery_model": {"const": "m_of_n"}}, "required": ["m", "n"]},
@@ -72,5 +116,9 @@
72116
"n": {"type": "null"},
73117
}
74118
},
119+
{
120+
"properties": {"mastery_model": {"const": "pre_post_test"}},
121+
"required": ["pre_post_test"],
122+
},
75123
],
76124
}

spec/schema-mastery_criteria.json

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,47 @@
1515
"num_correct_in_a_row_2",
1616
"num_correct_in_a_row_3",
1717
"num_correct_in_a_row_5",
18-
"num_correct_in_a_row_10"
18+
"num_correct_in_a_row_10",
19+
"pre_post_test"
20+
]
21+
},
22+
"pre_post_test": {
23+
"type": "object",
24+
"description": "Definition for pre/post test",
25+
"additionalProperties": false,
26+
"properties": {
27+
"assessment_item_ids": {
28+
"type": "array",
29+
"minItems": 2,
30+
"items": {
31+
"type": "string",
32+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
33+
},
34+
"description": "List of assessment item UUIDs for version A and B of the pre/post test"
35+
},
36+
"version_a_item_ids": {
37+
"type": "array",
38+
"minItems": 1,
39+
"items": {
40+
"type": "string",
41+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
42+
},
43+
"description": "List of assessment item UUIDs for version A of the pre/post test"
44+
},
45+
"version_b_item_ids": {
46+
"type": "array",
47+
"minItems": 1,
48+
"items": {
49+
"type": "string",
50+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
51+
},
52+
"description": "List of assessment item UUIDs for version B of the pre/post test"
53+
}
54+
},
55+
"required": [
56+
"assessment_item_ids",
57+
"version_a_item_ids",
58+
"version_b_item_ids"
1959
]
2060
}
2161
},
@@ -24,6 +64,9 @@
2464
"n": true,
2565
"mastery_model": {
2666
"$ref": "#/definitions/mastery_model"
67+
},
68+
"pre_post_test": {
69+
"$ref": "#/definitions/pre_post_test"
2770
}
2871
},
2972
"anyOf": [
@@ -53,6 +96,14 @@
5396
"type": "null"
5497
}
5598
}
99+
},
100+
{
101+
"properties": {
102+
"mastery_model": {
103+
"const": "pre_post_test"
104+
}
105+
},
106+
"required": ["pre_post_test"]
56107
}
57108
]
58109
}

tests/test_schemas.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,24 @@ def test_completion_criteria__mastery_model__valid():
223223
"threshold": {"mastery_model": "m_of_n", "m": 1, "n": 2},
224224
}
225225
)
226+
_validate_completion_criteria(
227+
{
228+
"model": "mastery",
229+
"threshold": {
230+
"mastery_model": "pre_post_test",
231+
"pre_post_test": {
232+
"assessment_item_ids": [
233+
str(uuid.uuid4()),
234+
str(uuid.uuid4()),
235+
], # v4 UUID
236+
"version_a_item_ids": [str(uuid.uuid4())], # v4 UUID
237+
"version_b_item_ids": [
238+
str(uuid.uuid5(uuid.NAMESPACE_DNS, "test"))
239+
], # v5 UUID
240+
},
241+
},
242+
}
243+
)
226244

227245

228246
@skip_if_jsonschema_unavailable
@@ -258,6 +276,37 @@ def test_completion_criteria__mastery_model__invalid():
258276
"threshold": -1,
259277
}
260278
)
279+
# Missing version_b_item_ids
280+
with pytest.raises(jsonschema.ValidationError):
281+
_validate_completion_criteria(
282+
{
283+
"model": "mastery",
284+
"threshold": {
285+
"mastery_model": "pre_post_test",
286+
"pre_post_test": {
287+
"assessment_item_ids": [str(uuid.uuid4())], # v4 UUID
288+
"version_a_item_ids": [str(uuid.uuid4())], # v4 UUID
289+
},
290+
},
291+
"learner_managed": False,
292+
}
293+
)
294+
# Invalid UUIDs
295+
with pytest.raises(jsonschema.ValidationError):
296+
_validate_completion_criteria(
297+
{
298+
"model": "mastery",
299+
"threshold": {
300+
"mastery_model": "pre_post_test",
301+
"pre_post_test": {
302+
"assessment_item_ids": ["not-a-uuid"],
303+
"version_a_item_ids": ["not-a-uuid"],
304+
"version_b_item_ids": ["not-a-uuid"],
305+
},
306+
},
307+
"learner_managed": False,
308+
}
309+
)
261310

262311

263312
@skip_if_jsonschema_unavailable

0 commit comments

Comments
 (0)