Skip to content

Commit

Permalink
MDL-36135 Display the workshop grading evaluation method chooser
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mudrd8mz committed Oct 19, 2012
1 parent 7e8ae12 commit a93dc3e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mod/workshop/lang/en/workshop.php
Expand Up @@ -100,7 +100,7 @@
$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';
Expand Down
1 change: 0 additions & 1 deletion mod/workshop/lib.php
Expand Up @@ -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
Expand Down
36 changes: 35 additions & 1 deletion mod/workshop/locallib.php
Expand Up @@ -185,7 +185,6 @@ public function __construct(stdclass $dbrecord, stdclass $cm, stdclass $course,
} else {
$this->context = $context;
}
$this->evaluation = 'best'; // todo make this configurable although we have no alternatives yet
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -283,6 +282,19 @@ public static function available_strategies_list() {
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
*
Expand Down Expand Up @@ -1229,6 +1241,28 @@ public function grading_strategy_instance() {
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
*
Expand Down
5 changes: 5 additions & 0 deletions mod/workshop/styles.css
Expand Up @@ -520,3 +520,8 @@
.path-mod-workshop div.buttonwithhelp div {
display: inline;
}

.path-mod-workshop #evaluationmethodchooser {
margin: 2em auto;
text-align: center;
}
15 changes: 15 additions & 0 deletions mod/workshop/view.php
Expand Up @@ -38,6 +38,7 @@
$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);
Expand Down Expand Up @@ -73,6 +74,13 @@
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);

Expand Down Expand Up @@ -395,6 +403,13 @@
$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(),
Expand Down

0 comments on commit a93dc3e

Please sign in to comment.