ethz-let / moodle-qtype_drawing

1 stars 6 forks source link

Error in background image #10

Closed taraghi closed 2 years ago

taraghi commented 2 years ago

Hi,

We just installed the plugin to give it a try. No matter what SVG image we upload (even if we do not provide any background image) we are confronted with a browser alert saying Error in background image. Background image most likely not in clean SVG format.

Now the question is if we are using the question type incorrectly or there is indeed a problem (bug) with the plugin.

Thanks for your help

nexterday commented 2 years ago

Hi, if the background image is in SVG format, it must be clean and in full strict svg standard. If we allow background images to be uploaded without being compliant, it will cause bigger problems within the attempt or response.

what you can do: open the svg in a notepad or any text editor and clean all no complaint tags (and html, comments etc) and then save it and then try to upload it again.

And if you want to share the original svg, I can point to you where the additional non compliant code is.

taraghi commented 2 years ago

Thanks for your quick response. I just downloaded a sample SVG from the web:

<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' viewBox='0 0 800 800'>
    <rect fill='#ffffff' width='800' height='800'/>
    <defs>
        <radialGradient id='a' cx='400' cy='400' r='50%' gradientUnits='userSpaceOnUse'>
            <stop  offset='0' stop-color='#ffffff'/>
            <stop  offset='1' stop-color='#0EF'/>
        </radialGradient>
        <radialGradient id='b' cx='400' cy='400' r='70%' gradientUnits='userSpaceOnUse'>
            <stop  offset='0' stop-color='#ffffff'/>
            <stop  offset='1' stop-color='#0FF'/>
        </radialGradient>
    </defs>
    <rect fill='url(#a)' width='800' height='800'/>
    <g fill-opacity='.8'>
        <path fill='url(#b)' d='M998.7 439.2c1.7-26.5 1.7-52.7 0.1-78.5L401 399.9c0 0 0-0.1 0-0.1l587.6-116.9c-5.1-25.9-11.9-51.2-20.3-75.8L400.9 399.7c0 0 0-0.1 0-0.1l537.3-265c-11.6-23.5-24.8-46.2-39.3-67.9L400.8 399.5c0 0 0-0.1-0.1-0.1l450.4-395c-17.3-19.7-35.8-38.2-55.5-55.5l-395 450.4c0 0-0.1 0-0.1-0.1L733.4-99c-21.7-14.5-44.4-27.6-68-39.3l-265 537.4c0 0-0.1 0-0.1 0l192.6-567.4c-24.6-8.3-49.9-15.1-75.8-20.2L400.2 399c0 0-0.1 0-0.1 0l39.2-597.7c-26.5-1.7-52.7-1.7-78.5-0.1L399.9 399c0 0-0.1 0-0.1 0L282.9-188.6c-25.9 5.1-51.2 11.9-75.8 20.3l192.6 567.4c0 0-0.1 0-0.1 0l-265-537.3c-23.5 11.6-46.2 24.8-67.9 39.3l332.8 498.1c0 0-0.1 0-0.1 0.1L4.4-51.1C-15.3-33.9-33.8-15.3-51.1 4.4l450.4 395c0 0 0 0.1-0.1 0.1L-99 66.6c-14.5 21.7-27.6 44.4-39.3 68l537.4 265c0 0 0 0.1 0 0.1l-567.4-192.6c-8.3 24.6-15.1 49.9-20.2 75.8L399 399.8c0 0 0 0.1 0 0.1l-597.7-39.2c-1.7 26.5-1.7 52.7-0.1 78.5L399 400.1c0 0 0 0.1 0 0.1l-587.6 116.9c5.1 25.9 11.9 51.2 20.3 75.8l567.4-192.6c0 0 0 0.1 0 0.1l-537.3 265c11.6 23.5 24.8 46.2 39.3 67.9l498.1-332.8c0 0 0 0.1 0.1 0.1l-450.4 395c17.3 19.7 35.8 38.2 55.5 55.5l395-450.4c0 0 0.1 0 0.1 0.1L66.6 899c21.7 14.5 44.4 27.6 68 39.3l265-537.4c0 0 0.1 0 0.1 0L207.1 968.3c24.6 8.3 49.9 15.1 75.8 20.2L399.8 401c0 0 0.1 0 0.1 0l-39.2 597.7c26.5 1.7 52.7 1.7 78.5 0.1L400.1 401c0 0 0.1 0 0.1 0l116.9 587.6c25.9-5.1 51.2-11.9 75.8-20.3L400.3 400.9c0 0 0.1 0 0.1 0l265 537.3c23.5-11.6 46.2-24.8 67.9-39.3L400.5 400.8c0 0 0.1 0 0.1-0.1l395 450.4c19.7-17.3 38.2-35.8 55.5-55.5l-450.4-395c0 0 0-0.1 0.1-0.1L899 733.4c14.5-21.7 27.6-44.4 39.3-68l-537.4-265c0 0 0-0.1 0-0.1l567.4 192.6c8.3-24.6 15.1-49.9 20.2-75.8L401 400.2c0 0 0-0.1 0-0.1L998.7 439.2z'/>
    </g>
</svg>

Is a background image necessary and if yes, can it be any format other than SVG?

nexterday commented 2 years ago

Hi,

  1. Background is optional, you can leave it empty.
  2. I created the svg file and it worked (see attached file [change the .txt extension to svg] + screenshot). maybe encoding was wrong? Screenshot 2021-11-10 at 13 16 27 Screenshot 2021-11-10 at 13 16 01

    x.svg.txt

taraghi commented 2 years ago

Unfortunately I get the same error as before with the modified SVG. The alert message pops up on preview page and also on the page when the user starts the quiz attempt with the corresponding question. If I create a quiz with no background. Opening the quiz ist no problem. The user can draw something. The alert popup comes up as soon as the user finishes the attempts and submits all.

I have installed plugin version 2021091000 on Moodle 3.9.9

Thanks