diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 0000000..f6cbe1d Binary files /dev/null and b/backend/.DS_Store differ diff --git a/backend/src/database/practiceQuestions.json b/backend/src/database/practiceQuestions.json index 12321fd..4d8d4d6 100644 --- a/backend/src/database/practiceQuestions.json +++ b/backend/src/database/practiceQuestions.json @@ -44,11 +44,90 @@ "Frames" ], "canvasConfig": { - "elements": [ - ], + "elements": [], "ids": [], "classes": [] - } + }, + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 2 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 4 + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 2, + "c": 3 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 4 + }, + { + "id": 3, + "type": "int", + "value": 6 + } + ] + } + ] }, { "id": 2, @@ -97,6 +176,90 @@ "Lists", "Aliasing", "Variables" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 2 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 8 + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 2, + "c": 3 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 8 + }, + { + "id": 3, + "type": "list", + "value": [ + 1, + 1, + 1 + ] + } + ] + } ] }, { @@ -150,6 +313,70 @@ "Lists", "Nesting", "Aliasing" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 4 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "list", + "value": [ + 1 + ] + }, + { + "id": 3, + "type": "list", + "value": [ + 2 + ] + }, + { + "id": 4, + "type": "list", + "value": [ + 3 + ] + } + ] + } ] }, { @@ -218,6 +445,142 @@ "Aliasing", "Concatenation", "Rebinding" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + } ] }, { @@ -276,6 +639,133 @@ "Sets", "Aliasing", "Mutation" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "set", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "set", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "set", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 4, + "type": "int", + "value": 4 + } + ] + } ] }, { @@ -356,6 +846,398 @@ "Loops", "Mutation", "Nesting" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "item": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "item": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 8, + "type": "int", + "value": 88 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 8 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "item": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 8, + "type": "int", + "value": 88 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 8 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "item": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 8, + "type": "int", + "value": 88 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 8 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4, + 8 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "item": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 8, + "type": "int", + "value": 88 + }, + { + "id": 5, + "type": "list", + "value": [ + 6, + 7 + ] + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 8 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4, + 8 + ] + } + ] + } ] }, { @@ -394,6 +1276,63 @@ "topics": [ "Lists", "Aliasing" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 2 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "list", + "value": [ + 1 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 2, + "b": 2 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "list", + "value": [ + 1 + ] + } + ] + } ] }, { @@ -431,6 +1370,54 @@ "Lists", "Object Identity", "Creation" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "list", + "value": [] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 1, + "b": 2 + }, + "inactive": false + }, + { + "id": 1, + "type": "list", + "value": [] + }, + { + "id": 2, + "type": "list", + "value": [] + } + ] + } ] }, { @@ -469,6 +1456,75 @@ "Integers", "Aliasing", "Rebinding" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "n": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 14 + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "n": 1, + "n2": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 14 + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "n": 2, + "n2": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 14 + }, + { + "id": 2, + "type": "int", + "value": 15 + } + ] + } ] }, { @@ -507,6 +1563,75 @@ "Strings", "Slicing", "Rebinding" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "s": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "str", + "value": "hello" + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "s": 1, + "s2": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "str", + "value": "hello" + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "s": 2, + "s2": 1 + }, + "inactive": false + }, + { + "id": 1, + "type": "str", + "value": "hello" + }, + { + "id": 2, + "type": "str", + "value": "llo" + } + ] + } ] }, { @@ -579,6 +1704,171 @@ "Lists", "Slicing", "Aliasing" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "one": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 0 + }, + { + "id": 2, + "type": "int", + "value": 1 + }, + { + "id": 3, + "type": "int", + "value": 2 + }, + { + "id": 4, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 4, + 5 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "one": 6, + "two": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 0 + }, + { + "id": 2, + "type": "int", + "value": 1 + }, + { + "id": 3, + "type": "int", + "value": 2 + }, + { + "id": 4, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 4, + 5 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "one": 7, + "two": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 0 + }, + { + "id": 2, + "type": "int", + "value": 1 + }, + { + "id": 3, + "type": "int", + "value": 2 + }, + { + "id": 4, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 4, + 5 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 2, + 3 + ] + } + ] + } ] }, { @@ -648,6 +1938,169 @@ "Lists", "Mutation", "Remove" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 9 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 2, + 4 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 6, + "b": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 9 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2, + 3, + 2, + 4 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 1, + 2, + 3, + 2, + 4 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 6, + "b": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 9 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 3, + 2, + 4 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 1, + 2, + 3, + 2, + 4 + ] + } + ] + } ] }, { @@ -706,6 +2159,132 @@ "Aliasing", "Mutation", "Index Assignment" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "x": 5, + "y": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 4, + 3 + ] + }, + { + "id": 4, + "type": "int", + "value": 100 + } + ] + } ] }, { @@ -765,6 +2344,133 @@ "Aliasing", "Mutation", "Append" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 3 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "lst2": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 3 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 5, + "lst2": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 3 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 5, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 4, + "type": "int", + "value": 99 + } + ] + } ] }, { @@ -850,6 +2556,287 @@ "Aliasing", "Mutation", "Rebinding" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "temp": 8 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 10 + }, + { + "id": 3, + "type": "int", + "value": 15 + }, + { + "id": 8, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "temp": 8, + "other": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 10 + }, + { + "id": 3, + "type": "int", + "value": 15 + }, + { + "id": 5, + "type": "int", + "value": 75 + }, + { + "id": 8, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "temp": 8, + "other": 5, + "L": 9 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 10 + }, + { + "id": 3, + "type": "int", + "value": 15 + }, + { + "id": 5, + "type": "int", + "value": 75 + }, + { + "id": 7, + "type": "str", + "value": "hey" + }, + { + "id": 8, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [ + 8, + 7, + 5 + ] + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "temp": 8, + "other": 5, + "L": 9 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 10 + }, + { + "id": 3, + "type": "int", + "value": 15 + }, + { + "id": 4, + "type": "int", + "value": 99 + }, + { + "id": 5, + "type": "int", + "value": 75 + }, + { + "id": 7, + "type": "str", + "value": "hey" + }, + { + "id": 8, + "type": "list", + "value": [ + 1, + 4, + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [ + 8, + 7, + 5 + ] + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "temp": 8, + "other": 6, + "L": 9 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 5 + }, + { + "id": 2, + "type": "int", + "value": 10 + }, + { + "id": 3, + "type": "int", + "value": 15 + }, + { + "id": 4, + "type": "int", + "value": 99 + }, + { + "id": 5, + "type": "int", + "value": 75 + }, + { + "id": 7, + "type": "str", + "value": "hey" + }, + { + "id": 8, + "type": "list", + "value": [ + 1, + 4, + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [ + 8, + 7, + 5 + ] + }, + { + "id": 6, + "type": "int", + "value": 0 + } + ] + } ] }, { @@ -927,6 +2914,392 @@ "Loops", "Rebinding", "Lists" + ], + "steps": [ + { + "lineNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8, + "item": 6 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8, + "item": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 88 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8, + "item": 7 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 88 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8, + "item": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 88 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "L": 8, + "item": 5 + }, + "inactive": false + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 88 + }, + { + "id": 6, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 7, + "type": "list", + "value": [ + 3, + 4 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 6, + 7 + ] + } + ] + } ] } -] +] \ No newline at end of file diff --git a/backend/src/database/prepQuestions.json b/backend/src/database/prepQuestions.json index aa46c9c..a22671a 100644 --- a/backend/src/database/prepQuestions.json +++ b/backend/src/database/prepQuestions.json @@ -167,8 +167,14 @@ "value": null, "className": "_Node", "classVariables": [ - { "key": "item", "value": 5 }, - { "key": "next", "value": 6 } + { + "key": "item", + "value": 5 + }, + { + "key": "next", + "value": 6 + } ] } }, @@ -183,8 +189,14 @@ "value": null, "className": "_Node", "classVariables": [ - { "key": "item", "value": 3 }, - { "key": "next", "value": 4 } + { + "key": "item", + "value": 3 + }, + { + "key": "next", + "value": 4 + } ] } }, @@ -198,12 +210,3479 @@ "type": "class", "value": null, "className": "LinkedList", - "classVariables": [{ "key": "_first", "value": 2 }] + "classVariables": [ + { + "key": "_first", + "value": 2 + } + ] } } ], - "ids": [1, 2, 3, 4, 5, 6], - "classes": ["_Node", "LinkedList"] - } + "ids": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "classes": [ + "_Node", + "LinkedList" + ] + }, + "steps": [ + { + "lineNumber": 20, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 9, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 10, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 9, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 11, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 7, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 12, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 6 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 13, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 4 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 4 + } + } + ] + }, + { + "lineNumber": 14, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 2 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 4 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 2 + } + } + ] + }, + { + "lineNumber": 15, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 6 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 4 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 2 + } + } + ] + }, + { + "lineNumber": 17, + "answer": [ + { + "id": null, + "name": "LinkedList.move_to_back", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "curr": 2, + "result": 7 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 6 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 4 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 2 + } + } + ] + }, + { + "lineNumber": 22, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst": 1 + } + }, + { + "id": 3, + "type": "int", + "value": 148 + }, + { + "id": 5, + "type": "int", + "value": 165 + }, + { + "id": 7, + "type": "int", + "value": 108 + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "name": "_Node", + "type": ".class", + "value": { + "item": 5, + "next": 6 + } + }, + { + "id": 2, + "name": "_Node", + "type": ".class", + "value": { + "item": 3, + "next": 4 + } + }, + { + "id": 1, + "name": "LinkedList", + "type": ".class", + "value": { + "_first": 2 + } + } + ] + } + ] + }, + { + "id": 2, + "question": "Draw the memory model for the code below **immediately after** `bst = BST(None)` executes.\n\n**Notes:**\n- You are allowed to use either Practice or Test mode to complete this question.", + "code": [ + "class BST:", + " \"\"\"Binary Search Tree class from the course notes.", + "", + " Representation Invariants:", + " - If self._root is None, then so are self._left and self._right;", + " this represents an empty BST.", + " - If self._root is not None, then self._left and self._right", + " are BSTs; in particular, self is a leaf in this case", + " if self._left and self._right are both empty BSTs", + " - (BST Property) If self is not empty, then all items in", + " self._left are <= self._root, and all items in", + " self._right are >= self._root.", + " \"\"\"", + " _root: Any | None", + " _left: BST | None", + " _right: BST | None", + "", + " def __init__(self, root: Any | None) -> None:", + " \"\"\"", + " Initialize a new BST containing only the given root value.", + " If is None, initialize an empty tree.", + " \"\"\"", + " if root is None:", + " self._root = None", + " self._left = None", + " self._right = None", + " else:", + " self._root = root", + " self._left = BST(None)", + " self._right = BST(None)", + "", + "", + "if __name__ == '__main__':", + " bst = BST(None) # draw the memory model here" + ], + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "description": null, + "topics": [ + "BST", + "Classes", + "CSC148" + ], + "canvasConfig": null, + "steps": [ + { + "lineNumber": 18, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 23, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 24, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 25, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 26, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 34, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 18, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + } + ] + }, + { + "lineNumber": 23, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + } + ] + }, + { + "lineNumber": 27, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + } + ] + }, + { + "lineNumber": 28, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 3, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + } + ] + }, + { + "lineNumber": 29, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 3, + "_left": 4, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + }, + { + "lineNumber": 30, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 3 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 3, + "_left": 4, + "_right": 5 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 3, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 5, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + } + ] + }, + { + "id": 3, + "question": "You are given an initially empty BST (the memory model is preloaded on the canvas). Update the memory model to show what it will look like **after** `bst.insert(148)` executes.\n\n**Notes:**\n- The `insert` method is not shown \u00e2\u20ac\u201d use the BST representation invariants to reason about the result.\n- You are allowed to use either Practice or Test mode to complete this question.", + "code": [ + "class BST:", + " \"\"\"Binary Search Tree class from the course notes.", + "", + " Representation Invariants:", + " - If self._root is None, then so are self._left and self._right;", + " this represents an empty BST.", + " - If self._root is not None, then self._left and self._right", + " are BSTs; in particular, self is a leaf in this case", + " if self._left and self._right are both empty BSTs", + " - (BST Property) If self is not empty, then all items in", + " self._left are <= self._root, and all items in", + " self._right are >= self._root.", + " \"\"\"", + " _root: Any | None", + " _left: BST | None", + " _right: BST | None", + "", + " def __init__(self, root: Any | None) -> None:", + " \"\"\"", + " Initialize a new BST containing only the given root value.", + " If is None, initialize an empty tree.", + " \"\"\"", + " if root is None:", + " self._root = None", + " self._left = None", + " self._right = None", + " else:", + " self._root = root", + " self._left = BST(None)", + " self._right = BST(None)", + "", + " # (insert and other methods not shown)", + "", + "", + "if __name__ == '__main__':", + " bst = BST(None)", + " # initial memory model (empty BST) is preloaded on the canvas", + " bst.insert(148) # update the memory model to show the result" + ], + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ], + "description": null, + "topics": [ + "BST", + "Classes", + "CSC148" + ], + "canvasConfig": { + "elements": [ + { + "boxId": 0, + "id": "_", + "x": 0, + "y": 0, + "kind": { + "name": "function", + "type": "function", + "value": null, + "functionName": "__main__", + "params": [ + { + "name": "bst", + "targetId": 1 + } + ], + "order": 1 + } + }, + { + "boxId": 1, + "id": 1, + "x": 735, + "y": 186, + "kind": { + "name": "class", + "type": "class", + "value": null, + "className": "BST", + "classVariables": [ + { + "key": "_root", + "value": 2 + }, + { + "key": "_left", + "value": 2 + }, + { + "key": "_right", + "value": 2 + } + ] + } + }, + { + "boxId": 2, + "id": 2, + "x": 738, + "y": 396, + "kind": { + "name": "primitive", + "type": "NoneType", + "value": "None" + } + } + ], + "ids": [ + 1, + 2 + ], + "classes": [ + "BST" + ] + }, + "steps": [ + { + "lineNumber": 18, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 23, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 24, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 25, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 26, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 36, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 18, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 23, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 27, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 28, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 29, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + }, + { + "lineNumber": 30, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + }, + { + "lineNumber": 38, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + } + ] + }, + { + "id": 4, + "question": "You are given a BST that is initially only a leaf containing the value 148 (the memory model is preloaded on the canvas). Update the memory model to show what it will look like **after** `bst.insert(108)` executes.\n\n**Hint**: Which of `bst`'s subtrees will be mutated?\n\n**Notes:**\n- The `insert` method is not shown \u00e2\u20ac\u201d use the BST representation invariants to reason about the result.\n- You are allowed to use either Practice or Test mode to complete this question.", + "code": [ + "class BST:", + " \"\"\"Binary Search Tree class from the course notes.", + "", + " Representation Invariants:", + " - If self._root is None, then so are self._left and self._right;", + " this represents an empty BST.", + " - If self._root is not None, then self._left and self._right", + " are BSTs; in particular, self is a leaf in this case", + " if self._left and self._right are both empty BSTs", + " - (BST Property) If self is not empty, then all items in", + " self._left are <= self._root, and all items in", + " self._right are >= self._root.", + " \"\"\"", + " _root: Any | None", + " _left: BST | None", + " _right: BST | None", + "", + " def __init__(self, root: Any | None) -> None:", + " \"\"\"", + " Initialize a new BST containing only the given root value.", + " If is None, initialize an empty tree.", + " \"\"\"", + " if root is None:", + " self._root = None", + " self._left = None", + " self._right = None", + " else:", + " self._root = root", + " self._left = BST(None)", + " self._right = BST(None)", + "", + " # (insert and other methods not shown)", + "", + "", + "if __name__ == '__main__':", + " bst = BST(None)", + " bst.insert(148)", + " # initial memory model (BST with root 148) is preloaded on the canvas", + " bst.insert(108) # update the memory model to show the result" + ], + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 8, + "_left": 6, + "_right": 7 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 6, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 7, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ], + "description": null, + "topics": [ + "BST", + "Classes", + "CSC148" + ], + "canvasConfig": { + "elements": [ + { + "boxId": 0, + "id": "_", + "x": 0, + "y": 0, + "kind": { + "name": "function", + "type": "function", + "value": null, + "functionName": "__main__", + "params": [ + { + "name": "bst", + "targetId": 1 + } + ], + "order": 1 + } + }, + { + "boxId": 1, + "id": 1, + "x": 735, + "y": 186, + "kind": { + "name": "class", + "type": "class", + "value": null, + "className": "BST", + "classVariables": [ + { + "key": "_root", + "value": 5 + }, + { + "key": "_left", + "value": 3 + }, + { + "key": "_right", + "value": 4 + } + ] + } + }, + { + "boxId": 2, + "id": 2, + "x": 744, + "y": 492, + "kind": { + "name": "primitive", + "type": "NoneType", + "value": "None" + } + }, + { + "boxId": 3, + "id": 3, + "x": 497, + "y": 424, + "kind": { + "name": "class", + "type": "class", + "value": null, + "className": "BST", + "classVariables": [ + { + "key": "_root", + "value": 2 + }, + { + "key": "_left", + "value": 2 + }, + { + "key": "_right", + "value": 2 + } + ] + } + }, + { + "boxId": 4, + "id": 4, + "x": 998, + "y": 420, + "kind": { + "name": "class", + "type": "class", + "value": null, + "className": "BST", + "classVariables": [ + { + "key": "_root", + "value": 2 + }, + { + "key": "_left", + "value": 2 + }, + { + "key": "_right", + "value": 2 + } + ] + } + }, + { + "boxId": 5, + "id": 5, + "x": 963, + "y": 140, + "kind": { + "name": "primitive", + "type": "int", + "value": "148" + } + } + ], + "ids": [ + 1, + 2, + 3, + 4, + 5 + ], + "classes": [ + "BST" + ] + }, + "steps": [ + { + "lineNumber": 18, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 23, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": {} + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 24, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 25, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 26, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": {} + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 36, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + } + ] + }, + { + "lineNumber": 18, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 23, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 27, + "iterationNumber": 1, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 28, + "iterationNumber": 1, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 2, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 29, + "iterationNumber": 1, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 2 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + }, + { + "lineNumber": 30, + "iterationNumber": 1, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 1, + "root": 5 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + } + ] + }, + { + "lineNumber": 37, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + } + ] + }, + { + "lineNumber": 18, + "iterationNumber": 3, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 23, + "iterationNumber": 3, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 27, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 28, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 8, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 29, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 8, + "_left": 6, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 6, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 30, + "iterationNumber": 2, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": ".frame", + "name": "BST.__init__", + "id": null, + "order": 2, + "value": { + "self": 3, + "root": 8 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 8, + "_left": 6, + "_right": 7 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 6, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 7, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + }, + { + "lineNumber": 39, + "answer": [ + { + "type": ".frame", + "name": "__main__", + "id": null, + "order": 1, + "value": { + "bst": 1 + } + }, + { + "type": "object", + "name": "BST", + "id": 1, + "value": { + "_root": 5, + "_left": 3, + "_right": 4 + } + }, + { + "type": "NoneType", + "id": 2, + "value": "None" + }, + { + "type": "object", + "name": "BST", + "id": 3, + "value": { + "_root": 8, + "_left": 6, + "_right": 7 + } + }, + { + "type": "object", + "name": "BST", + "id": 4, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 5, + "value": 148 + }, + { + "type": "object", + "name": "BST", + "id": 6, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "object", + "name": "BST", + "id": 7, + "value": { + "_root": 2, + "_left": 2, + "_right": 2 + } + }, + { + "type": "int", + "id": 8, + "value": 108 + } + ] + } + ] } -] +] \ No newline at end of file diff --git a/backend/src/database/schema.sql b/backend/src/database/schema.sql index 6425414..3946f10 100644 --- a/backend/src/database/schema.sql +++ b/backend/src/database/schema.sql @@ -4,6 +4,7 @@ CREATE TABLE IF NOT EXISTS practice_questions ( question TEXT, code TEXT[], answer JSONB, + steps JSONB, description TEXT, canvas_config JSONB ); @@ -14,6 +15,7 @@ CREATE TABLE IF NOT EXISTS test_questions ( question TEXT, code TEXT[], answer JSONB, + steps JSONB, description TEXT, canvas_config JSONB ); diff --git a/backend/src/database/testQuestions.json b/backend/src/database/testQuestions.json index 9a64647..701b2fc 100644 --- a/backend/src/database/testQuestions.json +++ b/backend/src/database/testQuestions.json @@ -124,7 +124,477 @@ ], "ids": [], "classes": [] - } + }, + "steps": [ + { + "lineNumber": 20, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + } + ] + }, + { + "lineNumber": 13, + "answer": [ + { + "id": null, + "name": "Fries.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 4, + "p": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "Food.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 4, + "n": 1, + "p": 2 + } + }, + { + "id": null, + "name": "Fries.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 4, + "p": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1 + } + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "Food.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 4, + "n": 1, + "p": 2 + } + }, + { + "id": null, + "name": "Fries.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 4, + "p": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + } + ] + }, + { + "lineNumber": 21, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4, + "menu": 5 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + }, + { + "id": 6, + "type": "list", + "value": [ + 4 + ] + }, + { + "id": 5, + "name": "Menu", + "type": "object", + "value": { + "items": 6 + } + } + ] + }, + { + "lineNumber": 17, + "answer": [ + { + "id": null, + "name": "Menu.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 5, + "items": 6 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + }, + { + "id": 6, + "type": "list", + "value": [ + 4 + ] + }, + { + "id": 5, + "name": "Menu", + "type": "object", + "value": { + "items": 6 + } + } + ] + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "Food.update_price", + "type": ".frame", + "order": 2, + "value": { + "self": 4, + "new_price": 3, + "price": 2 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4, + "menu": 5 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + }, + { + "id": 6, + "type": "list", + "value": [ + 4 + ] + }, + { + "id": 5, + "name": "Menu", + "type": "object", + "value": { + "items": 6 + } + } + ] + }, + { + "lineNumber": 9, + "answer": [ + { + "id": null, + "name": "Food.update_price", + "type": ".frame", + "order": 2, + "value": { + "self": 4, + "new_price": 3, + "price": 3 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4, + "menu": 5 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + }, + { + "id": 6, + "type": "list", + "value": [ + 4 + ] + }, + { + "id": 5, + "name": "Menu", + "type": "object", + "value": { + "items": 6 + } + } + ] + }, + { + "lineNumber": 22, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "f": 4, + "menu": 5 + } + }, + { + "id": 1, + "type": "str", + "value": "fries" + }, + { + "id": 2, + "type": "int", + "value": 5 + }, + { + "id": 3, + "type": "int", + "value": 7 + }, + { + "id": 4, + "name": "Fries", + "type": "object", + "value": { + "name": 1, + "price": 2 + } + }, + { + "id": 6, + "type": "list", + "value": [ + 4 + ] + }, + { + "id": 5, + "name": "Menu", + "type": "object", + "value": { + "items": 6 + } + } + ] + } + ] }, { "id": 2, @@ -250,6 +720,834 @@ "Constructors", "Objects", "Linked List" + ], + "steps": [ + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": {} + } + ] + }, + { + "lineNumber": 6, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": {} + } + ] + }, + { + "lineNumber": 6, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3 + } + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 4, + "value": { + "self": 7, + "items": 9 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": {} + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 4, + "value": { + "self": 7, + "items": 9 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 6, + "_rest": 6 + } + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 4, + "value": { + "self": 7, + "items": 9 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 6, + "_rest": 6 + } + } + ] + }, + { + "lineNumber": 7, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2, + "_rest": 5 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3, + "_rest": 7 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 6, + "_rest": 6 + } + } + ] + }, + { + "lineNumber": 7, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": {} + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3, + "_rest": 7 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 6, + "_rest": 6 + } + } + ] + }, + { + "lineNumber": 10, + "answer": [ + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 4, + "value": { + "self": 7, + "items": 9 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 3, + "value": { + "self": 5, + "items": 8 + } + }, + { + "id": null, + "name": "RecursiveList.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 1, + "items": 4 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "rec_lst": 1 + } + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "str", + "value": "hi" + }, + { + "id": 6, + "type": "NoneType", + "value": "None" + }, + { + "id": 4, + "type": "list", + "value": [ + 2, + 3 + ] + }, + { + "id": 8, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 9, + "type": "list", + "value": [] + }, + { + "id": 1, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 2, + "_rest": 5 + } + }, + { + "id": 5, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 3, + "_rest": 7 + } + }, + { + "id": 7, + "name": "RecursiveList", + "type": "object", + "value": { + "_first": 6, + "_rest": 6 + } + } + ] + } ] }, { @@ -350,6 +1648,502 @@ "Aliasing", "Mutation", "Call Stack" + ], + "steps": [ + { + "lineNumber": 13, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 14, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "a_fun", + "type": ".frame", + "order": 4, + "value": { + "lst": 148, + "v": 3, + "x": 4 + } + }, + { + "id": null, + "name": "y_fun", + "type": ".frame", + "order": 3, + "value": { + "d": 148 + } + }, + { + "id": null, + "name": "have_fun", + "type": ".frame", + "order": 2, + "value": { + "lst": 148 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "a_fun", + "type": ".frame", + "order": 4, + "value": { + "lst": 148, + "v": 3, + "x": 4 + } + }, + { + "id": null, + "name": "y_fun", + "type": ".frame", + "order": 3, + "value": { + "d": 148 + } + }, + { + "id": null, + "name": "have_fun", + "type": ".frame", + "order": 2, + "value": { + "lst": 148 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "y_fun", + "type": ".frame", + "order": 3, + "value": { + "d": 148 + } + }, + { + "id": null, + "name": "have_fun", + "type": ".frame", + "order": 2, + "value": { + "lst": 148 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 7, + "answer": [ + { + "id": null, + "name": "y_fun", + "type": ".frame", + "order": 3, + "value": { + "d": 148 + } + }, + { + "id": null, + "name": "have_fun", + "type": ".frame", + "order": 2, + "value": { + "lst": 148 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 10, + "answer": [ + { + "id": null, + "name": "have_fun", + "type": ".frame", + "order": 2, + "value": { + "lst": 148 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 15, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + }, + { + "lineNumber": 16, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "a": 148, + "b": 148 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 148, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + } + ] + } ] }, { @@ -435,6 +2229,668 @@ "Shallow Copy", "Lists", "Aliasing" + ], + "steps": [ + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 102 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [] + } + ] + }, + { + "lineNumber": 4, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 102 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 103 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102 + ] + } + ] + }, + { + "lineNumber": 4, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 103 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102, + 103 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 103 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102, + 103 + ] + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "duplicate", + "type": ".frame", + "order": 2, + "value": { + "matrix": 101, + "answer": 104, + "item": 103 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102, + 103 + ] + } + ] + }, + { + "lineNumber": 9, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "m1": 101, + "m2": 104 + } + }, + { + "id": 50, + "type": "int", + "value": 1 + }, + { + "id": 60, + "type": "int", + "value": 2 + }, + { + "id": 70, + "type": "int", + "value": 3 + }, + { + "id": 80, + "type": "int", + "value": 4 + }, + { + "id": 102, + "type": "list", + "value": [ + 50, + 60 + ] + }, + { + "id": 103, + "type": "list", + "value": [ + 70, + 80 + ] + }, + { + "id": 101, + "type": "list", + "value": [ + 102, + 103 + ] + }, + { + "id": 104, + "type": "list", + "value": [ + 102, + 103 + ] + } + ] + } ] }, { @@ -540,6 +2996,1575 @@ "Loops", "Rebinding", "Objects" + ], + "steps": [ + { + "lineNumber": 11, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + } + ] + }, + { + "lineNumber": 12, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 100, + "type": "list", + "value": [ + 80 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + } + ] + }, + { + "lineNumber": 13, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 100, + "type": "list", + "value": [ + 80, + 81 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + } + ] + }, + { + "lineNumber": 14, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 100, + "type": "list", + "value": [ + 80, + 81, + 82 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + } + ] + }, + { + "lineNumber": 15, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 80, + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 80, + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 80, + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 5, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 80 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 80 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 80 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 81, + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 2 + }, + { + "lineNumber": 5, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 81 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 81 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 2 + }, + { + "lineNumber": 7, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 81 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 81 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 82, + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 5, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 82 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 82 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 82 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [ + 83 + ] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 4 + }, + { + "lineNumber": 5, + "iterationNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 83 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 83 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 4 + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 90, + "minimum": 67, + "temp_queue": 95, + "value": 83 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ], + "iterationNumber": 5 + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "filter_queue", + "type": ".frame", + "order": 2, + "value": { + "q": 95, + "minimum": 67, + "temp_queue": 95, + "value": 83 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + }, + { + "lineNumber": 16, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "q": 90 + } + }, + { + "id": 67, + "type": "int", + "value": 10 + }, + { + "id": 80, + "type": "int", + "value": 2 + }, + { + "id": 81, + "type": "int", + "value": 21 + }, + { + "id": 82, + "type": "int", + "value": 5 + }, + { + "id": 83, + "type": "int", + "value": 1 + }, + { + "id": 100, + "type": "list", + "value": [] + }, + { + "id": 90, + "name": "Queue", + "type": "object", + "value": { + "_items": 100 + } + }, + { + "id": 105, + "type": "list", + "value": [ + 81 + ] + }, + { + "id": 95, + "name": "Queue", + "type": "object", + "value": { + "_items": 105 + } + } + ] + } ] }, { @@ -621,6 +4646,306 @@ "Mutation", "Rebinding", "Lists" + ], + "steps": [ + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + } + ] + }, + { + "lineNumber": 9, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 99, + "type": "list", + "value": [ + 2 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "mystery", + "type": ".frame", + "order": 2, + "value": { + "a": 1, + "b": 99, + "c": 99 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 99, + "type": "list", + "value": [ + 2 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "mystery", + "type": ".frame", + "order": 2, + "value": { + "a": 1, + "b": 99, + "c": 99 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 99, + "type": "list", + "value": [ + 2, + 1 + ] + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "mystery", + "type": ".frame", + "order": 2, + "value": { + "a": 4, + "b": 99, + "c": 99 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 4, + "type": "int", + "value": 101 + }, + { + "id": 99, + "type": "list", + "value": [ + 2, + 1 + ] + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "mystery", + "type": ".frame", + "order": 2, + "value": { + "a": 4, + "b": 100, + "c": 99 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "int", + "value": 5 + }, + { + "id": 4, + "type": "int", + "value": 101 + }, + { + "id": 99, + "type": "list", + "value": [ + 2, + 1 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 3 + ] + } + ] + }, + { + "lineNumber": 10, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "my_num": 1, + "my_lst": 99 + } + }, + { + "id": 1, + "type": "int", + "value": 100 + }, + { + "id": 2, + "type": "int", + "value": 7 + }, + { + "id": 3, + "type": "int", + "value": 5 + }, + { + "id": 4, + "type": "int", + "value": 101 + }, + { + "id": 99, + "type": "list", + "value": [ + 2, + 1 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 3 + ] + } + ] + } ] }, { @@ -726,6 +5051,905 @@ "Shallow Copy", "Lists", "Aliasing" + ], + "steps": [ + { + "lineNumber": 10, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [] + } + ] + }, + { + "lineNumber": 4, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10 + ] + } + ] + }, + { + "lineNumber": 4, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 30 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 4, + "iterationNumber": 3, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 30 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 3, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 30 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 4 + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "copy_of", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new_lst": 200, + "item": 30 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 11, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "board": 100, + "temp_board": 200 + } + }, + { + "id": 1, + "type": "str", + "value": "O" + }, + { + "id": 2, + "type": "str", + "value": "" + }, + { + "id": 3, + "type": "str", + "value": "X" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 1, + 3, + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 3, + 2, + 3 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + }, + { + "id": 200, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + } ] }, { @@ -734,7 +5958,7 @@ "code": [ "def append_sometimes(lst: list[list[int]], new: int) -> list[list[int]]:", " \"\"\"Return a new list equal to , with appended to each", - " sub‑list that doesn't already contain it.\"\"\"", + " sub\u2011list that doesn't already contain it.\"\"\"", " answer = lst", " for item in answer:", " if new not in item:", @@ -833,6 +6057,1083 @@ "Mutation", "Loops", "Lists" + ], + "steps": [ + { + "lineNumber": 11, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 4, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "answer": 100, + "item": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "answer": 100, + "item": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 1 + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "answer": 100, + "item": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 2 + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "answer": 100, + "item": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 2 + }, + { + "lineNumber": 7, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 20, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 30, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 30, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 7, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 30, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5, + 2 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 5, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 30, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5, + 2 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ], + "iterationNumber": 4 + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "append_sometimes", + "type": ".frame", + "order": 2, + "value": { + "lst": 100, + "new": 2, + "item": 30, + "answer": 100 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5, + 2 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + }, + { + "lineNumber": 12, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "lst1": 100, + "new_lst1": 100 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 3, + 2 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 4, + 5, + 2 + ] + }, + { + "id": 100, + "type": "list", + "value": [ + 10, + 20, + 30 + ] + } + ] + } ] }, { @@ -915,6 +7216,399 @@ "Aliasing", "Mutation", "Objects" + ], + "steps": [ + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "BagOfStuff.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 20, + "stuff": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + }, + { + "lineNumber": 7, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10, + "my_stuff": 20 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10, + "my_stuff": 20 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 4, + "type": "str", + "value": "snacks" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "BagOfStuff.__init__", + "type": ".frame", + "order": 2, + "value": { + "self": 30, + "stuff": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10, + "my_stuff": 20 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 4, + "type": "str", + "value": "snacks" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + }, + { + "id": 30, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + }, + { + "lineNumber": 9, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10, + "my_stuff": 20, + "your_stuff": 30 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 4, + "type": "str", + "value": "snacks" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + }, + { + "id": 30, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + }, + { + "lineNumber": 10, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "some_stuff": 10, + "my_stuff": 20, + "your_stuff": 30 + } + }, + { + "id": 1, + "type": "str", + "value": "wallet" + }, + { + "id": 2, + "type": "str", + "value": "phone" + }, + { + "id": 3, + "type": "str", + "value": "keys" + }, + { + "id": 4, + "type": "str", + "value": "snacks" + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 4 + ] + }, + { + "id": 20, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + }, + { + "id": 30, + "name": "BagOfStuff", + "type": "object", + "value": { + "stuff": 10 + } + } + ] + } ] }, { @@ -1019,6 +7713,719 @@ "Mutation", "Loops", "Lists" + ], + "steps": [ + { + "lineNumber": 6, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 7, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "do_something", + "type": ".frame", + "order": 2, + "value": { + "lst": 40, + "sublst": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 1, + "answer": [ + { + "id": null, + "name": "do_something", + "type": ".frame", + "order": 2, + "value": { + "lst": 40, + "sublst": 10 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 7, + "type": "int", + "value": 99 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 7 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 2, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "do_something", + "type": ".frame", + "order": 2, + "value": { + "lst": 40, + "sublst": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 7, + "type": "int", + "value": 99 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 7 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 3, + "iterationNumber": 2, + "answer": [ + { + "id": null, + "name": "do_something", + "type": ".frame", + "order": 2, + "value": { + "lst": 40, + "sublst": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 7, + "type": "int", + "value": 99 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 7 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6, + 7 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + }, + { + "lineNumber": 2, + "answer": [ + { + "id": null, + "name": "do_something", + "type": ".frame", + "order": 2, + "value": { + "lst": 40, + "sublst": 20 + } + }, + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 7, + "type": "int", + "value": 99 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 7 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6, + 7 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ], + "iterationNumber": 3 + }, + { + "lineNumber": 8, + "answer": [ + { + "id": null, + "name": "__main__", + "type": ".frame", + "order": 1, + "value": { + "original_lst": 30, + "lst_copy": 40 + } + }, + { + "id": 1, + "type": "int", + "value": 1 + }, + { + "id": 2, + "type": "int", + "value": 2 + }, + { + "id": 3, + "type": "int", + "value": 3 + }, + { + "id": 4, + "type": "int", + "value": 4 + }, + { + "id": 5, + "type": "int", + "value": 5 + }, + { + "id": 6, + "type": "int", + "value": 6 + }, + { + "id": 7, + "type": "int", + "value": 99 + }, + { + "id": 10, + "type": "list", + "value": [ + 1, + 2, + 3, + 7 + ] + }, + { + "id": 20, + "type": "list", + "value": [ + 4, + 5, + 6, + 7 + ] + }, + { + "id": 30, + "type": "list", + "value": [ + 10, + 20 + ] + }, + { + "id": 40, + "type": "list", + "value": [ + 10, + 20 + ] + } + ] + } ] } ] diff --git a/backend/src/features/informationTabs/questionTab/index.ts b/backend/src/features/informationTabs/questionTab/index.ts index ce9502e..441df0e 100644 --- a/backend/src/features/informationTabs/questionTab/index.ts +++ b/backend/src/features/informationTabs/questionTab/index.ts @@ -30,6 +30,7 @@ type QuestionRow = { question: string; code: string[]; // text[] answer: unknown; // jsonb + steps: unknown | null; // jsonb — optional per-line answer steps description: string | null; topics: string[] | null; // text[] canvasConfig: unknown | null; // jsonb @@ -56,7 +57,7 @@ router.get("/practicequestions/:id", async (req: Request, res: Response) => { try { const { rows } = await getPool().query( - 'SELECT id, question, code, answer, topics, canvas_config AS "canvasConfig" FROM practice_questions WHERE id = $1', + 'SELECT id, question, code, answer, steps, topics, canvas_config AS "canvasConfig" FROM practice_questions WHERE id = $1', [id] ); if (rows.length === 0) { @@ -91,7 +92,7 @@ router.get("/testquestions/:id", async (req: Request, res: Response) => { try { const { rows } = await getPool().query( - 'SELECT id, question, code, answer, description, topics, canvas_config AS "canvasConfig" FROM test_questions WHERE id = $1', + 'SELECT id, question, code, answer, steps, description, topics, canvas_config AS "canvasConfig" FROM test_questions WHERE id = $1', [id] ); if (rows.length === 0) { @@ -126,7 +127,7 @@ router.get("/prepquestions/:id", async (req: Request, res: Response) => { try { const { rows } = await getPool().query( - 'SELECT id, question, code, answer, topics, canvas_config AS "canvasConfig" FROM prep_questions WHERE id = $1', + 'SELECT id, question, code, answer, steps, topics, canvas_config AS "canvasConfig" FROM prep_questions WHERE id = $1', [id] ); if (rows.length === 0) { diff --git a/backend/src/features/validationServices/index.ts b/backend/src/features/validationServices/index.ts index a4062d4..d6938c6 100644 --- a/backend/src/features/validationServices/index.ts +++ b/backend/src/features/validationServices/index.ts @@ -1,5 +1,5 @@ import express from "express"; -import validateAnswer from "./validateAnswer"; +import validateAnswer, { validateAnswerAtLine } from "./validateAnswer"; const router = express.Router(); @@ -17,4 +17,19 @@ router.post("/submit", async (req, res) => { res.status(200).json(result); }); +router.post("/submitAtLine", async (req, res) => { + const { model, questionIndex, questionType, lineNumber, iterationNumber } = req.body; + const iterLabel = iterationNumber !== undefined ? `, iter ${iterationNumber}` : ""; + console.log(`Canvas data (check at line ${lineNumber}${iterLabel}):`, model); + + const result = await validateAnswerAtLine(model, questionIndex, questionType, lineNumber, iterationNumber); + console.log(`Line ${lineNumber}${iterLabel} check is`, result.correct ? "Correct" : "Incorrect"); + if (!result.correct) { + console.log("Errors:"); + result.errors.forEach((err) => console.log(" -", err.message)); + } + + res.status(200).json(result); +}); + export default router; diff --git a/backend/src/features/validationServices/validateAnswer.ts b/backend/src/features/validationServices/validateAnswer.ts index 1fbacd0..8092bd5 100644 --- a/backend/src/features/validationServices/validateAnswer.ts +++ b/backend/src/features/validationServices/validateAnswer.ts @@ -862,27 +862,11 @@ async function fetchAnswerModel( return raw as MemoryBox[]; } -/* ---------- main validation function ---------- */ -export default async function validateAnswer( +/* ---------- shared comparison logic ---------- */ +function runComparison( userModel: MemoryBox[], - questionId: number, - questionType: "test" | "practice" | "prep" -): Promise<{ - correct: boolean; - errors: FeedbackError[]; -}> { - const answerModel = await fetchAnswerModel(questionType, questionId); - if (!answerModel) { - return { - correct: false, - errors: [{ - type: ErrorType.GENERIC_ERROR, - message: `Invalid question id: ${questionId}`, - severity: 'error' - }], - }; - } - + answerModel: MemoryBox[] +): { correct: boolean; errors: FeedbackError[] } { const errors: FeedbackError[] = []; // gather frames from both models @@ -935,3 +919,97 @@ export default async function validateAnswer( return { correct: errors.length === 0, errors }; } + +/* ---------- main validation function ---------- */ +export default async function validateAnswer( + userModel: MemoryBox[], + questionId: number, + questionType: "test" | "practice" | "prep" +): Promise<{ + correct: boolean; + errors: FeedbackError[]; +}> { + const answerModel = await fetchAnswerModel(questionType, questionId); + if (!answerModel) { + return { + correct: false, + errors: [{ + type: ErrorType.GENERIC_ERROR, + message: `Invalid question id: ${questionId}`, + severity: 'error' + }], + }; + } + + return runComparison(userModel, answerModel); +} + +/* ---------- line-specific validation ---------- */ +type QuestionStep = { lineNumber: number; iterationNumber?: number; answer: unknown }; + +async function fetchStepsModel( + questionType: "test" | "practice" | "prep", + questionId: number, + lineNumber: number, + iterationNumber?: number +): Promise { + const table = + questionType === "practice" + ? "practice_questions" + : questionType === "prep" + ? "prep_questions" + : "test_questions"; + + const result = await getPool().query<{ steps: unknown }>( + `SELECT steps FROM ${table} WHERE id = $1`, + [questionId] + ); + if (result.rows.length === 0) return null; + + const steps = result.rows[0].steps; + if (!Array.isArray(steps)) return "no_steps"; + + const step = (steps as QuestionStep[]).find( + (s) => s.lineNumber === lineNumber && s.iterationNumber === iterationNumber + ); + if (!step) return "no_steps"; + + if (!Array.isArray(step.answer)) { + throw new Error(`Step answer for line ${lineNumber} is not an array`); + } + return step.answer as MemoryBox[]; +} + +export async function validateAnswerAtLine( + userModel: MemoryBox[], + questionId: number, + questionType: "test" | "practice" | "prep", + lineNumber: number, + iterationNumber?: number +): Promise<{ correct: boolean; errors: FeedbackError[] }> { + const stepModel = await fetchStepsModel(questionType, questionId, lineNumber, iterationNumber); + + if (stepModel === null) { + return { + correct: false, + errors: [{ + type: ErrorType.GENERIC_ERROR, + message: `Invalid question id: ${questionId}`, + severity: 'error' + }], + }; + } + + if (stepModel === "no_steps") { + return { + correct: false, + errors: [{ + type: ErrorType.GENERIC_ERROR, + message: `No answer defined for line ${lineNumber}${iterationNumber !== undefined ? ` iteration ${iterationNumber}` : ""}`, + severity: 'error' + }], + }; + } + + return runComparison(userModel, stepModel); +} diff --git a/backend/src/scripts/import-questions.ts b/backend/src/scripts/import-questions.ts index a207ba8..00a9e3d 100644 --- a/backend/src/scripts/import-questions.ts +++ b/backend/src/scripts/import-questions.ts @@ -10,6 +10,7 @@ interface Question { question: string; code: string[]; answer: any; + steps?: Array<{ lineNumber: number; answer: any }> | null; description: string | null; topics: string[]; canvasConfig?: { @@ -74,6 +75,7 @@ async function createTablesIfNotExist(pool: Pool) { question TEXT, code TEXT[], answer JSONB, + steps JSONB, description TEXT, topics TEXT[], canvas_config JSONB @@ -84,6 +86,7 @@ async function createTablesIfNotExist(pool: Pool) { question TEXT, code TEXT[], answer JSONB, + steps JSONB, description TEXT, topics TEXT[], canvas_config JSONB @@ -94,6 +97,7 @@ async function createTablesIfNotExist(pool: Pool) { question TEXT, code TEXT[], answer JSONB, + steps JSONB, description TEXT, topics TEXT[], canvas_config JSONB @@ -123,6 +127,15 @@ async function createTablesIfNotExist(pool: Pool) { await pool.query( "ALTER TABLE prep_questions ADD COLUMN IF NOT EXISTS canvas_config JSONB" ); + await pool.query( + "ALTER TABLE practice_questions ADD COLUMN IF NOT EXISTS steps JSONB" + ); + await pool.query( + "ALTER TABLE test_questions ADD COLUMN IF NOT EXISTS steps JSONB" + ); + await pool.query( + "ALTER TABLE prep_questions ADD COLUMN IF NOT EXISTS steps JSONB" + ); console.log("Tables created or already exist"); } @@ -186,12 +199,13 @@ async function importQuestions() { console.log("Importing practice questions..."); for (const q of practiceQuestions) { await pool.query( - `INSERT INTO practice_questions (question, code, answer, description, topics, canvas_config) - VALUES ($1, $2, $3, $4, $5, $6)`, + `INSERT INTO practice_questions (question, code, answer, steps, description, topics, canvas_config) + VALUES ($1, $2, $3, $4, $5, $6, $7)`, [ q.question, q.code, JSON.stringify(q.answer), + q.steps ? JSON.stringify(q.steps) : null, q.description, q.topics ?? [], q.canvasConfig ?? null, @@ -203,12 +217,13 @@ async function importQuestions() { console.log("\nImporting test questions..."); for (const q of testQuestions) { await pool.query( - `INSERT INTO test_questions (question, code, answer, description, topics, canvas_config) - VALUES ($1, $2, $3, $4, $5, $6)`, + `INSERT INTO test_questions (question, code, answer, steps, description, topics, canvas_config) + VALUES ($1, $2, $3, $4, $5, $6, $7)`, [ q.question, q.code, JSON.stringify(q.answer), + q.steps ? JSON.stringify(q.steps) : null, q.description, q.topics ?? [], q.canvasConfig ?? null, @@ -220,12 +235,13 @@ async function importQuestions() { console.log("\nImporting prep questions..."); for (const q of prepQuestions) { await pool.query( - `INSERT INTO prep_questions (question, code, answer, description, topics, canvas_config) - VALUES ($1, $2, $3, $4, $5, $6)`, + `INSERT INTO prep_questions (question, code, answer, steps, description, topics, canvas_config) + VALUES ($1, $2, $3, $4, $5, $6, $7)`, [ q.question, q.code, JSON.stringify(q.answer), + q.steps ? JSON.stringify(q.steps) : null, q.description, q.topics ?? [], q.canvasConfig ?? null, diff --git a/frontend/src/features/canvas/Canvas.tsx b/frontend/src/features/canvas/Canvas.tsx index 1f6f57c..85d28f4 100644 --- a/frontend/src/features/canvas/Canvas.tsx +++ b/frontend/src/features/canvas/Canvas.tsx @@ -41,6 +41,8 @@ interface FloatingEditorProps { addClasses?: (className: string) => void; removeClasses?: (className: string) => void; sandbox: boolean; + canManageClasses?: boolean; + canManageFunctions?: boolean; elements: CanvasElement[]; editorScale: number; questionFunctionNames?: string[]; @@ -61,6 +63,8 @@ function FloatingEditor({ addClasses, removeClasses, sandbox, + canManageClasses, + canManageFunctions, elements, editorScale, questionFunctionNames, @@ -107,6 +111,8 @@ function FloatingEditor({ addClasses={addClasses} removeClasses={removeClasses} sandbox={sandbox} + canManageClasses={canManageClasses ?? sandbox} + canManageFunctions={canManageFunctions ?? sandbox} elements={elements} questionFunctionNames={questionFunctionNames} /> @@ -126,6 +132,8 @@ interface CanvasProps { addClasses?: (className: string) => void; removeClasses?: (className: string) => void; sandbox?: boolean; + canManageClasses?: boolean; + canManageFunctions?: boolean; onClear: () => void; onEditorOpenerReady?: (openEditor: (element: CanvasElement) => void) => void; scale?: number; @@ -144,6 +152,8 @@ function Canvas({ addClasses, removeClasses, sandbox = true, + canManageClasses, + canManageFunctions, onEditorOpenerReady, scale: externalScale, editorScale = 1, @@ -256,6 +266,17 @@ function Canvas({ .forEach((id) => addId(id)); }, [elements, ids, sandbox, addId]); + // Close any floating editors whose element no longer exists + // (e.g. when exiting a question clears the canvas, or an element is deleted) + useEffect(() => { + setOpenEditors((prev) => { + const filtered = prev.filter((editor) => + elements.some((el) => el.boxId === editor.boxId) + ); + return filtered.length === prev.length ? prev : filtered; + }); + }, [elements]); + // Validate elements whenever they change // Create a stable signature of elements for comparison const elementsSignature = useMemo(() => { @@ -501,6 +522,8 @@ function Canvas({ addClasses={addClasses} removeClasses={removeClasses} sandbox={sandbox} + canManageClasses={canManageClasses ?? sandbox} + canManageFunctions={canManageFunctions ?? sandbox} elements={elements} editorScale={editorScale} questionFunctionNames={questionFunctionNames} diff --git a/frontend/src/features/canvasControls/CanvasControls.module.css b/frontend/src/features/canvasControls/CanvasControls.module.css index 03bb9eb..9c11656 100644 --- a/frontend/src/features/canvasControls/CanvasControls.module.css +++ b/frontend/src/features/canvasControls/CanvasControls.module.css @@ -217,3 +217,53 @@ .toggleActive .toggleThumb { transform: translateX(20px); } + +/* ======================================= + === Font Zoom Controls ================ +======================================= */ + +.fontZoomControls { + display: flex; + flex-direction: row; + gap: 4px; + width: 100%; +} + +.fontZoomBtn { + all: unset; + flex: 1; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + font-size: 1.2rem; + font-weight: 600; + line-height: 1; + background-color: var(--button-bg); + color: var(--text-secondary); + border: 1px solid var(--border-primary); + border-radius: 8px; + box-shadow: var(--shadow-sm); + cursor: pointer; + transition: all 160ms ease; +} + +.fontZoomBtn:hover:not(:disabled) { + background-color: var(--button-hover); + border-color: var(--border-secondary); + color: var(--text-primary); +} + +.fontZoomBtn:active:not(:disabled) { + background-color: var(--button-active); +} + +.fontZoomBtn:disabled { + opacity: 0.35; + cursor: not-allowed; +} + +.fontZoomBtn:focus-visible { + outline: 2px solid var(--border-focus); + outline-offset: 2px; +} diff --git a/frontend/src/features/canvasControls/CanvasControls.tsx b/frontend/src/features/canvasControls/CanvasControls.tsx index 305ea51..1e9e317 100644 --- a/frontend/src/features/canvasControls/CanvasControls.tsx +++ b/frontend/src/features/canvasControls/CanvasControls.tsx @@ -22,6 +22,8 @@ interface CanvasControlsProps { onScaleChange?: (scale: number) => void; editorScale?: number; onEditorScaleChange?: (scale: number) => void; + fontScale?: number; + onFontScaleChange?: (delta: number) => void; } type ControlTab = "actions" | "view" | "settings"; @@ -61,6 +63,8 @@ export default function CanvasControls({ onScaleChange, editorScale = 1, onEditorScaleChange, + fontScale = 1, + onFontScaleChange, }: CanvasControlsProps) { const { theme, toggleTheme } = useTheme(); const isDarkMode = theme === 'dark'; @@ -131,6 +135,39 @@ export default function CanvasControls({ )} + + {onFontScaleChange && ( + <> +
+ + {Math.round(fontScale * 100)}% +
+
+
+ + +
+
+ + )} )} diff --git a/frontend/src/features/editors/boxEditor/BoxEditor.tsx b/frontend/src/features/editors/boxEditor/BoxEditor.tsx index f04c427..30c19ff 100644 --- a/frontend/src/features/editors/boxEditor/BoxEditor.tsx +++ b/frontend/src/features/editors/boxEditor/BoxEditor.tsx @@ -39,6 +39,8 @@ const BoxEditorModule = ({ addClasses, removeClasses, sandbox = true, + canManageClasses = sandbox, + canManageFunctions = sandbox, elements = [], questionFunctionNames, }: BoxEditorType) => { @@ -123,6 +125,8 @@ const BoxEditorModule = ({ setElementId={setOwnId} removeId={removeId} sandbox={sandbox} + canManageClasses={canManageClasses} + canManageFunctions={canManageFunctions} elements={elements} onClose={onClose} /> diff --git a/frontend/src/features/editors/boxEditor/Header.tsx b/frontend/src/features/editors/boxEditor/Header.tsx index eeab6f0..b22c2f6 100644 --- a/frontend/src/features/editors/boxEditor/Header.tsx +++ b/frontend/src/features/editors/boxEditor/Header.tsx @@ -20,6 +20,8 @@ interface Props { setElementId: (id: ID) => void; removeId: (id: ID) => void; sandbox: boolean; + canManageClasses?: boolean; + canManageFunctions?: boolean; classes?: string[]; addClasses?: (className: string) => void; ownClasses?: string; @@ -56,6 +58,8 @@ const Header = ({ setElementId, removeId, sandbox, + canManageClasses = sandbox, + canManageFunctions = sandbox, classes = [], addClasses = () => {}, ownClasses = "", @@ -117,6 +121,7 @@ const Header = ({ setElementClassName={setOwnClassName} removeClassName={removeClasses} sandbox={sandbox} + canManageClasses={canManageClasses} /> ) : kind === "function" ? ( ) : ( {typeLabel} diff --git a/frontend/src/features/editors/boxEditor/classBoxes/ClassDisplay.tsx b/frontend/src/features/editors/boxEditor/classBoxes/ClassDisplay.tsx index fc87041..585de64 100644 --- a/frontend/src/features/editors/boxEditor/classBoxes/ClassDisplay.tsx +++ b/frontend/src/features/editors/boxEditor/classBoxes/ClassDisplay.tsx @@ -11,6 +11,7 @@ interface Props { setElementClassName: (className: string) => void; removeClassName: (className: string) => void; sandbox: boolean; + canManageClasses?: boolean; } /** @@ -25,6 +26,7 @@ const ClassDisplay = ({ setElementClassName, removeClassName, sandbox, + canManageClasses = sandbox, }: Props) => ( ); diff --git a/frontend/src/features/editors/classEditor/ClassEditorPanel.tsx b/frontend/src/features/editors/classEditor/ClassEditorPanel.tsx index 0dc1fd4..0f344dd 100644 --- a/frontend/src/features/editors/classEditor/ClassEditorPanel.tsx +++ b/frontend/src/features/editors/classEditor/ClassEditorPanel.tsx @@ -9,6 +9,7 @@ interface Props { onRemove: (className: string) => void; onClose: () => void; sandbox: boolean; + canManageClasses?: boolean; } const ClassSelectorPanel: React.FC = ({ @@ -18,6 +19,7 @@ const ClassSelectorPanel: React.FC = ({ onRemove, onClose, sandbox, + canManageClasses = sandbox, }) => { const [customClass, setCustomClass] = useState(""); const [showWarn, setShowWarn] = useState(false); @@ -63,7 +65,7 @@ const ClassSelectorPanel: React.FC = ({ > {className} - {sandbox && ( + {canManageClasses && ( - {sandbox && ( + {canManageFunctions && ( +
+ +
+ +
); diff --git a/frontend/src/features/informationTabs/questionTab/QuestionTab.module.css b/frontend/src/features/informationTabs/questionTab/QuestionTab.module.css index 1cb45b3..2469ad8 100644 --- a/frontend/src/features/informationTabs/questionTab/QuestionTab.module.css +++ b/frontend/src/features/informationTabs/questionTab/QuestionTab.module.css @@ -119,7 +119,7 @@ } .questionText { - font-size: 0.95rem; + font-size: calc(0.95rem * var(--font-scale, 1)); line-height: 1.55; margin-bottom: 0.875rem; color: var(--text-secondary); @@ -149,7 +149,7 @@ cursor: pointer; padding: 0.6rem 0.85rem; font-weight: 600; - font-size: 0.85rem; + font-size: calc(0.85rem * var(--font-scale, 1)); color: var(--text-secondary); background: var(--bg-tertiary); list-style: none; @@ -192,7 +192,7 @@ border: 1px solid #bfdbfe; border-radius: 6px; padding: 0.2rem 0.6rem; - font-size: 0.73rem; + font-size: calc(0.73rem * var(--font-scale, 1)); font-weight: 600; letter-spacing: 0.01em; } @@ -200,7 +200,7 @@ .topicsEmpty { margin: 0; color: var(--text-muted); - font-size: 0.85rem; + font-size: calc(0.85rem * var(--font-scale, 1)); transition: color 200ms ease; } @@ -216,7 +216,7 @@ border-radius: 8px; cursor: pointer; font-weight: 500; - font-size: 0.85rem; + font-size: calc(0.85rem * var(--font-scale, 1)); flex: 1; transition: all 160ms ease; background: var(--bg-primary); @@ -239,7 +239,7 @@ border-radius: 8px; cursor: pointer; font-weight: 600; - font-size: 0.85rem; + font-size: calc(0.85rem * var(--font-scale, 1)); flex: 1; transition: all 160ms ease; background: #10b981; @@ -254,6 +254,107 @@ background: #047857; } +.checkAtLineButton { + padding: 0.5rem 1rem; + border: 1.5px solid #7dd3fc; + border-radius: 8px; + cursor: pointer; + font-weight: 600; + font-size: calc(0.85rem * var(--font-scale, 1)); + flex: 1; + transition: all 160ms ease; + background: rgba(125, 211, 252, 0.1); + color: #7dd3fc; +} + +.checkAtLineButton:hover { + background: rgba(125, 211, 252, 0.2); + border-color: #38bdf8; + color: #38bdf8; +} + +.checkAtLineButton:active { + background: rgba(125, 211, 252, 0.3); +} + +.lineHint { + margin: 0.5rem 0 0 0; + font-size: calc(0.75rem * var(--font-scale, 1)); + color: var(--text-muted); + font-style: italic; + transition: color 200ms ease; +} + +.iterationPicker { + display: flex; + align-items: center; + gap: 0.4rem; + margin-top: 0.5rem; + flex-wrap: wrap; +} + +.iterationLabel { + font-size: calc(0.75rem * var(--font-scale, 1)); + color: var(--text-muted); + font-style: italic; + transition: color 200ms ease; +} + +.iterationBtn { + padding: 0.2rem 0.6rem; + border: 1.5px solid #7dd3fc; + border-radius: 6px; + cursor: pointer; + font-weight: 600; + font-size: calc(0.78rem * var(--font-scale, 1)); + background: transparent; + color: #7dd3fc; + transition: all 140ms ease; +} + +.iterationBtn:hover { + background: rgba(125, 211, 252, 0.15); +} + +.iterationBtnActive { + background: rgba(125, 211, 252, 0.25); + border-color: #38bdf8; + color: #38bdf8; +} + +/* Light mode iteration buttons */ +:root:not([data-theme="dark"]) .iterationBtn { + border-color: #0e7490; + color: #0e7490; +} + +:root:not([data-theme="dark"]) .iterationBtn:hover { + background: rgba(14, 116, 144, 0.1); +} + +:root:not([data-theme="dark"]) .iterationBtnActive { + background: rgba(14, 116, 144, 0.18); + border-color: #0369a1; + color: #0369a1; +} + +/* Light mode overrides */ +:root:not([data-theme="dark"]) .checkAtLineButton { + background: rgba(14, 116, 144, 0.1); + border-color: #0e7490; + color: #0e7490; +} + +:root:not([data-theme="dark"]) .checkAtLineButton:hover { + background: rgba(14, 116, 144, 0.18); + border-color: #0369a1; + color: #0369a1; +} + +:root:not([data-theme="dark"]) .checkAtLineButton:active { + background: rgba(14, 116, 144, 0.28); +} + /* Dark mode overrides */ :root[data-theme="dark"] .questionText code { color: #fb7185; diff --git a/frontend/src/features/informationTabs/questionTab/QuestionTab.tsx b/frontend/src/features/informationTabs/questionTab/QuestionTab.tsx index d8f9d0f..02f52ce 100644 --- a/frontend/src/features/informationTabs/questionTab/QuestionTab.tsx +++ b/frontend/src/features/informationTabs/questionTab/QuestionTab.tsx @@ -44,6 +44,7 @@ interface QuestionData { question: string; code: string[]; answer: unknown; + steps?: Array<{ lineNumber: number; iterationNumber?: number; answer: unknown }> | null; description?: string | null; topics?: string[] | null; canvasConfig?: CanvasData | null; @@ -67,12 +68,14 @@ interface QuestionTabProps { questionView: QuestionView; setQuestionView: (view: QuestionView) => void; onSubmit: () => Promise; + onSubmitAtLine: (lineNumber: number, iterationNumber?: number) => Promise; setSubmissionResults: (results: SubmissionResult | null) => void; onClearCanvas: () => void; onRestoreCanvas: (elements: any[], ids: number[], classes: string[]) => void; currentCanvasState: { elements: any[]; ids: number[]; classes: string[] }; onQuestionDataChange?: (data: any) => void; isSandboxMode: boolean; + fontScale?: number; } function loadQuestionStatus(): QuestionStatusMap { @@ -105,12 +108,14 @@ export default function QuestionTab({ questionView: questionViewProp, setQuestionView, onSubmit, + onSubmitAtLine, setSubmissionResults, onClearCanvas, onRestoreCanvas, currentCanvasState, onQuestionDataChange, isSandboxMode, + fontScale = 1, }: QuestionTabProps) { const [view, setView] = useState( () => (VALID_VIEWS.includes(questionViewProp as View) && questionViewProp !== "loading" ? (questionViewProp as View) : "root") @@ -126,6 +131,8 @@ export default function QuestionTab({ index: number; } | null>(null); const [showResetModal, setShowResetModal] = useState(false); + const [selectedLine, setSelectedLine] = useState(null); + const [selectedIteration, setSelectedIteration] = useState(undefined); const hydratedList = useRef(false); const hydratedQuestion = useRef(false); @@ -202,6 +209,17 @@ export default function QuestionTab({ return questionStatus[key] || "unattempted"; }; + const handleSubmitAtLine = async (lineNumber: number, iterationNumber?: number) => { + if (questionType && questionIndex !== null) { + try { + await onSubmitAtLine(lineNumber, iterationNumber); + // line-check results don't change question completion status + } catch (error) { + console.error("Error during line submission:", error); + } + } + }; + const handleSubmit = async () => { if (questionType && questionIndex !== null) { try { @@ -270,6 +288,8 @@ export default function QuestionTab({ hydratedQuestion.current = false; setQuestionData(null); setSubmissionResults(null); + setSelectedLine(null); + setSelectedIteration(undefined); setView("loading"); @@ -321,6 +341,8 @@ export default function QuestionTab({ setQuestionIndex(null); setQuestionData(null); + setSelectedLine(null); + setSelectedIteration(undefined); hydratedQuestion.current = false; onRestoreCanvas([], [], []); setView("list"); @@ -332,6 +354,8 @@ export default function QuestionTab({ if (pendingNavigation.index === -1) { setQuestionIndex(null); setQuestionData(null); + setSelectedLine(null); + setSelectedIteration(undefined); hydratedQuestion.current = false; onRestoreCanvas([], [], []); setView("list"); @@ -480,7 +504,7 @@ export default function QuestionTab({ variant="category" text="CSC148 Prep Questions" subtitle="" - icon="🔗" + icon="🎓" categoryType="prep" onClick={() => loadQuestions("prep")} /> @@ -513,63 +537,126 @@ export default function QuestionTab({ )} - {view === "question" && questionData && ( - <> -
-
- Topics -
- {(questionData.topics ?? []).length > 0 ? ( -
- {(questionData.topics ?? []).map((topic, index) => ( - - {topic} - - ))} -
- ) : ( -

- No topics listed yet. -

- )} + {view === "question" && questionData && (() => { + const checkableLines = new Set( + questionData.steps?.map((s) => s.lineNumber) ?? [] + ); + // Map from lineNumber → sorted iteration numbers (empty array = no iterations) + const lineIterations = new Map(); + for (const s of questionData.steps ?? []) { + if (s.iterationNumber !== undefined) { + const arr = lineIterations.get(s.lineNumber) ?? []; + arr.push(s.iterationNumber); + lineIterations.set(s.lineNumber, arr); + } + } + const selectedLineHasIterations = + selectedLine !== null && (lineIterations.get(selectedLine)?.length ?? 0) > 0; + const canCheckAtLine = + selectedLine !== null && + checkableLines.has(selectedLine) && + (!selectedLineHasIterations || selectedIteration !== undefined); + return ( + <> +
+
+ Topics +
+ {(questionData.topics ?? []).length > 0 ? ( +
+ {(questionData.topics ?? []).map((topic, index) => ( + + {topic} + + ))} +
+ ) : ( +

+ No topics listed yet. +

+ )} +
+
+ +
+ {questionData.question}
-
- -
- {questionData.question} -
- - -
- - + { + setSelectedLine((prev) => (prev === n ? null : n)); + setSelectedIteration(undefined); + }} + /> + + {checkableLines.size > 0 && ( +

+ Click a highlighted line number to check your answer at that point. +

+ )} + + {selectedLine !== null && selectedLineHasIterations && ( +
+ After iteration: + {(lineIterations.get(selectedLine) ?? []).map((iter) => ( + + ))} +
+ )} + +
+ + {canCheckAtLine && ( + + )} + +
-
- - )} + + ); + })()} {showCanvasClearModal && ( diff --git a/frontend/src/features/informationTabs/questionTab/components/CodeBlock.module.css b/frontend/src/features/informationTabs/questionTab/components/CodeBlock.module.css index a2c401c..8f91681 100644 --- a/frontend/src/features/informationTabs/questionTab/components/CodeBlock.module.css +++ b/frontend/src/features/informationTabs/questionTab/components/CodeBlock.module.css @@ -3,7 +3,7 @@ padding: 1rem 1.25rem; border-radius: 10px; overflow-x: auto; - font-size: 0.85rem; + font-size: calc(0.85rem * var(--font-scale, 1)); line-height: 1.5; background: #1e1e2e; } @@ -29,3 +29,30 @@ white-space: pre; padding-right: 1.25rem; } + +/* Interactive line selection */ +.checkableLine { + cursor: pointer; +} + +.checkableLine:hover { + background: rgba(255, 255, 255, 0.05); +} + +.checkableGutter { + opacity: 1; + color: #60a5fa; +} + +.selectedLine { + background: rgba(96, 165, 250, 0.2); + border-left: 4px solid #3b82f6; + padding-left: 0; +} + +.selectedLine .gutter { + padding-left: 0; + color: #93c5fd; + font-weight: bold; + opacity: 1; +} diff --git a/frontend/src/features/informationTabs/questionTab/components/CodeBlock.tsx b/frontend/src/features/informationTabs/questionTab/components/CodeBlock.tsx index df2a07d..76d4035 100644 --- a/frontend/src/features/informationTabs/questionTab/components/CodeBlock.tsx +++ b/frontend/src/features/informationTabs/questionTab/components/CodeBlock.tsx @@ -6,6 +6,9 @@ interface CodeBlockProps { language: "python" | "javascript" | "typescript" | "java" | string; showLineNumbers?: boolean; startLineNumber?: number; + checkableLines?: Set; + selectedLine?: number | null; + onLineClick?: (lineNumber: number) => void; } export default function CodeBlock({ @@ -13,6 +16,9 @@ export default function CodeBlock({ language, showLineNumbers = true, startLineNumber = 1, + checkableLines, + selectedLine, + onLineClick, }: CodeBlockProps) { return ( @@ -26,11 +32,28 @@ export default function CodeBlock({ {tokens.map((line, index) => { const lineNumber = startLineNumber + index; const lineProps = getLineProps({ line, key: index }); + const isCheckable = checkableLines?.has(lineNumber) ?? false; + const isSelected = selectedLine === lineNumber; + + const lineClassName = [ + styles.line, + lineProps.className ?? "", + isCheckable ? styles.checkableLine : "", + isSelected ? styles.selectedLine : "", + ] + .filter(Boolean) + .join(" "); return (
onLineClick(lineNumber) + : undefined + } + title={isCheckable ? `Check answer at line ${lineNumber}` : undefined} {...Object.fromEntries( Object.entries(lineProps).filter( ([key]) => key !== "className" @@ -38,7 +61,10 @@ export default function CodeBlock({ )} > {showLineNumbers && ( -
@@ -509,6 +522,8 @@ export default function MemoryModelEditor({ addClasses={addElementClass} removeClasses={removeElementClass} sandbox={!state.isSandboxMode} + canManageClasses={!state.isSandboxMode || state.selectedQuestionIndex === null} + canManageFunctions={!state.isSandboxMode || state.selectedQuestionIndex === null} onClear={() => state.setShowClearCanvasModal(true)} onEditorOpenerReady={handleEditorOpenerReady} scale={canvasScale} @@ -555,6 +570,7 @@ export default function MemoryModelEditor({ questionView={state.questionView} setQuestionView={state.setQuestionView} onSubmit={handleCanvasSubmit} + onSubmitAtLine={handleCanvasSubmitAtLine} setSubmissionResults={state.setSubmissionResults} onClearCanvas={clearCanvas} onRestoreCanvas={restoreCanvas} @@ -567,6 +583,7 @@ export default function MemoryModelEditor({ onQuestionDataChange={setCurrentQuestionData} tabScrollPositions={state.tabScrollPositions} setTabScrollPositions={state.setTabScrollPositions} + fontScale={fontScale} /> diff --git a/frontend/src/features/memoryModelEditor/hooks/useCanvasSubmission.ts b/frontend/src/features/memoryModelEditor/hooks/useCanvasSubmission.ts index 09b14f8..a72426b 100644 --- a/frontend/src/features/memoryModelEditor/hooks/useCanvasSubmission.ts +++ b/frontend/src/features/memoryModelEditor/hooks/useCanvasSubmission.ts @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef } from "react"; import { CanvasElement, SubmissionResult, Tab } from "../../shared/types"; -import { submitCanvas } from "../../validationServices/questionValidationService"; +import { submitCanvas, submitCanvasAtLine } from "../../validationServices/questionValidationService"; import { applyFeedbackErrors, clearFeedbackErrors } from "../utils/feedbackErrorMapper"; interface UseCanvasSubmissionParams { @@ -14,6 +14,7 @@ interface UseCanvasSubmissionParams { interface UseCanvasSubmissionReturn { handleCanvasSubmit: () => Promise; + handleCanvasSubmitAtLine: (lineNumber: number, iterationNumber?: number) => Promise; } /** @@ -118,7 +119,61 @@ export function useCanvasSubmission({ } }, []); - return { handleCanvasSubmit }; + const handleCanvasSubmitAtLine = useCallback(async (lineNumber: number, iterationNumber?: number): Promise => { + const index = idxRef.current; + const qtype = typeRef.current; + const els = elsRef.current; + + if (index === null || qtype === null) { + console.warn("Cannot submit at line: question index or type is null"); + setResultsRef.current(null); + setTabRef.current("feedback"); + return false; + } + + const clearedElements = clearFeedbackErrors(els); + const validElements = clearedElements.filter((el) => !el.invalidated); + + if (validElements.length === 0) { + console.warn("No valid elements to submit at line"); + setResultsRef.current(null); + setTabRef.current("feedback"); + return false; + } + + try { + const result = await submitCanvasAtLine(validElements, index, qtype, lineNumber, iterationNumber); + + if (result !== undefined && result !== null) { + console.log('[useCanvasSubmission] submitAtLine result:', result); + + if (result.errors && result.errors.length > 0) { + const elementsWithFeedback = applyFeedbackErrors(clearedElements, result.errors); + setElsRef.current(elementsWithFeedback); + } else { + setElsRef.current(clearedElements); + } + + setResultsRef.current(result); + + const isCorrect = determineIfCorrect(result); + setTabRef.current("feedback"); + return isCorrect; + } else { + console.warn("submitAtLine returned undefined result"); + setResultsRef.current(null); + setTabRef.current("feedback"); + return false; + } + } catch (error) { + console.error("Canvas submitAtLine failed:", error); + setResultsRef.current(null); + setTabRef.current("feedback"); + return false; + } + }, []); + + return { handleCanvasSubmit, handleCanvasSubmitAtLine }; } /** diff --git a/frontend/src/features/palette/Palette.tsx b/frontend/src/features/palette/Palette.tsx index 34273f3..d8d770d 100644 --- a/frontend/src/features/palette/Palette.tsx +++ b/frontend/src/features/palette/Palette.tsx @@ -67,6 +67,8 @@ interface PaletteProps { onScaleChange?: (scale: number) => void; editorScale?: number; onEditorScaleChange?: (scale: number) => void; + fontScale?: number; + onFontScaleChange?: (delta: number) => void; } // Extract TabButton component inline @@ -114,6 +116,8 @@ export default function Palette({ onScaleChange, editorScale, onEditorScaleChange, + fontScale, + onFontScaleChange, }: PaletteProps) { const allBoxes = TAB_BOX_MAPPING[activeTab]; @@ -218,6 +222,8 @@ export default function Palette({ onScaleChange={onScaleChange} editorScale={editorScale} onEditorScaleChange={onEditorScaleChange} + fontScale={fontScale} + onFontScaleChange={onFontScaleChange} /> diff --git a/frontend/src/features/shared/types.ts b/frontend/src/features/shared/types.ts index 059d23e..1d4c0ca 100644 --- a/frontend/src/features/shared/types.ts +++ b/frontend/src/features/shared/types.ts @@ -171,6 +171,8 @@ export interface BoxEditorType { removeClasses?: (className: string) => void; sandbox?: boolean; + canManageClasses?: boolean; + canManageFunctions?: boolean; elements?: any[]; questionFunctionNames?: string[]; } diff --git a/frontend/src/features/validationServices/questionValidationService.ts b/frontend/src/features/validationServices/questionValidationService.ts index 785ac6b..493816a 100644 --- a/frontend/src/features/validationServices/questionValidationService.ts +++ b/frontend/src/features/validationServices/questionValidationService.ts @@ -6,6 +6,7 @@ import { buildJSONFromElements } from "./jsonBuilder"; const API_DEV_URL = process.env.NODE_ENV === "production" ? "" : "http://localhost:3001"; const SUBMIT_ENDPOINT = "/canvasEditor/submit"; +const SUBMIT_AT_LINE_ENDPOINT = "/canvasEditor/submitAtLine"; // Types export type QuestionType = "test" | "practice" | "prep"; @@ -16,6 +17,11 @@ export interface SubmissionPayload { questionType: QuestionType; } +export interface SubmissionAtLinePayload extends SubmissionPayload { + lineNumber: number; + iterationNumber?: number; +} + /** * Submits canvas elements for validation * @param elements - Array of canvas elements to validate @@ -57,3 +63,49 @@ export async function submitCanvas( throw new Error(`Unexpected error during submission: ${String(error)}`); } } + +/** + * Submits canvas elements for validation against the authored answer at a specific line + * @param elements - Array of canvas elements to validate + * @param questionIndex - Index of the current question + * @param questionType - Type of question ("test" or "practice") + * @param lineNumber - The line number to validate against + * @returns Promise with validation response + */ +export async function submitCanvasAtLine( + elements: CanvasElement[], + questionIndex: number, + questionType: QuestionType, + lineNumber: number, + iterationNumber?: number, +) { + try { + const payload: SubmissionAtLinePayload = { + model: buildJSONFromElements(elements), + questionIndex, + questionType, + lineNumber, + iterationNumber, + }; + + const response = await axios.post( + `${API_DEV_URL}${SUBMIT_AT_LINE_ENDPOINT}`, + payload, + ); + + console.log("[questionValidationService] submitAtLine response:", response.data); + console.log( + "[questionValidationService] submitAtLine errors:", + response.data.errors, + ); + + return response.data; + } catch (error) { + if (axios.isAxiosError(error)) { + const message = error.response?.data?.message || error.message; + throw new Error(`Submission failed: ${message}`); + } + + throw new Error(`Unexpected error during submission: ${String(error)}`); + } +}