Skip to content

Commit

Permalink
V405.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Oct 24, 2024
1 parent 13fb7de commit c9f8053
Show file tree
Hide file tree
Showing 21 changed files with 289 additions and 170 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2']
moodle-branch: ['MOODLE_404_STABLE']
php: ['8.3']
moodle-branch: ['MOODLE_405_STABLE']
database: [mariadb]

steps:
Expand All @@ -45,9 +45,9 @@ jobs:
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
#echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
# Install nvm v0.39.7 (Temporary workaround for https://github.com/moodlehq/moodle-plugin-ci/issues/309).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
Expand Down
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
History
=============

Version 405.0.1 - 24/10/2024
----------------------------
1. Release candidate version for Moodle 4.5.
2. Fix 'Generated images not showing when editing'.
3. Impact of MDL-81920 and MDL-81960.

Version 404.1.3 - 03/10/2024
----------------------------
1. Fix 'Orphaned sections problem when adding sections', a regression caused by
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ A topics based format that uses a grid of user selectable images to select a sec

Required release of Moodle
==========================
This version works with Moodle 4.4 version 2024042200.00 (Build: 20240422) and above within the MOODLE_404_STABLE branch until the
This version works with Moodle 4.5 version 2024100700.00 (Build: 20241007) and above within the MOODLE_405_STABLE branch until the
next release.

Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/404/en/Installing_Moodle)'.
Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/405/en/Installing_Moodle)'.

Free software
=============
The Grid format is 'free' software under the terms of the GNU GPLv3 License, please see 'COPYING.txt'.

The primary source for downloading this branch of the format is https://moodle.org/plugins/view.php?plugin=format_grid
with 'Your Moodle version:' set at 'Moodle 4.4'.
with 'Your Moodle version:' set at 'Moodle 4.5'.

The secondary source is https://github.com/gjbarnard/moodle-format_grid/tags

Expand Down
4 changes: 2 additions & 2 deletions Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ benefits.

Required release of Moodle
==========================
This version works with Moodle 4.4 version 2024042200.00 (Build: 20240422) and above within the MOODLE_404_STABLE branch until the
This version works with Moodle 4.5 version 2024100700.00 (Build: 20241007) and above within the MOODLE_405_STABLE branch until the
next release.

Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/404/en/Installing_Moodle)'.
Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/405/en/Installing_Moodle)'.

Reporting issues
================
Expand Down
12 changes: 8 additions & 4 deletions classes/admin_setting_information.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@

namespace format_grid;

use admin_setting;
use core_plugin_manager;
use core\output\html_writer;

/**
* Setting that displays information. Based on admin_setting_description in adminlib.php.
*
* @copyright © 2022-onwards G J Barnard.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
class admin_setting_information extends \admin_setting {
class admin_setting_information extends admin_setting {
/** @var int The branch this is for. */
protected $mbranch;

