- if (!$this->timeenrolled) {
- // Get users timenrolled
- // Can't find a more efficient way of doing this without alter get_users_by_capability()
- $context = get_context_instance(CONTEXT_COURSE, $this->course);
- if ($roleassignment = $DB->get_record('role_assignments', array('contextid' => $context->id, 'userid' => $this->userid))) {
- $this->timeenrolled = $roleassignment->timestart;
- } else {
- $this->timeenrolled = 0;
- }