Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AAU-P5-Moodle/moodle-2 into 10-home…
Browse files Browse the repository at this point in the history
…work-teacher-feature-be-able-to-add-links-for-other-sources
  • Loading branch information
Verdoner committed Oct 23, 2024
2 parents 93da1bd + 0692152 commit 4019be4
Show file tree
Hide file tree
Showing 447 changed files with 203 additions and 52,111 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ server/mysql/data/mysql_error.log
/server/apache/
/server/moodle/.grunt/
/server/moodle/calendar/
/server/moodle/blocks/
/server/moodle/grade/
/server/moodle/enrol/
/server/moodle/auth/
Expand Down Expand Up @@ -150,4 +149,4 @@ server/mysql/data/mysql_error.log
/server/moodle/mod/glossary/
/server/moodle/mod/workshop/
/server/moodle/mod/lesson/
/server/moodle/mod/assign/
/server/moodle/mod/assign/
1 change: 1 addition & 0 deletions .idea/moodle-2.iml

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

Binary file removed server/.DS_Store
Binary file not shown.
65 changes: 0 additions & 65 deletions server/apache/logs/install.log

This file was deleted.

Empty file removed server/apache/logs/ssl_request.log
Empty file.

This file was deleted.

This file was deleted.

55 changes: 0 additions & 55 deletions server/moodle/auth/cas/CAS/vendor/apereo/phpcas/composer.json

This file was deleted.

3 changes: 3 additions & 0 deletions server/moodle/blocks/homework/amd/build/scroll.min.js

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

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Block definition class for the block_homeworkfeed plugin.
* Block definition class for the block_homework plugin.
*
* @package block_homeworkfeed
* @package block_homework
* @copyright Year, You Name <[email protected]>
* @author group 11
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,11 +26,12 @@
// Checks for Moodle environment
defined('MOODLE_INTERNAL') || die();

class block_homeworkfeed extends block_base {

class block_homework extends block_base {

//constructor for the block
public function init() {
$this->title = get_string('homeworkfeed', 'block_homeworkfeed');
$this->title = get_string('homework', 'block_homework');
}

/**
Expand All @@ -40,7 +41,7 @@ public function get_content() {

global $OUTPUT, $PAGE, $DB;

$homeworks = $DB->get_records('Homework');
$homeworks = $DB->get_records('homework');
$data = [];

if ($this->content !== null) {
Expand All @@ -49,21 +50,25 @@ public function get_content() {

$this->content = new stdClass();

//If the current page is a course then remove unrelated homework
if ($PAGE->pagetype == 'course-view-topics') {
$homeworks = $this->filter_homework_content($PAGE->url, $homeworks);
}

foreach($homeworks as $homework) {
$tmp = [];
$tmp['name'] = $homework->name;
$tmp['duedate'] = $homework->duedate;
$tmp['description'] = $homework->description;
$tmp['intro'] = strip_tags($homework->intro);
$tmp['courseTitle'] = $DB->get_field('course', 'fullname', ['id' => $homework->course]);

$files = [];

//Get ids of homeworkfiles
$fileids = [];
$homeworkfiles = $DB->get_records('Files_homework', ['id'=>$homework->id]);
$homeworkfiles = $DB->get_records('files_homework', ['files_id'=>$homework->id]);
foreach ($homeworkfiles as $homeworkfile) {
array_push($fileids, $homeworkfile->Files_id);
array_push($fileids, $homeworkfile->files_id);
}

//Get file records
Expand Down Expand Up @@ -103,22 +108,40 @@ public function get_content() {
array_push($data, $tmp);
}


// Render the content using a template and pass the homework data to it
$this->content->text = $OUTPUT->render_from_template('block_homeworkfeed/data', ['data' => $data]);
$this->content->text = $OUTPUT->render_from_template('block_homework/data', ['data' => $data]);

// Include JavaScript functionality for scrolling behavior in the block
$PAGE->requires->js_call_amd('block_homeworkfeed/scroll', 'init');
$PAGE->requires->js_call_amd('block_homework/scroll', 'init');

return $this->content;
}

public static function filter_homework_content($URL,$homeworks): array
{
//Use a regex to remove everything but digits from the url
$courseid = preg_replace('/\D/', '',$URL);
$tmpHomeworks = [];

//Check each homework to see if the course matches the id
foreach ($homeworks as $homework) {
if($courseid == $homework->course){
array_push($tmpHomeworks, $homework);
}
}
return $tmpHomeworks;
}


/**
* Specifies where this block can be displayed in Moodle
*/
public function applicable_formats() {
return [
'admin' => false,
'site-index' => false,
'course-view' => false,
'course-view' => true,
'mod' => false,
'my' => true,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
/**
* Block definition class for the block_homeworkfeed plugin.
* Block definition class for the block_homework plugin.
*
* @package block_homeworkfeed
* @package block_homework
* @copyright Year, You Name <[email protected]>
* @author group 11
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = [
'block/homeworkfeed:myaddinstance' => [
'block/homework:myaddinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'user' => CAP_ALLOW
],
'clonepermissionsfrom' => 'moodle/my:manageblocks'
],
'block/homeworkfeed:addinstance' => [
'block/homework:addinstance' => [
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
Expand Down
Loading

0 comments on commit 4019be4

Please sign in to comment.