Wunderbyte-GmbH / moodle-mod_booking

Moodle Booking Module
https://www.wunderbyte.at
21 stars 39 forks source link

Problem with booking confirmation buttons #313

Closed Sandrokkan closed 1 year ago

Sandrokkan commented 1 year ago

By clicking on the booking confirmation or cancellation confirmation buttons, the button does not update automatically but only after updating the page

Moodle 4.1 Theme Moove Booking 8.0.32 2023083000

bernhard-wunderbyte commented 1 year ago

This has probably something to do with the customform condition or with subbookings.

Could you try the following: First update to Booking 8.0.33 (https://github.com/Wunderbyte-GmbH/moodle-mod_booking/releases/tag/v8.0.33) - go to the option where the problem occurs and click "Edit booking option" => Under "Availability conditions" check if there is a custom form condition. If so: Remove the checkbox. Also under "Subbookings" remove any subbookings if there are any. Now save the booking option. => Does the problem still occur?

bernhard-wunderbyte commented 1 year ago

One more thing, please also remove any "Booking policy" in your Booking instance settings for testing.

Sandrokkan commented 1 year ago

I followed all your instructions but the problem persists

bernhard-wunderbyte commented 1 year ago

This is how it should behave: https://github.com/Wunderbyte-GmbH/moodle-mod_booking/assets/78346453/3509149a-63ff-4b72-b3a1-65fdfb3de3b3

Does the problem occur with other booking options too?

Sandrokkan commented 1 year ago

By clicking on the buttons, the warnings do not disappear. Yes, I also encountered the problem with other booking options

bernhard-wunderbyte commented 1 year ago

What do you mean by warnings?

Sandrokkan commented 1 year ago

The button that says "do you really want to book " and the button "Do you really want to be removed from this booking option?"

bernhard-wunderbyte commented 1 year ago

Could you provide the following information:

Sandrokkan commented 1 year ago

I use Chrome I cleared the cache I entered the boost mail theme the problem persists

bernhard-wunderbyte commented 1 year ago

@georgmaisser Could you please have a look at this?

bernhard-wunderbyte commented 1 year ago

One more thing: Which version of local_wunderbyte_table do you use?

Sandrokkan commented 1 year ago

1.6.9 2023081100

georgmaisser commented 1 year ago

I just tried the exact same setup (booking 2023083000 & wunderbyte_table 2023081100) and normal booking works fine.

Do you have any settings in the booking option which could lead to this error?

Do you try booking with a student, a teacher or an admin user?

Sandrokkan commented 1 year ago

I didn't set any particular settings

georgmaisser commented 1 year ago

when you know the Chrome dev tools, you can look at the network panel. Once you click on the "do you really want to book"-button, you will see that there is a call going out like this: http://10.111.0.2:8000/lib/ajax/service.php?sesskey=y69JrJFl2M&info=mod_booking_bookit

When you look at the response, there might be an error. You might need to turn on the debug messages on your system, to really get a meaningful message. Can you send this error message?

Sandrokkan commented 1 year ago

https://seclabstaging.sec-lab.com/moodle/lib/ajax/service.php?sesskey=Z31yhKUB44&info=mod_booking_bookit

georgmaisser commented 1 year ago

Can you turn on debug information? and execute this request?

website administration -> development -> debugging Please set the first select to "Developer" and check "show debug messages"

Sandrokkan commented 1 year ago

I see no errors

bernhard-wunderbyte commented 1 year ago

https://seclabstaging.sec-lab.com/moodle/lib/ajax/service.php?sesskey=Z31yhKUB44&info=mod_booking_bookit

The error message says "Invalid json in request" => so what we need to find out is what about the JSON is invalid. Could you post it here?

After the second click (the one which doesn't work) go to DevTools > Network > click on the mod_booking_bookit webservice call > go to "Payload" > Request payload > Right click on the top node > Copy value

Please also copy the full response JSON (under the "response" tab).

Sandrokkan commented 1 year ago

Unfortunately I'm not a developer and don't know where to go. Could you make me some screenshots?

bernhard-wunderbyte commented 1 year ago

Bildschirmfoto 2023-09-01 um 09 58 05 Bildschirmfoto 2023-09-01 um 09 58 57 Bildschirmfoto 2023-09-01 um 09 59 40 Bildschirmfoto 2023-09-01 um 09 59 59

Sandrokkan commented 1 year ago

[ { "error": false, "data": { "status": 0, "message": "notallowedtobook", "template": "mod_booking\/bookit_button", "json": "[{\"data\":{\"itemid\":10,\"area\":\"option\",\"userid\":2,\"dataaction\":\"\",\"nojs\":false,\"main\":{\"label\":\"Click again to confirm booking\",\"class\":\"btn btn-warning w-100 text-center\",\"role\":\"button\"},\"fullwidth\":true,\"componentname\":\"mod_booking\"}}]" } } ]

Sandrokkan commented 1 year ago

I hope I copied the information you need

bernhard-wunderbyte commented 1 year ago

This is the correct respons after the first click. As "error" is false, we see that it worked correctly. Now we need to see the response after the second click.

Sandrokkan commented 1 year ago

[ { "error": true, "exception": { "message": "Eccezione - str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string", "errorcode": "generalexceptionmessage", "link": "https:\/\/seclabstaging.sec-lab.com\/moodle\/mod\/booking\/view.php?id=157", "moreinfourl": "https:\/\/docs.moodle.org\/402\/it_wp\/error\/moodle\/generalexceptionmessage" } } ]

bernhard-wunderbyte commented 1 year ago

I added a fix in wunderbyte table which might be responsible for this error. Could you install wunderbyte table 1.7.0 and test it?

https://github.com/Wunderbyte-GmbH/moodle-local_wunderbyte_table/releases/tag

Sandrokkan commented 1 year ago

Unfortunately the problem persists

bernhard-wunderbyte commented 1 year ago

Please go to https://seclabstaging.sec-lab.com/moodle/admin/environment.php

Is your Moodle version really 4.1? Which PHP version do you use?

Sandrokkan commented 1 year ago

Sorry I was wrong the version is 4.2 PHP 8

bernhard-wunderbyte commented 1 year ago

The problem is most probably PHP 8 which produces the exception with str_replace. If in any way possible please use PHP 7.4 until we have fixed that.

bernhard-wunderbyte commented 1 year ago

Moodle 4.2 might also be problematic. So if it's possible for you, please use the newest version of 4.1 currently.

Sandrokkan commented 1 year ago

I confirm that with Moodle 4.1 everything works correctly. Sorry for my inaccuracy

bernhard-wunderbyte commented 1 year ago

We'll try to fix it for 4.2 soon. I'll close this for now.