munchboka-edutools 0.1.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of munchboka-edutools might be problematic. Click here for more details.

Files changed (149) hide show
  1. munchboka_edutools/__init__.py +184 -0
  2. munchboka_edutools/_plotmath_shim.py +126 -0
  3. munchboka_edutools/_version.py +2 -0
  4. munchboka_edutools/directives/__init__.py +1 -0
  5. munchboka_edutools/directives/admonitions.py +389 -0
  6. munchboka_edutools/directives/cas_popup.py +272 -0
  7. munchboka_edutools/directives/clear.py +103 -0
  8. munchboka_edutools/directives/dialogue.py +137 -0
  9. munchboka_edutools/directives/escape_room.py +296 -0
  10. munchboka_edutools/directives/factor_tree.py +549 -0
  11. munchboka_edutools/directives/ggb.py +209 -0
  12. munchboka_edutools/directives/ggb_icon.py +105 -0
  13. munchboka_edutools/directives/ggb_popup.py +165 -0
  14. munchboka_edutools/directives/horner.py +324 -0
  15. munchboka_edutools/directives/interactive_code.py +75 -0
  16. munchboka_edutools/directives/jeopardy.py +252 -0
  17. munchboka_edutools/directives/multi_plot.py +1126 -0
  18. munchboka_edutools/directives/pair_puzzle.py +191 -0
  19. munchboka_edutools/directives/parsons.py +109 -0
  20. munchboka_edutools/directives/plot.py +3105 -0
  21. munchboka_edutools/directives/poly_icon.py +111 -0
  22. munchboka_edutools/directives/polydiv.py +344 -0
  23. munchboka_edutools/directives/popup.py +245 -0
  24. munchboka_edutools/directives/quiz.py +291 -0
  25. munchboka_edutools/directives/signchart.py +516 -0
  26. munchboka_edutools/directives/timed_quiz.py +436 -0
  27. munchboka_edutools/directives/turtle.py +157 -0
  28. munchboka_edutools/static/css/admonitions.css +2012 -0
  29. munchboka_edutools/static/css/cas_popup.css +242 -0
  30. munchboka_edutools/static/css/code_mirror_themes/github_dark_cm.css +112 -0
  31. munchboka_edutools/static/css/code_mirror_themes/github_dark_default_cm.css +40 -0
  32. munchboka_edutools/static/css/code_mirror_themes/github_dark_high_contrast_cm.css +141 -0
  33. munchboka_edutools/static/css/code_mirror_themes/github_light_cm.css +120 -0
  34. munchboka_edutools/static/css/code_mirror_themes/github_light_default_cm.css +108 -0
  35. munchboka_edutools/static/css/code_mirror_themes/one_dark_cm.css +121 -0
  36. munchboka_edutools/static/css/dialogue.css +92 -0
  37. munchboka_edutools/static/css/escapeRoom/escape-room.css +223 -0
  38. munchboka_edutools/static/css/figures.css +274 -0
  39. munchboka_edutools/static/css/general_style.css +74 -0
  40. munchboka_edutools/static/css/github-dark-high-contrast.css +141 -0
  41. munchboka_edutools/static/css/github-dark.css +112 -0
  42. munchboka_edutools/static/css/github-light.css +120 -0
  43. munchboka_edutools/static/css/interactive_code/style.css +575 -0
  44. munchboka_edutools/static/css/interactive_code.css +582 -0
  45. munchboka_edutools/static/css/jeopardy.css +529 -0
  46. munchboka_edutools/static/css/pairPuzzle/style.css +177 -0
  47. munchboka_edutools/static/css/parsons/parsonsPuzzle.css +331 -0
  48. munchboka_edutools/static/css/popup.css +115 -0
  49. munchboka_edutools/static/css/quiz.css +312 -0
  50. munchboka_edutools/static/css/timedQuiz.css +375 -0
  51. munchboka_edutools/static/icons/ggb/mode_evaluate.svg +1 -0
  52. munchboka_edutools/static/icons/ggb/mode_extremum.svg +1 -0
  53. munchboka_edutools/static/icons/ggb/mode_intersect.svg +1 -0
  54. munchboka_edutools/static/icons/ggb/mode_nsolve.svg +1 -0
  55. munchboka_edutools/static/icons/ggb/mode_numeric.svg +1 -0
  56. munchboka_edutools/static/icons/ggb/mode_point.svg +1 -0
  57. munchboka_edutools/static/icons/ggb/mode_solve.svg +1 -0
  58. munchboka_edutools/static/icons/misc/windows-logo.svg +1 -0
  59. munchboka_edutools/static/icons/outline/dark_mode/academic.svg +3 -0
  60. munchboka_edutools/static/icons/outline/dark_mode/backward.svg +3 -0
  61. munchboka_edutools/static/icons/outline/dark_mode/book.svg +3 -0
  62. munchboka_edutools/static/icons/outline/dark_mode/chat_bubble.svg +3 -0
  63. munchboka_edutools/static/icons/outline/dark_mode/check.svg +3 -0
  64. munchboka_edutools/static/icons/outline/dark_mode/cmd_line.svg +3 -0
  65. munchboka_edutools/static/icons/outline/dark_mode/file.svg +1 -0
  66. munchboka_edutools/static/icons/outline/dark_mode/fire.svg +4 -0
  67. munchboka_edutools/static/icons/outline/dark_mode/key.svg +3 -0
  68. munchboka_edutools/static/icons/outline/dark_mode/magnifying.svg +3 -0
  69. munchboka_edutools/static/icons/outline/dark_mode/pencil_square.svg +3 -0
  70. munchboka_edutools/static/icons/outline/dark_mode/play.svg +3 -0
  71. munchboka_edutools/static/icons/outline/dark_mode/question.svg +3 -0
  72. munchboka_edutools/static/icons/outline/dark_mode/square_check.svg +1 -0
  73. munchboka_edutools/static/icons/outline/dark_mode/stop.svg +3 -0
  74. munchboka_edutools/static/icons/outline/dark_mode/summary.svg +3 -0
  75. munchboka_edutools/static/icons/outline/dark_mode/undo.svg +3 -0
  76. munchboka_edutools/static/icons/outline/dark_mode/unlock.svg +3 -0
  77. munchboka_edutools/static/icons/outline/light_mode/academic.svg +3 -0
  78. munchboka_edutools/static/icons/outline/light_mode/backward.svg +3 -0
  79. munchboka_edutools/static/icons/outline/light_mode/book.svg +3 -0
  80. munchboka_edutools/static/icons/outline/light_mode/chat_bubble.svg +3 -0
  81. munchboka_edutools/static/icons/outline/light_mode/check.svg +3 -0
  82. munchboka_edutools/static/icons/outline/light_mode/cmd_line.svg +3 -0
  83. munchboka_edutools/static/icons/outline/light_mode/file.svg +1 -0
  84. munchboka_edutools/static/icons/outline/light_mode/fire.svg +4 -0
  85. munchboka_edutools/static/icons/outline/light_mode/key.svg +3 -0
  86. munchboka_edutools/static/icons/outline/light_mode/magnifying.svg +3 -0
  87. munchboka_edutools/static/icons/outline/light_mode/pencil_square.svg +3 -0
  88. munchboka_edutools/static/icons/outline/light_mode/play.svg +3 -0
  89. munchboka_edutools/static/icons/outline/light_mode/question.svg +3 -0
  90. munchboka_edutools/static/icons/outline/light_mode/square_check.svg +1 -0
  91. munchboka_edutools/static/icons/outline/light_mode/stop.svg +3 -0
  92. munchboka_edutools/static/icons/outline/light_mode/summary.svg +3 -0
  93. munchboka_edutools/static/icons/outline/light_mode/undo.svg +3 -0
  94. munchboka_edutools/static/icons/outline/light_mode/unlock.svg +3 -0
  95. munchboka_edutools/static/icons/polyicons/cubicdown.svg +3 -0
  96. munchboka_edutools/static/icons/polyicons/cubicup.svg +3 -0
  97. munchboka_edutools/static/icons/polyicons/frown.svg +3 -0
  98. munchboka_edutools/static/icons/polyicons/smile.svg +3 -0
  99. munchboka_edutools/static/icons/solid/dark_mode/academic.svg +5 -0
  100. munchboka_edutools/static/icons/solid/dark_mode/backward.svg +3 -0
  101. munchboka_edutools/static/icons/solid/dark_mode/book.svg +3 -0
  102. munchboka_edutools/static/icons/solid/dark_mode/brain.svg +1 -0
  103. munchboka_edutools/static/icons/solid/dark_mode/file.svg +1 -0
  104. munchboka_edutools/static/icons/solid/dark_mode/fire.svg +3 -0
  105. munchboka_edutools/static/icons/solid/dark_mode/key.svg +3 -0
  106. munchboka_edutools/static/icons/solid/dark_mode/pencil_square.svg +4 -0
  107. munchboka_edutools/static/icons/solid/dark_mode/play.svg +3 -0
  108. munchboka_edutools/static/icons/solid/dark_mode/python.svg +1 -0
  109. munchboka_edutools/static/icons/solid/dark_mode/scroll.svg +1 -0
  110. munchboka_edutools/static/icons/solid/dark_mode/stop.svg +3 -0
  111. munchboka_edutools/static/icons/solid/light_mode/academic.svg +5 -0
  112. munchboka_edutools/static/icons/solid/light_mode/backward.svg +3 -0
  113. munchboka_edutools/static/icons/solid/light_mode/book.svg +3 -0
  114. munchboka_edutools/static/icons/solid/light_mode/brain.svg +1 -0
  115. munchboka_edutools/static/icons/solid/light_mode/file.svg +1 -0
  116. munchboka_edutools/static/icons/solid/light_mode/fire.svg +3 -0
  117. munchboka_edutools/static/icons/solid/light_mode/key.svg +3 -0
  118. munchboka_edutools/static/icons/solid/light_mode/pencil_square.svg +4 -0
  119. munchboka_edutools/static/icons/solid/light_mode/play.svg +3 -0
  120. munchboka_edutools/static/icons/solid/light_mode/python.svg +1 -0
  121. munchboka_edutools/static/icons/solid/light_mode/scroll.svg +1 -0
  122. munchboka_edutools/static/icons/solid/light_mode/stop.svg +3 -0
  123. munchboka_edutools/static/icons/stickers/edit.svg +1 -0
  124. munchboka_edutools/static/icons/stickers/pencil_square.svg +3 -0
  125. munchboka_edutools/static/js/casThemeManager.js +99 -0
  126. munchboka_edutools/static/js/escapeRoom/escape-room.js +219 -0
  127. munchboka_edutools/static/js/geogebra-setup.js +6 -0
  128. munchboka_edutools/static/js/highlight-init.js +6 -0
  129. munchboka_edutools/static/js/interactiveCode/codeEditor.js +632 -0
  130. munchboka_edutools/static/js/interactiveCode/interactiveCodeSetup.js +348 -0
  131. munchboka_edutools/static/js/interactiveCode/pythonRunner.js +336 -0
  132. munchboka_edutools/static/js/interactiveCode/turtleCode.js +203 -0
  133. munchboka_edutools/static/js/interactiveCode/workerManager.js +353 -0
  134. munchboka_edutools/static/js/jeopardy.js +523 -0
  135. munchboka_edutools/static/js/pairPuzzle/draggableItem.js +64 -0
  136. munchboka_edutools/static/js/pairPuzzle/dropZone.js +119 -0
  137. munchboka_edutools/static/js/pairPuzzle/game.js +160 -0
  138. munchboka_edutools/static/js/parsons/parsonsPuzzle.js +641 -0
  139. munchboka_edutools/static/js/popup.js +85 -0
  140. munchboka_edutools/static/js/quiz.js +422 -0
  141. munchboka_edutools/static/js/skulpt/skulpt.js +35721 -0
  142. munchboka_edutools/static/js/timedQuiz/multipleChoiceQuestion.js +184 -0
  143. munchboka_edutools/static/js/timedQuiz/timedMultipleChoiceQuiz.js +244 -0
  144. munchboka_edutools/static/js/timedQuiz/utils.js +6 -0
  145. munchboka_edutools/static/js/utils.js +3 -0
  146. munchboka_edutools-0.1.13.dist-info/METADATA +108 -0
  147. munchboka_edutools-0.1.13.dist-info/RECORD +149 -0
  148. munchboka_edutools-0.1.13.dist-info/WHEEL +4 -0
  149. munchboka_edutools-0.1.13.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,119 @@
