Skip to content

Commit

Permalink
Merge branch 'main' into 31-homework-student-feature-pretify-the-prep…
Browse files Browse the repository at this point in the history
…aration-feed
  • Loading branch information
Not-Brundle authored Nov 21, 2024
2 parents 0c6b516 + f5a4295 commit 908b02c
Show file tree
Hide file tree
Showing 17 changed files with 557 additions and 33 deletions.
11 changes: 11 additions & 0 deletions server/moodle/blocks/homework/amd/build/filter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/moodle/blocks/homework/amd/build/filter.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions server/moodle/blocks/homework/amd/src/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import $ from 'jquery';
import Ajax from 'core/ajax';
/**
* Homework/amd/src/filter.js
*
* @package
* @copyright 2024, cs-24-sw-5-13 <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/

export const init = async() => {
let courses;
Ajax.call([{
methodname: 'block_homework_get_courses',
args: {},
done: async function(response) {
courses = JSON.parse(response.courses);
for (const course in courses) {
$('#filter').append('<option value="' + courses[course].fullname + '">' + courses[course].fullname + '</option>');
}
},
fail: (error) => {
throw new Error(`Failed to find courses: ${error}`);
}
}]);
$('#filter').on('change', () => {
Ajax.call([{
methodname: 'block_homework_filter_homework',
args: {filter: $('#filter').val()},
done: async function(response) {
let homeworks = JSON.parse(response.homework);
document.getElementById("outer-box").innerHTML = "";
homeworks.forEach((homework) => {
console.log(homework);
let box = document.createElement("div");
box.classList.add("infobox");

let h22 = document.createElement("h2");
h22.innerHTML = `${homework.course}`;
box.appendChild(h22);

let h2 = document.createElement("h2");
h2.innerHTML = `${homework.name}`;
box.appendChild(h2);

let h3 = document.createElement("h3");
h3.innerHTML = homework.duedate;
box.appendChild(h3);

let p = document.createElement("p");
p.innerHTML = `${homework.intro}`;
box.appendChild(p);

let button = document.createElement("button");
button.classList.add("Timebutton");
button.innerHTML = "Time";
box.appendChild(button);

document.getElementById("outer-box").appendChild(box);
});
},
fail: (error) => {
console.log(error);
throw new Error(`Failed to find filtered homework: ${error}`);
}
}]);
});
};
1 change: 0 additions & 1 deletion server/moodle/blocks/homework/amd/src/homework_injector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
define(function() {
return {
init: function(homework) {

//Check that the current page contains a calendar to stop the code on other pages with homework block.
if (document.querySelector('[data-region="calendar"]') && JSON.stringify(homework).length > 1) {

Expand Down
Loading

0 comments on commit 908b02c

Please sign in to comment.