From: David Mudrak Date: Mon, 4 Jan 2010 18:17:03 +0000 (+0000) Subject: Getting rid of supports_evaluation() X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5c397bab9256a459acd482c6a35085051954f503;p=moodle.git Getting rid of supports_evaluation() This seems to be over-desing-patternized. Methods needed by standard eval plugins (ie part of standard distribution) are part of strategy API. Contributed eval methods will have to patch strategy plugins if they need some other data from them. --- diff --git a/mod/workshop/eval/best/lib.php b/mod/workshop/eval/best/lib.php index 5e6103fe84..e73c8e80ac 100644 --- a/mod/workshop/eval/best/lib.php +++ b/mod/workshop/eval/best/lib.php @@ -61,10 +61,6 @@ class workshop_best_evaluation implements workshop_evaluation { global $DB; $grader = $this->workshop->grading_strategy_instance(); - if (! $grader->supports_evaluation($this)) { - throw new coding_exception('The currently selected grading strategy plugin does not - support this method of grading evaluation.'); - } // get the information about the assessment dimensions $diminfo = $grader->get_dimensions_info(); diff --git a/mod/workshop/form/accumulative/lib.php b/mod/workshop/form/accumulative/lib.php index 41a44eec48..68c8cf3fdd 100644 --- a/mod/workshop/form/accumulative/lib.php +++ b/mod/workshop/form/accumulative/lib.php @@ -241,34 +241,7 @@ class workshop_accumulative_strategy implements workshop_strategy { } /** - * Returns true if the given evaluation method is supported by this strategy - * - * To support an evaluation method, the strategy subplugin must usually implement some - * required public methods. In theory, this is what interfaces should be used for. - * Unfortunatelly, we can't extend "implements" declaration as the interface must - * be known to the PHP interpret. So we can't declare implementation of a non-installed - * evaluation subplugin. - * - * @param workshop_evaluation $evaluation the instance of grading evaluation class - * @return bool true if the evaluation method is supported, false otherwise - */ - public function supports_evaluation(workshop_evaluation $evaluation) { - if (is_a($evaluation, 'workshop_best_evaluation')) { - return true; - } - // all other evaluation methods are not supported yet - return false; - } - - //////////////////////////////////////////////////////////////////////////////// - // Methods required by the 'best' evaluation plugin // - //////////////////////////////////////////////////////////////////////////////// - - /** - * TODO - * - * @param resource $restrict - * @return TODO + * @see parent::get_assessments_recordset() */ public function get_assessments_recordset($restrict) { global $DB; @@ -298,9 +271,7 @@ class workshop_accumulative_strategy implements workshop_strategy { } /** - * TODO: short description. - * - * @return array [dimid] => stdClass (->id ->max ->min ->weight) + * @see parent::get_dimensions_info() */ public function get_dimensions_info() { global $DB; diff --git a/mod/workshop/form/lib.php b/mod/workshop/form/lib.php index 0f6400771d..69ba242390 100644 --- a/mod/workshop/form/lib.php +++ b/mod/workshop/form/lib.php @@ -79,20 +79,6 @@ interface workshop_strategy { */ public function form_ready(); - /** - * Returns true if the given evaluation method is supported by this strategy - * - * To support an evaluation method, the strategy subplugin must usually implement some - * required public methods. In theory, this is what interfaces should be used for. - * Unfortunatelly, we can't extend "implements" declaration as the interface must - * be known to the PHP interpret. So we can't declare implementation of a non-installed - * evaluation subplugin. - * - * @param workshop_evaluation $evaluation the instance of grading evaluation class - * @return bool true if the evaluation method is supported, false otherwise - */ - public function supports_evaluation(workshop_evaluation $evaluation); - /** * Returns a general information about the assessment dimensions * diff --git a/mod/workshop/form/numerrors/lib.php b/mod/workshop/form/numerrors/lib.php index e2d8ea032d..02da64b4cf 100644 --- a/mod/workshop/form/numerrors/lib.php +++ b/mod/workshop/form/numerrors/lib.php @@ -275,26 +275,6 @@ class workshop_numerrors_strategy implements workshop_strategy { return false; } - /** - * Returns true if the given evaluation method is supported by this strategy - * - * To support an evaluation method, the strategy subplugin must usually implement some - * required public methods. In theory, this is what interfaces should be used for. - * Unfortunatelly, we can't extend "implements" declaration as the interface must - * be known to the PHP interpret. So we can't declare implementation of a non-installed - * evaluation subplugin. - * - * @param workshop_evaluation $evaluation the instance of grading evaluation class - * @return bool true if the evaluation method is supported, false otherwise - */ - public function supports_evaluation(workshop_evaluation $evaluation) { - if (is_a($evaluation, 'workshop_best_evaluation')) { - return true; - } - // all other evaluation methods are not supported yet - return false; - } - //////////////////////////////////////////////////////////////////////////////// // Internal methods // //////////////////////////////////////////////////////////////////////////////// diff --git a/mod/workshop/form/rubric/lib.php b/mod/workshop/form/rubric/lib.php index 12cabcb930..41b0eea216 100644 --- a/mod/workshop/form/rubric/lib.php +++ b/mod/workshop/form/rubric/lib.php @@ -289,36 +289,7 @@ class workshop_rubric_strategy implements workshop_strategy { } /** - * Returns true if the given evaluation method is supported by this strategy - * - * To support an evaluation method, the strategy subplugin must usually implement some - * required public methods. In theory, this is what interfaces should be used for. - * Unfortunatelly, we can't extend "implements" declaration as the interface must - * be known to the PHP interpreter. So we can't declare implementation of a non-installed - * evaluation subplugin. - * - * @param workshop_evaluation $evaluation the instance of grading evaluation class - * @return bool true if the evaluation method is supported, false otherwise - */ - public function supports_evaluation(workshop_evaluation $evaluation) { - if (is_a($evaluation, 'workshop_best_evaluation')) { - return true; - } - // all other evaluation methods are not supported yet - return false; - } - - //////////////////////////////////////////////////////////////////////////////// - // Methods required by the 'best' evaluation plugin // - //////////////////////////////////////////////////////////////////////////////// - - /** - * Returns recordset with information of all assessments done using this strategy - * - * Required by /eval/best grading evaluation subplugin - * - * @param array|int|null $restrict optional id or ids of the reviewer - * @return moodle_recordset + * @see parent::get_assessments_recordset() */ public function get_assessments_recordset($restrict=null) { global $DB; @@ -348,11 +319,7 @@ class workshop_rubric_strategy implements workshop_strategy { } /** - * Returns a general information about the assessment dimensions - * - * In rubric, all dimensions have the same weight. - * - * @return array [dimid] => stdClass (->id ->max ->min ->weight) + * @see parent::get_dimensions_info() */ public function get_dimensions_info() { global $DB;