Incorrect number of mandatory items

We have 10 unit in our course and for each unit we have selected 'User needs to answer all mandatory assessments and view all pages in order to access the next unit'. This working except that in unit two there are 12 mandatory questions, but when all questions are answered the course progress page says '12 of 13 mandatory items completed'. This prevents the student from progressing to the next unit.

There are only 12 questions. In the student assessment it correctly shows that 12 questions have been answered. How do I find and remove this 'phantom' 13th answer field?


  • Milan
    • WordPress Wizard

    Hello @teckyhead,

    I hope you are having a good day and thanks for asking us. :slight_smile:

    Dear member first of all I tried to replicate this issue on my sandbox site but no luck. so it seems I'll need access to your site, Will you please grant me support staff access so that I can check in depth regarding your issue ?. You can grant me support access via WPMU DEV > Support > Support Access > Grant Access.

    Have a great day. :slight_smile:

    Thanks & Kind Regards,
    Milan Savaliya.

  • Predrag Dubajic
    • Support

    Hi Gary,

    I was doing some extensive testing on your site but still can't figure out what's causing this on your end, number of mandatory elements is indeed 12 and can't figure out what's adding that extra one.

    I will need to ping some of our second level support dev guys in here to see if they have any thoughts on this.
    Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Best regards,

  • teckyhead
    • Design Lord, Child of Thor

    Hi Predrag,

    I managed to fix this but it does seem like the plugin has a bug that is causing some of the course meta data to remain when an answer field is removed. Here's how I tracked this down:

    First up I tracked through the code to find the point at which the number of mandatory items is calculated. This happens in the get_module_completion_data function in class.course.unit.php. I added a var_dump for the $criteria array and it gave me the list of mandatory modules' post IDs:

    array(6) {
    array(13) {
    int(199) <==

    I then checked these in the database and they all existed except for post number 199. It wasn't in the wp_posts table or the wp_post_meta table.

    I then had a look in the wp_post_meta table and tracked down the relevant data in the input_modules row for the course (hope this formats okay...):


    I removed the entry for post ID 199 (the line that starts with i:199) and it now displays the correct number of mandatory items and allows me to complete that unit.

    I'll have a look at our other course now and see if the issue can be resolved in the same way.


  • teckyhead
    • Design Lord, Child of Thor

    This same process fixed the issue on the other course. Not straight away though. I'm guessing there's some caching somewhere as it was still showing incorrect numbers after I removed the data for the missing posts. I went and had lunch and refreshed the page when I got back and it was correct.


  • Jose
    • Bruno Diaz

    Hello there Gary,

    Hope you are doing great, and thanks for the detailed report.

    I'm guessing there's some caching somewhere...

    Yes. Due to performance concerns, the completion data for each student is cached in the session for 1 hour.
    There are some specific changes that will trigger a session refresh. Deleting a module wasn't one of those changes, so I went ahead and fixed it so that the deleted module is reflected in student's completion immediately.

    With regard to the original problem, I wasn't able to reproduce it. Nevertheless, I added some improvements to prevent any possible glitch.
    If you take a look in delete_module() method in wp-content/plugins/coursepress/includes/classes/class.course.unit.module.php you will notice the following call that updates the input_modules metadata accordingly:

    // Remove input module meta
    Unit::delete_input_module_meta( $unit_id, $id );

    So, the only way to re-create the issue would be deleting the modules without using this method.
    There is also a small chance that something is going wrong on your end before the metadata deletion is actually processed. In order to prevent any possible issue, I wrapped this routine in a transaction.

    All these improvements should be out soon with the next release :slight_smile:


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.