MDL-28248 completion: Incorrect SQL for finding enrol start date
authorAaron Barnes <aaron.barnes@totaralms.com>
Fri, 19 Aug 2011 02:56:29 +0000 (14:56 +1200)
committerAaron Barnes <aaron.barnes@totaralms.com>
Wed, 24 Aug 2011 00:05:34 +0000 (12:05 +1200)
lib/completion/completion_criteria_duration.php

index 6ce85e9..bc2c8a0 100644 (file)
@@ -90,7 +90,12 @@ class completion_criteria_duration extends completion_criteria {
     private function get_timeenrolled($completion) {
         global $DB;
 
-        return $DB->get_field('user_enrolments', 'timestart', array('courseid' => $this->course, 'userid' => $completion->userid));
+        return $DB->get_field_sql('
+            SELECT eu.timestart
+              FROM {user_enrolments} eu
+              JOIN {enrol} e ON eu.enrolid = e.id
+             WHERE e.courseid = ?
+               AND eu.userid = ?', array($this->course, $completion->userid));
     }
 
     /**