Skip to content

Commit

Permalink
workshop coding style - use stdclass instead of stdClass
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jan 4, 2010
1 parent a8b6fc0 commit 7a789aa
Show file tree
Hide file tree
Showing 27 changed files with 300 additions and 300 deletions.
2 changes: 1 addition & 1 deletion mod/workshop/allocation/lib.php
Expand Up @@ -55,7 +55,7 @@ public function init();
*
* If a form is part of the UI, the caller should have called $PAGE->set_url(...)
*
* @param stdClass $wsoutput workshop module renderer can be used
* @param stdclass $wsoutput workshop module renderer can be used
* @return string HTML code to be echoed
*/
public function ui();
Expand Down
12 changes: 6 additions & 6 deletions mod/workshop/allocation/manual/lib.php
Expand Up @@ -136,7 +136,7 @@ public function ui() {

$hlauthorid = -1; // highlight this author
$hlreviewerid = -1; // highlight this reviewer
$msg = new stdClass(); // message to render
$msg = new stdclass(); // message to render

$m = optional_param('m', '', PARAM_ALPHANUMEXT); // message code
if ($m) {
Expand Down Expand Up @@ -214,7 +214,7 @@ public function ui() {
$submissions = $this->workshop->get_submissions(array_keys($participants));
foreach ($submissions as $submission) {
if (!isset($userinfo[$submission->authorid])) {
$userinfo[$submission->authorid] = new stdClass();
$userinfo[$submission->authorid] = new stdclass();
$userinfo[$submission->authorid]->id = $submission->authorid;
$userinfo[$submission->authorid]->firstname = $submission->authorfirstname;
$userinfo[$submission->authorid]->lastname = $submission->authorlastname;
Expand All @@ -237,7 +237,7 @@ public function ui() {
$reviewers = $DB->get_records_sql($sql, $params);
foreach ($reviewers as $reviewer) {
if (!isset($userinfo[$reviewer->reviewerid])) {
$userinfo[$reviewer->reviewerid] = new stdClass();
$userinfo[$reviewer->reviewerid] = new stdclass();
$userinfo[$reviewer->reviewerid]->id = $reviewer->reviewerid;
$userinfo[$reviewer->reviewerid]->firstname = $reviewer->firstname;
$userinfo[$reviewer->reviewerid]->lastname = $reviewer->lastname;
Expand All @@ -264,7 +264,7 @@ public function ui() {
$reviewees = $DB->get_records_sql($sql, $params);
foreach ($reviewees as $reviewee) {
if (!isset($userinfo[$reviewee->revieweeid])) {
$userinfo[$reviewee->revieweeid] = new stdClass();
$userinfo[$reviewee->revieweeid] = new stdclass();
$userinfo[$reviewee->revieweeid]->id = $reviewee->revieweeid;
$userinfo[$reviewee->revieweeid]->firstname = $reviewee->firstname;
$userinfo[$reviewee->revieweeid]->lastname = $reviewee->lastname;
Expand All @@ -278,7 +278,7 @@ public function ui() {
$allocations = array();

foreach ($participants as $participant) {
$allocations[$participant->id] = new stdClass;
$allocations[$participant->id] = new stdclass;
$allocations[$participant->id]->userid = $participant->id;
$allocations[$participant->id]->submissionid = null;
$allocations[$participant->id]->reviewedby = array();
Expand All @@ -302,7 +302,7 @@ public function ui() {
unset($reviewees);

// prepare data to be displayed
$data = new stdClass();
$data = new stdclass();
$data->allocations = $allocations;
$data->userinfo = $userinfo;
$data->authors = $this->workshop->get_potential_authors();
Expand Down
10 changes: 5 additions & 5 deletions mod/workshop/allocation/manual/renderer.php
Expand Up @@ -33,10 +33,10 @@ class workshopallocation_manual_renderer extends plugin_renderer_base {
/**
* Display the table of all current allocations and widgets to modify them
*
* @param stdClass $data to be displayed - see the top of the function for the list of needed properties
* @param stdclass $data to be displayed - see the top of the function for the list of needed properties
* @return string html code
*/
public function display_allocations(stdClass $data) {
public function display_allocations(stdclass $data) {
$allocations = $data->allocations; // array prepared array of all allocations data
$userinfo = $data->userinfo; // names and pictures of all required users
$authors = $data->authors; // array potential reviewees
Expand Down Expand Up @@ -85,7 +85,7 @@ public function display_allocations(stdClass $data) {
*
* @return string HTML code
*/
protected function participant(stdClass $allocation, array $userinfo) {
protected function participant(stdclass $allocation, array $userinfo) {
$o = $this->output->user_picture($userinfo[$allocation->userid], $this->page->course->id);
$o .= fullname($userinfo[$allocation->userid]);
$o .= $this->output->container_start(array('submission'));
Expand All @@ -108,7 +108,7 @@ protected function participant(stdClass $allocation, array $userinfo) {
*
* @return string html code
*/
protected function reviewers_of_participant(stdClass $allocation, array $userinfo, array $reviewers, $selfassessment) {
protected function reviewers_of_participant(stdclass $allocation, array $userinfo, array $reviewers, $selfassessment) {
$o = '';
if (is_null($allocation->submissionid)) {
$o .= $this->output->container(get_string('nothingtoreview', 'workshop'), 'info');
Expand Down Expand Up @@ -154,7 +154,7 @@ protected function reviewers_of_participant(stdClass $allocation, array $userinf
*
* @return string html code
*/
protected function reviewees_of_participant(stdClass $allocation, array $userinfo, array $authors, $selfassessment) {
protected function reviewees_of_participant(stdclass $allocation, array $userinfo, array $authors, $selfassessment) {
$o = '';
if (is_null($allocation->submissionid)) {
$o .= $this->output->container(get_string('withoutsubmission', 'workshop'), 'info');
Expand Down
6 changes: 3 additions & 3 deletions mod/workshop/allocation/random/lib.php
Expand Up @@ -116,7 +116,7 @@ public function init() {
$this->add_new_allocations($newallocations, $authors, $reviewers);
foreach ($newallocations as $newallocation) {
list($reviewerid, $authorid) = each($newallocation);
$a = new stdClass();
$a = new stdclass();
$a->reviewername = fullname($reviewers[0][$reviewerid]);
$a->authorname = fullname($authors[0][$authorid]);
$o[] = 'ok::indent::' . get_string('allocationaddeddetail', 'workshopallocation_random', $a);
Expand All @@ -128,7 +128,7 @@ public function init() {
// by reviewer
$o[] = 'info::' . get_string('numofdeallocatedassessment', 'workshopallocation_random', count($delassessments));
foreach ($delassessments as $delassessmentkey => $delassessmentid) {
$a = new stdClass();
$a = new stdclass();
$a->authorname = fullname((object)array(
'lastname' => $assessments[$delassessmentid]->authorlastname,
'firstname' => $assessments[$delassessmentid]->authorfirstname));
Expand Down Expand Up @@ -159,7 +159,7 @@ public function ui() {
global $OUTPUT, $PAGE;

$m = optional_param('m', null, PARAM_INT); // status message code
$msg = new stdClass();
$msg = new stdclass();
if ($m == self::MSG_SUCCESS) {
$msg = (object)array('text' => get_string('randomallocationdone', 'workshopallocation_random'), 'sty' => 'ok');
}
Expand Down
18 changes: 9 additions & 9 deletions mod/workshop/allocation/random/simpletest/testallocator.php
Expand Up @@ -68,9 +68,9 @@ class workshop_allocation_random_test extends UnitTestCase {
protected $allocator;

public function setUp() {
$cm = new stdClass();
$course = new stdClass();
$context = new stdClass();
$cm = new stdclass();
$course = new stdclass();
$context = new stdclass();
$workshop = (object)array('id' => 42);
$this->workshop = new workshop($workshop, $cm, $course, $context);
$this->allocator = new testable_workshop_random_allocator($this->workshop);
Expand All @@ -88,8 +88,8 @@ public function test_self_allocation_empty_values() {

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 stdclass()));
$reviewers = array(0 => array_fill_keys(array(4, 6, 10), new stdclass()));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers);
// verify
Expand All @@ -98,8 +98,8 @@ public function test_self_allocation_equal_user_groups() {

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 stdclass()));
$reviewers = array(0 => array_fill_keys(array(4, 7, 10), new stdclass()));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers);
// verify
Expand All @@ -108,8 +108,8 @@ public function test_self_allocation_different_user_groups() {

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 stdclass()));
$reviewers = array(0 => array_fill_keys(array(3, 4, 10), new stdclass()));
$assessments = array(23 => (object)array('authorid' => 3, 'reviewerid' => 3));
// exercise SUT
$newallocations = $this->allocator->self_allocation($authors, $reviewers, $assessments);
Expand Down
4 changes: 2 additions & 2 deletions mod/workshop/assessment.php
Expand Up @@ -98,7 +98,7 @@
$feedbackform = $workshop->get_feedbackreviewer_form($PAGE->url, $assessment);
if ($data = $feedbackform->get_data()) {
$data = file_postupdate_standard_editor($data, 'feedbackreviewer', array(), $workshop->context);
$record = new stdClass();
$record = new stdclass();
$record->id = $assessment->id;
$record->gradinggradeover = $workshop->raw_grade_value($data->gradinggradeover, $workshop->gradinggrade);
$record->gradinggradeoverby = $USER->id;
Expand All @@ -121,7 +121,7 @@
echo $OUTPUT->heading(get_string('assessmentbyyourself', 'workshop'), 2);
} elseif (has_capability('mod/workshop:viewreviewernames', $workshop->context)) {
$assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
$reviewer = new stdClass();
$reviewer = new stdclass();
$reviewer->firstname = $assessment->reviewerfirstname;
$reviewer->lastname = $assessment->reviewerlastname;
echo $OUTPUT->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
Expand Down
40 changes: 20 additions & 20 deletions mod/workshop/eval/best/lib.php
Expand Up @@ -58,17 +58,17 @@ public function __construct(workshop $workshop) {
* This function relies on the grading strategy subplugin providing get_assessments_recordset() method.
* {@see self::process_assessments()} for the required structure of the recordset.
*
* @param stdClass $settings The settings for this round of evaluation
* @param stdclass $settings The settings for this round of evaluation
* @param null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewers(s)
*
* @return void
*/
public function update_grading_grades(stdClass $settings, $restrict=null) {
public function update_grading_grades(stdclass $settings, $restrict=null) {
global $DB;

// remember the recently used settings for this workshop
if (empty($this->settings)) {
$record = new stdClass();
$record = new stdclass();
$record->workshopid = $this->workshop->id;
$record->comparison = $settings->comparison;
$DB->insert_record('workshopeval_best_settings', $record);
Expand Down Expand Up @@ -131,12 +131,12 @@ public function get_settings_form(moodle_url $actionurl=null) {
/**
* Given a list of all assessments of a single submission, updates the grading grades in database
*
* @param array $assessments of stdClass (->assessmentid ->assessmentweight ->reviewerid ->gradinggrade ->submissionid ->dimensionid ->grade)
* @param array $diminfo of stdClass (->id ->weight ->max ->min)
* @param stdClass grading evaluation settings
* @param array $assessments of stdclass (->assessmentid ->assessmentweight ->reviewerid ->gradinggrade ->submissionid ->dimensionid ->grade)
* @param array $diminfo of stdclass (->id ->weight ->max ->min)
* @param stdclass grading evaluation settings
* @return void
*/
protected function process_assessments(array $assessments, array $diminfo, stdClass $settings) {
protected function process_assessments(array $assessments, array $diminfo, stdclass $settings) {
global $DB;

if (empty($assessments)) {
Expand Down Expand Up @@ -196,7 +196,7 @@ protected function process_assessments(array $assessments, array $diminfo, stdCl
foreach ($grades as $assessmentid => $grade) {
if (grade_floats_different($grade, $assessments[$assessmentid]->gradinggrade)) {
// the value has changed
$record = new stdClass();
$record = new stdclass();
$record->id = $assessmentid;
$record->gradinggrade = grade_floatval($grade);
$DB->update_record('workshop_assessments', $record, true); // bulk operations expected
Expand All @@ -217,7 +217,7 @@ protected function prepare_data_from_recordset($assessments) {
foreach ($assessments as $a) {
$id = $a->assessmentid; // just an abbrevation
if (!isset($data[$id])) {
$data[$id] = new stdClass();
$data[$id] = new stdclass();
$data[$id]->assessmentid = $a->assessmentid;
$data[$id]->weight = $a->assessmentweight;
$data[$id]->reviewerid = $a->reviewerid;
Expand All @@ -233,12 +233,12 @@ protected function prepare_data_from_recordset($assessments) {
/**
* Normalizes the dimension grades to the interval 0.00000 - 100.00000
*
* Note: this heavily relies on PHP5 way of handling references in array of stdClasses. Hopefuly
* Note: this heavily relies on PHP5 way of handling references in array of stdclasses. Hopefuly
* it will not change again soon.
*
* @param array $assessments of stdClass as returned by {@see self::prepare_data_from_recordset()}
* @param array $diminfo of stdClass
* @return array of stdClass with the same structure as $assessments
* @param array $assessments of stdclass as returned by {@see self::prepare_data_from_recordset()}
* @param array $diminfo of stdclass
* @return array of stdclass with the same structure as $assessments
*/
protected function normalize_grades(array $assessments, array $diminfo) {
foreach ($assessments as $asid => $assessment) {
Expand All @@ -261,7 +261,7 @@ protected function normalize_grades(array $assessments, array $diminfo) {
* The passed structure must be array of assessments objects with ->weight and ->dimgrades properties.
*
* @param array $assessments as prepared by {@link self::prepare_data_from_recordset()}
* @return null|stdClass
* @return null|stdclass
*/
protected function average_assessment(array $assessments) {
$sumdimgrades = array();
Expand All @@ -283,7 +283,7 @@ protected function average_assessment(array $assessments) {
return null;
}

$average = new stdClass();
$average = new stdclass();
$average->dimgrades = array();
foreach ($sumdimgrades as $dimid => $sumdimgrade) {
$average->dimgrades[$dimid] = grade_floatval($sumdimgrade / $sumweights);
Expand Down Expand Up @@ -356,13 +356,13 @@ protected function weighted_variance(array $assessments) {
* Returned value is rounded to 4 valid decimals to prevent some rounding issues - see the unit test
* for an example.
*
* @param stdClass $assessment the assessment being measured
* @param stdClass $referential assessment
* @param array $diminfo of stdClass(->weight ->min ->max ->variance) indexed by dimension id
* @param stdClass $settings
* @param stdclass $assessment the assessment being measured
* @param stdclass $referential assessment
* @param array $diminfo of stdclass(->weight ->min ->max ->variance) indexed by dimension id
* @param stdclass $settings
* @return float|null rounded to 4 valid decimals
*/
protected function assessments_distance(stdClass $assessment, stdClass $referential, array $diminfo, stdClass $settings) {
protected function assessments_distance(stdclass $assessment, stdclass $referential, array $diminfo, stdclass $settings) {
$distance = 0;
$n = 0;
foreach (array_keys($assessment->dimgrades) as $dimid) {
Expand Down
8 changes: 4 additions & 4 deletions mod/workshop/eval/best/simpletest/testlib.php
Expand Up @@ -47,7 +47,7 @@ public function average_assessment(array $assessments) {
public function weighted_variance(array $assessments) {
return parent::weighted_variance($assessments);
}
public function assessments_distance(stdClass $assessment, stdClass $referential, array $diminfo, stdClass $settings) {
public function assessments_distance(stdclass $assessment, stdclass $referential, array $diminfo, stdclass $settings) {
return parent::assessments_distance($assessment, $referential, $diminfo, $settings);
}
}
Expand All @@ -71,9 +71,9 @@ public function setUp() {
$this->realDB = $DB;
$DB = new mockDB();

$cm = new stdClass();
$course = new stdClass();
$context = new stdClass();
$cm = new stdclass();
$course = new stdclass();
$context = new stdclass();
$workshop = (object)array('id' => 42, 'evaluation' => 'best');
$this->workshop = new workshop($workshop, $cm, $course, $context);
$this->evaluator = new testable_workshop_best_evaluation($this->workshop);
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/exassessment.php
Expand Up @@ -101,7 +101,7 @@
echo $OUTPUT->heading(get_string('assessmentbyyourself', 'workshop'), 2);
} else {
$assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
$reviewer = new stdClass();
$reviewer = new stdclass();
$reviewer->firstname = $assessment->reviewerfirstname;
$reviewer->lastname = $assessment->reviewerlastname;
echo $OUTPUT->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/excompare.php
Expand Up @@ -88,7 +88,7 @@
if ($isreviewer) {
echo $OUTPUT->heading(get_string('assessmentbyyourself', 'workshop'), 2);
} elseif ($canmanage) {
$reviewer = new stdClass();
$reviewer = new stdclass();
$reviewer->firstname = $assessment->reviewerfirstname;
$reviewer->lastname = $assessment->reviewerlastname;
echo $OUTPUT->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/exsubmission.php
Expand Up @@ -50,7 +50,7 @@
$example = $workshop->get_example_by_id($id);
} else { // no example specified - create new one
require_capability('mod/workshop:manageexamples', $workshop->context);
$example = new stdClass();
$example = new stdclass();
$example->id = null;
$example->authorid = $USER->id;
}
Expand Down

0 comments on commit 7a789aa

Please sign in to comment.