cognikit 0.2.0 → 1.0.1
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.
- package/README.md +309 -237
- package/dist/client.js +194 -117
- package/dist/client.js.map +3 -3
- package/dist/index.js +225 -148
- package/dist/index.js.map +3 -3
- package/dist/interactions/shared/classification-implementation/grader.d.ts +1 -1
- package/dist/shell/simple-shell/script.d.ts +2 -1
- package/package.json +1 -1
- package/public/app.js +165 -110
- package/public/app.js.map +2 -2
- package/public/assets/DEMONSTRATION-1.jpeg +0 -0
- package/public/index.html +68 -16
|
Binary file
|
package/public/index.html
CHANGED
|
@@ -392,12 +392,8 @@
|
|
|
392
392
|
|
|
393
393
|
<div class="form-group">
|
|
394
394
|
<label for="theme-select">Theme</label>
|
|
395
|
-
<select id="theme-select">
|
|
396
|
-
|
|
397
|
-
<option value="dark">Dark</option>
|
|
398
|
-
<option value="dark-blue">Dark Blue</option>
|
|
399
|
-
</select>
|
|
400
|
-
<div class="form-help">Theme switching not yet implemented</div>
|
|
395
|
+
<select id="theme-select"></select>
|
|
396
|
+
<div class="form-help">Uses Cognikit theme presets directly in the preview.</div>
|
|
401
397
|
</div>
|
|
402
398
|
|
|
403
399
|
<div class="form-group">
|
|
@@ -475,13 +471,17 @@
|
|
|
475
471
|
RankOrder,
|
|
476
472
|
ListRecall,
|
|
477
473
|
MCQ,
|
|
474
|
+
getCognikitThemePresets,
|
|
478
475
|
parseYamlAssets,
|
|
476
|
+
setCognikitTheme,
|
|
479
477
|
validateAndNormalizeAssets
|
|
480
478
|
} from './app.js';
|
|
481
479
|
|
|
482
480
|
// State
|
|
483
481
|
let currentVariant = 'elegant';
|
|
482
|
+
let currentTheme = 'default-light';
|
|
484
483
|
let currentInteraction = null;
|
|
484
|
+
const themePresets = getCognikitThemePresets();
|
|
485
485
|
|
|
486
486
|
// DOM Elements
|
|
487
487
|
const viewport = document.getElementById('interaction-viewport');
|
|
@@ -501,6 +501,7 @@
|
|
|
501
501
|
|
|
502
502
|
// Form Elements
|
|
503
503
|
const variantSelect = document.getElementById('variant-select');
|
|
504
|
+
const themeSelect = document.getElementById('theme-select');
|
|
504
505
|
const accentColor = document.getElementById('accent-color');
|
|
505
506
|
const interactionType = document.getElementById('interaction-type');
|
|
506
507
|
const interactionHeading = document.getElementById('interaction-heading');
|
|
@@ -516,6 +517,45 @@
|
|
|
516
517
|
function closeModal(modal) {
|
|
517
518
|
modal.classList.remove('active');
|
|
518
519
|
}
|
|
520
|
+
|
|
521
|
+
function rgbTripletToCss(rgbTriplet) {
|
|
522
|
+
return `rgb(${rgbTriplet.trim().split(/\s+/).join(', ')})`;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function rgbTripletToHex(rgbTriplet) {
|
|
526
|
+
const [r, g, b] = rgbTriplet.trim().split(/\s+/).map(Number);
|
|
527
|
+
return `#${[r, g, b].map((value) => value.toString(16).padStart(2, '0')).join('')}`;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function syncThemeMeta(themeName) {
|
|
531
|
+
const theme = themePresets[themeName];
|
|
532
|
+
const metaTheme = document.querySelector('meta[name="theme-color"]');
|
|
533
|
+
if (theme && metaTheme) {
|
|
534
|
+
metaTheme.setAttribute('content', rgbTripletToCss(theme["--edu-bg"]));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function applyTheme(themeName) {
|
|
539
|
+
currentTheme = themeName;
|
|
540
|
+
setCognikitTheme(themeName);
|
|
541
|
+
syncThemeMeta(themeName);
|
|
542
|
+
|
|
543
|
+
const theme = themePresets[themeName];
|
|
544
|
+
if (theme) {
|
|
545
|
+
accentColor.value = rgbTripletToHex(theme["--edu-first-accent"]);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function populateThemes() {
|
|
550
|
+
themeSelect.innerHTML = Object.keys(themePresets).map((themeName) => {
|
|
551
|
+
const label = themeName
|
|
552
|
+
.split('-')
|
|
553
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
554
|
+
.join(' ');
|
|
555
|
+
const selected = themeName === currentTheme ? 'selected' : '';
|
|
556
|
+
return `<option value="${themeName}" ${selected}>${label}</option>`;
|
|
557
|
+
}).join('');
|
|
558
|
+
}
|
|
519
559
|
|
|
520
560
|
accentColor.addEventListener('change', (e) => {
|
|
521
561
|
const color = e.target.value;
|
|
@@ -547,6 +587,7 @@
|
|
|
547
587
|
// Settings Apply
|
|
548
588
|
settingsApply.addEventListener('click', () => {
|
|
549
589
|
currentVariant = variantSelect.value;
|
|
590
|
+
applyTheme(themeSelect.value);
|
|
550
591
|
if (viewport) {
|
|
551
592
|
currentInteraction.onVariantChange(currentVariant);
|
|
552
593
|
viewport.setAttribute('variant', currentVariant);
|
|
@@ -594,9 +635,12 @@
|
|
|
594
635
|
{ label: 'Mammals', items: ['Dog', 'Cat', 'Elephant', 'wolf'] },
|
|
595
636
|
{ label: 'Birds', items: ['Eagle', 'Sparrow'] }
|
|
596
637
|
],
|
|
597
|
-
distractors: ['
|
|
638
|
+
distractors: ['@:soup', '@:strawberry']
|
|
598
639
|
},
|
|
599
|
-
|
|
640
|
+
assets: `
|
|
641
|
+
strawberry:\n type: image\n url: https://images.unsplash.com/photo-1622921491193-345ffb510f6f?q=80&w=1171&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
|
|
642
|
+
soup:\n type: image\n url: https://plus.unsplash.com/premium_photo-1669831178095-005ed789250a?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
|
|
643
|
+
`,
|
|
600
644
|
},
|
|
601
645
|
RankOrder: {
|
|
602
646
|
data: {
|
|
@@ -619,27 +663,27 @@
|
|
|
619
663
|
{
|
|
620
664
|
question: '@:paris',
|
|
621
665
|
correctOptions: ['Paris'],
|
|
622
|
-
options: ['
|
|
666
|
+
options: ['London', 'Berlin', 'Madrid']
|
|
623
667
|
},
|
|
624
668
|
{
|
|
625
669
|
question: 'Which of these are programming languages?',
|
|
626
670
|
correctOptions: ['Python', 'JavaScript', 'Java'],
|
|
627
|
-
options: ['
|
|
671
|
+
options: ['HTML', 'CSS']
|
|
628
672
|
},
|
|
629
673
|
{
|
|
630
674
|
question: '@:exampleHtml',
|
|
631
675
|
correctOptions: ['4'],
|
|
632
|
-
options: ['3', '
|
|
676
|
+
options: ['3', '5', '6']
|
|
633
677
|
},
|
|
634
678
|
{
|
|
635
|
-
question: '@:
|
|
636
|
-
correctOptions: ['
|
|
637
|
-
options: ['
|
|
679
|
+
question: '@:movements',
|
|
680
|
+
correctOptions: ['Dancing'],
|
|
681
|
+
options: ['Sleeping', 'Cooking', 'Kissing']
|
|
638
682
|
},
|
|
639
683
|
{
|
|
640
684
|
question: '@:laugh',
|
|
641
685
|
correctOptions: ["laughing"],
|
|
642
|
-
options: ['Crying', 'Shouting'
|
|
686
|
+
options: ['Crying', 'Shouting']
|
|
643
687
|
}
|
|
644
688
|
]
|
|
645
689
|
},
|
|
@@ -651,7 +695,7 @@ exampleHtml:
|
|
|
651
695
|
content: <div style="padding:1rem;"><h3>Rich HTML Question</h3><p>What is <strong>2 + 2</strong>?</p><ul><li>Addition</li><li>Basic math</li></ul></div>
|
|
652
696
|
dialog: true
|
|
653
697
|
|
|
654
|
-
|
|
698
|
+
movements:\n type: video\n url: https://www.pexels.com/download/video/6548176\n dialog: false
|
|
655
699
|
|
|
656
700
|
laugh:\n type: audio\n url: https://www.soundjay.com/human/sounds/man-laughing-01.mp3\n dialog: true
|
|
657
701
|
`
|
|
@@ -735,6 +779,12 @@ laugh:\n type: audio\n url: https://www.soundjay.com/human/sounds/man-laughing-0
|
|
|
735
779
|
// The shell now reads everything from interaction.config
|
|
736
780
|
viewport.setInteraction(interaction);
|
|
737
781
|
|
|
782
|
+
const handler = () => {
|
|
783
|
+
alert(0);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
viewport.toggleCloseBtn(handler);
|
|
787
|
+
|
|
738
788
|
currentInteraction = interaction;
|
|
739
789
|
closeModal(configModal);
|
|
740
790
|
|
|
@@ -747,6 +797,8 @@ laugh:\n type: audio\n url: https://www.soundjay.com/human/sounds/man-laughing-0
|
|
|
747
797
|
|
|
748
798
|
// Initialize with default interaction
|
|
749
799
|
window.addEventListener('DOMContentLoaded', () => {
|
|
800
|
+
populateThemes();
|
|
801
|
+
applyTheme(currentTheme);
|
|
750
802
|
configApply.click();
|
|
751
803
|
});
|
|
752
804
|
</script>
|