NOMDL workshop: added new toolbox viewlet, first tool lets you to clear aggregated grades

This commit is contained in:
David Mudrak
2010-07-09 07:55:23 +00:00
parent 029a311744
commit 32c78bc325
6 changed files with 132 additions and 1 deletions
+4
View File
@@ -63,6 +63,9 @@ $string['calculategradinggrades'] = 'Calculate assessment grades';
$string['calculategradinggradesdetails'] = 'expected: {$a->expected}<br />calculated: {$a->calculated}';
$string['calculatesubmissiongrades'] = 'Calculate submission grades';
$string['calculatesubmissiongradesdetails'] = 'expected: {$a->expected}<br />calculated: {$a->calculated}';
$string['clearaggregatedgrades'] = 'Clear all aggregated grades';
$string['clearaggregatedgrades_help'] = 'The calculated grades for submission and grades for assessment will be reset. You can re-calculate these grades from scratch in Grading evaluation phase again.';
$string['clearaggregatedgradesconfirm'] = 'Are you sure you want to clear the calculated grades for submissions and grades for assessment? ';
$string['configexamplesmode'] = 'Default mode of examples assessment in workshops';
$string['configgrade'] = 'Default maximum grade for submission in workshops';
$string['configgradedecimals'] = 'Default number of digits that should be shown after the decimal point when displaying grades.';
@@ -209,6 +212,7 @@ $string['taskinstructauthors'] = 'Provide instructions for submission';
$string['taskinstructreviewers'] = 'Provide instructions for assessment';
$string['taskintro'] = 'Set the workshop introduction';
$string['tasksubmit'] = 'Submit your work';
$string['toolbox'] = 'Workshop toolbox';
$string['undersetup'] = 'The workshop is currently being set up. Please wait until it is switched to the next phase.';
$string['useexamples'] = 'Use examples';
$string['useexamples_desc'] = 'Example submissions are provided for practice in assessing';
+58
View File
@@ -1038,6 +1038,14 @@ class workshop {
return new moodle_url('/mod/workshop/aggregate.php', array('cmid' => $this->cm->id));
}
/**
* @return moodle_url of this workshop's toolbox page
*/
public function toolbox_url($tool) {
global $CFG;
return new moodle_url('/mod/workshop/toolbox.php', array('id' => $this->cm->id, 'tool' => $tool));
}
/**
* Are users allowed to create/edit their submissions?
*
@@ -1447,6 +1455,31 @@ class workshop {
return $this->real_grade_value($value, $this->gradinggrade);
}
/**
* Sets the grades for submission to null
*
* @param null|int|array $restrict If null, update all authors, otherwise update just grades for the given author(s)
* @return void
*/
public function clear_submission_grades($restrict=null) {
global $DB;
$sql = "workshopid = :workshopid AND example = 0";
$params = array('workshopid' => $this->id);
if (is_null($restrict)) {
// update all users - no more conditions
} elseif (!empty($restrict)) {
list($usql, $uparams) = $DB->get_in_or_equal($restrict, SQL_PARAMS_NAMED);
$sql .= " AND authorid $usql";
$params = array_merge($params, $uparams);
} else {
throw new coding_exception('Empty value is not a valid parameter here');
}
$DB->set_field_select('workshop_submissions', 'grade', null, $sql, $params);
}
/**
* Calculates grades for submission for the given participant(s) and updates it in the database
*
@@ -1501,6 +1534,31 @@ class workshop {
$rs->close();
}
/**
* Sets the aggregated grades for assessment to null
*
* @param null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewer(s)
* @return void
*/
public function clear_grading_grades($restrict=null) {
global $DB;
$sql = "workshopid = :workshopid";
$params = array('workshopid' => $this->id);
if (is_null($restrict)) {
// update all users - no more conditions
} elseif (!empty($restrict)) {
list($usql, $uparams) = $DB->get_in_or_equal($restrict, SQL_PARAMS_NAMED);
$sql .= " AND userid $usql";
$params = array_merge($params, $uparams);
} else {
throw new coding_exception('Empty value is not a valid parameter here');
}
$DB->set_field_select('workshop_aggregations', 'gradinggrade', null, $sql, $params);
}
/**
* Calculates grades for assessment for the given participant(s)
*
+6
View File
@@ -386,6 +386,12 @@
display: inline;
}
.path-mod-workshop .toolboxaction,
.path-mod-workshop .toolboxaction form,
.path-mod-workshop .toolboxaction form div {
display: inline;
}
.path-mod-workshop div.buttonwithhelp div {
display: inline;
}
+49
View File
@@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Various workshop maintainance utilities
*
* @package mod_workshop
* @copyright 2010 David Mudrak <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');
$id = required_param('id', PARAM_INT); // course_module ID
$tool = required_param('tool', PARAM_ALPHA);
$cm = get_coursemodule_from_id('workshop', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, false, $cm);
$workshop = new workshop($workshop, $cm, $course);
require_sesskey();
switch ($tool) {
case 'clearaggregatedgrades':
require_capability('mod/workshop:overridegrades', $workshop->context);
add_to_log($course->id, 'workshop', $tool, 'view.php?id=' . $cm->id, $workshop->name, $cm->id);
$workshop->clear_submission_grades();
$workshop->clear_grading_grades();
break;
}
redirect($workshop->view_url());
+1 -1
View File
@@ -28,6 +28,6 @@
defined('MOODLE_INTERNAL') || die();
$module->version = 2010070701;
$module->version = 2010070800;
$module->requires = 2010070604; // Requires this Moodle version
//$module->cron = 60;
+14
View File
@@ -318,6 +318,20 @@ case workshop::PHASE_EVALUATION:
echo $output->render($pagingbar);
}
}
if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'));
echo $output->box_start('generalbox toolbox');
// Clear aggregated grades
$url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades'), array('confirmed' => false));
$btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post');
$btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop'));
$btn->class .= ' toolboxaction';
echo $output->render($btn);
echo $output->help_icon('clearaggregatedgrades', 'workshop');
echo $output->box_end();
print_collapsible_region_end();
}
if (has_capability('mod/workshop:submit', $PAGE->context)) {
print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
echo $output->box_start('generalbox ownsubmission');