maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
141 stars 150 forks source link

Iss 1041 - Sort PRT nodes for display #1116

Closed EJMFarrow closed 7 months ago

EJMFarrow commented 7 months ago

Nodes are being display 1, 2, 11, 12, 3, 4, 5, 6, 7, 8, 9, 10

The node names are stored as strings but are always integers. However, the stored name is one less than the displayed name (and indeed any new name entered on the tidy page). This is the reason for the bizarre sort order - string sort on an integer combined with an off-by-one issue.

Unfortunately, as maths is being done on the names, adding a leading zero isn't going to work. The order of creation is also not preserved in the DB when a new version of the question is created as the new node records are saved in the mangled order.

Simplest solution is to sort nodes when they're requested.

sangwinc commented 7 months ago

Thanks for sorting out this obvious mess @EJMFarrow !