Fixing query see BT#7386
Minor - refactor code.
Merge branch '1.9.x' of ssh://github.com/chamilo/chamilo-lms into chamilo19