MDL-20236 overall codebase architecture cleanup and fixing regression

See the issue description for more details
This commit is contained in:
David Mudrak
2010-01-04 18:05:48 +00:00
parent 6516b9e9e4
commit f05c168d2e
35 changed files with 530 additions and 577 deletions
@@ -192,27 +192,29 @@ class workshop_manual_allocator implements workshop_allocator {
$peers = array();
$rs = $this->workshop->get_allocations_recordset();
foreach ($rs as $allocation) {
$currentuserid = $allocation->authorid;
if (!isset($peers[$currentuserid])) {
$peers[$currentuserid] = new stdClass();
$peers[$currentuserid]->id = $allocation->authorid;
$peers[$currentuserid]->firstname = $allocation->authorfirstname;
$peers[$currentuserid]->lastname = $allocation->authorlastname;
$peers[$currentuserid]->picture = $allocation->authorpicture;
$peers[$currentuserid]->imagealt = $allocation->authorimagealt;
$peers[$currentuserid]->submissionid = $allocation->submissionid;
$peers[$currentuserid]->submissiontitle = $allocation->submissiontitle;
$peers[$currentuserid]->submissiongrade = $allocation->submissiongrade;
$peers[$currentuserid]->reviewedby = array(); // users who are reviewing this user's submission
$peers[$currentuserid]->reviewerof = array(); // users whom submission is being reviewed by this user
}
if (!empty($allocation->reviewerid)) {
// example: "submission of user with id 45 is reviewed by user with id 87 in the assessment record 12"
$peers[$currentuserid]->reviewedby[$allocation->reviewerid] = $allocation->assessmentid;
if (!is_null($rs)) {
foreach ($rs as $allocation) {
$currentuserid = $allocation->authorid;
if (!isset($peers[$currentuserid])) {
$peers[$currentuserid] = new stdClass();
$peers[$currentuserid]->id = $allocation->authorid;
$peers[$currentuserid]->firstname = $allocation->authorfirstname;
$peers[$currentuserid]->lastname = $allocation->authorlastname;
$peers[$currentuserid]->picture = $allocation->authorpicture;
$peers[$currentuserid]->imagealt = $allocation->authorimagealt;
$peers[$currentuserid]->submissionid = $allocation->submissionid;
$peers[$currentuserid]->submissiontitle = $allocation->submissiontitle;
$peers[$currentuserid]->submissiongrade = $allocation->submissiongrade;
$peers[$currentuserid]->reviewedby = array(); // users who are reviewing this user's submission
$peers[$currentuserid]->reviewerof = array(); // users whom submission is being reviewed by this user
}
if (!empty($allocation->reviewerid)) {
// example: "submission of user with id 45 is reviewed by user with id 87 in the assessment record 12"
$peers[$currentuserid]->reviewedby[$allocation->reviewerid] = $allocation->assessmentid;
}
}
$rs->close();
}
$rs->close();
foreach ($peers as $author) {
foreach ($author->reviewedby as $reviewerid => $assessmentid) {
@@ -230,8 +232,8 @@ class workshop_manual_allocator implements workshop_allocator {
$data = new stdClass();
$data->wsoutput = $wsoutput;
$data->peers = $peers;
$data->authors = $this->workshop->get_potential_authors();
$data->reviewers = $this->workshop->get_potential_reviewers();
$data->authors = $this->workshop->get_potential_authors($PAGE->context);
$data->reviewers = $this->workshop->get_potential_reviewers($PAGE->context);
$data->hlauthorid = $hlauthorid;
$data->hlreviewerid = $hlreviewerid;
$data->msg = $msg;
@@ -75,14 +75,14 @@ class workshop_random_allocator implements workshop_allocator {
$o = array(); // list of output messages
$numofreviews = required_param('numofreviews', PARAM_INT);
$numper = required_param('numper', PARAM_INT);
$removecurrent = required_param('removecurrent', PARAM_INT);
$assesswosubmission = required_param('assesswosubmission', PARAM_INT);
$removecurrent = optional_param('removecurrent', false, PARAM_BOOL);
$assesswosubmission = optional_param('assesswosubmission', false, PARAM_BOOL);
$addselfassessment = optional_param('addselfassessment', false, PARAM_BOOL);
$musthavesubmission = empty($assesswosubmission);
$addselfassessment = optional_param('addselfassessment', false, PARAM_INT); // may be frozen in the form
$authors = $this->workshop->get_potential_authors();
$authors = $this->workshop->get_potential_authors($PAGE->context);
$authors = $this->workshop->get_grouped($authors);
$reviewers = $this->workshop->get_potential_reviewers($musthavesubmission);
$reviewers = $this->workshop->get_potential_reviewers($PAGE->context, $musthavesubmission);
$reviewers = $this->workshop->get_grouped($reviewers);
$assessments = $this->workshop->get_all_assessments();
@@ -72,22 +72,17 @@ class workshop_random_allocator_form extends moodleform {
$mform->setDefault('numper', workshop_random_allocator::USERTYPE_AUTHOR);
$mform->addGroup($grpnumofreviews, 'grpnumofreviews', get_string('numofreviews', 'workshop'), array(' '), false);
$mform->addElement('advcheckbox', 'removecurrent', get_string('removecurrentallocations', 'workshopallocation_random'));
$mform->addElement('checkbox', 'removecurrent', get_string('removecurrentallocations', 'workshopallocation_random'));
$mform->setDefault('removecurrent', 0);
$mform->addElement('advcheckbox', 'assesswosubmission', get_string('assesswosubmission', 'workshopallocation_random'));
$mform->addElement('checkbox', 'assesswosubmission', get_string('assesswosubmission', 'workshopallocation_random'));
$mform->setDefault('assesswosubmission', 0);
$grpselfassessment = array();
$grpselfassessment[] = $mform->createElement('advcheckbox', 'addselfassessment');
$mform->setDefault('addselfassessment', 0);
if (!$workshop->useselfassessment) {
$grpselfassessment[] = $mform->createElement('static', 'selfassessmentcheck', '',
get_string('selfassessmentdisabled', 'workshop'));
}
$mform->addGroup($grpselfassessment, 'grpselfassessment', get_string('addselfassessment', 'workshopallocation_random'));
if (!$workshop->useselfassessment) {
$mform->freeze(array('grpselfassessment'));
if (empty($workshop->useselfassessment)) {
$mform->addElement('static', 'addselfassessment', get_string('addselfassessment', 'workshopallocation_random'),
get_string('selfassessmentdisabled', 'workshop'));
} else {
$mform->addElement('checkbox', 'addselfassessment', get_string('addselfassessment', 'workshopallocation_random'));
}
$this->add_action_buttons();
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for mod/workshop/allocation/random/allocator.php
* Unit tests for Random allocation
*
* @package mod-workshop
* @copyright 2009 David Mudrak <[email protected]>
@@ -26,7 +26,8 @@
defined('MOODLE_INTERNAL') || die();
// Include the code to test
require_once($CFG->dirroot . '/mod/workshop/allocation/random/allocator.php');
require_once($CFG->dirroot . '/mod/workshop/locallib.php');
require_once($CFG->dirroot . '/mod/workshop/allocation/random/lib.php');
/**
* Make protected methods we want to test public