mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
90 stars 158 forks source link

Repositioning parts background image shifts #513

Closed alihamas575 closed 1 year ago

alihamas575 commented 1 year ago

Repositioning parts background image shifts

Hello, I will try to explain the problem with images. I will take a video if possible.

I've been using the custom certificate plugin since version 3.4. I didn't make any changes. Today I pressed the swap part positions button to fix a problem. I relocated a text field in the certificate and then the booom certificate background went up quite a bit and blocked the view of the save close buttons.

When I first open this first image certificate editing screen, the screen that appears, Hatasız 1

This is the second image. You can see that the certificate background area slides down when I change the position of any part again and save and close. HATA 2

Sometimes (I will add the third image if the same error occurs) the background image slides up and closes the save and close buttons.

Due to legal obligations in my country, I have to explain the occupational health and safety training (temel isg eğitimi) through the distance education system and give the certificates through this system. In my country, there are companies established by special law under the name of the joint health and safety unit (joint health and safety unit), and its abbreviation is osgb companies (osgb companies).

I am a private business that offers services like bursa osgb companies, I have been using this special certificate module for a long time. However, after recent updates the certificate software stopped working properly.

Urpokarhu1 commented 1 year ago

Hello,

there is a bug in custom certificate 3.11.1 (2021051701) & Moodle 4.0 when you add an element to certificate and open reposition elements

A) you can drag the element but it always resets to default position or B) if you are lucky and manage drag it to another position it sticks to it.

the bug might be in javascript working in background that recognizes the area you can drag elements to

https://user-images.githubusercontent.com/53904029/189571455-703392f9-9b73-4370-8bec-8dd447f0c77b.mp4

leonstr commented 1 year ago

Looking at the issue described by @Urpokarhu1 I also think this is an issue with the JavaScript code restricting the area you can drag elements into. It looks like isoutofbounds() (defined in mod/customcert/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange.js) may return true because it does not correctly handle the element's coordinates when the page has been scrolled in the browser.

If you zoom out in your browser so that you do not need to vertically scroll to see the whole PDF area then rearranging elements appears to work as expected.

This may be a different issue to that originally reported by @alihamas575.

leonstr commented 1 year ago

I've made an attempt at fixing this. Because I'm not very good at Git this has been merged with my pull request to fix the double title (issue #521, pull request #523). You only need commit 9668304 if you want to try just this fix (although there's no reason not to also have commit 6681f1f if you have Moodle 4.0). There are technical details about this change in the commit message.

In my tests this change fixes the issue in @Urpokarhu1's video. It may fix @alihamas575's issue too but if the background image is blocking the save/cancel buttons you may need to manually reset the background image position in the database. On my system I did this with:

UPDATE mdl_customcert_elements SET posy = 0 WHERE element = 'bgimage' AND posy < 0;

This may not work for you and may break your certificate layout. Always take a database backup before running statements like this.

mdjnelson commented 1 year ago

Thanks, cherry-picked. :)

mdjnelson commented 1 year ago

Ok, with this commit I am still having issues on 4.0 with elements moving around.

mdjnelson commented 1 year ago

Hm, I am unable to replicate this error now after purging caches, closing again.

mdjnelson commented 1 year ago

I believe this was fixed by #500.