LMS H5P Course Activities Not Being Correctly Evaluated

Created on 18 June 2025, about 2 months ago

Problem/Motivation

Courses are not marked completed after finishing H5P activities. After completing all activities (H5P) and click “Finish Course,” the system displays: “Course failed.”

The following PHP error appears in the logs:

TypeError: Drupal\lms\Controller\CourseController::activity(): Argument #3 ($activity_delta) must be of type int, string given in CourseController->activity() (line 81)
URL: /course/1/0/[object%20Object]
Referrer: /course/1/0/1

Notice the [object%20Object] in the url. It appears [object Object] is being passed instead of a numeric ID for $activity_delta.

Non-H5P activities are tracked and reported as expected.

Steps to reproduce

  1. Enable LMS H5P module and set
  2. Add H5P Activity type in /admin/lms/activity_type
  3. Set Widget to Editor under Form Display
  4. Add activity of type H5P and add to Module >> Course
  5. Complete all activities in Course
  6. Click Finish Course at the end

Notice "Course failed."
Go to my course-results
Answered Evaluated Score
Yes Yes 0

Notice a score of 0.

I tried setting up LMS xAPI and LRS but having issues with those (not sure if there's any connection there). I'm creating separate issues for those.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States GarChris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @GarChris
  • 🇬🇧United Kingdom catch

    This module depends on lrs_xapi (or an equivalent LRS) so that might be causing the problem here. Please link those issues once they're open, but moving this to 'needs more info' for now.

  • 🇺🇸United States GarChris

    Here is the linked issue, xAPI Statements Not Sent to External LRS (TraxLRS)
    https://www.drupal.org/project/lms_xapi/issues/3530894 💬 xAPI Statements Not Sent to External LRS (TraxLRS) Active

  • 🇺🇸United States GarChris

    LMS H5P activities work as expected after properly configuring the lms_xapi to point to the internal lrs_xapi. Thank you for your responsiveness on this and the related issues.

  • 🇬🇧United Kingdom catch

    I'm still getting that malformed url "/course/5/0/[object%20Object]" and the error

    This is really confusing to me - can you confirm whether you've got custom JavaScript or similar running on that page? I'm wondering if something is appending things to the URL incorrectly or similar. I can't think of a way this could ever be generated purely from PHP - at least not by accident.

  • 🇺🇸United States GarChris

    No custom codes or modules. I just did a fresh install and getting the same error. here is the relevant portion of my composer.json

        "repositories": [
           {
             "type": "vcs",
             "url": "https://github.com/amaikers/h5p-php-report"
           },
           {
             "type": "vcs",
             "url": "https://github.com/graber-1/drupal_lms_ddev"
           },
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            }
        ],
        "require": {
            "composer/installers": "^2.3",
            "drupal/core-composer-scaffold": "^11.2",
            "drupal/core-project-message": "^11.2",
            "drupal/core-recipe-unpack": "^11.2",
            "drupal/core-recommended": "^11.2",
            "drupal/h5p": "^2.0@alpha",
            "drupal/lms": "1.0.x-dev",
            "drupal/lms_h5p": "dev-1.0.x",
            "drupal/lms_xapi": "1.0.x-dev@dev",
            "drupal/views_bulk_operations": "^4.3",
            "drush/drush": "^13.6",
            "h5p/h5p-php-report": "dev-master"
        },
        "conflict": {
            "drupal/drupal": "*"
        },
        "minimum-stability": "dev",

    php:
    PHP 8.3.21
    mysql Ver 8.0.42

    And this is my virtualhost file (minus comments)

    server {
    
    
              listen 80;
              listen [::]:80;
    
            root /var/www/example.com/web;
    
            index index.php index.html index.htm;
    
            server_name example.com;
    
            include /etc/nginx/mime.types;
    
            # Serve .h5p files correctly
            location ~* /sites/default/files/h5p/exports/.*\.h5p$ {
                default_type application/vnd.h5p;
                add_header Content-Disposition "attachment";
                try_files $uri =404;
            }
    
            location / {
    
                    try_files $uri $uri/ /index.php?$args;
            }
    
            location ~ \.php$|^/update.php {
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }
    
    }

    and h5p was screaming about a .htaccess file despite running nginx, so I dropped one in at config/sync

    # Deny all requests from Apache 2.4+.
    <IfModule mod_authz_core.c>
      Require all denied
    </IfModule>
    
    # Deny all requests from Apache 2.0-2.2.
    <IfModule !mod_authz_core.c>
      Deny from all
    </IfModule>
    
    # Turn off all options we don't need.
    Options -Indexes -ExecCGI -Includes -MultiViews
    
    # Set the catch-all handler to prevent scripts from being executed.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
    <Files *>
      # Override the handler again if we're run later in the evaluation list.
      SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
    </Files>
    
    # If we know how to do it safely, disable the PHP engine entirely.
    <IfModule mod_php.c>
      php_flag engine off
    </IfModule>
Production build 0.71.5 2024