donhinkelman / moodle-block_sharing_cart

Content sharing plug-in for Moodle LMS. Now at version 4.4, release 3 (actually this is for Moodle LMS version 4.3. Requires PHP 7.4.
7 stars 38 forks source link

Sharing Cart no longer working with our Course Format #214

Open Richardvi opened 2 months ago

Richardvi commented 2 months ago

Hi @donhinkelman (and others?),

Our teachers really like to use the Sharing Cart, however after our last update to Moodle 4.4 the Sharing Cart is no longer working for us. We can add content to the cart, but we can't put it back into the course.

For us it's a bit a unique situation as we are using our own course format. I would really like to share our course format with you, perhaps you can see why it's no longer working. And perhaps if you understand why it's not working for us, you can make the sharing cart plugin even better (because I could understand that more custom course formats could have the same problem).

Can I come into contact with you, send our custom course format, and you could perhaps see why the sharing cart is not working? This might be a lot I'm asking, I know, so please feel free to react accordingly.

As a Dutch person, we are not shy of direct responses :)

effgarces commented 1 month ago

We are having the same issue, in our case we traced it to the Collapsible Topics format, if a course has this format then the sharing cart does not work properly. If we change it to the Topics format it behaves as expected.

Richardvi commented 1 month ago

Interesting. But I think I understand why this happens, and it would be nice if we get the sharing cart working in all course formats.

donhinkelman commented 1 month ago

Thanks for reporting this issue, Richard, and thanks effgarces for finding the possible cause. May I confirm, Richard, that this problem only happens when you use the Collapsible Topics format or your own format? Did you try switching to Topics format? What happened?

I can assign moxis team to look into the problem, but our custom has been to build the Sharing Cart for standard themes and course formats (there are so many in Moodle, we cannot make it universally compatible to all formats). Is Collapsible Topics a standard format? If it is custom/non-standard, do you have a programmer friend who could fix it and contribute a pull-request?

Richardvi commented 1 month ago

Hi @donhinkelman ! I don't know if this happens in Collapsible Topics. @effgarces says so. But we have our own course format.

Can you tell me a little bit on how you add the extra sharing cart stuff to the course format? Right now, for us, everything works except the placeholder where you would like to copy something to.

So sharing cart works, sharing cart block works, we can copy stuff into the sharing cart - but we can't get in out of the sharing cart onto the course page.

I'd be happy to share our course format with you if you would like to take a look in your test environment.

effgarces commented 1 month ago

The course format Collapsible Topics is a plugin available at https://moodle.org/plugins/format_collapsibletopics (yes we are aware that is deprecated, but it's working well so far and we will probably maintain it for some time if it is required). As mentioned by @Richardvi the issue is the placeholder that is not working properly, or better is not being inserted.

frederikmillingpytlick commented 1 month ago

Hi @Richardvi and @effgarces,

Which version of the sharing cart do you use? It may already be fixed in the latest version of sharing cart

Richardvi commented 1 month ago

The latest version afaik. Version image

Richardvi commented 1 month ago

Ah, now I see. On Github there's a newer version that hasn't been pushed to the Moodle plugin database yet. Let me try that one :)

frederikmillingpytlick commented 1 month ago

@Richardvi Be aware that we've totally refactored the plugin in the new version, so the backups you've made before upgrading will be marked as legacy and will not support all the new sharing cart features. You will still be able to backup/restore them one at a time though

Richardvi commented 1 month ago

Thanks! I was going to test this in production, living on the edge - but you convinced me otherwise. I will go to our test server first haha

Richardvi commented 1 month ago

Auch! The new Sharing Cart totally kills my Moodle course... image

Richardvi commented 1 month ago

I will bug hunt a little.

It seems I get that error as soon as the Sharing Cart block is added to a course.

Richardvi commented 1 month ago

Quite interesting so far. The Sharing Cart version from GitHub installed perfectly, no errors, but obviously a table block_sharing_cart_items is missing. These are the tables that I do have from the sharing cart:

image

So where is block_sharing_cart_items?

frederikmillingpytlick commented 1 month ago

@Richardvi Have you run the DB upgrade on your site? - Those tables should have been deleted and a new one should have been created

Richardvi commented 1 month ago

I just downloaded all files from github as a .zip, then uploaded that zip as a plugin. Moodle started installing the new plugin.

Was that wrong?

For those wondering, this is the SQL I made from the db/install.xml

CREATE TABLE block_sharing_cart_items ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT(10) UNSIGNED NOT NULL, file_id INT(10) UNSIGNED, parent_item_id INT(10) UNSIGNED, old_instance_id INT(10) UNSIGNED NOT NULL, type CHAR(255) NOT NULL, name CHAR(255) NOT NULL, status INT(10) UNSIGNED NOT NULL, sortorder INT(10) UNSIGNED, timecreated INT(10) NOT NULL, timemodified INT(10) NOT NULL, PRIMARY KEY (id), INDEX user_id (file_id), UNIQUE INDEX file_id (file_id), INDEX parent_item_id (parent_item_id), INDEX type (type), INDEX status (status) ) COMMENT='Table to store cart items';

Richardvi commented 1 month ago

Yeah no, that's not working... I will need to completely uninstall the sharing cart module and start again

frederikmillingpytlick commented 1 month ago

I found the issue. The upgrade script wasn't run because @donhinkelman & I have both made changes to the repository. We've somehow timed it perfectly to break the upgrade script. I'll fix it asap

frederikmillingpytlick commented 1 month ago

@Richardvi I've just updated git, now the upgrade script should work properly upgrading from version 2024072900

Richardvi commented 1 month ago

Did you increase the version number a bit? That helps :)

Richardvi commented 1 month ago

Unfortunately, the new version does not solve the problem. Please look at the screenshot. So every thing seems to be working fine, but there's simply no place holder to put the content in from the sharing cart:

image

frederikmillingpytlick commented 1 month ago

@Richardvi If it still doesn't work it may be because your custom course format strays to far away from moodle's default course format structure. We've tested it on all Moodle Core course formats and a couple of third party ones as well although we don't officially support them. All of the ones we tested worked as expected.

If you run the following in your browser console what output do you get? - These are the selectors we use to find all places to implement a restore in section button.

document.querySelector('.course-content');
document.querySelectorAll('.course-content [data-for="cmlist"]');

If you get no results from the above code, you could adapt your course format to match the selectors :)

Here is an example of a container we get in format_topics image

carlicockrell commented 3 days ago

Hi Sharing Cart team, I believe this problem actually extends to the course format that was previously called "Topics" and is now "Custom Sections." It was changed in Moodle 4.4, and I can reproduce that you cannot place items from your Sharing Cart into "Custom Sections" which is the "new" version of Topics. (Moodle doc for reference to the change: https://docs.moodle.org/405/en/Course_formats) There is also support in 4.5 for subsections, so I think it's likely related to some of these new features that has caused an issue with this plugin on newer Moodle versions.

frederikmillingpytlick commented 2 days ago

Hi @carlicockrell,

Do you have the following admin setting enabled? - If enabled, this setting breaks the sharing cart restores since it doesn't factor in that you can take backups of sections. See: https://tracker.moodle.org/browse/MDL-82750 image

Backup/restore in the sharing cart works fine for me on 4.4 after disabling this