From 1d44f5b8565d69ffd61ce66b98688f3c49ce595d Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:18:50 +0100 Subject: [PATCH 1/7] Prettified added styles.css --- server/moodle/mod/homework/styles.css | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 server/moodle/mod/homework/styles.css diff --git a/server/moodle/mod/homework/styles.css b/server/moodle/mod/homework/styles.css new file mode 100644 index 00000000..1f6ed38d --- /dev/null +++ b/server/moodle/mod/homework/styles.css @@ -0,0 +1,11 @@ +.homework-action-buttons button { + margin-right: 10px; +} + +.material { +border: 1px solid #ccc; +padding: 16px; +border-radius: 8px; +box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +background-color: #f9f9f9; +} \ No newline at end of file From 5d1a20afe3a57f789569cba996f5dd9d0506d718 Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:31:23 +0100 Subject: [PATCH 2/7] Update styles.css remove unnecessary padding from last button --- server/moodle/mod/homework/styles.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/moodle/mod/homework/styles.css b/server/moodle/mod/homework/styles.css index 1f6ed38d..d519a90a 100644 --- a/server/moodle/mod/homework/styles.css +++ b/server/moodle/mod/homework/styles.css @@ -2,6 +2,10 @@ margin-right: 10px; } +.homework-action-buttons button:last-child{ + margin-right: 0; +} + .material { border: 1px solid #ccc; padding: 16px; From b185ebffbf76cb745b73eaa884b498fc0651f023 Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:18:08 +0100 Subject: [PATCH 3/7] Correct indenting corrected indenting in styles.css --- server/moodle/mod/homework/styles.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/moodle/mod/homework/styles.css b/server/moodle/mod/homework/styles.css index d519a90a..4a2dac08 100644 --- a/server/moodle/mod/homework/styles.css +++ b/server/moodle/mod/homework/styles.css @@ -7,9 +7,9 @@ } .material { -border: 1px solid #ccc; -padding: 16px; -border-radius: 8px; -box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); -background-color: #f9f9f9; + border: 1px solid #ccc; + padding: 16px; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + background-color: #f9f9f9; } \ No newline at end of file From fbce11af8ec53983c895f45295d55fbe1e13cc21 Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:21:34 +0100 Subject: [PATCH 4/7] Add missing space add missing space --- server/moodle/mod/homework/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/moodle/mod/homework/styles.css b/server/moodle/mod/homework/styles.css index 4a2dac08..4ee1c1c9 100644 --- a/server/moodle/mod/homework/styles.css +++ b/server/moodle/mod/homework/styles.css @@ -2,7 +2,7 @@ margin-right: 10px; } -.homework-action-buttons button:last-child{ +.homework-action-buttons button:last-child { margin-right: 0; } From 979c228e054e0e9fbd15cf8ac838bcd66c85600e Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:27:50 +0100 Subject: [PATCH 5/7] Made changes to styles.css and edit.php Make the edit modal look like the view modal --- server/moodle/mod/homework/edit.php | 32 +++++++++++++++++---------- server/moodle/mod/homework/styles.css | 8 +++++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/server/moodle/mod/homework/edit.php b/server/moodle/mod/homework/edit.php index b82f8f2f..c197ae90 100644 --- a/server/moodle/mod/homework/edit.php +++ b/server/moodle/mod/homework/edit.php @@ -66,7 +66,6 @@ // Output the header - REQUIRED. echo $OUTPUT->header(); -echo html_writer::tag('div', 'This is the homework edit page', ['class' => 'content']); $homeworkmaterials = $DB->get_records_sql( "SELECT hm.*, f.filename @@ -85,6 +84,9 @@ * @copyright 2024, cs-24-sw-5-01 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +echo '
'; + foreach ($homeworkmaterials as $materials) : // Generate the preview URL for the file if it exists. if ($materials->file_id !== null) { @@ -104,16 +106,20 @@ } ?> -
+
+ + startpage != null): + echo ''; + elseif ($materials->link != null): + echo ''; + elseif ($materials->starttime != null): + echo ''; + elseif ($materials->file_id != null): + echo ''; + endif; ?> + +
+

