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.
8 stars 38 forks source link

Sharing Cart no longer working with our Course Format #214

Open Richardvi opened 3 months ago

Richardvi commented 3 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 2 months 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 2 months 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 2 months 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 2 months 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 2 months 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 2 months 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 2 months ago

The latest version afaik. Version image

Richardvi commented 2 months 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 2 months 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 2 months 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 2 months ago

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

Richardvi commented 2 months 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 2 months 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 2 months 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 2 months 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 2 months ago

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

frederikmillingpytlick commented 2 months 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 2 months ago

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

Richardvi commented 2 months ago

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

Richardvi commented 2 months 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 2 months 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 weeks 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 3 weeks 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

carlicockrell commented 2 weeks ago

@frederikmillingpytlick I can confirm this is not something we do not have on. The issue is that using Custom Sections (new Topics), when you copy an item, it never moves from "Copying this shared item" and you also cannot place it anywhere. However, if you switch to a different course format, you can place the copied item accordingly. I'm happy to start a new issue, but thought the issues all sounded similar in nature, and wondered if the course formats do factor in.

frederikmillingpytlick commented 2 weeks ago

@carlicockrell I'd need some more information to debug this. I can't reproduce it on a clean Moodle 4.4 site

donhinkelman commented 2 weeks ago

@carlicockrell I can confirm that course formats are frequent cause of bugs, particularly custom course formats. Note that section copy is a feature of the Sharing Cart that is a few years old. Sharing Cart versions go back almost twenty years. We thank Frederik and all the great staff at Moxis for handling these important but tedious bugs as Moodle course formats evolve.