Grid format V4.0.0.2 released for Moodle 4.0

Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Number of replies: 16
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

I have updated the Grid format for Moodle 4.0 as follows:

Version 4.0.0.2 for Moodle 4.0 version 2022041900.00 (Build: 20220419) and above within the MOODLE_400_STABLE branch until the next release:

with:

  1. Improved styles.
  2. Remove image when a section is deleted.
  3. Release candidate.

And now looks like this:

Example grid format course

with lots of subtle changes in the code to improve upon version 4.0.0.1.

I strongly suggest that this version is installed on a test server only!  It is a 'release candidate' release!  Ensure that you have multiple backups of all data before using.  Even better, run on an install on a virtual machine.

If you find this post useful, then please mark it so.  Please report any issues with this version ONLY here.

Gareth

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -

Hello, my name is Simon and i try to make work a moodle for my school about 2000 students

I try to update my moodle from 3.8 or 3.11 to 4.0

I got a lot of course which use "grid format"
My upgrade is a success except for the grid format

I have to upgrade manualy the plugin grid format.

When i do it i got this error and i cant even access to moodle and i have to reinstall a save with the previous version.

Do you have any idea of what can i do ? or if did something wrong ?

Thank you very much

Simon

Attachment error 2.png
Attachment error.png
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Simon,

This has been reported before but the test data I was given didn't lead to a conclusion. So, please could I have an export of the data (CSV file for example) in the old 'format_grid_icon' table, as things are not making sense to me. This is because that table should not have any duplicate section id's because its enforced by design. Are you running the script twice in any way? And I hope this is a test server install that's not critical.  You may have to replace the contents '/course/format/grid' folder with the M3.11 version in order to get Moodle back and not have the courses change to the default format if you were to delete the folder.

Kind regards,

Gareth
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -

Yes its a test server smile

I succeed to do 3 csv

One its before any update so its still 3.8
One intermediate, i juste install 4.0 but not the plugin

And one before the instalation of plugin.

I hope it could help.

I am not really sure how to do : " that You may have to replace the contents '/course/format/grid' folder with the M3.11 version in order to get Moodle back and not have the courses change to the default format if you were to delete the folder."

Thank you very much

In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Simon,

Thanks for the CSV's.  Did you attempt to upgrade more than once?  If so, did the error occur the second time?

