NOBUG workshop: add_allocation() parameters order changed
This commit is contained in:
@@ -256,7 +256,7 @@ class workshop_random_allocator implements workshop_allocator {
|
||||
throw new moodle_exception('unabletoallocateauthorwithoutsubmission', 'workshop');
|
||||
}
|
||||
$submission = $submissions[$authorid];
|
||||
$status = $this->workshop->add_allocation($submission, $reviewerid, true);
|
||||
$status = $this->workshop->add_allocation($submission, $reviewerid, 1, true); // todo configurable weight?
|
||||
if (workshop::ALLOCATION_EXISTS == $status) {
|
||||
debugging('newallocations array contains existing allocation, this should not happen');
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ if ($id and $assess and $canmanage) {
|
||||
// such assessment
|
||||
require_sesskey();
|
||||
if (!$refasid) {
|
||||
$refasid = $workshop->add_allocation($example, $USER->id, false, 1);
|
||||
$refasid = $workshop->add_allocation($example, $USER->id, 1);
|
||||
}
|
||||
redirect($workshop->exassess_url($refasid));
|
||||
}
|
||||
@@ -89,7 +89,7 @@ if ($id and $assess and $canassess) {
|
||||
$asid = $DB->get_field('workshop_assessments', 'id',
|
||||
array('submissionid' => $example->id, 'weight' => 0, 'reviewerid' => $USER->id));
|
||||
if (!$asid) {
|
||||
$asid = $workshop->add_allocation($example, $USER->id, false, 0);
|
||||
$asid = $workshop->add_allocation($example, $USER->id, 0);
|
||||
}
|
||||
redirect($workshop->exassess_url($asid));
|
||||
}
|
||||
|
||||
@@ -673,17 +673,25 @@ class workshop {
|
||||
*
|
||||
* @param stdclass $submission Submission object with at least id property
|
||||
* @param int $reviewerid User ID
|
||||
* @param bool $bulk repeated inserts into DB expected
|
||||
* @param int $weight of the new assessment, from 0 to 16
|
||||
* @param bool $bulk repeated inserts into DB expected
|
||||
* @return int ID of the new assessment or an error code
|
||||
*/
|
||||
public function add_allocation(stdclass $submission, $reviewerid, $bulk=false, $weight=1) {
|
||||
public function add_allocation(stdclass $submission, $reviewerid, $weight=1, $bulk=false) {
|
||||
global $DB;
|
||||
|
||||
if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $reviewerid))) {
|
||||
return self::ALLOCATION_EXISTS;
|
||||
}
|
||||
|
||||
$weight = (int)$weight;
|
||||
if ($weight < 0) {
|
||||
$weight = 0;
|
||||
}
|
||||
if ($weight > 16) {
|
||||
$weight = 16;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$assessment = new stdclass();
|
||||
$assessment->submissionid = $submission->id;
|
||||
|
||||
@@ -112,7 +112,7 @@ case workshop::PHASE_SUBMISSION:
|
||||
// make sure the current user has all examples allocated
|
||||
foreach ($examples as $exampleid => $example) {
|
||||
if (is_null($example->assessmentid)) {
|
||||
$examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, false, 0);
|
||||
$examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0);
|
||||
}
|
||||
if (is_null($example->grade)) {
|
||||
$todo++;
|
||||
|
||||
Reference in New Issue
Block a user