Uncaught TypeError: Word is not a constructor

In some servers, the H5P content is not displaying and i am seeing the below error in error console.

Attachments: 
BV52's picture

Hi kbaskar,

I think one of the main reasons why Oliver asked you to post your concern in the bugs forum so that you will provide more information as requested. So would you mind providing the followng:

  1. Detailed steps to reproduce the bug (exactly how and when did it happen)
  2. Platform and version number. E.g. Drupal, Wordpress, Moodle.
  3. Mobile or Desktop
  4. Browser: Chrome, Firefox, Safari etc
  5. H5P plugin version
  6. H5P content type and version (if a content type was used), and a sample URL or attached H5P.
  7. Any browser console errors
  8. Any PHP errors
  9. Screenshots if it's a visual problem

If it worked before:

  1. Any recent changes to the environment (new plugins/modules, updates, configuration changes etc.)
  2. Any recent changes to the browser you're using (new extensions, updates etc.)

The more information you provide, the quicker the community will be able to fix it and the quicker you'll have a working solution!

-BV

otacke's picture

Hi!

The "other" reason is that the "Developer forum" is for developer discussions, hence the description "Technical forum about Content Type or System Plugin development."

Best,
Oliver

Hi Oliver,

I have explained all the details in the attachment and attached the h5p package also, please check the same.

Hi Oliver,

Please find my comments below,

 

1. Detailed steps to reproduce the bug (exactly how and when did it happen)

--Now we have migrated the application to new server, after that the package is not working, before it was worked in old server. Both servers are on premise server. 2.Platform and version number. E.g. Drupal, Wordpress, Moodle.--Moodle 3. Mobile or Desktop--It is not working on both. 4.Browser: Chrome, Firefox, Safari etc--Chrome 5.H5P plugin version--2020061500 6.H5P content type and version (if a content type was used), and a sample URL or attached H5P.--I have attached the package that i used. 7.Any browser console errors-- We received a error called "Uncaught TypeError: Word is not a constructor" 8.Any PHP errors--No php error 9.Screenshots if it's a visual problemPlease find the attachment. If it worked before:1.Any recent changes to the environment (new plugins/modules, updates, configuration changes etc.)2.Any recent changes to the browser you're using (new extensions, updates etc.)---Recently we moved the application to new server. Seems after this migration, this package is not working. We checked with some other test servers, it is working there. 
Attachments: 
otacke's picture

Hi kbaskar!

You say "Now we have migrated the application to new server, after that the package is not working, before it was worked in old server". It is very likely that this is the root of your problem.

The message "Word is not a constructor" means that the `Word` class doesn't get instantiated, which is quite weird as it's part of the content type which itself seems to work. The only reasons that I can think of is that either the word.js file might be missing or cannot be loaded (in that case you'd see a red entry in the network tab of the browser's development tools) or that the respective entry in the database for the MarkTheWords library doesn't list it. Might have been a migration issue - and you don't describe how that migration took place.

As you can see at https://app.Lumi.education/run/WggBr0 your content works just fine on a platform where everything was installed properly.

You could try to download the MarkTheWords demo content and to upload that on the faulty moodle instance, but you will have to set the H5P plugin for moodle into development mode temporarily, please see https://h5p.org/node/1295120 for an explanation. Not sure if re-uploading a library is possible on moodle's custom H5P integration though (in case you're using that one) that was not created by the H5P core team.

Best,
Oliver

Hi Otacke,

I followed these steps and resolved the issue.

https://www.youtube.com/watch?v=dFDBtmapSSg&t=11s

otacke's picture

So you whiped all libraries in the database just to re-install Mark The Words!? Gee ...

Yes, when you update the h5p activity, the libraries will get update automatically.

otacke's picture

Not all of them. Only those that come along with the library that you uploaded.

Hi,

I followed these steps and fixed the issue.

https://www.youtube.com/watch?v=dFDBtmapSSg&t=11s

Yes, you have to update the remaining packages to update the library. 

otacke's picture

Just wanted to leave the note that deleting entries in the database can be dangerous, so you should only do that if you know what you are doing. Don't want to stop you if you wanna do it. Have fun. But maybe tell others that things may break! You're showing to delete every library entry including old minor versions that may still be required and cannot be obtained by uploading the latest release files.