1
+ class DropZone {
2
+ constructor(id, uniqueId, gameInstance) {
3
+ this.id = id;
4
+ this.uniqueId = uniqueId;
5
+ this.items = [];
6
+ this.element = null;
7
+ this.placeholder = null;
8
+ this.game = gameInstance;
9
+ }
10
+
11
+ createElement() {
12
+ const div = document.createElement('div');
13
+ div.classList.add('drop-zone');
14
+ div.dataset.id = this.id;
15
+ this.element = div;
16
+
17
+ // Create and add the placeholder element
18
+ this.placeholder = this.createPlaceholder();
19
+ div.appendChild(this.placeholder);
20
+
21
+ this.addDropEvents();
22
+ return div;
23
+ }
24
+
25
+ createPlaceholder() {
26
+ const placeholder = document.createElement('div');
27
+ placeholder.classList.add('placeholder');
28
+ placeholder.textContent = 'Dra og dropp her'; // Customize your placeholder text here
29
+ return placeholder;
30
+ }
31
+
32
+ addDropEvents() {
33
+ this.element.addEventListener('dragover', (e) => {
34
+ e.preventDefault(); // Necessary to allow dropping
35
+ this.element.classList.add('dropped');
36
+ });
37
+
38
+ this.element.addEventListener('dragleave', () => {
39
+ this.element.classList.remove('dropped');
40
+ });
41
+
42
+ this.element.addEventListener('drop', (e) => {
43
+ e.preventDefault();
44
+ const itemId = e.dataTransfer.getData('text/plain');
45
+ const droppedItem = this.game.getItemById(itemId);
46
+ if (droppedItem) {
47
+ // If the item was previously in another drop zone or draggable container, remove it from there
48
+ const previousZone = this.game.getDropZoneContainingItem(droppedItem);
49
+ if (previousZone) {
50
+ previousZone.removeItem(droppedItem);
51
+ } else {
52
+ const draggableContainer = this.game.getDraggableContainer();
53
+ draggableContainer.removeChild(droppedItem.element);
54
+ }
55
+
56
+ this.items.push(droppedItem);
57
+ droppedItem.element.style.opacity = '1'; // Ensure the item becomes visible after being dropped
58
+ this.element.insertBefore(droppedItem.element, this.placeholder); // Always append the item before the placeholder
59
+
60
+ // Re-render LaTeX in the drop zone
61
+ renderMathInElement(droppedItem.element, {
62
+ delimiters: [
63
+ { left: "$$", right: "$$", display: true },
64
+ { left: "$", right: "$", display: false },
65
+ { left: "\\[", right: "\\]", display: true },
66
+ { left: "\\(", right: "\\)", display: false }
67
+ ]
68
+ });
69
+
70
+ this.element.classList.remove('dropped');
71
+ }
72
+
73
+ // Update placeholder visibility
74
+ this.updatePlaceholderVisibility();
75
+ });
76
+ }
77
+
78
+ updatePlaceholderVisibility() {
79
+ // Show the placeholder if there are less than two items
80
+ if (this.items.length < 2) {
81
+ this.placeholder.style.display = 'block';
82
+ this.element.appendChild(this.placeholder); // Ensure placeholder is always at the bottom
83
+ } else {
84
+ this.placeholder.style.display = 'none';
85
+ }
86
+ }
87
+
88
+ removeItem(item) {
89
+ // Remove the item from the items array
90
+ this.items = this.items.filter(i => i.id !== item.id);
91
+ this.updatePlaceholderVisibility();
92
+ }
93
+
94
+ clear() {
95
+ this.items = [];
96
+ this.element.innerHTML = ''; // Clear all children elements
97
+ this.element.appendChild(this.placeholder); // Re-add the placeholder
98
+ this.updatePlaceholderVisibility();
99
+ this.resetColor();
100
+ }
101
+
102
+ isCorrect() {
103
+ if (this.items.length !== 2) return false;
104
+ return this.items[0].pairId === this.items[1].pairId;
105
+ }
106
+
107
+ // Add color feedback to the drop zone
108
+ setCorrect() {
109
+ this.element.style.backgroundColor = 'rgba(0, 128, 0, 0.5)';
110
+ }
111
+
112
+ setIncorrect() {
113
+ this.element.style.backgroundColor = 'rgba(255, 0, 0, 0.5)';
114
+ }
115
+
116
+ resetColor() {
117
+ this.element.style.backgroundColor = '';
118
+ }
119
+ }
@@ -0,0 +1,160 @@
1
+ function generateUUID() {
2
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
3
+ const r = Math.random() * 16 | 0,
4
+ v = c === 'x' ? r : (r & 0x3 | 0x8);
5
+ return v.toString(16);
6
+ });
7
+ }
8
+
9
+
10
+ class Game {
11
+ constructor(containerId, pairs) {
12
+ this.containerId = containerId;
13
+ this.uniqueId = generateUUID();
14
+ this.container = document.getElementById(containerId);
15
+ this.pairs = pairs;
16
+ this.items = [];
17
+ this.dropZones = [];
18
+ this.init();
19
+ }
20
+
21
+ init() {
22
+ this.generateHTML();
23
+ this.createItems();
24
+ this.createDropZones();
25
+ this.toast = this.createToast();
26
+
27
+ document.getElementById(`check-answer-${this.uniqueId}`).addEventListener('click', () => this.checkAnswer());
28
+ document.getElementById(`reset-puzzle-${this.uniqueId}`).addEventListener('click', () => this.resetPuzzle());
29
+
30
+ document.addEventListener('mousemove', (event) => {
31
+ this.cursorX = event.clientX;
32
+ this.cursorY = event.clientY;
33
+
34
+ });
35
+ }
36
+
37
+ generateHTML() {
38
+ if (!this.container) {
39
+ throw new Error('Container not found');
40
+ }
41
+
42
+ const uniqueId = this.uniqueId;
43
+
44
+ this.container.innerHTML = `
45
+ <div id="draggable-container-${uniqueId}" class="draggable-container"></div>
46
+ <div id="dropzone-container-${uniqueId}" class="drop-zone-container"></div>
47
+ <div class="button-container">
48
+ <button id="check-answer-${uniqueId}" class="button button-run">Sjekk svaret!</button>
49
+ <button id="reset-puzzle-${uniqueId}" class="button button-reset">Reset puslespill</button>
50
+ </div>
51
+ <!-- Toast Notification -->
52
+ <div id="toast-${uniqueId}" class="toast" style="display: none;">
53
+ <p>Riktig! Bra jobba 🔥</p>
54
+ </div>
55
+ `;
56
+ }
57
+
58
+
59
+ createItems() {
60
+ const itemsContainer = document.getElementById(`draggable-container-${this.uniqueId}`);
61
+ this.pairs.forEach((group, groupIndex) => {
62
+ group.forEach((item, itemIndex) => {
63
+ const draggableItem = new DraggableItem(`item-${groupIndex}-${itemIndex}`, item, groupIndex);
64
+ this.items.push(draggableItem);
65
+ });
66
+ });
67
+
68
+ // Shuffle items before adding them to the container
69
+ this.items.sort(() => 0.5 - Math.random());
70
+ this.items.forEach((item) => itemsContainer.appendChild(item.createElement()));
71
+ }
72
+
73
+ createDropZones() {
74
+ const dropzonesContainer = document.getElementById(`dropzone-container-${this.uniqueId}`);
75
+ this.pairs.forEach((_, index) => {
76
+ const dropZone = new DropZone(index, this.uniqueId, this);
77
+ this.dropZones.push(dropZone);
78
+ dropzonesContainer.appendChild(dropZone.createElement());
79
+ });
80
+ }
81
+
82
+ getItemById(id) {
83
+ return this.items.find((item) => item.id === id);
84
+ }
85
+
86
+ getDropZoneContainingItem(item) {
87
+ return this.dropZones.find(zone => zone.items.includes(item));
88
+ }
89
+
90
+ getDraggableContainer() {
91
+ return document.getElementById(`draggable-container-${this.uniqueId}`);
92
+ }
93
+
94
+
95
+ async checkAnswer() {
96
+ const results = await Promise.all(this.dropZones.map((zone) => zone.isCorrect()));
97
+ results.forEach((isCorrect, index) => {
98
+ const dropZone = this.dropZones[index];
99
+ if (isCorrect) {
100
+ dropZone.setCorrect(); // Set drop zone to green
101
+ } else {
102
+ dropZone.setIncorrect(); // Set drop zone to red
103
+ }
104
+ });
105
+
106
+ const allCorrect = results.every(result => result);
107
+ if (allCorrect) {
108
+ this.showToast();
109
+ }
110
+ }
111
+
112
+ resetPuzzle() {
113
+ // Reset puzzle by returning all items back to the draggable container
114
+ const draggableContainer = this.getDraggableContainer();
115
+ this.items.forEach(item => {
116
+ draggableContainer.appendChild(item.element);
117
+ item.element.style.opacity = '1';
118
+ });
119
+
120
+ // Clear the drop zones
121
+ this.dropZones.forEach(zone => zone.clear());
122
+ }
123
+
124
+ createToast() {
125
+ const toast = document.createElement('div');
126
+ toast.id = `toast-${this.uniqueId}`;
127
+ toast.className = 'toast';
128
+ toast.style.display = 'none';
129
+ toast.innerHTML = `
130
+ <p>Riktig! 🔥</p>
131
+ `;
132
+
133
+ document.body.appendChild(toast);
134
+ return toast;
135
+ }
136
+
137
+ showToast() {
138
+ console.log("toast: ", this.toast);
139
+
140
+ console.log("X = ", this.cursorX);
141
+ console.log("Y = ", this.cursorY);
142
+
143
+ this.toast.style.top = `${this.cursorY - 150}px`;
144
+ this.toast.style.left = `${this.cursorX}px`;
145
+
146
+ this.toast.style.display = 'block';
147
+
148
+
149
+
150
+ setTimeout(() => {
151
+ this.toast.style.display = 'none';
152
+ }, 2500); // Display for 2.5 seconds (2000 ms)
153
+
154
+ }
155
+ }
156
+
157
+
158
+ function initGame(containerId, pairs) {
159
+ return new Game(containerId, pairs);
160
+ }