Пример #1
0
 /**
  * Returns immediate child contexts of course (most likely classes),
  * decendents beyond immediate children are not returned.
  *
  * @return \local_elisprogram\context\course|array A context instance or an empty array
  */
 public function get_child_contexts()
 {
     global $DB;
     $result = array();
     $contextlevel = \local_eliscore\context\helper::get_level_from_class_name(get_class($this));
     $sql = "SELECT ctx.*\n                  FROM {context} ctx\n                 WHERE ctx.path LIKE ? AND (ctx.depth = ? OR ctx.contextlevel = ?)";
     $params = array($this->_path . '/%', $this->depth + 1, $contextlevel);
     $records = $DB->get_recordset_sql($sql, $params);
     foreach ($records as $record) {
         $result[$record->id] = \local_eliscore\context\base::create_instance_from_record($record);
     }
     unset($records);
     return $result;
 }