description) ?>

startpage !== null && $materials->endpage !== null) : ?>

file_id !== null && isset($previewurl)) : ?> filename, PATHINFO_EXTENSION)) === 'mp4') : ?> -

+
+ *:first-child { font-size: 20px; font-weight: bold; +} + +.homework-action-buttons button { + margin-right: 10px; +} + +.homework-action-buttons button:last-child { + margin-right: 0; } \ No newline at end of file From eb16e3c4e07159ef5afeb6a635bf85542547cc4e Mon Sep 17 00:00:00 2001 From: Not-Brundle <113098403+Not-Brundle@users.noreply.github.com> Date: Wed, 4 Dec 2024 02:10:15 +0100 Subject: [PATCH 6/7] prettified homework chooser Created a mustache file for get_homework_chooser.php. Addet css code to styles.css --- .../classes/external/get_homework_chooser.php | 48 +++-------- server/moodle/mod/homework/styles.css | 86 ++++++++++++++++++- .../templates/get_homework_chooser.mustache | 41 +++++++++ 3 files changed, 137 insertions(+), 38 deletions(-) create mode 100644 server/moodle/mod/homework/templates/get_homework_chooser.mustache diff --git a/server/moodle/mod/homework/classes/external/get_homework_chooser.php b/server/moodle/mod/homework/classes/external/get_homework_chooser.php index eeb8f86c..65f5b0a5 100644 --- a/server/moodle/mod/homework/classes/external/get_homework_chooser.php +++ b/server/moodle/mod/homework/classes/external/get_homework_chooser.php @@ -29,10 +29,12 @@ global $CFG; +use core\exception\coding_exception; use core_external\external_api; use core_external\external_function_parameters; use core_external\external_value; use core_external\external_single_structure; +use core\output\mustache_engine; /** * @@ -53,51 +55,23 @@ public static function execute_parameters() { * @param $cmid - The current modules id * @return string[] - The html to be shown client-side */ - public static function execute($cmid) { - global $DB; + public static function execute() : array { + $mustache = new Mustache_Engine(); - // Custom HTML for the homework chooser modal. - $html = ' -
-
-
-

-
-
-
- -
-
-
-
- - - - - -
-
-
- - - - - -
-
-
-
-
-
-
- '; + $templatepath = __DIR__ . "/../../templates/get_homework_chooser.mustache"; + if (!file_exists($templatepath)) { + throw new coding_exception("Template file does not exist: " . $templatepath); + } + $templatecontent = file_get_contents($templatepath); - return ['html' => $html]; + return ['html' => $mustache->render($templatecontent)]; } /** * * @return external_single_structure - Is a definition of the functions return type and a description of it */ - public static function execute_returns() { + public static function execute_returns() : external_single_structure { return new external_single_structure([ 'html' => new external_value(PARAM_RAW, 'HTML for the homework chooser modal'), ]); diff --git a/server/moodle/mod/homework/styles.css b/server/moodle/mod/homework/styles.css index 6c96201c..1ecd4cbe 100644 --- a/server/moodle/mod/homework/styles.css +++ b/server/moodle/mod/homework/styles.css @@ -49,4 +49,88 @@ .homework-action-buttons button:last-child { margin-right: 0; -} \ No newline at end of file +} + + +/* Below is the styling for the homework chooser modal */ +#homework-chooser-modal { + padding: 10px 20px; +} + +#homework-chooser-modal .block { + display: block; +} + +#homework-chooser-modal .maxw-100 { + max-width: 125px; +} + +#homework-chooser-modal .w-full { + width: 100%; +} + +#homework-chooser-modal .inline-flex { + display: flex; + flex-direction: row; + justify-content: flex-start; + flex-wrap: nowrap; + align-items: center; + gap: 5px; +} + +#homework-chooser-modal .mb-10 { + margin-bottom: 10px; +} + +#homework-chooser-modal .mb-20 { + margin-bottom: 20px; +} + +#homework-chooser-modal .flex-grow { + flex: 1; +} + +form label { + font-weight: bold; +} + +textarea { + width: 100%; + height: 80px; + padding: 10px; + border: 1px solid black; + border-radius: 4px; +} + +input[type="text"], +input[type="url"], +input[type="number"] { + padding: 10px; + border: 1px solid black; + border-radius: 4px; +} + + +.page-range-input, .video-time-input { + gap: 5px; + margin-bottom: 10px; +} + +#dropzone-container { + padding: 20px; + margin-top: 10px; +} + +#file-content { + min-height: 43px; + padding: 10px; +} + +#file-content:empty:before { + content:attr(data-placeholder); + color: grey; +} + +#file-content p { + margin-bottom: 0; +} diff --git a/server/moodle/mod/homework/templates/get_homework_chooser.mustache b/server/moodle/mod/homework/templates/get_homework_chooser.mustache new file mode 100644 index 00000000..17fb1889 --- /dev/null +++ b/server/moodle/mod/homework/templates/get_homework_chooser.mustache @@ -0,0 +1,41 @@ +
+
+
+ + +
+
+ + +
+
+
+ +
+ + - + + +
+
+
+ +
+ + + - + + +
+
+
+
+
+
Attached file:
+
+
+
+
+
+
\ No newline at end of file From ac1b98c890a68b923a3d5368249980c6ff532547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolaj=20Skj=C3=B8dt?= Date: Wed, 4 Dec 2024 10:47:29 +0100 Subject: [PATCH 7/7] Added id for html elements necessary for tests to pass --- server/moodle/mod/homework/amd/build/eventlinker.min.js.map | 1 + .../mod/homework/templates/get_homework_chooser.mustache | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 server/moodle/mod/homework/amd/build/eventlinker.min.js.map diff --git a/server/moodle/mod/homework/amd/build/eventlinker.min.js.map b/server/moodle/mod/homework/amd/build/eventlinker.min.js.map new file mode 100644 index 00000000..b9b6b66f --- /dev/null +++ b/server/moodle/mod/homework/amd/build/eventlinker.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"eventlinker.min.js","sources":["../src/eventlinker.js"],"sourcesContent":["import Modal from 'core/modal';\nimport Ajax from \"../../../../lib/amd/src/ajax\";\n\n/**\n * Creates the event linker modal.\n *\n * @param {int} cmid\n * @param {int} homeworkid\n */\nexport const init = async(cmid, homeworkid) => {\n // Add an eventlistner to the open event linker button.\n document.querySelector('#open-event-linker').addEventListener('click', async()=>{\n\n // Call the server to get all avalible events.\n Ajax.call([{\n methodname: 'mod_homework_get_events_for_homework',\n args: {homeworkid: homeworkid},\n done: async function(response) {\n // Create a modal for the user to link events and homework.\n const modal = await Modal.create({\n title: 'Homework event linker',\n body: response.events,\n footer: '\\n' +\n '',\n show: true,\n removeOnClose: true,\n });\n\n modal.show();\n // If there is nothing to link then hide submit and cancel buttons.\n if (response.events.includes(\"There are no available events to link\")) {\n modal.hideFooter();\n }\n\n // Attach event listeners for buttons\n modal.getRoot().on('click', '[data-action=\"submit\"]', (e) => {\n e.preventDefault();\n submitEventLink(modal, homeworkid, cmid);\n });\n modal.getRoot().on('click', '[data-action=\"cancel\"]', (e) => {\n e.preventDefault();\n modal.destroy();\n location.reload();\n });\n },\n fail: (error) => {\n console.error(\"Fail:\", error);\n },\n }]);\n\n\n });\n\n\n};\n\n/**\n * Sumbits the event and homework to link.\n *\n * @param {modal} modal\n * @param {int} homeworkid\n * @param {int} cmid\n */\nfunction submitEventLink(modal, homeworkid, cmid) {\n\n // Get the selected event\n let form = document.getElementById(\"evntlinkerform\");\n let selectedEvent = form.querySelector('input[name=\"eventtolink\"]:checked');\n\n // If there are non click then complain\n\n if (!selectedEvent) {\n alert(\"Please select an event!\");\n } else {\n // Submit the event to link\n Ajax.call([{\n methodname: 'mod_homework_homework_event_link',\n args: {homeworkid: homeworkid, course_module_id: cmid, eventid: selectedEvent.value},\n done: async function(response) {\n modal.destroy();\n location.reload();\n },\n fail: (error) =>{\n console.log(\"Error: \", error);\n }\n }]);\n }\n\n\n}"],"names":["_interopRequireDefault","e","__esModule","default","_modal","_ajax","_exports","init","async","cmid","homeworkid","document","querySelector","addEventListener","Ajax","call","methodname","args","done","response","modal","Modal","create","title","body","events","footer","show","removeOnClose","includes","hideFooter","getRoot","on","preventDefault","selectedEvent","getElementById","course_module_id","eventid","value","destroy","location","reload","fail","error","console","log","alert","submitEventLink"],"mappings":"2HACgD,SAAAA,uBAAAC,GAAAA,OAAAA,GAAAA,EAAAC,WAAAD,EAAAE,CAAAA,QAAAF,EAAA,8EADhDG,OAAAJ,uBAAAI,QACAC,MAAAL,uBAAAK,OAqDEC,SAAAC,KA7CkBC,MAAMC,KAAMC,cAE5BC,SAASC,cAAc,sBAAsBC,iBAAiB,SAASL,UAGnEM,MAAIX,QAACY,KAAK,CAAC,CACPC,WAAY,uCACZC,KAAM,CAACP,WAAYA,YACnBQ,KAAMV,eAAeW,UAEb,MAAMC,YAAcC,OAAKlB,QAACmB,OAAO,CAC7BC,MAAO,wBACPC,KAAML,SAASM,OACfC,OAAQ,2KAERC,MAAM,EACNC,eAAe,IAGnBR,MAAMO,OAEFR,SAASM,OAAOI,SAAS,0CACzBT,MAAMU,aAIVV,MAAMW,UAAUC,GAAG,QAAS,0BAA2B/B,IACnDA,EAAEgC,iBA2B1B,SAAyBb,MAAOV,WAAYD,MAGxC,IACIyB,cADOvB,SAASwB,eAAe,kBACVvB,cAAc,qCAIlCsB,cAIDpB,MAAIX,QAACY,KAAK,CAAC,CACPC,WAAY,mCACZC,KAAM,CAACP,WAAYA,WAAY0B,iBAAkB3B,KAAM4B,QAASH,cAAcI,OAC9EpB,KAAMV,eAAeW,UACjBC,MAAMmB,UACNC,SAASC,QACZ,EACDC,KAAOC,QACHC,QAAQC,IAAI,UAAWF,MAAM,KAXrCG,MAAM,0BAiBd,CApDwBC,CAAgB3B,MAAOV,WAAYD,KAAK,IAE5CW,MAAMW,UAAUC,GAAG,QAAS,0BAA2B/B,IACnDA,EAAEgC,iBACFb,MAAMmB,UACNC,SAASC,QAAQ,GAE5B,EACDC,KAAOC,QACHC,QAAQD,MAAM,QAASA,MAAM,IAElC,GAGL,CAsCL"} \ No newline at end of file diff --git a/server/moodle/mod/homework/templates/get_homework_chooser.mustache b/server/moodle/mod/homework/templates/get_homework_chooser.mustache index 17fb1889..b1584429 100644 --- a/server/moodle/mod/homework/templates/get_homework_chooser.mustache +++ b/server/moodle/mod/homework/templates/get_homework_chooser.mustache @@ -5,12 +5,12 @@
-
+
-
+
@@ -19,7 +19,7 @@
-
+