Best practice forum (Archived)

organisations displayed in wrong order

 
? ?
organisations displayed in wrong order
by ? ? - Monday, 15 July 2013, 7:58 AM
 

We have a large organisation hierarchy in Totara 1.1 which is showing some odd behaviour when viewed in "Manage Organisations". There are a few hundred entities organised geographically with Towns in Regions in Zones. This has appeared to work as expected for several months as far as the reporting goes, but now we have to re-distribute these with some Towns being allocated to different Regions and we've discovered that some of them are displayed in the wrong order.

In the screenshot below I've drawn rectangles around the orgs which are (from the top) in Region 28, 26 and 27 but which all appear under region 28. Clicking the edit icon shows the correct region (parent org) and you can see they all have the correct up/down arrow icons to move within their correct parents. Downloading the spreadsheet from here also contains the same errors so presumably this rules out any javascript post-processing which was my best guess so far.

Looking into the database mdl_org table shows the correct values for their heirarchy and they generally seem to behave themselves in reporting, however reorganising them has become a confusing chore.

Anyone else seen anything like this, or got any suggestions?

 

orgs

Yuliya Bozhko
Re: organisations displayed in wrong order
by Yuliya Bozhko - Tuesday, 16 July 2013, 5:06 PM
 

Hi Alan

This is indeed a strange behaviour. I will try to reproduce this and will let you know.

Yuliya

me
Re: organisations displayed in wrong order
by George Angus - Monday, 22 July 2013, 3:50 PM
Group Totara

Hi Alan,

Apologies for the delay in getting back. Can you provide us with a copy of the database mdl_org table? Is there any chance you can give us a detailed description of what you did in order to get this error - or can you recreate it? This is very likely a bug, but we need a bit more info to nail it down!

regards,

 

George.

? ?
Re: organisations displayed in wrong order
by ? ? - Wednesday, 24 July 2013, 5:44 AM
 

Thanks for looking. File attached (I've anonymised it, but would would appreciate if you can delete from forum once received. I wasn't sure how else to send it)

This is all the mdl_org* tables in case there is something pertinent going on with frameworks or elsewhere.

I just imported this into a different totara install and it reproduced the same error.

This page demonstrates the problem:
..../hierarchy/index.php?prefix=organisation&frameworkid=7&page=1

(Edited by Simon Coggins (Totara Software Architect) - original submission Thursday, 25 July 2013, 12:44 AM)

Simon Coggins
Re: organisations displayed in wrong order
by Simon Coggins - Wednesday, 24 July 2013, 4:47 PM
Group Totara

Hi Alan,

I've removed the file now thanks.

This is indeed very strange. It's clear from the database that the sort order has been messed up, but unfortunately there is no clear trail as to what caused it to happen in the first place.

I have created a script that will fix the sort order for you - as long as you are on at least 1.1.13 (or above). You just need to put the attached script in your site's webroot then visit the url via a browser:

[site-url]/fix.php

It should sit there for a while then print 'DONE!'. Once the page finishes loading they should all be fixed. I would suggest backing up your database before you do this operation as a precaution.

As to the cause, to help me narrow down what could have happened, can you let me know if you've done any of the following on your site (between when everything was ok and when it started going wrong):

  • Reorder organisations using the up/down arrows on the hierarchy index page
  • Move organisations by editing an individual organisation and changing it's parent
  • Bulk move organisations using the bulk actions pulldown
  • Any kind of import or sync operation to populate or update your hierarchies

Simon

? ?
Re: organisations displayed in wrong order
by ? ? - Thursday, 25 July 2013, 4:22 AM
 

Thanks hugely for this. 

We're not sure when it went wrong but have certainly moved orgs around in all the first three ways in your list during the past few months.

We are stuck at version 1.1.11 due to customisations, so your script isn't working. However from this I see there is a function fix_sortthreads() introduced later which I may be able to use (presumably as long as there are no org table changes between versions?)

fix_sortthreads()  sort of implies there must have been a known bug there somewhere so this is all pointing us in the right direction.

thanks again
Alan 

Simon Coggins
Re: organisations displayed in wrong order
by Simon Coggins - Thursday, 25 July 2013, 1:29 PM
Group Totara

Hi Alan,

Yes, we have had this issue reported once before, and like now we really struggled to pin down the cause. Since the fix_sortthreads() function fixed it for them and they didn't report any more problems we assumed it was a one off glitch, import problem or a bug that did exist but has subsequently been fixed. The original thread is here:

https://totara.community/mod/forum/discuss.php?d=1388

Looking at the changelog I can't see anything in 1.1.12 or 1.1.13 that would stop you from just copying the fix_sortthreads() function into your code, which would allow you to run the script.

I will try again to narrow down the cause of this based on your comments and using the data you provided. If you have any more problems and are able to describe exactly what caused it (something like: Moved org item "item 1" from parent "item 2" to parent "item 3") that would be of great help.

Simon

? ?
Re: organisations displayed in wrong order
by ? ? - Tuesday, 30 July 2013, 7:59 AM
 

I've applied that fix and it seems to have worked a treat.

Thanks again

Alan