Esempio n. 1
0
 /**
  * Perform a text search based and return all results and their parents.
  *
  * Requires moodle/competency:competencyview capability at the framework context.
  *
  * @param string $textsearch A string to search for.
  * @param int $competencyframeworkid The id of the framework to limit the search.
  * @return array of competencies
  */
 public static function search_competencies($textsearch, $competencyframeworkid)
 {
     static::require_enabled();
     $framework = new competency_framework($competencyframeworkid);
     // First we do a permissions check.
     $context = $framework->get_context();
     if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $context)) {
         throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
     }
     // OK - all set.
     $competencies = competency::search($textsearch, $competencyframeworkid);
     return $competencies;
 }