Course Doesn't Exist - Moodle 2.9

Course Doesn't Exist - Moodle 2.9

by Dave Emsley -
Number of replies: 1

Hi there,

I have an issue with a course that does not exist.  I need to ask a couple of questions please:

On the help page it says:   "To fix this problem, try running Cron repeatedly until you see the message "Running clean-up tasks..." near the top of the output."  

  1. Does cron renumber the courses to remove deleted courses?  (not normal practice but I need to ask)
  2. Using $course = get_course($row->courseid); I can't seem to catch the error with:
    if (!$course) {
         some code
    }

    How can I catch the error?

Cheers


Dave




Average of ratings: -
In reply to Dave Emsley

Re: Course Doesn't Exist - Moodle 2.9

by A. Obeid -
I don't think cron renumber courses. course-ids remain the same. Deleted courses-ids return "Can not find data record in database table course."
if $course not set, try  if (!isset($courses)) {...}.
get_course if id not empty return $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 
and that trows an dml_missing_record_exception.