Skip to content

Commit

Permalink
Merge branch 'MOODLE39'
Browse files Browse the repository at this point in the history
  • Loading branch information
luukverhoeven committed Jul 16, 2020
2 parents 5bc586c + e627643 commit 8e285d3
Show file tree
Hide file tree
Showing 25 changed files with 9,176 additions and 78 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*dockermd_*/
node_modules/
node_modules/
privacy_test.php
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Types of changes
* **Fixed** for any bug fixes.
* **Security** in case of vulnerabilities.

# Version (3.9) - 2020-05-06

### Changed
- Updated version number, no issues found.
- Minimum version PHP 7.2
- Add core_userlist_provider

## Version (3.8.0) - 2019-10-11
### Changed
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

module.exports = function (grunt) {
module.exports = function(grunt) {
// Running local with
// First time npm install
// nvm use 8.9
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Special thanks to Gemma Lesterhuis ([Lesterhuis Training & Consultancy](https://
![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)
![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)
## Screens
Expand Down
2 changes: 1 addition & 1 deletion amd/src/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* JS Canvas
*
* Tested in Moodle 3.5
* Tested in Moodle 3.9
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
Expand Down
6 changes: 4 additions & 2 deletions backup/moodle2/backup_gcanvas_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ protected function define_my_settings() {

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

Expand All @@ -56,7 +58,7 @@ protected function define_my_steps() {
*
* @return string.
*/
static public function encode_content_links($content) {
public static function encode_content_links($content): string {
global $CFG;

$base = preg_quote($CFG->wwwroot, "/");
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/backup_gcanvas_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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() {
protected function define_structure() : backup_nested_element{

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

Expand Down
9 changes: 4 additions & 5 deletions backup/moodle2/restore_gcanvas_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ protected function define_my_settings() {
*
* @return void .
* @throws base_task_exception
* @throws restore_step_exception
*/
protected function define_my_steps() {
protected function define_my_steps() : void {
$this->add_step(new restore_gcanvas_activity_structure_step('gcanvas_structure', 'gcanvas.xml'));
}

Expand All @@ -57,7 +56,7 @@ protected function define_my_steps() {
*
* @return array.
*/
static public function define_decode_contents() {
public static function define_decode_contents() : array{
$contents = [];
$contents[] = new restore_decode_content('gcanvas', ['intro', 'helptext'], 'gcanvas');

Expand All @@ -69,7 +68,7 @@ static public function define_decode_contents() {
*
* @return array.
*/
static public function define_decode_rules() {
public static function define_decode_rules() : array {
$rules = [];

// Define the rules.
Expand All @@ -84,7 +83,7 @@ static public function define_decode_rules() {
*
* @return array.
*/
static public function define_restore_log_rules() {
public static function define_restore_log_rules() : array{
$rules = [];

// Define the rules.
Expand Down
6 changes: 3 additions & 3 deletions backup/moodle2/restore_gcanvas_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class restore_gcanvas_activity_structure_step extends restore_activity_structure
*
* @return restore_path_element[].
*/
protected function define_structure() {
protected function define_structure() : array {
$paths = [];
$paths[] = new restore_path_element('gcanvas', '/activity/gcanvas');

Expand All @@ -53,7 +53,7 @@ protected function define_structure() {
* @throws base_step_exception
* @throws dml_exception
*/
protected function process_gcanvas($data) {
protected function process_gcanvas($data) : void {
global $DB;

$data = (object)$data;
Expand All @@ -72,7 +72,7 @@ protected function process_gcanvas($data) {
/**
* after_execute
*/
protected function after_execute() {
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');
Expand Down
25 changes: 13 additions & 12 deletions classes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace mod_gcanvas;

use context_module;
use dml_exception;
use file_storage;

defined('MOODLE_INTERNAL') || die;
Expand Down Expand Up @@ -60,7 +61,7 @@ public function __construct($data) {
*
* @return array
*/
public function callable_load_history() {
public function callable_load_history() : array {
global $PAGE;

$renderer = $PAGE->get_renderer('mod_gcanvas');
Expand All @@ -75,11 +76,11 @@ public function callable_load_history() {
* Save student there canvas to a attempt
*
* @return array
* @throws \dml_exception
* @throws dml_exception
* @throws \file_exception
* @throws \stored_file_creation_exception
*/
public function callable_save_canvas() {
public function callable_save_canvas() : array {
global $DB, $USER;
$fileid = 0;
$cobject = $this->load_cm_and_course();
Expand Down Expand Up @@ -118,10 +119,10 @@ public function callable_save_canvas() {
/**
* Load emoji html
*
* @return arrayd
* @return array
* @throws \moodle_exception
*/
public function callable_emoji() {
public function callable_emoji() : array {
global $PAGE, $CFG;

$renderer = $PAGE->get_renderer('mod_gcanvas');
Expand All @@ -138,9 +139,9 @@ public function callable_emoji() {
* Delete a attempt
*
* @return array
* @throws \dml_exception
* @throws dml_exception
*/
public function callable_delete_attempt() {
public function callable_delete_attempt() : array {
global $USER, $DB;

$DB->delete_records('gcanvas_attempt', [
Expand All @@ -155,9 +156,9 @@ public function callable_delete_attempt() {
* Delete a attempt
*
* @return array
* @throws \dml_exception
* @throws dml_exception
*/
public function callable_get_attempt() {
public function callable_get_attempt() : array {
global $USER, $DB;

$record = $DB->get_record('gcanvas_attempt', [
Expand All @@ -178,7 +179,7 @@ public function callable_get_attempt() {
* @throws \moodle_exception
* @throws \required_capability_exception
*/
public function callable_upload_images() {
public function callable_upload_images() : array {
$filearea = $this->data->filearea;
$image = helper::upload_file($filearea, $this->data->$filearea);

Expand All @@ -194,7 +195,7 @@ public function callable_upload_images() {
* @throws \coding_exception
* @throws \moodle_exception
*/
public function callable_get_toolbar_images() {
public function callable_get_toolbar_images() : array {
$cobject = $this->load_cm_and_course();
$modulecontext = context_module::instance($cobject->cm->id);

Expand All @@ -209,7 +210,7 @@ public function callable_get_toolbar_images() {
*
* @return object
*/
protected function load_cm_and_course() {
protected function load_cm_and_course() : object {
global $PAGE;

return (object)[
Expand Down
4 changes: 2 additions & 2 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class course_module_viewed extends \core\event\course_module_viewed {
*
* @return void
*/
protected function init() {
protected function init() : void{
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'gcanvas';
Expand All @@ -50,7 +50,7 @@ protected function init() {
*
* @return array|string
*/
public static function get_objectid_mapping() {
public static function get_objectid_mapping() : array{
return [
'db' => 'gcanvas',
'restore' => 'gcanvas',
Expand Down
2 changes: 1 addition & 1 deletion classes/form/filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class filepicker extends \moodleform {
*
* @throws \coding_exception
*/
protected function definition() {
protected function definition() : void {
$mform = &$this->_form;
$context = $this->_customdata['context'];
$mform->addElement('filemanager', $this->_customdata['filearea'],
Expand Down
2 changes: 1 addition & 1 deletion classes/form/intro.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class intro extends \moodleform {
*
* @throws \coding_exception
*/
protected function definition() {
protected function definition() : void {
global $CFG, $PAGE;
$mform = &$this->_form;
$mform->addElement('editor', 'helptext', get_string('form:helptext', 'mod_gcanvas'), null, [
Expand Down
23 changes: 13 additions & 10 deletions classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
**/

namespace mod_gcanvas;
use coding_exception;
use moodle_exception;
use required_capability_exception;

defined('MOODLE_INTERNAL') || die;

/**
Expand All @@ -41,7 +45,7 @@ class helper {
*
* @return bool
*/
public static function has_debugging_enabled() {
public static function has_debugging_enabled() : bool {
global $CFG;

// Check if the environment has debugging enabled.
Expand All @@ -57,7 +61,7 @@ public static function has_debugging_enabled() {
* @param int $limit
*
* @return array
* @throws \coding_exception
* @throws coding_exception
*/
public static function get_images(string $filearea, $context, int $canvasid, int $limit = 1) : array {
global $CFG;
Expand All @@ -84,12 +88,12 @@ public static function get_images(string $filearea, $context, int $canvasid, int
* @param string $filearea
* @param int $fileareaid
*
* @return mixed|string
* @throws \coding_exception
* @throws \moodle_exception
* @throws \required_capability_exception
* @return string
* @throws coding_exception
* @throws moodle_exception
* @throws required_capability_exception
*/
public static function upload_file(string $filearea, int $fileareaid) {
public static function upload_file(string $filearea, int $fileareaid) : string {
global $PAGE;

switch ($filearea) {
Expand All @@ -101,7 +105,7 @@ public static function upload_file(string $filearea, int $fileareaid) {
require_capability('mod/gcanvas:student_image', $PAGE->context);
break;
default:
throw new \moodle_exception('Unknown filearea');
throw new moodle_exception('Unknown filearea');
}

$return = file_save_draft_area_files($fileareaid,
Expand Down Expand Up @@ -129,8 +133,7 @@ public static function upload_file(string $filearea, int $fileareaid) {
*
* @return array
*/
public static function get_file_options($context, int $max = 50) {

public static function get_file_options($context, int $max = 50) : array {
global $CFG;

return [
Expand Down
10 changes: 6 additions & 4 deletions classes/output/output_canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
namespace mod_gcanvas\output;
defined('MOODLE_INTERNAL') || die;

use coding_exception;
use context_module;
use renderable;
use renderer_base;
use stdClass;
Expand All @@ -53,7 +55,7 @@ class output_canvas implements renderable, templatable {
*
* @param stdClass $canvas
*/
public function __construct(\stdClass $canvas) {
public function __construct(stdClass $canvas) {
$this->canvas = $canvas;
}

Expand All @@ -66,9 +68,9 @@ public function __construct(\stdClass $canvas) {
* @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
*
* @return stdClass|array
* @throws \coding_exception
* @throws coding_exception
*/
public function export_for_template(renderer_base $output) {
public function export_for_template(renderer_base $output) : stdClass {
global $PAGE;
$data = [];

Expand All @@ -83,7 +85,7 @@ public function export_for_template(renderer_base $output) {
$object->linkintro = $object->linkintro->out(false);

// Fix links to files.
$context = \context_module::instance($PAGE->cm->id);
$context = context_module::instance($PAGE->cm->id);
$options = [
'noclean' => true,
'para' => false,
Expand Down
Loading

0 comments on commit 8e285d3

Please sign in to comment.