Skip to content

Commit

Permalink
Update #886bwwnb0j - Refactor for Moodle 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentcornelis committed Feb 29, 2024
1 parent 8e84ad7 commit 44b1b2a
Show file tree
Hide file tree
Showing 33 changed files with 1,090 additions and 1,220 deletions.
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Types of changes
* **Security** in case of vulnerabilities.


## Version (4.2.0) - 2024-02-29
- Upgraded and refactored for Moodle 4.2
- Deprecated support for versions before Moodle 3.9 and PHP 7.4

## Version (4.0.1) - 2022-08-08
##### Changed
- No double activity description
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Special thanks to Gemma Lesterhuis ([Lesterhuis Training & Consultancy](https://

* Author: Luuk Verhoeven, [MFreak.nl](https://MFreak.nl/)
* Author: Gemma Lesterhuis, [Lesterhuis Training & Consultancy](https://ltnc.nl/)
* Min. required: Moodle 3.5.x
* Min. required: Moodle 3.9.x
* Max. Required: Moodle 4.1.x
* Supports PHP: 7.2 - 8.0
* Supports PHP: 7.4 - 8.1

![Moodle35](https://img.shields.io/badge/moodle-3.5-brightgreen.svg)
![Moodle36](https://img.shields.io/badge/moodle-3.6-brightgreen.svg)
![Moodle37](https://img.shields.io/badge/moodle-3.7-brightgreen.svg)
![Moodle38](https://img.shields.io/badge/moodle-3.8-brightgreen.svg)
![Moodle39](https://img.shields.io/badge/moodle-3.9-brightgreen.svg)
![Moodle310](https://img.shields.io/badge/moodle-3.10-brightgreen.svg)
![PHP7.2](https://img.shields.io/badge/PHP-7.2-brightgreen.svg)
[![Build Status](https://travis-ci.org/MFreakNL/moodle-mod_gcanvas.svg?branch=master)](https://travis-ci.org/MFreakNL/moodle-mod_gcanvas)
![Moodle402](https://img.shields.io/badge/moodle-4.2-brightgreen.svg)

![PHP7.4](https://img.shields.io/badge/PHP-7.2-blue.svg)
![PHP8.0](https://img.shields.io/badge/PHP-8.0-blue.svg)
![PHP8.1](https://img.shields.io/badge/PHP-8.1-blue.svg)

## Screens

<img src="https://content.screencast.com/users/LuukVerhoeven/folders/Snagit/media/3ec4223b-20ba-4757-a6ff-407ee2d6078f/11.07.2018-14.47.png" width="600" border="0" />
Expand Down
16 changes: 12 additions & 4 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@
* @copyright 9-10-2018 MFreak.nl
* @author Luuk Verhoeven
**/
define('AJAX_SCRIPT', true);
define('NO_DEBUG_DISPLAY', true);

require_once(__DIR__ . '/../../config.php');
defined('MOODLE_INTERNAL') || die;
require_once(__DIR__ . '/../../config.php');

/**
* @var bool AJAX_SCRIPT
*/
const AJAX_SCRIPT = true;

/**
* @var bool NO_DEBUG_DISPLAY
*/
const NO_DEBUG_DISPLAY = true;

$action = optional_param('action', '', PARAM_TEXT);
$data = (object)optional_param('data', [], PARAM_RAW);
Expand Down Expand Up @@ -58,4 +66,4 @@
$return = $ajax->{'callable_' . $action}();
}

echo json_encode($return);
echo json_encode($return);
5 changes: 2 additions & 3 deletions amd/src/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @package local_commander
* @copyright 2018 MFreak.nl
* @author Luuk Verhoeven
**/
Expand Down Expand Up @@ -484,7 +483,7 @@ define(['jquery', 'core/notification'], function($, notification) {
*/
setBackgroundImage: function() {

if (opts.background !== '') {
if (opts.background !== '' && opts.background !== 'false') {
fabric.Image.fromURL(opts.background, function(img) {
// Add background image.
canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas), {
Expand Down Expand Up @@ -1003,4 +1002,4 @@ define(['jquery', 'core/notification'], function($, notification) {
});
}
};
});
});
13 changes: 7 additions & 6 deletions backup/moodle2/backup_gcanvas_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ class backup_gcanvas_activity_task extends backup_activity_task {
/**
* Defines particular settings for the plugin.
*/
protected function define_my_settings() {

protected function define_my_settings(): void {
// No defined settings.
}

/**
* Defines particular steps for the backup process.
*
* @throws base_task_exception
*/
protected function define_my_steps() : void {
protected function define_my_steps(): void {
$this->add_step(new backup_gcanvas_activity_structure_step('gcanvas_structure', 'gcanvas.xml'));
}

/**
* Codes the transformations to perform in the activity in order to get transportable (encoded) links.
*
* @param string $content .
* @param string $content
*
* @return string.
* @return string
*/
public static function encode_content_links($content) : string {
public static function encode_content_links($content): string {
global $CFG;

$base = preg_quote($CFG->wwwroot, "/");
Expand All @@ -73,4 +73,5 @@ public static function encode_content_links($content) : string {

return $content;
}

}
5 changes: 2 additions & 3 deletions backup/moodle2/backup_gcanvas_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Define the complete structure for backup, with file and id annotations.
*
Expand All @@ -44,7 +42,7 @@ class backup_gcanvas_activity_structure_step extends backup_activity_structure_s
* @throws base_element_struct_exception
* @throws base_step_exception
*/
protected function define_structure() : backup_nested_element {
protected function define_structure(): backup_nested_element {

$userinfo = $this->get_setting_value('userinfo');

Expand Down Expand Up @@ -89,4 +87,5 @@ protected function define_structure() : backup_nested_element {
// Return the root element (gcanvas), wrapped into standard activity structure.
return $this->prepare_activity_structure($gcanvas);
}

}
21 changes: 11 additions & 10 deletions backup/moodle2/restore_gcanvas_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ class restore_gcanvas_activity_task extends restore_activity_task {
* Defines particular settings that this activity can have.
*/
protected function define_my_settings() {

// No defined settings.
}

/**
* Defines particular steps that this activity can have.
*
* @return void .
* @return void
* @throws base_task_exception
*/
protected function define_my_steps() : void {
protected function define_my_steps(): void {
$this->add_step(new restore_gcanvas_activity_structure_step('gcanvas_structure', 'gcanvas.xml'));
}

/**
* Defines the contents in the activity that must be processed by the link decoder.
*
* @return array.
* @return array
*/
public static function define_decode_contents() : array {
public static function define_decode_contents(): array {
$contents = [];
$contents[] = new restore_decode_content('gcanvas', ['intro', 'helptext'], 'gcanvas');

Expand All @@ -66,9 +66,9 @@ public static function define_decode_contents() : array {
/**
* Defines the decoding rules for links belonging to the activity to be executed by the link decoder.
*
* @return array.
* @return array
*/
public static function define_decode_rules() : array {
public static function define_decode_rules(): array {
$rules = [];

// Define the rules.
Expand All @@ -77,16 +77,17 @@ public static function define_decode_rules() : array {
}

/**
* Defines the restore log rules that will be applied by the
* Defines the restore log rules that will be applied
* when restoring mod_gcanvas logs. It must return one array of objects.
*
* @return array.
* @return array
*/
public static function define_restore_log_rules() : array {
public static function define_restore_log_rules(): array {
$rules = [];

// Define the rules.

return $rules;
}

}
15 changes: 7 additions & 8 deletions backup/moodle2/restore_gcanvas_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Defines the structure step to restore one mod_gcanvas activity.
*
Expand All @@ -35,9 +33,9 @@ class restore_gcanvas_activity_structure_step extends restore_activity_structure
/**
* Defines the structure to be restored.
*
* @return restore_path_element[].
* @return restore_path_element[]
*/
protected function define_structure() : array {
protected function define_structure(): array {
$paths = [];
$paths[] = new restore_path_element('gcanvas', '/activity/gcanvas');

Expand All @@ -46,17 +44,17 @@ protected function define_structure() : array {
}

/**
* process_gcanvas
* Process gcanvas
*
* @param stdClass $data
*
* @throws base_step_exception
* @throws dml_exception
*/
protected function process_gcanvas($data) : void {
protected function process_gcanvas($data): void {
global $DB;

$data = (object)$data;
$data = (object) $data;
$oldid = $data->id;
$data->course = $this->get_courseid();

Expand All @@ -72,12 +70,13 @@ protected function process_gcanvas($data) : void {
/**
* after_execute
*/
protected function after_execute() : void {
protected function after_execute(): void {
// Add page related files, no need to match by itemname (just internally handled context).
$this->add_related_files('mod_gcanvas', 'intro', 'gcanvas');
$this->add_related_files('mod_gcanvas', 'helptext', 'gcanvas');
$this->add_related_files('mod_gcanvas', 'background', 'gcanvas');
$this->add_related_files('mod_gcanvas', 'toolbar_shape', 'gcanvas');
$this->add_related_files('mod_gcanvas', 'attempt', 'gcanvas_attempt');
}

}
Loading

0 comments on commit 44b1b2a

Please sign in to comment.