MDL-43908 mod_assign: Remove redundant code and improve SQL query

Signed-off-by: Tony Butler <tonyjbutler@gmail.com>
MDL-43908 mod_assign: Order submissions by course id then cm id

Signed-off-by: Tony Butler <tonyjbutler@gmail.com>