Expand Down Expand Up @@ -93,7 +97,7 @@ public function output_html($data, $query = '') {
if (!empty($formats['grid'])) {
$plugininfo = $formats['grid'];
} else {
$plugininfo = \core_plugin_manager::instance()->get_plugin_info('format_grid');
$plugininfo = core_plugin_manager::instance()->get_plugin_info('format_grid');
$plugininfo->version = $plugininfo->versiondisk;
}

Expand All @@ -102,8 +106,8 @@ public function output_html($data, $query = '') {
$attributes['aria-hidden'] = 'true';
$attributes['class'] = 'fa fa-heart';
$attributes['title'] = get_string('love', 'format_grid');
$content = \html_writer::tag('span', $attributes['title'], ['class' => 'sr-only']);
$content = \html_writer::tag('span', $content, $attributes);
$content = html_writer::tag('span', $attributes['title'], ['class' => 'sr-only']);
$content = html_writer::tag('span', $content, $attributes);
$context['versioninfo'] = get_string(
'versioninfo',
'format_grid',
Expand Down
7 changes: 5 additions & 2 deletions classes/admin_setting_markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@

namespace format_grid;

use admin_setting;
use stdClass;

/**
* Setting that displays markdown files. Based on admin_setting_description in adminlib.php.
*
* @copyright © 2022-onwards G J Barnard.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
class admin_setting_markdown extends \admin_setting {
class admin_setting_markdown extends admin_setting {
/** @var string Filename */
private $filename;

Expand Down Expand Up @@ -89,7 +92,7 @@ public function write_setting($data) {
public function output_html($data, $query = '') {
global $CFG, $OUTPUT;

$context = new \stdClass();
$context = new stdClass();
$context->title = $this->visiblename;
$context->description = $this->description;

Expand Down
6 changes: 4 additions & 2 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace format_grid;

/**
* Event observers supported by this format.
*/
class format_grid_observer {
class observer {
/**
* Observer for the event course_content_deleted.
*
Expand Down Expand Up @@ -67,6 +69,6 @@ public static function course_restored(\core\event\course_restored $event) {
*/
protected static function delete_images($courseid) {
// Delete any images associated with the course.
\format_grid\toolbox::delete_images($courseid);
toolbox::delete_images($courseid);
}
}
36 changes: 21 additions & 15 deletions classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@

namespace format_grid\output\courseformat;

use completion_info;
use context_course;
use core_courseformat\output\local\content as content_base;
use core\output\renderer_base;
use core\url;
use format_grid\toolbox;
use moodle_exception;
use stdClass;

/**
Expand Down Expand Up @@ -63,7 +69,7 @@ class content extends content_base {
* @param renderer_base $output typically, the renderer that's calling this method.
* @return string Mustache template name.
*/
public function get_template_name(\renderer_base $renderer): string {
public function get_template_name(renderer_base $renderer): string {
return 'format_grid/local/content';
}

Expand All @@ -73,7 +79,7 @@ public function get_template_name(\renderer_base $renderer): string {
* @param renderer_base $output typically, the renderer that's calling this method.
* @return stdClass data context for a Mustache template.
*/
public function export_for_template(\renderer_base $output) {
public function export_for_template(renderer_base $output) {
global $DB, $PAGE;
$format = $this->format;
$editing = $PAGE->user_is_editing();
Expand Down Expand Up @@ -125,9 +131,9 @@ public function export_for_template(\renderer_base $output) {
$data->hasnavigation = true;
$data->singlesection = array_shift($data->sections);
$data->sectionreturn = $singlesectionno;
$data->maincoursepage = new \moodle_url('/course/view.php', ['id' => $course->id]);
$data->maincoursepage = new url('/course/view.php', ['id' => $course->id]);
} else {
$toolbox = \format_grid\toolbox::get_instance();
$toolbox = toolbox::get_instance();
$coursesectionimages = $DB->get_records('format_grid_image', ['courseid' => $course->id]);
if (!empty($coursesectionimages)) {
$fs = get_file_storage();
Expand All @@ -145,7 +151,7 @@ public function export_for_template(\renderer_base $output) {
if (!empty($replacement)) {
$coursesectionimages[$coursesectionimage->id] = $replacement;
}
} catch (\moodle_exception $me) {
} catch (moodle_exception $me) {
$coursesectionimages[$coursesectionimage->id]->imageerror = $me->getMessage();
}
}
Expand Down Expand Up @@ -188,7 +194,7 @@ public function export_for_template(\renderer_base $output) {
$displayediswebp = (get_config('format_grid', 'defaultdisplayedimagefiletype') == 2);

$completionshown = false;
$headerimages = false;
$sectionheaderimages = false;
if ($editing) {
$datasectionmap = [];
foreach ($data->sections as $datasectionkey => $datasection) {
Expand Down Expand Up @@ -241,7 +247,7 @@ public function export_for_template(\renderer_base $output) {
if (!empty($data->sections[$datasectionmap[$section->id]])) {
// Add the image to the section content.
$data->sections[$datasectionmap[$section->id]]->gridimage = $sectionimages[$section->id];
$headerimages = true;
$sectionheaderimages = true;
}
} else {
// Section link.
Expand Down Expand Up @@ -302,15 +308,15 @@ public function export_for_template(\renderer_base $output) {
$data->gridsectionnumbers = implode(',', $gridsectionnums);
}

if ($headerimages) {
$data->hasheaderimages = true;
if ($sectionheaderimages) {
$data->hassectionheaderimages = true;
$coursesettings['imagecontainerwidth'] = 144;
$data->coursestyles = $toolbox->get_displayed_image_container_properties($coursesettings);
}
}

if ($this->hassteathwithcontent) {
$context = \context_course::instance($course->id);
$context = context_course::instance($course->id);
if (has_capability('moodle/course:update', $context)) {
$data->stealthwarning = get_string('stealthwarning', 'format_grid', $this->hassteathwithcontent);
}
Expand All @@ -337,7 +343,7 @@ public function export_for_template(\renderer_base $output) {
*
* @return array data context for a mustache template
*/
protected function get_grid_sections(\renderer_base $output, $settings): array {
protected function get_grid_sections(renderer_base $output, $settings): array {

$format = $this->format;
$course = $format->get_course();
Expand All @@ -359,7 +365,7 @@ protected function get_grid_sections(\renderer_base $output, $settings): array {
foreach ($sectioninfos as $thissection) {
// The course/view.php check the section existence but the output can be called from other parts so we need to check it.
if (!$thissection) {
throw new \moodle_exception(
throw new moodle_exception(
'unknowncoursesection',
'error',
'',
Expand Down Expand Up @@ -407,7 +413,7 @@ protected function get_grid_sections(\renderer_base $output, $settings): array {
* @param stdClass $modinfo the course module information.
* @param renderer_base $output typically, the renderer that's calling this method.
*/
protected function calculate_section_activity_completion($section, $course, $modinfo, \renderer_base $output) {
protected function calculate_section_activity_completion($section, $course, $modinfo, renderer_base $output) {
if (empty($this->sectioncompletioncalculated[$section->section])) {
$this->sectioncompletionmarkup[$section->section] = '';
if (empty($modinfo->sections[$section->section])) {
Expand All @@ -421,7 +427,7 @@ protected function calculate_section_activity_completion($section, $course, $mod
$cancomplete = isloggedin() && !isguestuser();
$asectionisavailable = false;
if ($cancomplete) {
$completioninfo = new \completion_info($course);
$completioninfo = new completion_info($course);
foreach ($modinfo->sections[$section->section] as $cmid) {
$thismod = $modinfo->cms[$cmid];

Expand Down Expand Up @@ -452,7 +458,7 @@ protected function calculate_section_activity_completion($section, $course, $mod
$percentage = round(($complete / $total) * 100);
$this->sectioncompletionpercentage[$section->section] = $percentage;

$data = new \stdClass();
$data = new stdClass();
$data->percentagevalue = $this->sectioncompletionpercentage[$section->section];
if ($data->percentagevalue < 11) {
$data->percentagecolour = 'low';
Expand Down
5 changes: 3 additions & 2 deletions classes/output/courseformat/content/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use core_courseformat\base as course_format;
use core_courseformat\output\local\content\section as section_base;
use core\output\renderer_base;
use stdClass;

/**
Expand All @@ -51,7 +52,7 @@ class section extends section_base {
* @param renderer_base $output typically, the renderer that's calling this function.
* @return array data context for a mustache template.
*/
public function export_for_template(\renderer_base $output): stdClass {
public function export_for_template(renderer_base $output): stdClass {
$format = $this->format;

$data = parent::export_for_template($output);
Expand All @@ -74,7 +75,7 @@ public function export_for_template(\renderer_base $output): stdClass {
* @param renderer_base $output typically, the renderer that's calling this function
* @return bool if the cm has name data
*/
protected function add_format_data(stdClass &$data, array $haspartials, \renderer_base $output): bool {
protected function add_format_data(stdClass &$data, array $haspartials, renderer_base $output): bool {
parent::add_format_data($data, $haspartials, $output);
$data->collapsemenu = false;

Expand Down
9 changes: 6 additions & 3 deletions classes/output/courseformat/content/section/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

use core_courseformat\output\local\content\section\summary as summary_base;
use core_courseformat\base as course_format;
use context_course;
use core\output\renderer_base;
use format_grid\toolbox;
use section_info;
use stdClass;

Expand Down Expand Up @@ -62,7 +65,7 @@ public function __construct(course_format $format, section_info $section) {
* @param renderer_base $output typically, the renderer that's calling this function.
* @return array data context for a mustache template.
*/
public function export_for_template(\renderer_base $output): stdClass {
public function export_for_template(renderer_base $output): stdClass {

$section = $this->thesection;

Expand Down Expand Up @@ -113,8 +116,8 @@ protected function singlepagesummaryimage($summary, $output): string {
);
if (!empty($coursesectionimage)) {
$fs = get_file_storage();
$coursecontext = \context_course::instance($courseid);
$toolbox = \format_grid\toolbox::get_instance();
$coursecontext = context_course::instance($courseid);
$toolbox = toolbox::get_instance();
$replacement = $toolbox->check_displayed_image(
$coursesectionimage,
$courseid,
Expand Down
5 changes: 4 additions & 1 deletion classes/output/courseformat/content/sectionnavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

namespace format_grid\output\courseformat\content;

use core\output\renderer_base;
use stdClass;

/**
* Base class to render a course add section navigation.
*/
Expand All @@ -39,7 +42,7 @@ class sectionnavigation extends \core_courseformat\output\local\content\sectionn
* @param renderer_base $output typically, the renderer that's calling this function
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output): \stdClass {
public function export_for_template(renderer_base $output): stdClass {
global $USER;

if ($this->data !== null) {
Expand Down
Loading

0 comments on commit c9f8053

Please sign in to comment.