Posts made by Ross Stanbridge

Moodle in English -> General help -> My Moodle not working

by Ross Stanbridge -

"My Moodle" has stopped working on our system.  10% of the time it works.  The other 90% of the time we now get the following output (with debugging switched on):


Ambiguous column name 'sortorder'.

SELECT c.id,c.sortorder,c.shortname,c.idnumber,c.category,c.fullname,c.teacher,c.teachers,c.student,c.students,c.guest,c.startdate,c.visible,c.newsitems,c.cost,c.enrol,c.groupmode,c.groupmodeforce,c.*, ctxid, ctxpath, ctxdepth, ctxlevel, categorypath FROM ( SELECT c.id, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, cc.path AS categorypath FROM mdl_course c JOIN mdl_course_categories cc ON c.category=cc.id JOIN mdl_context ctx ON (c.id=ctx.instanceid AND ctx.contextlevel=50) JOIN mdl_role_assignments ra ON (ra.contextid=ctx.id AND ra.userid=2) UNION SELECT c.id, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel, cc.path AS categorypath FROM mdl_course c JOIN mdl_course_categories cc ON c.category=cc.id JOIN mdl_context ctx ON (c.id=ctx.instanceid AND ctx.contextlevel=50) JOIN mdl_role_capabilities rc ON (rc.contextid=ctx.id AND (rc.capability='moodle/course:view' )) ) inline_view INNER JOIN mdl_course c ON inline_view.id = c.id ORDER BY visible DESC,sortorder ASC
  • line 686 of lib\dmllib.php: call to debugging()
  • line 1065 of lib\accesslib.php: call to get_recordset_sql()
  • line 936 of lib\datalib.php: call to get_user_courses_bycap()
  • line 68 of my\index.php: call to get_my_courses()
No course information to show.
 

Our Moodle setup is Moodle 1.9.3 (20081015), Apache 2.2, Windows 2003, PHP 5.2 and MS SQL 2005 (with FreeTDS DB connection).

Average of ratings: -

Hi Adam,

I had the same issue.  See my forum posting (liked below) for the soloution.  Alternativly upgrade to the very latest version of Moodle as the issue has now been fixed.

http://moodle.org/mod/forum/discuss.php?d=106337

In addition to this it is importent to note that you will need to put the courses back where they came were first created/restored before they will have the correct permissions again.  If the original location no longer exists, or cannot be recalled then back the course up and restore it back again.  I had problems backing up and restoring using MS SQL though.  If you have the same then turn debugging on and set the table fields mentioned when backup/restore fails to allow NULL fields.  Alternativly search the forums for a list of tables and fields that should allow NULL values.

Hope this helps,

Ross

Hi John,

Have applied the change on our test server and it works!! I'll double check on our live server then post the updated accesslib.php file for anyone else that wants it (or is too lazy to edit the code by hand! tongueout).

For anyone that wants to do the change by hand using John's instructions above note that you will also need to put a ,0 after the +1 as substring requires this variable.

Cheers for the help - much appreciated .

Ross

Average of ratings: Useful (2)

Just talked to our database guy and it looks like the error I reported above is related to MS SQL.  MS SQL doesn't know what SUBSTR is.  In MS SQL it is called SUBSTRING.  However the MS SQL version need to have a length parameter set.

I'll hopefully run some tests on this today.  I'll post the results as soon as I have.  Maybe this will solve the issue with the non-editable course content?!  Fingers crossed eh! smile

Cheers,

Ross

Hi Bill,

Sounds like we are both having exactly the same problem!  I also tried running the User Roles reports and just get a blank page.

Our Moodle setup is as follows:

  • Moodle 1.9.2
  • Apache 2.2
  • PHP 5.2.6
  • MS SQL 2005 (on seperate server)
  • FreeTDS (for communication between Moodle and MS SQL)

You mentioned you had MS SQL 2005.  How similar is the rest of your setup to ours?

I have noticed that if you turn on debugging (server > debuggin) and set the level to ALL you get the following error when you move your course.

'SUBSTR' is not a recognized built-in function name.

UPDATE mdl_context SET path = CAST('/1/3/12' AS VARCHAR(255))+CAST(SUBSTR(path, 8 +1) AS VARCHAR(255)) WHERE path LIKE '/1/11/12/%'
  • line 103 of lib\dmllib.php: call to debugging()
  • line 5438 of lib\accesslib.php: call to execute_sql()
  • line 3158 of course\lib.php: call to context_moved()
  • line 122 of course\edit.php: call to update_course()
Error output, so disabling automatic redirect.
Cheers,

Ross