/** * Create a new rule object from record. */ public static function from_record($record) { $record = (object) $record; $obj = static::create_rule($record->rule, $record->config); $obj->id = $record->id; $obj->target = \tool_cat\target::create_target($record->target, $record->targetid); if (empty($record->datatype)) { $record->datatype = 'standard'; $record->data = null; } // Add a datatype to the rule. $datatype = \tool_cat\datatype::create_datatype($record->datatype, $record->data); $obj->target->set_datatype($datatype); return $obj; }
/** * Returns a list of valid activities for the activity. * * @return array [string] * @throws \invalid_parameter_exception */ public static function get_activities() { $obj = \tool_cat\datatype::create_datatype('activity'); $keys = $obj->get_supported_activities(); $values = array_map(function ($str) { return get_string('pluginname', "mod_{$str}"); }, $keys); return array_combine($keys, $values); }