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

Invalid course module ID error when attempting to copy section with hidden modules #73

Closed brian-winstead closed 1 year ago

brian-winstead commented 3 years ago

DESCRIPTION When using the Sharing Cart block to copy a course section, the copy fails with an "Invalid course module ID error" if the course section contains an instance of an activity module which has been hidden.

STEPS TO REPLICATE NOTE: Steps will demonstrate the issue with an example community module and a core Moodle module.

  1. Create a new course.
  2. In the first course section add a page and an assignment. This section is the control for the test.
  3. In the second course section add a page, an assignment, and a lesson.
  4. In the third course section add a page, an assignment, and an OU blog.
  5. Go to Site administration > Plugins > Activity modules > Manage activities. Hide the Lesson and OU Blog modules.
  6. Return to the course and confirm that the lesson and ou blog are no longer visible in their course sections.
  7. Turn on editing in the course.
  8. Add the Sharing cart block to the course.
  9. In the Sharing cart block, select the first course section in the drop-down menu and click Copy section. Click Confirm.
  10. Observe that the section is successfully add to the Sharing Cart block.
  11. Select the second or third course section in the drop-down menu and click Copy section. Click Confirm.

OBSERVED BEHAVIOR: An error is received stating, "Invalid course module ID". If you refresh the page you will see that the page and assignment from the course section were added to the sharing cart as individual items, but the section as a whole was not added.

EXPECTED BEHAVIOR: The course section is added to the Sharing Cart.

REPLICATION LOCATIONS Replicated in Moodle 3.8.3 using Sharing Cart version 2020051800.

dcadiou commented 2 years ago

Hello.

I found a similar problem (invalid course module id) with test activity copy, using the sharing cart.

See https://tracker.moodle.org/browse/CONTRIB-8785

marxjohnson commented 1 year ago

I just attempted to reproduce this on Moodle 4.0 with Sharing Cart version 2022101400 (4.0, release 2) and it behaved as expected. The disabled module was not added to the sharing cart with other activities in the section, and copying the section somewhere else brought only the instances of the active modules. I believe this can be closed.

dcadiou commented 1 year ago

Hello marxjohnson.

Did you tried with all five conditions present ? (as described in https://tracker.moodle.org/browse/CONTRIB-8785) :

Recall :

I saw it fails with 2021112300.00 (4.0dev+ (Build: 20211123)).

marxjohnson commented 1 year ago

Hi @dcadiou, I didn't try following those instructions. Perhaps it's worth filing that as a separate issue here, to avoid confusion between that and the original report in this issue?

AraPraxis commented 1 year ago

I'm guessing this issue is resolved, from the following comment on the issue: https://github.com/donhinkelman/moodle-block_sharing_cart/issues/73#issuecomment-1296977267

If you find any errors regarding the scenarios/tests described by @dcadiou then you're welcome to create a new issue, as long as the error still occurs on Moodle 4.0+, as we will not update the sharing cart prior to Moodle 4.0 - However we do follow the Moodle releases and are willing to fix any security risks regarding this plugin. https://moodledev.io/general/releases

Kind regards, Anders Rasmussen

Praxis Team

dcadiou commented 1 year ago

Hello.

Thank you for investigating on this.

I tried again today with a Moodle in version 2022112801.04 (4.1.1+ (Build: 20230210)) and sharing cart plugin version 2023030900 (4.0, release 5).

Steps used to reproduce didn't generate any error. The copy is done as expected. I think this issue can now be closed.

(I updated https://tracker.moodle.org/browse/CONTRIB-8785).