コード例 #1
0
ファイル: generator_test.php プロジェクト: evltuma/moodle
 public function test_create_competency()
 {
     $this->resetAfterTest(true);
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $framework = $lpg->create_framework();
     $this->assertEquals(0, competency::count_records());
     $competency = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $this->assertEquals(2, competency::count_records());
     $this->assertInstanceOf('\\core_competency\\competency', $competency);
 }
コード例 #2
0
ファイル: api.php プロジェクト: gabrielrosset/moodle
 /**
  * Perform a search based on the provided filters and return a paginated list of records.
  *
  * Requires moodle/competency:competencyview capability at some context.
  *
  * @param array $filters A list of filters to apply to the list.
  * @return int
  */
 public static function count_competencies($filters)
 {
     static::require_enabled();
     if (!isset($filters['competencyframeworkid'])) {
         $context = context_system::instance();
     } else {
         $framework = new competency_framework($filters['competencyframeworkid']);
         $context = $framework->get_context();
     }
     // First we do a permissions check.
     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.
     return competency::count_records($filters);
 }