Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort Answers - Questions Column #42

Open
demontech opened this issue Oct 30, 2020 · 3 comments
Open

Sort Answers - Questions Column #42

demontech opened this issue Oct 30, 2020 · 3 comments
Labels

Comments

@demontech
Copy link

Hi AL,

Hope everything is fine with you!

I wanted to check with you if there's a way to add a functionality to sort the answers. I'm creating an auction in my classroom, and all the entries need to be values.

Maybe every time you click on the Questions header column it swaps the sorting order of the answers. A-Z or highest to lowest then goes to the opposite, of course, keeping the current sorting which it's by answer date newest to oldest.

Thanks and congrats on this wonderful plugin!

Mark

@drachels
Copy link
Owner

Hi Mark, I don't have time to work on this new sort functionality at the moment, but you can "simulate" it with the priority column. The teacher just needs to click the up/down thumbs to raise/lower the count as needed to get the desired order.

@demontech
Copy link
Author

Hi AL,

I see that's an option. Thank you for your quick reply, hopefully this can be developed someday.

Stay Safe!

Mark

@drachels
Copy link
Owner

The option to sort the question content the way you want to, is not practical, without a lot of extra coding. The teacher priority is your best option, because it is a numerical field in the table and gets sorted the way you would expect. The question content field is a text field and gets sorted based on left to right evaluation of the contents. e.g. Let's say you have the following bids: 5, 10, and 11. We want to sort descending where we expect the high bid of 11 to be first, then 10, and finally 5. However if I sort the question DESC (highest to lowest), we will get 5, 11, 10, which is NOT what you want. You will see that any number from 10 to 49, will come after the 5.
If you have access to a development server for your Moodle you can try this yourself. Look for the get_questions function in yourmoodle/mod/hotquestion/locallib.php. In the current HQv3.9.2 it should be about line number 425. In line 440, look at the ORDER BY, and change it from this:
ORDER BY tpriority DESC, votecount DESC, q.time DESC', $params);
to this:
ORDER BY q.content DESC, tpriority DESC, votecount DESC, q.time DESC', $params);
Now, in your Hot Question auction activity place some bids, and you should quickly see how your results are NOT what you want. Since the tpriority is evaluated after the content, you can override and make the order correct. But, if you are doing that, you might as well just use the tpriority to begin with.
Be sure and change line 440 back to the original code when you are done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants