marcusgreen / moodle-qtype_wordselect

langHighlight words by clicking e.g. select all nouns in this sentence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wordselect doesn´t show images

juanpablopradootero opened this issue · comments

I have a question using images but when I upload them into moodle the images are broken. here the screeenshots and the code.
Thanjs
BEFORE PREVIEW
imagen1
IN PREVIEW AND TEST MODE
imagen2

CODE OF QUESTION:


1. 1
A.
[B.]
C.
in a shop
in a library
in a hotel

2. 2
A.
B.
[C.]
in a museum
in a hotel
at a market
3. 3
[A.]
B.
C.
in a classroom
in a museum
in an office
4. 4
A.
B.
[C.]
in a school
in a hospital
in a department store
5. 5
A.
B.
[C.]
in a theater
in an airport
in a station



I would require a dump of the question in xml format to investigate further. Here is an example of the question type using and image.
image

Thank you,
Here I attach the file, I have tried with Mozilla, and Google Chrome, and I get the same, I mean it is not showing the images.
Thanks a lot for any support

Sorry Here,
I attach the file thanks
[
questio with word select.zip
](url)

I can reproduce what you are seeing and I don't know why it is happening.

May I get the code of the question you sent me with the cat's image? I would like to see what is the difference in checking my questions
Regards

It is probably a bug. You can get the example questions from here.

https://github.com/marcusgreen/moodle-qtype_wordselect/blob/master/examples/en/wordselect_examples.xml

I think the difference is that I have copy/pasted the images into the questions and you have added them via the editor button. That should work but it seems it does not, my apologies.

This has also been reported on the Moodle.org forums here

https://moodle.org/mod/forum/discuss.php?d=435813#p1753923

There is an indication of the source of the problem when debug is set to developer with this error message

Before calling format_text(), the content must be processed with file_rewrite_pluginfile_urls()
line 1347 of /lib/weblib.php: call to debugging()
line 448 of /question/type/wordselect/question.php: call to format_text()
line 109 of /question/behaviour/deferredfeedback/behaviour.php: call to qtype_wordselect_question->grade_response()
line 57 of /question/behaviour/deferredfeedback/behaviour.php: call to qbehaviour_deferredfeedback->process_finish()
line 1356 of /question/engine/questionattempt.php: call to qbehaviour_deferredfeedback->process_action()
line 1396 of /question/engine/questionattempt.php: call to question_attempt->process_action()
line 859 of /question/engine/questionusage.php: call to question_attempt->finish()
line 167 of /question/preview.php: call to question_usage_by_activity->finish_all_questions()

I am tagging @timhunt as he will want to know this issue exists

If you are going to use Cloze, then you may find this plugin helpful
https://moodle.org/plugins/atto_cloze

Is there are reason you are calling format_text yourself, rather than calling $this->format_questiontext, which will do the right thing.

More to the point, it seems incredibly dangerous to do

$this->questiontext = format_text($this->questiontext, ...);

since other code (e.g. rendering) might later want to display stuff, and itself do format_text($this->questiontext, ...) again. format_text cannot be called repeatedly on the same content - at least not if you want a sensible result.

If you need to ready-to-output HTML in the grading code, then just do

$formattedquestiontext = format_text($this->questiontext, ...); // Or rather $this->format_questiontext();

there.

I hope this helps.

"I hope this helps."
I suspect it will :)
The order of the 'words' that are rendered is used to determined which responses are correct and processing by filters can change that order. So it can work without any filter processing but mlang or embedded media will change it so I am not sure what would be a good solution.

Hi Juan, yes that would work, The examples I gave were pasted in from the Atto editor, which might be easier than using a 3rd party site for base64. I have been working hard on getting it to work without needing to do things like that and have created some new test questions that include the use of various filters including core multi language, mlang2 and audio file (that is clickable and plays) and also images.

I have a version that appears to work as expected but it needs some more testing. At the moment it works when I test it by hand and it passes the automated tests. However questions can be used in many different ways (E.G through the quesitons filter) and I need to check other things like backup and restore.

Here is the POST (info) https://moodle.org/mod/forum/discuss.php?d=435813#p1753894

There are only 2 choices to be chosen for the full 2 marks. But never CORRECT! Please help!

Word Select: 2.48 2022020500

Moodle 3.8.1 (Build: 20200113)

=====

It's a beautiful [picture].

She has a [pretty] face.

=====

2022-06-25_14-24-04

Here are the exported files. Thank you.

XML Exported files.zip

Thank you for the link. I have been working on this. It seems there was a general issue with filters and images. I should have a branch and a test site available soon.