moodle-mod_customcert icon indicating copy to clipboard operation
moodle-mod_customcert copied to clipboard

Elements go to random places when saving the certificate

Open PedroHenriqueMorais opened this issue 7 years ago • 10 comments

Hello Mark, I'm designing some certificates on my Moodle site and I'm having some trouble. When I am setting the pieces (a.k.a text areas, user info etc) on the right places, and then I save, some of these pieces move from their original place, which makes my certificate look wrong. Do you know why is it possibly happening? Or what could I do to fix it? Sometimes to make the pieces (elements of the certificate) stay in the right positions, I have to try a lot of times, by changing it's place and then saving and then looking at it's curent possition and guess where should I locate it next to have the right positioning, multiple times, until I find the right position when editing that will look correct when saved. I'm using the 3.2 version of Moodle an the 3.2 release (Build: 2016120504) 201612050 version of the plugin. Thank you so much for helping.

PedroHenriqueMorais avatar Mar 08 '17 12:03 PedroHenriqueMorais

Hi Pedro,

Do they move a lot? Like to a completely separate location (eg. other side of the PDF) or is it a subtle difference?

This is tricky as the HTML and PDF generation are done by separate code and it's hard to ensure they are exactly the same. The HTML is a representation of the PDF but is obviously not the PDF itself.

mdjnelson avatar Mar 28 '17 03:03 mdjnelson

Good day,

I have the same problem now. After pressing the save button all elements move 15-20px upwards, partly also out of the sheet. So no certificate creation is possible.

cedric-schumann avatar Jan 23 '22 21:01 cedric-schumann

@mdjnelson I know that this message is a bit longer ago, but is there possibly a solution to the problem?

cedric-schumann avatar Jan 25 '22 19:01 cedric-schumann

Hi @cedric-schumann can you tell me the following -

  1. What browser you are using.
  2. The version of Moodle.
  3. The version of the Custom Certificate plugin.
  4. What elements are you adding.
  5. What page does this occur on, the rearrangement page in the browser or on the PDF?

To fix this I really need to be able to replicate which I have not been able to do yet.

mdjnelson avatar Jan 28 '22 04:01 mdjnelson

@mdjnelson

I work mainly with Microsoft Edge, but I have also tried it with Chrome and Filezilla with the same result. My Moodle version is 3.11.4+ and as plugin version I have 3.11.1. Elements I have actually tried all of them, all elements move equally. So whether image, text or user field does not matter. First the problem occurs on the page in the browser, but this is also transferred to the PDF. So the view in the browser is then the same as the view of the PDF.

Whenever I save, all elements move to the top. This happens at "save and continue" and at "save and exit".

cedric-schumann avatar Jan 28 '22 12:01 cedric-schumann

Hi, I had this situation too, several times on one certificate. I was using chrome and firefox (latest at that time - about 12/2021) on windows 10 fully updated (12/2021) I sadly had no time to play around what caused this, but in my case I think: the positioning of an element (a picture) closely out of the "box" or at least very close to the border of the certificate caused it. As this causes a lot of work in my case, I would like to fix it or at least find the exact reason. @mdjnelson: I know everybodies time ist short, but could you be so kind and explain me simplified how the technical process works, when someone uses the visual positioning? I guess it could be a CSS problem while rendering and than returning wrong values back during save? best regards

antoniobeermann avatar Jan 29 '22 12:01 antoniobeermann

Hi, just wanted to know if someone else could confirm: If elements are jumping to different places - I noticed:

  • I can not save edit values in the WYSIWYG view for those misspositioned elements
  • I can edit them in the default list view
  • I use a backgroundimage as big as the certsize
  • In the list view some items have wrong descriptions - mostly a textfield gets a description of an image, so the image "name" is then used more then once in the list view - but for a textfield
  • the misspositioned elements are moved to top and may have negative values (-12px)

Does somebody notice this when having no special Characters in the description?

As I am forced to use this plugin (AND I think its gorgious) I will try to keep an eye on this, any hints or thoughts are welcome! best regards

antoniobeermann avatar Feb 16 '22 12:02 antoniobeermann

My personal thinking is, that during edit or store process the info(array?) gets mixed up cause one element has any unallowed value - saw a datarefpoint=NaN once ...

antoniobeermann avatar Feb 16 '22 12:02 antoniobeermann

I was having the same issue.

I found that all elements were being moved up by 12mm in the saved DB value.

I found that the this.pdfy was initially being set with Y.one('#pdf').getY(); at line 128 in the setPdfDimensions function.

If I checked the value of Y.one('#pdf').getY() again in the savePositions function, it didn't match what was in this.pdfy.

So somehow the value changed between page load and clicking the Save button.

Since the position of the elements before saving is determined relative to this.pdfy, I think this was the cause of the elements being shifted unexpectedly.

To fix this for my purposes, I simply set the value of this.pdfy again at the beginning of the savePositions function. There is probably a better method, like waiting to set it initially until elements on the page have loaded or something like that.

jfleming-powertrain avatar Jul 29 '22 17:07 jfleming-powertrain

@jfleming-powertrain was this in 4.x?

Is anyone able to create a merge request with a fix?

mdjnelson avatar Aug 30 '22 07:08 mdjnelson

Closing as I believe this was fixed in https://github.com/mdjnelson/moodle-mod_customcert/issues/500.

mdjnelson avatar Jul 31 '24 20:07 mdjnelson