diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..cb1265b --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..e9caa94 --- /dev/null +++ b/metadata.json @@ -0,0 +1,16 @@ +{ + "name": "Advanced Code Test", + "type": "assessment", + "properties": { + "type": "test", + "icon": "./icon.svg", + "defaultHeight": 500, + "gradingControls": { + "points": true, + "allowPartialPoints": true, + "useMaximumScore": true, + "definedNumberOfAttempts": true, + "rationale": true + } + } +} diff --git a/settings.css b/settings.css new file mode 100644 index 0000000..27da8ee --- /dev/null +++ b/settings.css @@ -0,0 +1,13 @@ +.settings-content-row-container { + display: flex; + flex-direction: row; + gap: 10px; +} + +.test-case-controls-container { + align-items: end; +} + +.test-case-add-case-container { + flex: 1; +} diff --git a/settings.html b/settings.html new file mode 100644 index 0000000..943ee55 --- /dev/null +++ b/settings.html @@ -0,0 +1,164 @@ + + + + + Settings + + + + + + + +
+
+ + +
+
+
+ +
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ + +
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ + +
+ +
+
+
+
+ + diff --git a/settings.js b/settings.js new file mode 100644 index 0000000..613079b --- /dev/null +++ b/settings.js @@ -0,0 +1,83 @@ +(function () { + const collectSettings = () => { + const instructions = $('#instructions').val() + const timeout = parseInt($('#timeout').val(), 10); + + return {instructions, timeout}; + } + + const exportSettings = () => { + const data = collectSettings(); + window.codioAssessmentsHelper.send(window.codioAssessmentsHelper.METHODS.EXPORT_SETTINGS_RESPONSE, data); + } + + const applySettings = (settings = {}) => { + $('#instructions').val(settings.instructions || ''); + $('#timeout').val(settings.timeout || ''); + } + + const processMessage = (jsonData) => { + console.log('settings iframe processMessage', jsonData) + try { + const {method, data} = JSON.parse(jsonData); + switch (method) { + case window.codioAssessmentsHelper.METHODS.EXPORT_SETTINGS: + exportSettings(); + break; + case window.codioAssessmentsHelper.METHODS.GET_SETTINGS_RESPONSE: + applySettings(data.settings); + break; + } + } catch {} + } + + const onSubtypeChanged = (language, subtype) => { + $('.lang-subtype-settings-container').addClass('hide') + $(`.lang-subtype-${language}-${subtype}-settings`).removeClass('hide') + } + + const onLanguageChanged = (language) => { + $('.language-settings-container').addClass('hide') + $(`.${language}-container`).removeClass('hide') + const subtype = $(`#${language}LangSubtype`).val() + onSubtypeChanged(language, subtype) + } + + const bindEvents = () => { + $('#languageType').on('change', function () { + const languageType = $(this).val(); + onLanguageChanged(languageType); + }) + $('.lang-subtype-select').on('change', function () { + const langSubtype = $(this).val(); + onSubtypeChanged($('#languageType').val(), langSubtype); + }) + + // $("html").on("dragover", function(event) { + // event.preventDefault(); + // event.stopPropagation(); + // console.log('dragover', event); + // }); + // + // $("html").on("dragleave", function(event) { + // event.preventDefault(); + // event.stopPropagation(); + // console.log('dragover', event); + // }); + + $("html").on("drop", function(event) { + event.preventDefault(); + event.stopPropagation(); + console.log('drop', event); + }); + } + + const onLoad = async () => { + window.codioAssessmentsHelper.registerMessageListener(processMessage) + window.codioAssessmentsHelper.send(window.codioAssessmentsHelper.METHODS.GET_SETTINGS) + + bindEvents() + } + + window.addEventListener('load', onLoad); +})()