John: "You code solves the problem within the drag and drop question. (I don't think headings needs to be turned on for it to work..) "
No, no, no You are getting this wrong. Here's my final post about this (too) lengthy discussion (partly my own fault).
1.- On Tuesday, 22 October 2024, 11:15 PM I wrote: "I am pleased to report that, after heavy testing, including various languages in the text of Drag & Drop into text choices works without needing any extra Javascript." and attached a link to my Moode online test site to prove it worked, and attached a working question file questions-TestCourse01-Order of Precedence joseph (Canada)-20241022-2314.xml. That should have solved your problem and ended the discussion, but I had missed point (4) below.
2.- In further discussions you mentioned that although things worked as expected on my Moodle test site it didn't work for you. I installed a Moodle 4.1.x and PHP 7.4.x test site on my local machine, and could confirm the problem, and provided a fix in an attached file quiz-multilang-drag_into_text-for moodle411 PHP 7.4.xml
3.- However, in parallel with the continuing discussion here, I was intrigued by the fact that I still had the original problem on my local test sites running Moodle 4.5. It took me some time and much brain-racking 😵💫😵🤬😠to finally realise the simple reason that it worked on my online Moodle 4.5 and didn't work on my local Moodle 4.5 site:
4.- On my local site at "Site Administration->Filters->Manage filters Multi-Language Content (v2) settings I had kept the default "Apply to Content" setting. I should have read the warning at the bottom where it says "Applying filters to headings as well as content can greatly increase the load on your server. Please use that 'Apply to' settings sparingly. The main use is with the multilang filter." Once I had selected the "Apply to Content and headings" setting things worked as expected in displaying multi languages content in the Drag&drop into text questions.
5.- What next? On your Moodle sites at "Site Administration->Filters->Manage filters Multi-Language Content (v2) you should/must select the "Apply to Content and headings" setting and totally disregard the workaround script I provided in my post of Friday, 25 October 2024, 6:06 PM. Yes, that workaround script works if you do not set Multi-Language Content (v2) "Apply to Content and headings" but it's only a transient workaround which you would have to use in all of your created Drag&Drop into text questions, and ... which could be broken at any time in the future (Note 1).
Hope that helps and settles the problem at hand for good.
Joseph
Note 1 That is the problem with all those wonderful JS scripts that our friend Dominique provides on the Moodle Quiz forum: they are an ad hoc solution which does work and momentarily solves a problem, but they cannot be relied on in the long run.