Issue Details (XML | Word | Printable)

Key: MDL-15265
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Martin Dougiamas
Reporter: Richard Burton
Votes: 5
Watchers: 8
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Backport course sortorder rewrite to 1.9.x

Created: 16/Jun/08 10:26 PM   Updated: 17/Dec/09 03:39 PM
Component/s: Other
Affects Version/s: 1.8.4, 1.8.5, 1.9
Fix Version/s: None

File Attachments: 1. Text File sortorders-moodle192.txt (39 kB)
2. Text File sortorders-moodle192.txt (39 kB)
3. Text File sortorders-moodle195.txt (37 kB)
4. Text File sortorders-moodle195_2.txt (37 kB)

Environment:
Debian Etch PHP Version 5.2.0-8+etch7
Issue Links:
Cloners
 
Dependency
 
Relates
 

Database: MySQL
Participants: Anthony Borrow, Dani Ureña, Martin Dougiamas, Michael Blake, Richard Burton, Sean Keogh and Tobias Marx
Security Level: None
Affected Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
I have an installation which when using the page /course/category.php to reorder courses, when you click on the arrows to change the order of a course the page refreshes but nothing else happens. On investigation this seems to be due to the sortorder value in the mdl_course table being set to the maximum allowed for an int field, ie 4294967295.

I reset the values to 1,2,3 and 4 and then tried the arrows buttons again and the values did not change as I had expected, ie the values swapped around but 1000 was added to each value, eg they changed to 1001, 1002 etc. Use one of the arrow buttons again and 1000 was added. E.g. 2001, 2002 etc

I then tried with a set of courses on another installation which I hadn't fiddled with whose values were 13005, 13006 and 13007, I then used the reordering buttons and they changed to 14006, 14005, 14007.

I accept that a user will have to re-order courses quite a few times to reach the int field maximum, but somehow on this site they have. I don't understand why Moodle is adding 1000 to each number, surely it only has to swap the existing values around.

Thanks

Richard



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Anthony Borrow added a comment - 16/May/09 11:03 PM
Nicolas - This was initially assigned to Petr who worked on the patch for HEAD found at MDL-14580; however, it has been marked as being resolved by MDL-14718. A quick glance makes me think that rather than being resolved by MDL-14718 that perhaps this might be a duplicate of MDL-14718. I figured I would assign this to you since it was assigned to nobody simply to determine if it is in fact a duplicate. The issues (or at least something very similar) has been discussed at http://moodle.org/mod/forum/discuss.php?d=93618. If it is a duplicate, then we can resolve this issue in favor or MDL-14718. If it is not a duplicate a comment about what makes it different would be helpful as well. Peace - Anthony

Dani Ureña added a comment - 19/May/09 09:35 PM
I made the backport of MDL-15265 into a 192 version (Build: 20080711) of moodle.
I hope this helps

Anthony Borrow added a comment - 19/May/09 10:15 PM
Thanks Dani - that helps a great deal. Hopefully Nicolas will get a moment to look at it. It is much quicker to check a proposed patch than to produce one. Peace - Anthony

Dani Ureña added a comment - 20/May/09 04:15 PM
I made a small change in the course/index.php file.

Dani Ureña added a comment - 20/May/09 11:03 PM
I created the version 1.9.5 of the patch, that I needed.
I hope you be of help

Anthony Borrow added a comment - 20/May/09 11:16 PM
Dani - A definite help. I know the 1.9.5 /lib/accesslib.php file was giving me trouble with an older 1.9 patch so having something more recent is great. Thanks again! Peace - Anthony

Tobias Marx added a comment - 21/Sep/09 10:40 PM
I have applied the Dani's patch for 1.9.5 to our 1.9.5+ (Build: 20090909) installation (testing system). While it has correctly "compressed" the values in "sortorder" I still can't move courses by clicking on those arrows.
I have enabled debugging and get the following errors:

Duplicate entry '201-7573007' for key 2

UPDATE mdl_course SET sortorder = '7573007' WHERE id = '1176'


Tobias Marx added a comment - 14/Oct/09 01:08 AM
added:

set_field('course', 'sortorder', $max, 'id', $swapcourse->id);

this fixes a problem where courses can't be moved up or down, due to an unique index violation.


Tobias Marx added a comment - 14/Oct/09 01:11 AM
doh!

my above comment relates to the edited patch file that i've attached to this bug. it fixes an issue that we had with Dani's patch.


Anthony Borrow added a comment - 30/Oct/09 11:34 AM
Tobias - Is this issue resolved for your site? I would like to chat with you about this so that I can better understand what is happening. Peace - Anthony

Sean Keogh added a comment - 01/Dec/09 12:51 AM
hey guys, I have a site that has this exact problem. The site is running 1.9.6+ (Build: 20091028)

Has this been put into CVS yet? I'm going to have to update this site to 1.9.7 very soon, and I suspect that the patches above won't work with 1.9.7.

cheers

Sean K


Tobias Marx added a comment - 01/Dec/09 01:09 AM
Hi Sean,

I wouldn't advice using those patches. We ran into a lot of problems with them. Though you could try to use them to get rid of your problems for the time beeing.

When you apply the patches a function will "compress" the sortorder values the first time you try to move a course around. This seems to work just fine. But after that a lot of errors occured (index violations when moving courses (only with some), etc.), so I've reinstalled the standard Moodle files (just copied them over the patched ones).

This left me with a Moodle installation which will run "out of numbers" sometime in the future, but for the time beeing everything works fine.

I know this is not really a fix, but at least we have a working Moodle installation. I will cope with sortorder fix when it emerges again.

Btw.: Please don't use "sortorders-moodle195_2.txt", I might have "fixed it to be broken"...


Sean Keogh added a comment - 10/Dec/09 02:55 AM
I tried the 195 set of patches, and it failed on the category.php bit. Could this be because the 1.9.6 version of this file is too different for the patch program to recognise it?

Michael Blake added a comment - 14/Dec/09 08:45 AM
Can we get a fix ported to 1.9x for this please?