MDL-36135 Display the workshop grading evaluation method chooser

Teachers can now choose the actual grading evaluation method to use
during the grading evaluation phase. The workshopeval_best is still used
as the default one (this may be made configurable later, although there
is no big benefit of it).
This commit is contained in:
David Mudrák 2012-10-19 23:31:52 +08:00
parent 7e8ae12a7a
commit a93dc3ecb7
5 changed files with 56 additions and 3 deletions

View File

@ -100,7 +100,7 @@ $string['err_removegrademappings'] = 'Unable to remove the unused grade mappings
$string['evaluategradeswait'] = 'Please wait until the assessments are evaluated and the grades are calculated';
$string['evaluation'] = 'Grading evaluation';
$string['evaluationmethod'] = 'Grading evaluation method';
$string['evaluationmethod_help'] = 'The grading evaluation method determines how the grade for assessment is calculated. There is currently just one option - comparison with the best assessment.';
$string['evaluationmethod_help'] = 'The grading evaluation method determines how the grade for assessment is calculated. You can let it re-calculate grades repeatedly with different settings unless you are happy with the result.';
$string['example'] = 'Example submission';
$string['exampleadd'] = 'Add example submission';
$string['exampleassess'] = 'Assess example submission';

View File

@ -136,7 +136,6 @@ function workshop_update_instance(stdclass $workshop) {
$workshop->useselfassessment = (int)!empty($workshop->useselfassessment);
$workshop->latesubmissions = (int)!empty($workshop->latesubmissions);
$workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);
$workshop->evaluation = 'best';
// todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls
// todo - if maximum grades are being changed, we should probably recalculate or invalidate them

View File

@ -185,7 +185,6 @@ class workshop {
} else {
$this->context = $context;
}
$this->evaluation = 'best'; // todo make this configurable although we have no alternatives yet
}
////////////////////////////////////////////////////////////////////////////////
@ -283,6 +282,19 @@ class workshop {
return $forms;
}
/**
* Returns the list of available grading evaluation methods
*
* @return array of (string)name => (string)localized title
*/
public static function available_evaluators_list() {
$evals = array();
foreach (get_plugin_list_with_file('workshopeval', 'lib.php', false) as $eval => $evalpath) {
$evals[$eval] = get_string('pluginname', 'workshopeval_' . $eval);
}
return $evals;
}
/**
* Return an array of possible values of assessment dimension weight
*
@ -1229,6 +1241,28 @@ class workshop {
return $this->strategyinstance;
}
/**
* Sets the current evaluation method to the given plugin.
*
* @param string $method the name of the workshopeval subplugin
* @return bool true if successfully set
* @throws coding_exception if attempting to set a non-installed evaluation method
*/
public function set_grading_evaluation_method($method) {
global $DB;
$evaluationlib = dirname(__FILE__) . '/eval/' . $method . '/lib.php';
if (is_readable($evaluationlib)) {
$this->evaluationinstance = null;
$this->evaluation = $method;
$DB->set_field('workshop', 'evaluation', $method, array('id' => $this->id));
return true;
}
throw new coding_exception('Attempt to set a non-existing evaluation method.');
}
/**
* Returns instance of grading evaluation class
*

View File

@ -520,3 +520,8 @@
.path-mod-workshop div.buttonwithhelp div {
display: inline;
}
.path-mod-workshop #evaluationmethodchooser {
margin: 2em auto;
text-align: center;
}

View File

@ -38,6 +38,7 @@ $page = optional_param('page', 0, PARAM_INT);
$perpage = optional_param('perpage', null, PARAM_INT);
$sortby = optional_param('sortby', 'lastname', PARAM_ALPHA);
$sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA);
$eval = optional_param('eval', null, PARAM_PLUGIN);
if ($id) {
$cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST);
@ -73,6 +74,13 @@ if ($perpage and $perpage > 0 and $perpage <= 1000) {
redirect($PAGE->url);
}
if ($eval) {
require_sesskey();
require_capability('mod/workshop:overridegrades', $workshop->context);
$workshop->set_grading_evaluation_method($eval);
redirect($PAGE->url);
}
$output = $PAGE->get_renderer('mod_workshop');
$userplan = new workshop_user_plan($workshop, $USER->id);
@ -395,6 +403,13 @@ case workshop::PHASE_EVALUATION:
$showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
if (has_capability('mod/workshop:overridegrades', $PAGE->context)) {
// Print a drop-down selector to change the current evaluation method.
$selector = new single_select($PAGE->url, 'eval', workshop::available_evaluators_list(),
$workshop->evaluation, false, 'evaluationmethodchooser');
$selector->set_label(get_string('evaluationmethod', 'mod_workshop'));
$selector->set_help_icon('evaluationmethod', 'mod_workshop');
$selector->method = 'post';
echo $output->render($selector);
// load the grading evaluator
$evaluator = $workshop->grading_evaluation_instance();
$form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(),