With downgrading to M3.11, then get the zip of the M3.11 version, then extract all of the files.  Then when not in Moodle or anybody else, delete the contents of the '/course/format/grid' folder and replace with the contents of the extracted zip (but make sure its the files and folders, not just having one folder in that folder that contains the format).  Then you'll get a 'cannot downgrade' type issue.  So in '/course/format/grid', create 'downgrade_me.php' and put this in there:

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>;.
/**
 * Grid format.
 *
 * @package    format_grid
 * @copyright  &copy; 2022-onwards G J Barnard.
 * @author     G J Barnard - {@link http://moodle.org/user/profile.php?id=442195}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once(__DIR__.'/../../../config.php');
require_login();
if (is_siteadmin()) {
    $plugin = new stdClass;
    require_once('version.php');
    set_config('allversionshash', '');
    $currentconfigversion = get_config('format_grid', 'version');
    $currentversionversion = $plugin->version;
    $newversion = 0;
    set_config('version', $newversion, 'format_grid');
    echo 'Grid downgraded to version: '.$newversion.' from config version '.$currentconfigversion.', version.php version '.$currentversionversion.'.';
}



Then run once in another tab on the browser when logged in as an admin, i.e. 'https://mymoodle/course/format/grid/downgrade_me.php', then close the tab.  Then you'll be able to get the M3.11 version up and running.

G
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Simon,

Was anybody else accessing Moodle during the upgrade and / or did you a have a Grid format course open? And do you still have the 'format_grid_image' table from the bug? If so, then a CSV of that would be great please.

G
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Simon,

I've thought about this overnight and the only possible explanation I can currently think of however implausible is that two or more processes / threads are running the upgrade code at the same time.  Therefore, please could you try using: https://raw.githubusercontent.com/gjb2048/moodle-format_grid/cd1ee6818acf5d3c6e19a5f3aa60d692b351199b/db/upgrade.php as a direct replacement for that file in the db folder of the format in M4.0 and see if it makes a difference.

G
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -
Can you just explain to me a little bit more how to do that.  Where i have to put that code ? "Therefore, please could you try using: https://raw.githubusercontent.com/gjb2048/moodle-format_grid/cd1ee6818acf5d3c6e19a5f3aa60d692b351199b/db/upgrade.php as a direct replacement for that file in the db folder of the format in M4.0 and see if it makes a difference."

When i install the new version the pluggin grid seem not install
when i go into the menu i have this icon (cf image)

I dont know how i could launch a double update smile
The only thing i did is download the plugin and install it like other plugin

If you explain just a little bit more i cant try what you suggest.
Thank you very much.
Attachment format de cours.png
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Replace /course/format/grid/db/upgrade.php with https://raw.githubusercontent.com/gjb2048/moodle-format_grid/cd1ee6818acf5d3c6e19a5f3aa60d692b351199b/db/upgrade.php. Then place the downgrade_me.php file in /course/format/grid/ and run via the URL whilst logged into Moodle.
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -

Hello, I reinstall a 4.0 version and when i do the file grid do not exist.

Do i have to create one by myself ?

I did the upgrade like i did before and i got the bug  and the fil grid was created.

 I put the two files upgrade.php and downgrade_me.php

I excute the downgrade_me.php with the url : mymoodle/course/format/grid/downgrade_me.php

I got this message : Grid downgraded to version: 0 from config version 0, version.php version 2022072201.

I dont know if it worked.

After i try to execute the upgrade with the url mymoodle/course/format/grid/db/upgrade.php

or just trying to acces moodle and he want to do an upgade i cant access moodle witeout doing it i got this screen (screen 1)

I continue i got this second screen (screen 2)

I click on update and i got the nearly the same bug

Info de débogage  Table 'mdl_format_grid_image' already exists
CREATE TABLE mdl_format_grid_image (
id BIGINT(10) NOT NULL auto_increment,
image LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci,
contenthash VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
displayedimagestate BIGINT(10) NOT NULL,
sectionid BIGINT(10) NOT NULL,
courseid BIGINT(10) NOT NULL,
CONSTRAINT PRIMARY KEY (id)
, UNIQUE KEY mdl_formgridimag_sec2_uix (sectionid)
, KEY mdl_formgridimag_cou2_ix (courseid)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE = utf8_general_ci
COMMENT='Images for each topic, used by the grid course format'
Error code: ddlexecuteerror Trace de la pile 

  • line 492 of /lib/dml/moodle_database.php: ddl_change_structure_exception thrown
  • line 291 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
  • line 1098 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
  • line 77 of /lib/ddl/database_manager.php: call to mysqli_native_moodle_database->change_database_structure()
  • line 427 of /lib/ddl/database_manager.php: call to database_manager->execute_sql_arr()
  • line 372 of /lib/ddl/database_manager.php: call to database_manager->install_from_xmldb_structure()
  • line 671 of /lib/upgradelib.php: call to database_manager->install_from_xmldb_file()
  • line 1935 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 719 of /admin/index.php: call to upgrade_noncore()
Sory i am really begginer in php and moodle and my english is not really good too but really thank your for your help smile

Attachment screen 1.png
Attachment screen 2.png
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Simon,

Drop the 'format_grid_image' table in the database and try again.

G
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -
What do you mean by drop ?
Do you want the csv from format_grid_image ?
Do i have to erase it ?
Do i have to put inside database an older version ?
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Delete / remove the table from the database -> https://www.w3schools.com/sql/sql_drop_table.asp.
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -
It works smile
So after uprgade i have to install the plugin
I have to put the downgrade_me.php in course/format/grid
and upgrade.php in course/format/grid/db
I execute downgrade.php with url
Moodle do the upgrade
I have to export the table format_grid_icon' table
I suppress the table
Moodle do the upgrade again
And import the table format_grid_icon' table

ITs working smile

Thank you so much for the help
In reply to Simon CHARBIT

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Thanks for letting me know Simon. I've just released V4.0.1.0 which you can upgrade to as normal, you won't need to use the downgrade script.
In reply to Gareth J Barnard

Re: Grid format V4.0.0.2 released for Moodle 4.0

by Simon CHARBIT -
Your new is working perfectly, i just had to install the plugins and everything was working smile
Again thank you very much