Workshop: assessment weight can be set
This commit is contained in:
+43
-20
@@ -57,7 +57,8 @@ $PAGE->navbar->add(get_string('assessingsubmission', 'workshop'));
|
||||
|
||||
$canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context);
|
||||
$canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context);
|
||||
$canoverridegrades = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capability('mod/workshop:overridegrades', $workshop->context));
|
||||
$cansetassessmentweight = has_capability('mod/workshop:allocate', $workshop->context);
|
||||
$canoverridegrades = has_capability('mod/workshop:overridegrades', $workshop->context);
|
||||
$isreviewer = ($USER->id == $assessment->reviewerid);
|
||||
$isauthor = ($USER->id == $submission->authorid);
|
||||
|
||||
@@ -103,32 +104,50 @@ if ($assessmenteditable and $workshop->useexamples and $workshop->examplesmode =
|
||||
// load the grading strategy logic
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
|
||||
// load the assessment form and process the submitted data eventually
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable);
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($workshop->view_url());
|
||||
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
|
||||
$rawgrade = $strategy->save_assessment($assessment, $data);
|
||||
if (!is_null($rawgrade) and isset($data->saveandclose)) {
|
||||
if (is_null($assessment->grade) and !$assessmenteditable) {
|
||||
$mform = null;
|
||||
} else {
|
||||
// load the assessment form and process the submitted data eventually
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable,
|
||||
array('editableweight' => $cansetassessmentweight));
|
||||
$mform->set_data(array('weight' => $assessment->weight)); // other values are set by subplugins
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($workshop->view_url());
|
||||
} else {
|
||||
// either it is not possible to calculate the $rawgrade
|
||||
// or the reviewer has chosen "Save and continue"
|
||||
redirect($PAGE->url);
|
||||
} elseif ($assessmenteditable and ($data = $mform->get_data())) {
|
||||
$rawgrade = $strategy->save_assessment($assessment, $data);
|
||||
if (isset($data->weight) and $cansetassessmentweight) {
|
||||
$DB->set_field('workshop_assessments', 'weight', $data->weight, array('id' => $assessment->id));
|
||||
}
|
||||
if (!is_null($rawgrade) and isset($data->saveandclose)) {
|
||||
redirect($workshop->view_url());
|
||||
} else {
|
||||
// either it is not possible to calculate the $rawgrade
|
||||
// or the reviewer has chosen "Save and continue"
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load the form to override gradinggrade and process the submitted data eventually
|
||||
if ($canoverridegrades) {
|
||||
$feedbackform = $workshop->get_feedbackreviewer_form($PAGE->url, $assessment);
|
||||
// load the form to override gradinggrade and/or set weight and process the submitted data eventually
|
||||
if ($canoverridegrades or $cansetassessmentweight) {
|
||||
$options = array(
|
||||
'editable' => true,
|
||||
'editableweight' => $cansetassessmentweight,
|
||||
'overridablegradinggrade' => $canoverridegrades);
|
||||
$feedbackform = $workshop->get_feedbackreviewer_form($PAGE->url, $assessment, $options);
|
||||
if ($data = $feedbackform->get_data()) {
|
||||
$data = file_postupdate_standard_editor($data, 'feedbackreviewer', array(), $workshop->context);
|
||||
$record = new stdclass();
|
||||
$record->id = $assessment->id;
|
||||
$record->gradinggradeover = $workshop->raw_grade_value($data->gradinggradeover, $workshop->gradinggrade);
|
||||
$record->gradinggradeoverby = $USER->id;
|
||||
$record->feedbackreviewer = $data->feedbackreviewer;
|
||||
$record->feedbackreviewerformat = $data->feedbackreviewerformat;
|
||||
if ($cansetassessmentweight) {
|
||||
$record->weight = $data->weight;
|
||||
}
|
||||
if ($canoverridegrades) {
|
||||
$record->gradinggradeover = $workshop->raw_grade_value($data->gradinggradeover, $workshop->gradinggrade);
|
||||
$record->gradinggradeoverby = $USER->id;
|
||||
$record->feedbackreviewer = $data->feedbackreviewer;
|
||||
$record->feedbackreviewerformat = $data->feedbackreviewerformat;
|
||||
}
|
||||
$DB->update_record('workshop_assessments', $record);
|
||||
redirect($workshop->view_url());
|
||||
}
|
||||
@@ -154,7 +173,11 @@ if ($isreviewer) {
|
||||
echo $OUTPUT->heading(get_string('assessmentbyunknown', 'workshop'), 2);
|
||||
}
|
||||
|
||||
$mform->display();
|
||||
if ($mform) {
|
||||
$mform->display();
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('notassessed', 'workshop'));
|
||||
}
|
||||
if ($canoverridegrades) {
|
||||
$feedbackform->display();
|
||||
}
|
||||
|
||||
@@ -34,20 +34,28 @@ class workshop_feedbackreviewer_form extends moodleform {
|
||||
|
||||
$current = $this->_customdata['current'];
|
||||
$workshop = $this->_customdata['workshop'];
|
||||
$opts = $this->_customdata['feedbackopts'];
|
||||
$editoropts = $this->_customdata['editoropts'];
|
||||
$options = $this->_customdata['options'];
|
||||
|
||||
$mform->addElement('header', 'feedbackreviewerform', get_string('feedbackreviewer', 'workshop'));
|
||||
$mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
|
||||
|
||||
if (!empty($options['editableweight'])) {
|
||||
$mform->addElement('select', 'weight',
|
||||
get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list());
|
||||
$mform->setDefault('weight', 1);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'gradinggrade', get_string('gradinggradecalculated', 'workshop'));
|
||||
if (!empty($options['overridablegradinggrade'])) {
|
||||
$grades = array('' => get_string('notoverridden', 'workshop'));
|
||||
for ($i = (int)$workshop->gradinggrade; $i >= 0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
$mform->addElement('select', 'gradinggradeover', get_string('gradinggradeover', 'workshop'), $grades);
|
||||
|
||||
$grades = array('' => get_string('notoverridden', 'workshop'));
|
||||
for ($i = (int)$workshop->gradinggrade; $i >= 0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
$mform->addElement('editor', 'feedbackreviewer_editor', get_string('feedbackreviewer', 'workshop'), null, $editoropts);
|
||||
$mform->setType('feedbackreviewer_editor', PARAM_RAW);
|
||||
}
|
||||
$mform->addElement('select', 'gradinggradeover', get_string('gradinggradeover', 'workshop'), $grades);
|
||||
|
||||
$mform->addElement('editor', 'feedbackreviewer_editor', get_string('feedbackreviewer', 'workshop'), null, $opts);
|
||||
$mform->setType('feedbackreviewer_editor', PARAM_RAW);
|
||||
|
||||
$mform->addElement('hidden', 'asid');
|
||||
|
||||
|
||||
@@ -151,8 +151,9 @@ class workshop_accumulative_strategy implements workshop_strategy {
|
||||
* @param string $mode Mode to open the form in: preview/assessment
|
||||
* @param stdclass $assessment The current assessment
|
||||
* @param bool $editable
|
||||
* @param array $options
|
||||
*/
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true) {
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) {
|
||||
global $CFG; // needed because the included files use it
|
||||
global $PAGE;
|
||||
global $DB;
|
||||
@@ -185,6 +186,7 @@ class workshop_accumulative_strategy implements workshop_strategy {
|
||||
$customdata['strategy'] = $this;
|
||||
$customdata['workshop'] = $this->workshop;
|
||||
$customdata['mode'] = $mode;
|
||||
$customdata['options'] = $options;
|
||||
|
||||
// set up strategy-specific custom data
|
||||
$customdata['nodims'] = $nodimensions;
|
||||
|
||||
@@ -55,13 +55,20 @@ class workshop_assessment_form extends moodleform {
|
||||
$this->mode = $this->_customdata['mode']; // influences the save buttons
|
||||
$this->strategy = $this->_customdata['strategy']; // instance of the strategy api class
|
||||
$this->workshop = $this->_customdata['workshop']; // instance of the workshop api class
|
||||
|
||||
// add the data common for all subplugins
|
||||
$mform->addElement('hidden', 'strategy', $this->workshop->strategy);
|
||||
$this->options = $this->_customdata['options']; // array with addiotional options
|
||||
|
||||
// add the strategy-specific fields
|
||||
$this->definition_inner($mform);
|
||||
|
||||
// add the data common for all subplugins
|
||||
$mform->addElement('hidden', 'strategy', $this->workshop->strategy);
|
||||
if (!empty($this->options['editableweight']) and !$mform->isFrozen()) {
|
||||
$mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop'));
|
||||
$mform->addElement('select', 'weight',
|
||||
get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list());
|
||||
$mform->setDefault('weight', 1);
|
||||
}
|
||||
|
||||
$buttonarray = array();
|
||||
if ($this->mode == 'preview') {
|
||||
$buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop'));
|
||||
|
||||
@@ -151,8 +151,9 @@ class workshop_comments_strategy implements workshop_strategy {
|
||||
* @param string $mode Mode to open the form in: preview/assessment
|
||||
* @param stdclass $assessment The current assessment
|
||||
* @param bool $editable
|
||||
* @param array $options
|
||||
*/
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true) {
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) {
|
||||
global $CFG; // needed because the included files use it
|
||||
global $PAGE;
|
||||
global $DB;
|
||||
@@ -184,6 +185,7 @@ class workshop_comments_strategy implements workshop_strategy {
|
||||
$customdata['strategy'] = $this;
|
||||
$customdata['workshop'] = $this->workshop;
|
||||
$customdata['mode'] = $mode;
|
||||
$customdata['options'] = $options;
|
||||
|
||||
// set up strategy-specific custom data
|
||||
$customdata['nodims'] = $nodimensions;
|
||||
|
||||
@@ -57,8 +57,9 @@ interface workshop_strategy {
|
||||
* @param string $mode Mode to open the form in: preview|assessment
|
||||
* @param stdclass $assessment If opening in the assessment mode, the current assessment record
|
||||
* @param bool $editable Shall the form be opened as editable (true) or read-only (false)
|
||||
* @param array $options More assessment form options, editableweight implemented only now
|
||||
*/
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true);
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array());
|
||||
|
||||
/**
|
||||
* Saves the filled assessment and returns the grade for submission as suggested by the reviewer
|
||||
|
||||
@@ -186,8 +186,9 @@ class workshop_numerrors_strategy implements workshop_strategy {
|
||||
* @param string $mode Mode to open the form in: preview/assessment
|
||||
* @param stdclass $assessment
|
||||
* @param bool $editable
|
||||
* @param array $options
|
||||
*/
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true) {
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) {
|
||||
global $CFG; // needed because the included files use it
|
||||
global $PAGE;
|
||||
global $DB;
|
||||
@@ -220,6 +221,7 @@ class workshop_numerrors_strategy implements workshop_strategy {
|
||||
$customdata['workshop'] = $this->workshop;
|
||||
$customdata['strategy'] = $this;
|
||||
$customdata['mode'] = $mode;
|
||||
$customdata['options'] = $options;
|
||||
|
||||
// set up strategy-specific custom data
|
||||
$customdata['nodims'] = $nodimensions;
|
||||
|
||||
@@ -190,8 +190,11 @@ class workshop_rubric_strategy implements workshop_strategy {
|
||||
*
|
||||
* @param moodle_url $actionurl URL of form handler, defaults to auto detect the current url
|
||||
* @param string $mode Mode to open the form in: preview/assessment/readonly
|
||||
* @param stdclass $assessment The current assessment
|
||||
* @param bool $editable
|
||||
* @param array $options
|
||||
*/
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true) {
|
||||
public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()) {
|
||||
global $CFG; // needed because the included files use it
|
||||
global $DB;
|
||||
require_once(dirname(__FILE__) . '/assessment_form.php');
|
||||
@@ -233,6 +236,7 @@ class workshop_rubric_strategy implements workshop_strategy {
|
||||
$customdata['strategy'] = $this;
|
||||
$customdata['workshop'] = $this->workshop;
|
||||
$customdata['mode'] = $mode;
|
||||
$customdata['options'] = $options;
|
||||
|
||||
// set up strategy-specific custom data
|
||||
$customdata['nodims'] = $nodimensions;
|
||||
|
||||
@@ -54,6 +54,7 @@ $string['assessmentreferenceneeded'] = 'You have to assess this example submissi
|
||||
$string['assessmentsettings'] = 'Assessment settings';
|
||||
$string['assessmentstart'] = 'Assessing not allowed before';
|
||||
$string['assessmentstartdatetime'] = 'Assessing starts on {$a->daydatetime} ({$a->distanceday})';
|
||||
$string['assessmentweight'] = 'Assessment weight';
|
||||
$string['assignedassessments'] = 'Assigned submissions to assess';
|
||||
$string['assignedassessmentsnone'] = 'You have no assigned submission to assess';
|
||||
$string['backtoeditform'] = 'Back to editing form';
|
||||
@@ -145,6 +146,7 @@ $string['nogradeyet'] = 'No grade yet';
|
||||
$string['nosubmissionfound'] = 'No submission found for this user';
|
||||
$string['nosubmissions'] = 'No submissions yet in this workshop';
|
||||
$string['nothingtoreview'] = 'Nothing to review';
|
||||
$string['notassessed'] = 'Not assessed yet';
|
||||
$string['notoverridden'] = 'Not overriden';
|
||||
$string['noworkshops'] = 'There are no workshops in this course';
|
||||
$string['noyoursubmission'] = 'You have not submitted your work yet';
|
||||
|
||||
@@ -291,6 +291,25 @@ class workshop {
|
||||
return $weights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of possible values of assessment weight
|
||||
*
|
||||
* Note there is no real reason why the maximum value here is 16. It used to be 10 in
|
||||
* workshop 1.x and I just decided to use the same number as in the maximum weight of
|
||||
* a single assessment dimension.
|
||||
* The value looks reasonable, though. Teachers who would want to assign themselves
|
||||
* higher weight probably do not want peer assessment really...
|
||||
*
|
||||
* @return array of integers 0, 1, 2, ..., 16
|
||||
*/
|
||||
public static function available_assessment_weights_list() {
|
||||
$weights = array();
|
||||
for ($i=16; $i>=0; $i--) {
|
||||
$weights[$i] = $i;
|
||||
}
|
||||
return $weights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function returning the greatest common divisor
|
||||
*
|
||||
@@ -1202,7 +1221,8 @@ class workshop {
|
||||
FROM {workshop_assessments} a
|
||||
JOIN {user} r ON (a.reviewerid = r.id)
|
||||
JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)
|
||||
WHERE a.submissionid $submissionids";
|
||||
WHERE a.submissionid $submissionids
|
||||
ORDER BY a.weight DESC, r.lastname, r.firstname";
|
||||
$reviewers = $DB->get_records_sql($sql, $params);
|
||||
foreach ($reviewers as $reviewer) {
|
||||
if (!isset($userinfo[$reviewer->reviewerid])) {
|
||||
@@ -1228,7 +1248,8 @@ class workshop {
|
||||
JOIN {workshop_assessments} a ON (a.reviewerid = u.id)
|
||||
JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)
|
||||
JOIN {user} e ON (s.authorid = e.id)
|
||||
WHERE u.id $participantids AND s.workshopid = :workshopid";
|
||||
WHERE u.id $participantids AND s.workshopid = :workshopid
|
||||
ORDER BY a.weight DESC, e.lastname, e.firstname";
|
||||
$reviewees = $DB->get_records_sql($sql, $params);
|
||||
foreach ($reviewees as $reviewee) {
|
||||
if (!isset($userinfo[$reviewee->authorid])) {
|
||||
@@ -1485,14 +1506,18 @@ class workshop {
|
||||
/**
|
||||
* Returns the mform the teachers use to put a feedback for the reviewer
|
||||
*
|
||||
* @param moodle_url $actionurl
|
||||
* @param stdclass $assessment
|
||||
* @param array $options editable, editableweight, overridablegradinggrade
|
||||
* @return workshop_feedbackreviewer_form
|
||||
*/
|
||||
public function get_feedbackreviewer_form(moodle_url $actionurl, stdclass $assessment, $editable=true) {
|
||||
public function get_feedbackreviewer_form(moodle_url $actionurl, stdclass $assessment, $options=array()) {
|
||||
global $CFG;
|
||||
require_once(dirname(__FILE__) . '/feedbackreviewer_form.php');
|
||||
|
||||
$current = new stdclass();
|
||||
$current->asid = $assessment->id;
|
||||
$current->weight = $assessment->weight;
|
||||
$current->gradinggrade = $this->real_grading_grade($assessment->gradinggrade);
|
||||
$current->gradinggradeover = $this->real_grading_grade($assessment->gradinggradeover);
|
||||
$current->feedbackreviewer = $assessment->feedbackreviewer;
|
||||
@@ -1500,21 +1525,29 @@ class workshop {
|
||||
if (is_null($current->gradinggrade)) {
|
||||
$current->gradinggrade = get_string('nullgrade', 'workshop');
|
||||
}
|
||||
if (!isset($options['editable'])) {
|
||||
$editable = true; // by default
|
||||
} else {
|
||||
$editable = (bool)$options['editable'];
|
||||
}
|
||||
|
||||
// prepare wysiwyg editor
|
||||
$current = file_prepare_standard_editor($current, 'feedbackreviewer', array());
|
||||
|
||||
return new workshop_feedbackreviewer_form($actionurl,
|
||||
array('workshop' => $this, 'current' => $current, 'feedbackopts' => array()),
|
||||
array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options),
|
||||
'post', '', null, $editable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mform the teachers use to put a feedback for the author on their submission
|
||||
*
|
||||
* @param moodle_url $actionurl
|
||||
* @param stdclass $submission
|
||||
* @param array $options editable
|
||||
* @return workshop_feedbackauthor_form
|
||||
*/
|
||||
public function get_feedbackauthor_form(moodle_url $actionurl, stdclass $submission, $editable=true) {
|
||||
public function get_feedbackauthor_form(moodle_url $actionurl, stdclass $submission, $options=array()) {
|
||||
global $CFG;
|
||||
require_once(dirname(__FILE__) . '/feedbackauthor_form.php');
|
||||
|
||||
@@ -1527,12 +1560,17 @@ class workshop {
|
||||
if (is_null($current->grade)) {
|
||||
$current->grade = get_string('nullgrade', 'workshop');
|
||||
}
|
||||
if (!isset($options['editable'])) {
|
||||
$editable = true; // by default
|
||||
} else {
|
||||
$editable = (bool)$options['editable'];
|
||||
}
|
||||
|
||||
// prepare wysiwyg editor
|
||||
$current = file_prepare_standard_editor($current, 'feedbackauthor', array());
|
||||
|
||||
return new workshop_feedbackauthor_form($actionurl,
|
||||
array('workshop' => $this, 'current' => $current, 'feedbackopts' => array()),
|
||||
array('workshop' => $this, 'current' => $current, 'feedbackopts' => array(), 'options' => $options),
|
||||
'post', '', null, $editable);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ if ($id) { // submission is specified
|
||||
$submission = new stdclass();
|
||||
$submission->id = null;
|
||||
$submission->authorid = $USER->id;
|
||||
$submission->grade = null;
|
||||
$submission->gradeover = null;
|
||||
$submission->feedbackauthor = null;
|
||||
$submission->feedbackauthorformat = FORMAT_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user