/** * Factory method returning an instance of the grading manager * * There are basically ways how to use this factory method. If the area record * id is known to the caller, get the manager for that area by providing just * the id. If the area record id is not know, the context, component and area name * can be provided. Note that null values are allowed in the second case as the context, * component and the area name can be set explicitly later. * * @category grading * @example $manager = get_grading_manager($areaid); * @example $manager = get_grading_manager(context_system::instance()); * @example $manager = get_grading_manager($context, 'mod_assignment', 'submission'); * @param stdClass|int|null $context_or_areaid if $areaid is passed, no other parameter is needed * @param string|null $component the frankenstyle name of the component * @param string|null $area the name of the gradable area * @return grading_manager */ function get_grading_manager($context_or_areaid = null, $component = null, $area = null) { global $DB; $manager = new grading_manager(); if (is_object($context_or_areaid)) { $context = $context_or_areaid; } else { $context = null; if (is_numeric($context_or_areaid)) { $manager->load($context_or_areaid); return $manager; } } if (!is_null($context)) { $manager->set_context($context); } if (!is_null($component)) { $manager->set_component($component); } if (!is_null($area)) { $manager->set_area($area); } return $manager; }