drachels / moodle-mod_hotquestion

An activity to help teachers collect questions from students in or out of the classroom.
5 stars 15 forks source link

Hot Question Activity Completion possible bug #97

Closed dragos5436 closed 2 months ago

dragos5436 commented 3 months ago

Hi there,

We recently discovered an odd behaviour when setting conditions for the Hot Question Activity Completion. On the activity settings page, select 'Add requirements' and then either 'Student must add questions:' or 'Student must add heat:'. Then go into the activity and submit a question or give heat to another question. A 'Done' label will then be visible inside the activity (Fig. 1) as well as a green tick in the completion dropdown on the right-hand side of the activity on the course page (Fig. 2). However the completion button will still remain set as 'To Do' rather than 'Done' (Fig. 2 & 3). Screenshots are for the 'Post question' requirement, but the behaviour is the same for the 'Give heat' requirement or for a combination of these two.

image Fig. 1

image Fig. 2

image Fig. 3

We tried switching the theme to check if it's related to that, but we observed the same behaviour on different themes. Could this be a bug?

Moodle version: 4.3.5+ HotQuestion version: 4.2.0 (Build: 2024020900)

drachels commented 3 months ago

I suspect this is caused by something changed by Moodle. I had a server running Moodle 4.3.3+ and the completion worked as you would expect it to. However, I then upgraded the server to the latest Moodle 4.3.5 and tested with another user name and the completion for Post question: 1, no longer worked.

drachels commented 3 months ago

I have gone back to a Moodle 4.2 site for testing and all the completions worked as expected. I will have to do some more digging around to see if I can figure out what has happened.

drachels commented 3 months ago

I will do more testing, but I just now I have gone back to the Moodle 4.3.5 upgraded site and now post question 1 and give heat 1 are both working correctly.

dragos5436 commented 3 months ago

Hi,

Thank you for looking into this. Is there anything you recommend we do on our end to fix this or should we wait until we upgrade to Moodle 4.4 which might resolve it?

drachels commented 3 months ago

An upgrade to Moodle 4.4 will not fix this. Right now if the teacher edits the activity and saves it without making any changes, it will update the status, including To do, for all the completions. I have found a couple of places where the completion code for HotQuestion needs to be updated, and the only remaining thing I need to work on is to get it to update the To do in the course topics.

dragos5436 commented 3 months ago

Thank you again for investigating this. Please let us know if there is any progress on it

drachels commented 3 months ago

Just created a new branch, HotQuestion v4.2.1 RC1. That seems to do what is needed for completions to work like they should for post and vote. Still need to do some more testing for the grade/rating. I will not be able to do that until tomorrow, but thought you might be able to start testing, too.

dragos5436 commented 3 months ago

Hi,

I've tested the changes and can confirm that completion now works for the 'post question' condition. However for the 'give heat/vote' condition at first the completion doesn't seem to pick up the change: image However, after entering the question activity and navigating back to the course page the 'To do' status is finally changed to 'Done'.

drachels commented 3 months ago

The reason for the difference in behavior is that making a post reloads the view.php page, which does an immediate update_state for completions. When a user clicks the little hand icons to apply heat/vote, it stays on the view.php page and therefore does not invoke the update_state. I think I am going to do the standard method of adding a hotquestion/classes/task/cron_task.php. file that will do an update_state to get things on the course page to change to, Done.

I have tried adding a redirect to the view.php page, but then I get a, Too many redirects error.

drachels commented 3 months ago

I have just added branch, MOODLE_427_RC2, which seems to do the, Done, completion in the course like other Moodle activities. It implements a, hotquestion/classes/task/cron_task.php, file that runs every 60 seconds. Will be doing some more testing before doing a new release. I will try to get it done soon, but I seem to have come down with a minor sinus infection making me feel pretty bad right now, so I will not get to this until tomorrow. Hopefully, you will get a chance to check it out and let me know what you think.

drachels commented 2 months ago

I still need to do some code cleanup and testing, but the branch, MOODLE_421_RC3, now does immediate completion updates and switches the, To do, over to, Done, right away.

dragos5436 commented 2 months ago

Hi there,

I just tested it again and it now works as you said, with immediate completion updates and switches the 'To do' to 'Done' right away for the 'Give heat' condition. I can see your updates are already on the master branch, so I think we can consider this issue as resolved now. Thank you very much for your help and prompt responses, it is very much appreciated.

Best wishes, Dragos

drachels commented 2 months ago

Thank you for letting me know of the problem and confirming it is now working the way we need it too. I will try to get the new version released in the next day or two. I was just running Codechecker on HotQuestion when I saw that you had closed the issue, so thanks again.