protected $workshop;
/**
- * @param stdClass $workshop Workshop record
+ * @param workshop $workshop Workshop API object
*/
public function __construct(workshop $workshop) {
$this->workshop = $workshop;
$hlauthorid = -1; // highlight this author
$hlreviewerid = -1; // highlight this reviewer
- $msg = new stdClass; // message to render
+ $msg = new object(); // message to render
$m = optional_param('m', '', PARAM_ALPHANUMEXT); // message object
if ($m) {
foreach ($rs as $allocation) {
$currentuserid = $allocation->authorid;
if (!isset($peer[$currentuserid])) {
- $peer[$currentuserid] = new stdClass();
+ $peer[$currentuserid] = new object();
$peer[$currentuserid]->id = $allocation->authorid;
$peer[$currentuserid]->firstname = $allocation->authorfirstname;
$peer[$currentuserid]->lastname = $allocation->authorlastname;
/**
* Returns information about the workshop participant
*
- * @param stdClass $user participant data
+ * @param object $user participant data
* @return string HTML code
*/
- protected function participant(stdClass $user) {
+ protected function participant(object $user) {
$o = $this->output->user_picture($user, $this->page->course->id);
$o .= fullname($user);
$o .= $this->output->container_start(array('submission'));
/**
* Returns information about the current reviewers of the given participant and a selector do add new one
*
- * @param stdClass $user participant data
+ * @param object $user participant data
* @param workshop $workshop workshop record
* @param array $peers objects with properties to display picture and fullname
* @return string html code
*/
- protected function reviewers_of_participant(stdClass $user, workshop $workshop, &$peers) {
+ protected function reviewers_of_participant(object $user, workshop $workshop, &$peers) {
$o = '';
if (is_null($user->submissionid)) {
$o .= $this->output->output_tag('span', array('class' => 'info'), get_string('nothingtoreview', 'workshop'));
/**
* Returns information about the current reviewees of the given participant and a selector do add new one
*
- * @param stdClass $user participant data
+ * @param object $user participant data
* @param workshop $workshop workshop record
* @param array $peers objects with properties to display picture and fullname
* @return string html code
*/
- protected function reviewees_of_participant(stdClass $user, workshop $workshop, &$peers) {
+ protected function reviewees_of_participant(object $user, workshop $workshop, &$peers) {
$o = '';
if (is_null($user->submissionid)) {
$o .= $this->output->container(get_string('withoutsubmission', 'workshop'), 'info');
$this->add_new_allocations($newallocations, $authors, $reviewers);
foreach ($newallocations as $newallocation) {
list($reviewerid, $authorid) = each($newallocation);
- $a = new stdClass();
+ $a = new object();
$a->reviewername = fullname($reviewers[0][$reviewerid]);
$a->authorname = fullname($authors[0][$authorid]);
$o[] = 'ok::indent::' . get_string('allocationaddeddetail', 'workshop', $a);
// by reviewer
$o[] = 'info::' . get_string('numofdeallocatedassessment', 'workshop', count($delassessments));
foreach ($delassessments as $delassessmentkey => $delassessmentid) {
- $a = new stdClass();
+ $a = new object();
$a->authorname = fullname((object)array(
'lastname' => $assessments[$delassessmentid]->authorlastname,
'firstname' => $assessments[$delassessmentid]->authorfirstname));
global $OUTPUT;
$m = optional_param('m', null, PARAM_INT); // status message code
- $msg = new stdClass();
+ $msg = new object();
if ($m == WORKSHOP_ALLOCATION_RANDOM_MSG_SUCCESS) {
$msg = (object)array('text' => get_string('randomallocationdone', 'workshop'), 'sty' => 'ok');
}
public function test_self_allocation_equal_user_groups() {
// fixture setup
- $authors = array(0 => array_fill_keys(array(4, 6, 10), new stdClass()));
- $reviewers = array(0 => array_fill_keys(array(4, 6, 10), new stdClass()));
+ $authors = array(0 => array_fill_keys(array(4, 6, 10), new object()));
+ $reviewers = array(0 => array_fill_keys(array(4, 6, 10), new object()));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers);
// verify
public function test_self_allocation_different_user_groups() {
// fixture setup
- $authors = array(0 => array_fill_keys(array(1, 4, 5, 10, 13), new stdClass()));
- $reviewers = array(0 => array_fill_keys(array(4, 7, 10), new stdClass()));
+ $authors = array(0 => array_fill_keys(array(1, 4, 5, 10, 13), new object()));
+ $reviewers = array(0 => array_fill_keys(array(4, 7, 10), new object()));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers);
// verify
public function test_self_allocation_skip_existing() {
// fixture setup
- $authors = array(0 => array_fill_keys(array(3, 4, 10), new stdClass()));
- $reviewers = array(0 => array_fill_keys(array(3, 4, 10), new stdClass()));
+ $authors = array(0 => array_fill_keys(array(3, 4, 10), new object()));
+ $reviewers = array(0 => array_fill_keys(array(3, 4, 10), new object()));
$assessments = array(23 => (object)array('authorid' => 3, 'reviewerid' => 3));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers, $assessments);
$cm = get_coursemodule_from_id('workshop', $preview, 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);
- $submission = new stdClass();
- $assessment = new stdClass();
+ $submission = new object();
+ $assessment = new object();
} else {
$mode = 'assessment';
$c = 0; // counter
foreach ($authors as $authorid => $author) {
$timenow = time() - rand(0, 60 * 60 * 24 * 7); // submitted sometimes during last week
- $submission = new stdClass();
+ $submission = new object();
$submission->workshopid = $workshop->id;
$submission->example = 0;
$submission->userid = $authorid;
*/
protected function prepare_form_fields(array $raw) {
- $formdata = new stdClass();
+ $formdata = new object();
$key = 0;
foreach ($raw as $dimension) {
$formdata->{'dimensionid__idx_' . $key} = $dimension->id; // master id, not the local one!
* @param object $data Raw data returned by the dimension editor form
* @return void
*/
- public function save_edit_strategy_form(stdClass $data) {
+ public function save_edit_strategy_form(object $data) {
global $DB, $PAGE;
if (!isset($data->strategyname) || ($data->strategyname != $this->name())) {
* @param object $raw Raw data returned by mform
* @return array Array of objects to be inserted/updated in DB
*/
- protected function prepare_database_fields(stdClass $raw) {
+ protected function prepare_database_fields(object $raw) {
global $PAGE;
- $cook = new stdClass(); // to be returned
+ $cook = new object(); // to be returned
$cook->forms = array(); // to be stored in {workshop_forms}
$cook->forms_accumulative = array(); // to be stored in {workshop_forms_accumulative}
for ($i = 0; $i < $raw->norepeats; $i++) {
- $cook->forms_accumulative[$i] = new stdClass();
+ $cook->forms_accumulative[$i] = new object();
$fieldname = 'description__idx_'.$i.'_editor';
$cook->forms_accumulative[$i]->description_editor = isset($raw->$fieldname) ? $raw->$fieldname : null;
$fieldname = 'weight__idx_'.$i;
$cook->forms_accumulative[$i]->weight = isset($raw->$fieldname) ? $raw->$fieldname : null;
- $cook->forms[$i] = new stdClass();
+ $cook->forms[$i] = new object();
$cook->forms[$i]->id = isset($raw->{'dimensionid__idx_'.$i}) ? $raw->{'dimensionid__idx_'.$i} : null;
$cook->forms[$i]->workshopid = $this->workshop->id;
$cook->forms[$i]->sort = $i + 1;
* @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
*/
- public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdClass $assessment=null) {
+ public function get_assessment_form(moodle_url $actionurl=null, $mode='preview', object $assessment=null) {
global $CFG; // needed because the included files use it
global $PAGE;
global $DB;
if ('assessment' === $mode and !empty($assessment)) {
// load the previously saved assessment data
$grades = $this->reindex_grades_by_dimension($this->get_current_assessment_data($assessment));
- $current = new stdClass();
+ $current = new object();
for ($i = 0; $i < $nodimensions; $i++) {
$dimid = $fields->{'dimensionid__idx_'.$i};
if (isset($grades[$dimid])) {
* @param object $data Raw data as returned by the assessment form
* @return float|null Percentual grade for submission as suggested by the peer
*/
- public function save_assessment(stdClass $assessment, stdClass $data) {
+ public function save_assessment(object $assessment, object $data) {
global $DB;
if (!isset($data->strategyname) || ($data->strategyname != $this->name())) {
throw coding_expection('You did not send me the number of assessment dimensions to process');
}
for ($i = 0; $i < $data->nodims; $i++) {
- $grade = new stdClass();
+ $grade = new object();
$grade->id = $data->{'gradeid__idx_' . $i};
$grade->assessmentid = $assessment->id;
$grade->dimensionid = $data->{'dimensionid__idx_' . $i};
* @param object $assessment Assessment record
* @return array of filtered records from the table workshop_grades
*/
- protected function get_current_assessment_data(stdClass $assessment) {
+ protected function get_current_assessment_data(object $assessment) {
global $DB;
// fetch all grades accociated with this assessment
/**
* Aggregates the assessment form data and sets the grade for the submission given by the peer
*
- * @param stdClass $assessment Assessment record
+ * @param object $assessment Assessment record
* @return float|null Percentual grade for submission as suggested by the peer
*/
- protected function update_peer_grade(stdClass $assessment) {
+ protected function update_peer_grade(object $assessment) {
$grades = $this->get_current_assessment_data($assessment);
$suggested = $this->calculate_peer_grade($grades);
if (!is_null($suggested)) {
* @param object $data Raw data as returned by the form editor
* @return void
*/
- public function save_edit_strategy_form(stdClass $data);
+ public function save_edit_strategy_form(object $data);
/**
* Factory method returning an instance of an assessment form
* @param object $data Raw data as returned by the assessment form
* @return float|float Percentual grade for submission as suggested by the peer or null if impossible to count
*/
- public function save_assessment(stdClass $assessment, stdClass $data);
+ public function save_assessment(object $assessment, object $data);
}
* @param object $data Raw data returned by the dimension editor form
* @return void
*/
- public function save_form(stdClass $data) {
+ public function save_form(object $data) {
global $DB;
if (!isset($data->strategyname) || ($data->strategyname != $this->name())) {
* @param object $raw Raw data returned by mform
* @return array Array of objects to be inserted/updated in DB
*/
- protected function _cook_form_data(stdClass $raw) {
+ protected function _cook_form_data(object $raw) {
$cook = array();
for ($k = 0; $k < $raw->numofdimensions; $k++) {
- $cook[$k] = new stdClass();
+ $cook[$k] = new object();
$cook[$k]->id = isset($raw->dimensionid[$k]) ? $raw->dimensionid[$k] : null;
$cook[$k]->workshopid = $this->workshop->id;
$cook[$k]->sort = $k + 1;
* @todo Finish documenting this function
*/
function workshop_user_outline($course, $user, $mod, $workshop) {
- $return = new stdClass;
+ $return = new object();
$return->time = 0;
$return->info = '';
return $return;
function workshop_get_comparison_levels() {
$levels = array();
- $levels[WORKSHOP_COMPARISON_VERYHIGH] = new stdClass;
+ $levels[WORKSHOP_COMPARISON_VERYHIGH] = new object();
$levels[WORKSHOP_COMPARISON_VERYHIGH]->name = get_string('comparisonveryhigh', 'workshop');
$levels[WORKSHOP_COMPARISON_VERYHIGH]->value = 5.00;
- $levels[WORKSHOP_COMPARISON_HIGH] = new stdClass;
+ $levels[WORKSHOP_COMPARISON_HIGH] = new object();
$levels[WORKSHOP_COMPARISON_HIGH]->name = get_string('comparisonhigh', 'workshop');
$levels[WORKSHOP_COMPARISON_HIGH]->value = 3.00;
- $levels[WORKSHOP_COMPARISON_NORMAL] = new stdClass;
+ $levels[WORKSHOP_COMPARISON_NORMAL] = new object();
$levels[WORKSHOP_COMPARISON_NORMAL]->name = get_string('comparisonnormal', 'workshop');
$levels[WORKSHOP_COMPARISON_NORMAL]->value = 2.50;
- $levels[WORKSHOP_COMPARISON_LOW] = new stdClass;
+ $levels[WORKSHOP_COMPARISON_LOW] = new object();
$levels[WORKSHOP_COMPARISON_LOW]->name = get_string('comparisonlow', 'workshop');
$levels[WORKSHOP_COMPARISON_LOW]->value = 1.67;
- $levels[WORKSHOP_COMPARISON_VERYLOW] = new stdClass;
+ $levels[WORKSHOP_COMPARISON_VERYLOW] = new object();
$levels[WORKSHOP_COMPARISON_VERYLOW]->name = get_string('comparisonverylow', 'workshop');
$levels[WORKSHOP_COMPARISON_VERYLOW]->value = 1.00;
* @param object $cm Course module record as returned by {@link get_coursemodule_from_id()}
* @param object $course Course record from {course} table
*/
- public function __construct(stdClass $instance, stdClass $cm, stdClass $course) {
+ public function __construct(object $instance, object $cm, object $course) {
foreach ($instance as $key => $val) {
if (is_object($val) || (is_array($val))) {
// this should not happen if the $instance is really just the record returned by $DB
* The returned objects contain id, lastname and firstname properties and are ordered by lastname,firstname
*
* @param bool $musthavesubmission If true, return only users who have already submitted. All possible authors otherwise.
- * @return array array[userid] => stdClass{->id ->lastname ->firstname}
+ * @return array array[userid] => object{->id ->lastname ->firstname}
*/
public function get_peer_authors($musthavesubmission=true) {
global $DB;
*
* @param bool $musthavesubmission If true, return only users who have already submitted. All possible users otherwise.
* @see get_super_reviewers()
- * @return array array[userid] => stdClass{->id ->lastname ->firstname}
+ * @return array array[userid] => object{->id ->lastname ->firstname}
*/
public function get_peer_reviewers($musthavesubmission=false) {
global $DB;
*
* @param bool $musthavesubmission If true, return only users who have already submitted. All possible users otherwise.
* @see get_peer_reviewers()
- * @return array array[userid] => stdClass{->id ->lastname ->firstname}
+ * @return array array[userid] => object{->id ->lastname ->firstname}
*/
public function get_super_reviewers() {
global $DB;
* is set, returns only groups withing the course module grouping. Always returns group [0] with
* all the given users.
*
- * @param array $users array[userid] => stdClass{->id ->lastname ->firstname}
- * @return array array[groupid][userid] => stdClass{->id ->lastname ->firstname}
+ * @param array $users array[userid] => object{->id ->lastname ->firstname}
+ * @return array array[groupid][userid] => object{->id ->lastname ->firstname}
*/
public function get_grouped($users) {
global $DB;
if (is_array($id)) {
$submissions = array();
foreach ($rs as $submission) {
- $submissions[$submission->id] = new stdClass();
+ $submissions[$submission->id] = new object();
foreach ($submission as $property => $value) {
// we do not want text fields here to prevent possible memory issues
if (in_array($property, array('id', 'workshopid', 'example', 'userid', 'authorlastname', 'authorfirstname',
foreach ($rs as $assessment) {
// copy selected properties into the array to be returned. This is here mainly in order not
// to include text comments.
- $assessments[$assessment->id] = new stdClass;
+ $assessments[$assessment->id] = new object();
foreach ($assessment as $property => $value) {
if (in_array($property, array('id', 'submissionid', 'userid', 'timecreated', 'timemodified',
'timeagreed', 'grade', 'gradinggrade', 'gradinggradeover', 'gradinggradeoverby',
* @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) {
+ public function add_allocation(object $submission, $reviewerid, $bulk=false) {
global $DB;
if ($DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'userid' => $reviewerid))) {
}
$now = time();
- $assessment = new stdClass();
+ $assessment = new object();
$assessment->submissionid = $submission->id;
$assessment->userid = $reviewerid;
$assessment->timecreated = $now;
* @param string $message to display
* @return string html
*/
- public function status_message(stdClass $message) {
+ public function status_message(object $message) {
if (empty($message->text)) {
return '';
}
* @return string html to be echoed
*/
public function allocation_init_result($result='') {
- $msg = new stdClass();
+ $msg = new object();
if ($result === 'WORKSHOP_ALLOCATION_RANDOM_ERROR') {
$msg = (object)array('text' => get_string('randomallocationerror', 'workshop'), 'sty' => 'error');
} else {
*
* By default, this looks similar to a forum post.
*
- * @param stdClass $submission The submission record
+ * @param object $submission The submission record
* @param bool $showauthorname Should the author name be displayed
- * @param stdClass $author If author's name should be displayed, this object contains the author data
+ * @param object $author If author's name should be displayed, this object contains the author data
* @return string html to be echoed
*/
- public function submission_full(stdClass $submission, $showauthorname=false, stdClass $author=null) {
+ public function submission_full(object $submission, $showauthorname=false, object $author=null) {
global $CFG;
$o = ''; // output code
$userpic = $this->output->user_picture($userpic);
$userurl = new moodle_url($CFG->wwwroot . '/user/view.php',
array('id' => $author->id, 'course' => $this->page->course->id));
- $a = new stdClass();
+ $a = new object();
$a->name = fullname($author);
$a->url = $userurl->out();
$byfullname = get_string('byfullname', 'workshop', $a);
* If format==html, then format a html string. If format==text, then format a text-only string.
* Otherwise, returns html for non-images and html to display the image inline.
*
- * @param stdClass $submission Submission record
+ * @param object $submission Submission record
* @param string format The format of the returned string
* @return string HTML code to be echoed
*/
- public function submission_attachments(stdClass $submission, $format=null) {
+ public function submission_attachments(object $submission, $format=null) {
global $CFG;
require_once($CFG->libdir.'/filelib.php');