Unapproved items are not displayed reliably when using PostgreSQL
ksteitz opened this issue · 12 comments
We discovered a new issue using PostgreSQL.
The behaviour is as follows:
- Load the hotquestion activity
- If unapproved items don't show, refresh > unapproved items show.
- Once refreshing again, the unapproved items disappear.
- With every refresh, the items appear/disappear, depending on if they were visible before.
We could replicate this behaviour with different Moodle versions (3.11, 4.1, 4.2).
It makes no difference if we use a freshly installed version of the plugin or if it's an existing one that was updated.
We even tested on a completely fresh Moodle installation with nothing but the hotquestion plugin installed, the behaviour is always the same.
In our installations we are using PostgreSQL as our database.
To narrow down the cause of the problem, we then tested the behaviour with a Moodle installation that uses a MySQL database: here, the unapproved items always show reliably.
So, it seems this is an issue only related to PostgreSQL.
Thanks for the bug report. I am able to reproduce the bug on my PostgreSQL v14.7 server and Moodle 4.1.3+. I will take a look at it today and see if I can come up with a fix, hopefully soon.
I have found the problem and it occurs with MariaDB and MySQL, also, so I will try to get it fixed in a couple of days. I had discovered this a few weeks ago when I ran into the same bug in another plugin I maintain, but I got sick and so did my dog. I recovered but unfortunately, she did not and I just forgot to follow up on fixing it here in HotQuestion.
I have a working fix that I've only had time to test in MariaDB. I have to quit for today, but I am going to push a working copy to git hub master branch today that has a bunch of comments I need to remove, so you can try it out if you want too.
Just pushed code changes for the new preferences selector to the master branch that fixes a bug in Moodle 3.11. I have the new code working at https://m3x.drachels.com/mod/hotquestion/view.php?id=2937
Still need to track down and fix another bug in Moodle 3.11 where it is not treating the link for, View all course Hot Questions, the way I want it to.
Thanks for the quick answer and very quick fix. I just tested it (6c214cc) and it looks like intended: There is a new drow-down "Unapproved question visibility" and it does what it should.
Just one thing is a little bit irritating: There are three drop-down-options, See und Hide unapproved, but the first one is just empty text, see screen attached.
Especcially if that empty option is pre-selected, looks like it´s the case at first call of existing instances after update, it may look like that all questions have suddenly disappeared, until the new drop-down is found.
Thanks for the feedback. That empty option 0 was deliberate to let users know that they need to do something. I just added a new string for that option, Preference not set. With it selected users should not see any questions at all.
The reason I have not tried to do a release yet, is that I have been getting some odd behavior when using Visible groups. In some versions of Moodle the Group selector works as expected. However in some combinations of of Moodle, PHP, and DB, the group drop-down menu does not update unless the user changes the new drop-down too.
I am doing more inspection/testing and will probably try using my own group selector code instead of the one in the API.
Meanwhile, I have just pushed my latest changes to the master branch.
Instead of trying to create my own code for a group selector, I just created a one row table with three cells. It seems to have fixed the Group selector problems I was seeing. Still needs more testing, tomorrow, but I have pushed the latest code to the master branch.
You might want to look and try the latest master branch code as I have changed the new dropdown menu per another user request in issue 82.
Thanks a lot for that improvement, it addresses exactly the issue i mentioned two weeks ago above.
It works fine at our system. I just still wondering why there is an empty option in the first line of the drop-down.
In the meantime i added and improved some german transtlations at AMOS and hoping to reach 100% translation including all new options these days.
Thanks for the feedback.
The blank option has bugged me ever since I came up with this change to the vispreference to replace the toggle link. It just seems to be a function of the html_writer::select() code in the view.php file, at about line 301. Sometime today, I hope to get a chance to get away from that code, and do the drop down menu another way.
20230612 The fix for this was included in yesterday's release of Hot Question v4.1.7.02+.
Thanks a lot AL!
Works fine as expected and is also live at our productive environement in the meantime.