diff --git a/admin/tool/generator/locallib.php b/admin/tool/generator/locallib.php index c7d25dadf4d..1eceb1aaee4 100644 --- a/admin/tool/generator/locallib.php +++ b/admin/tool/generator/locallib.php @@ -348,7 +348,7 @@ class generator { $base_course->summary = 'Blah Blah'; $base_course->format = 'weeks'; $base_course->numsections = '10'; - $base_course->startdate = mktime(); + $base_course->startdate = time(); $base_course->id = '0'; $courses_count = 0; @@ -461,7 +461,7 @@ class generator { case 'assignment': $module->intro = $description; $module->assignmenttype = $this->get_module_type('assignment'); - $module->timedue = mktime() + 89487321; + $module->timedue = time() + 89487321; $module->grade = rand(50,100); break; case 'chat': @@ -505,8 +505,8 @@ class generator { break; case 'lesson': $module->lessondefault = 1; - $module->available = mktime(); - $module->deadline = mktime() + 719891987; + $module->available = time(); + $module->deadline = time() + 719891987; $module->grade = 100; break; case 'quiz': diff --git a/admin/tool/unittest/dbtest.php b/admin/tool/unittest/dbtest.php index e5e2eb193ee..b3f060cb9f9 100644 --- a/admin/tool/unittest/dbtest.php +++ b/admin/tool/unittest/dbtest.php @@ -28,10 +28,6 @@ define('NO_OUTPUT_BUFFERING', true); require(dirname(__FILE__) . '/../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); -// unfortunately outdated SimpleTest is not E_STRICT compatible -$CFG->debug = ($CFG->debug & ~E_STRICT); -error_reporting($CFG->debug); - require_once('simpletestlib.php'); require_once('simpletestcoveragelib.php'); require_once('ex_simple_test.php'); diff --git a/admin/tool/unittest/index.php b/admin/tool/unittest/index.php index 62a60a7c97d..93057b55d54 100644 --- a/admin/tool/unittest/index.php +++ b/admin/tool/unittest/index.php @@ -28,13 +28,6 @@ define('NO_OUTPUT_BUFFERING', true); require(dirname(__FILE__) . '/../../../config.php'); require_once($CFG->libdir.'/adminlib.php'); - -// Always run the unit tests in developer debug mode. -// unfortunately outdated SimpleTest is not E_STRICT compatible -$CFG->debug = (DEBUG_DEVELOPER & ~E_STRICT); -error_reporting($CFG->debug); -raise_memory_limit(MEMORY_EXTRA); - require_once('simpletestlib.php'); require_once('simpletestcoveragelib.php'); require_once('ex_simple_test.php'); @@ -48,6 +41,8 @@ $showsearch = optional_param('showsearch', false, PARAM_BOOL); admin_externalpage_setup('toolsimpletest', '', array('showpasses'=>$showpasses, 'showsearch'=>$showsearch)); +raise_memory_limit(MEMORY_EXTRA); + $unittest = true; global $UNITTEST; diff --git a/admin/tool/unittest/simpletestcoveragelib.php b/admin/tool/unittest/simpletestcoveragelib.php index addcd83786f..306bf2941e7 100644 --- a/admin/tool/unittest/simpletestcoveragelib.php +++ b/admin/tool/unittest/simpletestcoveragelib.php @@ -135,6 +135,7 @@ class autogroup_test_coverage extends AutoGroupTest { $covrecorder->start_instrumentation(); parent::run($simpletestreporter); $covrecorder->stop_instrumentation(); + set_time_limit(60*10); // it may take a long time to generate the report $covrecorder->generate_report(); moodle_coverage_reporter::print_summary_info(basename($this->coveragedir)); } else { diff --git a/admin/webservice/forms.php b/admin/webservice/forms.php index 96e53c6b685..91aa0585b54 100644 --- a/admin/webservice/forms.php +++ b/admin/webservice/forms.php @@ -254,7 +254,7 @@ class web_service_token_form extends moodleform { return $data; } - function validation(&$data, $files) { + function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); diff --git a/auth/cas/auth.php b/auth/cas/auth.php index d8c95231ffb..94ea981fffe 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -150,7 +150,7 @@ class auth_plugin_cas extends auth_plugin_ldap { function prelogout_hook() { global $CFG; - if ($this->config->logoutcas) { + if (!empty($this->config->logoutcas)) { $backurl = $CFG->wwwroot; $this->connectCAS(); phpCAS::logoutWithURL($backurl); diff --git a/auth/shibboleth/config.html b/auth/shibboleth/config.html index 8eff5f29d78..18dfdeae4a2 100644 --- a/auth/shibboleth/config.html +++ b/auth/shibboleth/config.html @@ -41,7 +41,7 @@ ?> - alt_login ?> + alt_login) ? $config->alt_login : '') ?> diff --git a/backup/converter/convertlib.php b/backup/converter/convertlib.php index 61b148bd754..ef37f5ea3ca 100644 --- a/backup/converter/convertlib.php +++ b/backup/converter/convertlib.php @@ -112,7 +112,8 @@ abstract class base_converter implements loggable { * @return string the system name of the converter */ public function get_name() { - return array_shift(explode('_', get_class($this))); + $parts = explode('_', get_class($this)); + return array_shift($parts); } /** diff --git a/backup/converter/moodle1/handlerlib.php b/backup/converter/moodle1/handlerlib.php index da87824949b..51cad6429d2 100644 --- a/backup/converter/moodle1/handlerlib.php +++ b/backup/converter/moodle1/handlerlib.php @@ -863,6 +863,7 @@ class moodle1_course_outline_handler extends moodle1_xml_handler { // host... $versionfile = $CFG->dirroot.'/mod/'.$data['modulename'].'/version.php'; if (file_exists($versionfile)) { + $module = new stdClass(); include($versionfile); $data['version'] = $module->version; } else { @@ -1852,7 +1853,7 @@ abstract class moodle1_qtype_handler extends moodle1_plugin_handler { /** * Question type handlers cannot open the xml_writer */ - final protected function open_xml_writer() { + final protected function open_xml_writer($filename) { throw new moodle1_convert_exception('opening_xml_writer_forbidden'); } @@ -1971,7 +1972,7 @@ abstract class moodle1_resource_successor_handler extends moodle1_mod_handler { * @param array $data pre-cooked legacy resource data * @param array $raw raw legacy resource data */ - public function process_legacy_resource(array $data, array $raw) { + public function process_legacy_resource(array $data, array $raw = null) { } /** diff --git a/backup/util/structure/simpletest/testbackupstructures.php b/backup/util/structure/simpletest/testbackupstructures.php index 5b98144d62c..5677932e306 100644 --- a/backup/util/structure/simpletest/testbackupstructures.php +++ b/backup/util/structure/simpletest/testbackupstructures.php @@ -337,7 +337,8 @@ class backup_structure_test extends UnitTestCaseUsingDatabase { $this->assertEqual($inventeds->get_counter(), 2); // Array // Perform some validations with the generated XML - $dom = DOMDocument::loadXML($xo->get_allcontents()); + $dom = new DomDocument(); + $dom->loadXML($xo->get_allcontents()); $xpath = new DOMXPath($dom); // Some more counters $query = '/forum/discussions/discussion/posts/post'; diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 46f2bbacc02..644c225efe2 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -571,7 +571,7 @@ class block_base { return false; } - function get_extra_capabilities() { + static function get_extra_capabilities() { return array('moodle/block:view', 'moodle/block:edit'); } diff --git a/blog/external_blog_edit.php b/blog/external_blog_edit.php index 0ce519008b6..a511f6a3b5f 100644 --- a/blog/external_blog_edit.php +++ b/blog/external_blog_edit.php @@ -80,7 +80,7 @@ if ($externalblogform->is_cancelled()){ $newexternal->userid = $USER->id; $newexternal->url = $data->url; $newexternal->filtertags = $data->filtertags; - $newexternal->timemodified = mktime(); + $newexternal->timemodified = time(); $newexternal->id = $DB->insert_record('blog_external', $newexternal); blog_sync_external_entries($newexternal); @@ -99,7 +99,7 @@ if ($externalblogform->is_cancelled()){ $external->userid = $USER->id; $external->url = $data->url; $external->filtertags = $data->filtertags; - $external->timemodified = mktime(); + $external->timemodified = time(); $DB->update_record('blog_external', $external); tag_set('blog_external', $external->id, explode(',', $data->autotags)); diff --git a/blog/locallib.php b/blog/locallib.php index 19b01ca322c..b8385da2f0d 100644 --- a/blog/locallib.php +++ b/blog/locallib.php @@ -1132,13 +1132,13 @@ class blog_filter_entry extends blog_filter { } /** - * This filter restricts the results to a time interval in seconds up to mktime() + * This filter restricts the results to a time interval in seconds up to time() */ class blog_filter_since extends blog_filter { public function __construct($interval) { $this->conditions[] = 'p.lastmodified >= ? AND p.lastmodified <= ?'; - $this->params[] = mktime() - $interval; - $this->params[] = mktime(); + $this->params[] = time() - $interval; + $this->params[] = time(); } } diff --git a/comment/lib.php b/comment/lib.php index d770e16643c..dbf1058b417 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -636,7 +636,7 @@ class comment { * } * @return boolean */ - public function delete_comments($param) { + public static function delete_comments($param) { global $DB; $param = (array)$param; if (empty($param['contextid'])) { @@ -651,7 +651,7 @@ class comment { * * @param stdClass $context course context */ - public function reset_course_page_comments($context) { + public static function reset_course_page_comments($context) { global $DB; $contexts = array(); $contexts[] = $context->id; diff --git a/config-dist.php b/config-dist.php index 4919ed14bee..0aec77a0dd4 100644 --- a/config-dist.php +++ b/config-dist.php @@ -420,10 +420,10 @@ $CFG->admin = 'admin'; //========================================================================= // // Force a debugging mode regardless the settings in the site administration -// @error_reporting(1023); // NOT FOR PRODUCTION SERVERS! -// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS! -// $CFG->debug = 38911; // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS! -// $CFG->debugdisplay = true; // NOT FOR PRODUCTION SERVERS! +// @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS! +// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS! +// $CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS! +// $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS! // // You can specify a comma separated list of user ids that that always see // debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay diff --git a/course/lib.php b/course/lib.php index dfc33df1c0e..42edb6a2562 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2830,6 +2830,7 @@ function add_mod_to_section($mod, $beforemod=NULL) { return $section->id; // Return course_sections ID that was used. } else { // Insert a new record + $section = new stdClass(); $section->course = $mod->course; $section->section = $mod->section; $section->summary = ""; diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 9fc6c50e885..dd324192967 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -656,7 +656,7 @@ abstract class moodleform_mod extends moodleform { * @return bool True if one or more rules is enabled, false if none are; * default returns false */ - function completion_rule_enabled(&$data) { + function completion_rule_enabled($data) { return false; } diff --git a/grade/edit/tree/grade.php b/grade/edit/tree/grade.php index 53fc1ee0c25..25a3f91262b 100644 --- a/grade/edit/tree/grade.php +++ b/grade/edit/tree/grade.php @@ -160,6 +160,7 @@ if ($grade = $DB->get_record('grade_grades', array('itemid' => $grade_item->id, $mform->set_data($grade); } else { + $grade = new stdClass(); $grade->feedback = array('text'=>'', 'format'=>FORMAT_HTML); $mform->set_data(array('itemid'=>$itemid, 'userid'=>$userid, 'locked'=>$grade_item->locked, 'locktime'=>$grade_item->locktime)); } diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 8a71a42777f..7601fea44a8 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -280,6 +280,10 @@ class grade_report_grader extends grade_report { global $SESSION; + if (!isset($SESSION->gradeuserreport)) { + $SESSION->gradeuserreport = new stdClass(); + } + if ($this->sortitemid) { if (!isset($SESSION->gradeuserreport->sort)) { if ($this->sortitemid == 'firstname' || $this->sortitemid == 'lastname') { @@ -439,7 +443,7 @@ class grade_report_grader extends grade_report { foreach ($grades as $graderec) { if (in_array($graderec->userid, $userids) and array_key_exists($graderec->itemid, $this->gtree->get_items())) { // some items may not be present!! $this->grades[$graderec->userid][$graderec->itemid] = new grade_grade($graderec, false); - $this->grades[$graderec->userid][$graderec->itemid]->grade_item =& $this->gtree->get_item($graderec->itemid); // db caching + $this->grades[$graderec->userid][$graderec->itemid]->grade_item = $this->gtree->get_item($graderec->itemid); // db caching } } } @@ -451,7 +455,7 @@ class grade_report_grader extends grade_report { $this->grades[$userid][$itemid] = new grade_grade(); $this->grades[$userid][$itemid]->itemid = $itemid; $this->grades[$userid][$itemid]->userid = $userid; - $this->grades[$userid][$itemid]->grade_item =& $this->gtree->get_item($itemid); // db caching + $this->grades[$userid][$itemid]->grade_item = $this->gtree->get_item($itemid); // db caching } } } diff --git a/index.php b/index.php index 946332d4c5f..48857709acc 100644 --- a/index.php +++ b/index.php @@ -102,6 +102,7 @@ if (!$section = $DB->get_record('course_sections', array('course'=>$SITE->id, 'section'=>1))) { $DB->delete_records('course_sections', array('course'=>$SITE->id, 'section'=>1)); // Just in case + $section = new stdClass(); $section->course = $SITE->id; $section->section = 1; $section->summary = ''; diff --git a/lib/completionlib.php b/lib/completionlib.php index f9f153e995a..a47a1f89ee2 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -573,7 +573,7 @@ class completion_info { $this->internal_systemerror("Unexpected result: multiple grades for item '{$item->id}', user '{$userid}'"); } - $newstate = $this->internal_get_grade_state($item, reset($grades)); + $newstate = self::internal_get_grade_state($item, reset($grades)); if ($newstate == COMPLETION_INCOMPLETE) { return COMPLETION_INCOMPLETE; } @@ -1116,7 +1116,7 @@ class completion_info { $groupjoin = "JOIN {groups_members} gm ON gm.userid = u.id"; $groupselect = " AND gm.groupid = :groupid "; - + $return->data['groupid'] = $groupid; } @@ -1249,9 +1249,9 @@ class completion_info { // Grade being deleted, so only change could be to make it incomplete $possibleresult = COMPLETION_INCOMPLETE; } else { - $possibleresult = $this->internal_get_grade_state($item, $grade); + $possibleresult = self::internal_get_grade_state($item, $grade); } - + // OK, let's update state based on this $this->update_state($cm, $possibleresult, $grade->userid); } @@ -1267,7 +1267,7 @@ class completion_info { * @param grade_grade $grade an instance of grade_grade * @return int Completion state e.g. COMPLETION_INCOMPLETE */ - public function internal_get_grade_state($item, $grade) { + public static function internal_get_grade_state($item, $grade) { if (!$grade) { return COMPLETION_INCOMPLETE; } diff --git a/lib/dml/simpletest/testdml.php b/lib/dml/simpletest/testdml.php index c10eccaff71..6a9c8328ac2 100644 --- a/lib/dml/simpletest/testdml.php +++ b/lib/dml/simpletest/testdml.php @@ -2284,13 +2284,13 @@ class dml_test extends UnitTestCase { $this->assertEqual(1, $DB->count_records($tablename, array('course' => 2))); $this->assertEqual(1, $DB->count_records($tablename, array('course' => 3))); - $record = $DB->get_record($tablename, array('course' => 1)); + $record = $DB->get_record($tablename, array('course' => 3)); $record->xxxxx = 2; try { $DB->update_record_raw($tablename, $record); $this->fail("Expecting an exception, none occurred"); } catch (Exception $e) { - $this->assertTrue($e instanceof coding_exception); + $this->assertTrue($e instanceof moodle_exception); } $record = $DB->get_record($tablename, array('course' => 3)); diff --git a/lib/grade/simpletest/testgradecategory.php b/lib/grade/simpletest/testgradecategory.php index 3c9ba96c191..a5b8451fd0d 100644 --- a/lib/grade/simpletest/testgradecategory.php +++ b/lib/grade/simpletest/testgradecategory.php @@ -38,7 +38,7 @@ class grade_category_test extends grade_test { public function __destruct() { $this->endtime = time(); //var_dump($this->endtime-$this->starttime); - + parent::__destruct(); } @@ -118,7 +118,7 @@ class grade_category_test extends grade_test { $grade_category = new grade_category($params, false); $grade_category->insert(); $this->grade_categories[50] = $grade_category;//going to delete this one later hence the special index - + $this->assertEqual(4, $grade_category->depth); $this->assertEqual($parentpath.$grade_category->id."/", $grade_category->path); } @@ -251,7 +251,7 @@ class grade_category_test extends grade_test { /** * Tests the calculation of grades using the various aggregation methods with and without hidden grades * This will not work entirely until MDL-11837 is done - * @global type $DB + * @global type $DB */ function sub_test_grade_category_generate_grades() { global $DB; @@ -286,13 +286,13 @@ class grade_category_test extends grade_test { $grade_items[$i]->grademin = 0; $grade_items[$i]->grademax = 10; $grade_items[$i]->iteminfo = 'Manual grade item used for unit testing'; - $grade_items[$i]->timecreated = mktime(); - $grade_items[$i]->timemodified = mktime(); - + $grade_items[$i]->timecreated = time(); + $grade_items[$i]->timemodified = time(); + //used as the weight by weighted mean and as extra credit by mean with extra credit //Will be 0, 1 and 2 $grade_items[$i]->aggregationcoef = $i; - + $grade_items[$i]->insert(); } @@ -304,8 +304,8 @@ class grade_category_test extends grade_test { $grade_grades[$i]->userid = $this->userid; $grade_grades[$i]->rawgrade = ($i+1)*2;//produce grade grades of 2, 4 and 6 $grade_grades[$i]->finalgrade = ($i+1)*2; - $grade_grades[$i]->timecreated = mktime(); - $grade_grades[$i]->timemodified = mktime(); + $grade_grades[$i]->timecreated = time(); + $grade_grades[$i]->timemodified = time(); $grade_grades[$i]->information = '1 of 2 grade_grades'; $grade_grades[$i]->informationformat = FORMAT_PLAIN; $grade_grades[$i]->feedback = 'Good, but not good enough..'; @@ -316,14 +316,14 @@ class grade_category_test extends grade_test { //3 grade items with 1 grade_grade each. //grade grades have the values 2, 4 and 6 - + //First correct answer is the aggregate with all 3 grades //Second correct answer is with the first grade (value 2) hidden - + $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_MEDIAN, 'GRADE_AGGREGATE_MEDIAN', 8, 8); $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_MAX, 'GRADE_AGGREGATE_MAX', 12, 12); $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_MODE, 'GRADE_AGGREGATE_MODE', 12, 12); - + //weighted mean. note grade totals are rounded to an int to prevent rounding discrepancies. correct final grade isnt actually exactly 10 //3 items with grades 2, 4 and 6 with weights 0, 1 and 2 and all out of 10. then doubled to be out of 20. $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_WEIGHTED_MEAN, 'GRADE_AGGREGATE_WEIGHTED_MEAN', 10, 10); @@ -335,16 +335,16 @@ class grade_category_test extends grade_test { //mean of grades with extra credit //3 items with grades 2, 4 and 6 with extra credit 0, 1 and 2 equally weighted and all out of 10. then doubled to be out of 20. $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_EXTRACREDIT_MEAN, 'GRADE_AGGREGATE_EXTRACREDIT_MEAN', 10, 13); - + //aggregation tests the are affected by a hidden grade currently dont work as we dont store the altered grade in the database //instead an in memory recalculation is done. This should be remedied by MDL-11837 //fails with 1 grade hidden. still reports 8 as being correct $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_MEAN, 'GRADE_AGGREGATE_MEAN', 8, 10); - + //fails with 1 grade hidden. still reports 4 as being correct $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_MIN, 'GRADE_AGGREGATE_MIN', 4, 8); - + //fails with 1 grade hidden. still reports 12 as being correct $this->helper_test_grade_agg_method($grade_category, $grade_items, $grade_grades, GRADE_AGGREGATE_SUM, 'GRADE_AGGREGATE_SUM', 12, 10); } @@ -384,27 +384,27 @@ class grade_category_test extends grade_test { */ function helper_test_grade_aggregation_result($grade_category, $correctgrade, $msg) { global $DB; - + $category_grade_item = $grade_category->get_grade_item(); - + //this creates all the grade_grades we need grade_regrade_final_grades($this->courseid); - + $grade = $DB->get_record('grade_grades', array('itemid'=>$category_grade_item->id, 'userid'=>$this->userid)); $this->assertWithinMargin($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax); $this->assertEqual(intval($correctgrade), intval($grade->finalgrade), $msg); - + /* * TODO this doesnt work as the grade_grades created by $grade_category->generate_grades(); dont * observe the category's max grade //delete the grade_grades for the category itself and check they get recreated correctly $DB->delete_records('grade_grades', array('itemid'=>$category_grade_item->id)); $grade_category->generate_grades(); - + $grade = $DB->get_record('grade_grades', array('itemid'=>$category_grade_item->id, 'userid'=>$this->userid)); $this->assertWithinMargin($grade->rawgrade, $grade->rawgrademin, $grade->rawgrademax); $this->assertEqual(intval($correctgrade), intval($grade->finalgrade), $msg); - * + * */ } diff --git a/lib/grade/simpletest/testgradescale.php b/lib/grade/simpletest/testgradescale.php index 771deb0e7ad..22a740ae970 100644 --- a/lib/grade/simpletest/testgradescale.php +++ b/lib/grade/simpletest/testgradescale.php @@ -48,7 +48,7 @@ class grade_scale_test extends grade_test { $params->userid = $this->userid; $params->scale = 'Distinction, Very Good, Good, Pass, Fail'; $params->description = 'This scale is used to mark standard assignments.'; - $params->timemodified = mktime(); + $params->timemodified = time(); $scale = new grade_scale($params, false); diff --git a/lib/installlib.php b/lib/installlib.php index 566bc8cb3c6..148dfb484c7 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -402,9 +402,9 @@ function install_cli_database(array $options, $interactive) { require_once($CFG->libdir.'/upgradelib.php'); // show as much debug as possible - @error_reporting(1023); + @error_reporting(E_ALL | E_STRICT); @ini_set('display_errors', '1'); - $CFG->debug = 38911; + $CFG->debug = (E_ALL | E_STRICT); $CFG->debugdisplay = true; $CFG->version = ''; diff --git a/lib/pear/OLE.php b/lib/pear/OLE.php index e8af6b5e95e..cfdb0eac860 100644 --- a/lib/pear/OLE.php +++ b/lib/pear/OLE.php @@ -148,7 +148,7 @@ class OLE extends PEAR fseek($this->_file_handle, $pointer); $pps_wk = fread($this->_file_handle, OLE_PPS_SIZE); if (strlen($pps_wk) != OLE_PPS_SIZE) { - break; // Excel likes to add a trailing byte sometimes + break; // Excel likes to add a trailing byte sometimes //return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk)); } $name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??) @@ -185,7 +185,7 @@ class OLE extends PEAR $pointer += OLE_PPS_SIZE; } } - + /** * It checks whether the PPS tree is complete (all PPS's read) * starting with the given PPS (not necessarily root) @@ -215,7 +215,7 @@ class OLE extends PEAR return true; } - /** + /** * Checks whether a PPS is a File PPS or not. * If there is no PPS for the index given, it will return false. * @@ -231,7 +231,7 @@ class OLE extends PEAR return false; } - /** + /** * Checks whether a PPS is a Root PPS or not. * If there is no PPS for the index given, it will return false. * @@ -247,7 +247,7 @@ class OLE extends PEAR return false; } - /** + /** * Gives the total number of PPS's found in the OLE container. * * @access public @@ -279,7 +279,7 @@ class OLE extends PEAR fseek($this->_file_handle, $this->_list[$index]->_data + $position); return fread($this->_file_handle, $length); } - + /** * Gets the data length from a PPS * If there is no PPS for the index given, it will return 0. @@ -304,7 +304,7 @@ class OLE extends PEAR * @param string $ascii The ASCII string to transform * @return string The string in Unicode */ - function Asc2Ucs($ascii) + static function Asc2Ucs($ascii) { $rawname = ''; for ($i = 0; $i < strlen($ascii); $i++) { @@ -319,10 +319,10 @@ class OLE extends PEAR * * @access public * @static - * @param integer $date A timestamp + * @param integer $date A timestamp * @return string The string for the OLE container */ - function LocalDate2OLE($date = null) + static function LocalDate2OLE($date = null) { if (!isset($date)) { return "\x00\x00\x00\x00\x00\x00\x00\x00"; @@ -398,10 +398,10 @@ class OLE extends PEAR $big_date = ($high_part*$factor) + $low_part; // translate to seconds $big_date /= 10000000; - + // days from 1-1-1601 until the beggining of UNIX era $days = 134774; - + // translate to seconds from beggining of UNIX era $big_date -= $days*24*3600; return floor($big_date); diff --git a/lib/pear/README_MOODLE.txt b/lib/pear/README_MOODLE.txt index 94902c8e9e1..9632e50b63e 100644 --- a/lib/pear/README_MOODLE.txt +++ b/lib/pear/README_MOODLE.txt @@ -25,6 +25,10 @@ and documented for Moodle at: Such modifications should be carefully each time the Excel PEAR package is updated to a new release within Moodle. +5/ static keywords in OLE.php +* static function Asc2Ucs() +* static function LocalDate2OLE() + XML/Parser ================= 1/ changed ereg_ to preg_ diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index 614682cf292..2bea87e8808 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -104,7 +104,7 @@ class grade_test extends UnitTestCaseUsingDatabase { $scale->userid = $this->userid; $scale->scale = 'Way off topic, Not very helpful, Fairly neutral, Fairly helpful, Supportive, Some good information, Perfect answer!'; $scale->description = 'This scale defines some of qualities that make posts helpful within the Moodle help forums.\n Your feedback will help others see how their posts are being received.'; - $scale->timemodified = mktime(); + $scale->timemodified = time(); $scale->id = $DB->insert_record('scale', $scale); $this->scale[0] = $scale; @@ -118,7 +118,7 @@ class grade_test extends UnitTestCaseUsingDatabase { $scale->userid = $this->userid; $scale->scale = 'Distinction, Very Good, Good, Pass, Fail'; $scale->description = 'This scale is used to mark standard assignments.'; - $scale->timemodified = mktime(); + $scale->timemodified = time(); $scale->id = $DB->insert_record('scale', $scale); $this->scale[1] = $scale; @@ -132,7 +132,7 @@ class grade_test extends UnitTestCaseUsingDatabase { $scale->userid = $this->userid; $scale->scale = 'Loner, Contentious, Disinterested, Participative, Follower, Leader'; $scale->description = 'Describes the level of teamwork of a student.'; - $scale->timemodified = mktime(); + $scale->timemodified = time(); $temp = explode(',', $scale->scale); $scale->max = count($temp) -1; @@ -146,7 +146,7 @@ class grade_test extends UnitTestCaseUsingDatabase { $scale->userid = $this->userid; $scale->scale = 'Does not understand theory, Understands theory but fails practice, Manages through, Excels'; $scale->description = 'Level of expertise at a technical task, with a theoretical framework.'; - $scale->timemodified = mktime(); + $scale->timemodified = time(); $temp = explode(',', $scale->scale); $scale->max = count($temp) -1; @@ -160,7 +160,7 @@ class grade_test extends UnitTestCaseUsingDatabase { $scale->userid = $this->userid; $scale->scale = 'Insufficient, Acceptable, Excellent.'; $scale->description = 'Description of skills.'; - $scale->timemodified = mktime(); + $scale->timemodified = time(); $temp = explode(',', $scale->scale); $scale->max = count($temp) -1; @@ -197,8 +197,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_category->keephigh = 0; $grade_category->droplow = 0; $grade_category->parent = $course_category->id; - $grade_category->timecreated = mktime(); - $grade_category->timemodified = mktime(); + $grade_category->timecreated = time(); + $grade_category->timemodified = time(); $grade_category->depth = 2; $grade_category->id = $DB->insert_record('grade_categories', $grade_category); @@ -215,8 +215,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_category->keephigh = 0; $grade_category->droplow = 0; $grade_category->parent = $this->grade_categories[0]->id; - $grade_category->timecreated = mktime(); - $grade_category->timemodified = mktime(); + $grade_category->timecreated = time(); + $grade_category->timemodified = time(); $grade_category->depth = 3; $grade_category->id = $DB->insert_record('grade_categories', $grade_category); @@ -233,8 +233,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_category->keephigh = 0; $grade_category->droplow = 0; $grade_category->parent = $this->grade_categories[0]->id; - $grade_category->timecreated = mktime(); - $grade_category->timemodified = mktime(); + $grade_category->timecreated = time(); + $grade_category->timemodified = time(); $grade_category->depth = 3; $grade_category->id = $DB->insert_record('grade_categories', $grade_category); @@ -253,8 +253,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_category->keephigh = 0; $grade_category->droplow = 0; $grade_category->parent = $course_category->id; - $grade_category->timecreated = mktime(); - $grade_category->timemodified = mktime(); + $grade_category->timecreated = time(); + $grade_category->timemodified = time(); $grade_category->depth = 2; $grade_category->id = $DB->insert_record('grade_categories', $grade_category); @@ -378,8 +378,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->itemnumber = 1; $grade_item->idnumber = 'item id 0'; $grade_item->iteminfo = 'Grade item 0 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 3; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -400,8 +400,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Grade item 1 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 4; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -421,8 +421,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = $this->scalemax[0]; $grade_item->iteminfo = 'Grade item 2 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 6; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -441,8 +441,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Grade item 3 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 1; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -460,8 +460,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Grade item 4 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 2; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -479,8 +479,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Grade item 5 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 5; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -502,8 +502,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademax = 120; $grade_item->locked = time(); $grade_item->iteminfo = 'Orphan Grade 6 item used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 7; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -524,8 +524,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = $this->scalemax[0]; $grade_item->iteminfo = 'Grade item 7 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 9; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -544,8 +544,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Grade item 8 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 10; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -565,8 +565,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Orphan Grade item 9 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->sortorder = 8; $grade_item->id = $DB->insert_record('grade_items', $grade_item); @@ -586,8 +586,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_item->grademin = 0; $grade_item->grademax = 100; $grade_item->iteminfo = 'Manual grade item 10 used for unit testing'; - $grade_item->timecreated = mktime(); - $grade_item->timemodified = mktime(); + $grade_item->timecreated = time(); + $grade_item->timemodified = time(); $grade_item->id = $DB->insert_record('grade_items', $grade_item); $this->grade_items[10] = $grade_item; @@ -608,8 +608,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 1; $grade->rawgrade = 15; // too small $grade->finalgrade = 30; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '1 of 17 grade_grades'; $grade->informationformat = FORMAT_PLAIN; $grade->feedback = 'Good, but not good enough..'; @@ -623,8 +623,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 2; $grade->rawgrade = 40; $grade->finalgrade = 40; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '2 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -635,8 +635,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 3; $grade->rawgrade = 170; // too big $grade->finalgrade = 110; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '3 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -649,8 +649,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->itemid = $this->grade_items[1]->id; $grade->userid = 1; $grade->finalgrade = 72; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '4 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -660,8 +660,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->itemid = $this->grade_items[1]->id; $grade->userid = 2; $grade->finalgrade = 92; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '5 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -671,8 +671,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->itemid = $this->grade_items[1]->id; $grade->userid = 3; $grade->finalgrade = 100; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '6 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -687,8 +687,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->rawgrade = 2; $grade->finalgrade = 6; $grade->scaleid = $this->scale[3]->id; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '7 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -700,8 +700,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->rawgrade = 3; $grade->finalgrade = 2; $grade->scaleid = $this->scale[3]->id; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '8 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -713,8 +713,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->rawgrade = 1; $grade->finalgrade = 3; $grade->scaleid = $this->scale[3]->id; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '9 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -727,8 +727,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 1; $grade->rawgrade = 97; $grade->finalgrade = 69; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '10 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -739,8 +739,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 2; $grade->rawgrade = 49; $grade->finalgrade = 87; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '11 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -751,8 +751,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 3; $grade->rawgrade = 67; $grade->finalgrade = 94; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '12 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -765,8 +765,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 2; $grade->rawgrade = 3; $grade->finalgrade = 3; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '13 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -777,8 +777,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 3; $grade->rawgrade = 6; $grade->finalgrade = 6; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '14 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -791,8 +791,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 1; $grade->rawgrade = 20; $grade->finalgrade = 20; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '15 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -803,8 +803,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 2; $grade->rawgrade = 50; $grade->finalgrade = 50; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '16 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -815,8 +815,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade->userid = 3; $grade->rawgrade = 100; $grade->finalgrade = 100; - $grade->timecreated = mktime(); - $grade->timemodified = mktime(); + $grade->timecreated = time(); + $grade->timemodified = time(); $grade->information = '17 of 17 grade_grades'; $grade->id = $DB->insert_record('grade_grades', $grade); @@ -837,8 +837,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_outcome->fullname = 'Team work'; $grade_outcome->shortname = 'Team work'; $grade_outcome->fullname = 'Team work outcome'; - $grade_outcome->timecreated = mktime(); - $grade_outcome->timemodified = mktime(); + $grade_outcome->timecreated = time(); + $grade_outcome->timemodified = time(); $grade_outcome->scaleid = $this->scale[2]->id; $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome); @@ -849,8 +849,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_outcome->fullname = 'Complete circuit board'; $grade_outcome->shortname = 'Complete circuit board'; $grade_outcome->fullname = 'Complete circuit board'; - $grade_outcome->timecreated = mktime(); - $grade_outcome->timemodified = mktime(); + $grade_outcome->timecreated = time(); + $grade_outcome->timemodified = time(); $grade_outcome->scaleid = $this->scale[3]->id; $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome); @@ -861,8 +861,8 @@ class grade_test extends UnitTestCaseUsingDatabase { $grade_outcome->fullname = 'Debug Java program'; $grade_outcome->shortname = 'Debug Java program'; $grade_outcome->fullname = 'Debug Java program'; - $grade_outcome->timecreated = mktime(); - $grade_outcome->timemodified = mktime(); + $grade_outcome->timecreated = time(); + $grade_outcome->timemodified = time(); $grade_outcome->scaleid = $this->scale[4]->id; $grade_outcome->id = $DB->insert_record('grade_outcomes', $grade_outcome); diff --git a/lib/simpletest/portfolio_testclass.php b/lib/simpletest/portfolio_testclass.php index 9100c194e1c..0adcefbf339 100644 --- a/lib/simpletest/portfolio_testclass.php +++ b/lib/simpletest/portfolio_testclass.php @@ -115,7 +115,7 @@ class portfolio_caller_test extends portfolio_caller_base { class portfolio_exporter_test extends portfolio_exporter { private $files; - public function write_new_file($content, $name) { + public function write_new_file($content, $name, $manifest=true) { if (empty($this->files)) { $this->files = array(); } @@ -126,11 +126,11 @@ class portfolio_exporter_test extends portfolio_exporter { throw new portfolio_exception('notimplemented', 'portfolio', 'files api test'); } - public function get_tempfiles() { + public function get_tempfiles($skipfile='portfolio-export.zip') { return $this->files; } - public function zip_tempfiles() { + public function zip_tempfiles($filename='portfolio-export.zip', $filepath='/final/') { return new portfolio_fake_file('fake content zipfile', 'portfolio-export.zip'); } } @@ -196,19 +196,19 @@ class portfoliolib_test extends UnitTestCaseUsingDatabase { protected $testtables = array( 'lib' => array( - 'portfolio_instance', 'portfolio_instance_user', 'portfolio_instance_config', + 'portfolio_instance', 'portfolio_instance_user', 'portfolio_instance_config', 'user', 'course', 'course_categories')); function setup() { global $USER; parent::setup(); - + $this->switch_to_test_db(); // Switch to test DB for all the execution foreach ($this->testtables as $dir => $tables) { $this->create_test_tables($tables, $dir); // Create tables } - + // It is necessary to store $USER object because some subclasses use generator // stuff which breaks $USER $this->olduser = $USER; diff --git a/lib/simpletest/testcompletionlib.php b/lib/simpletest/testcompletionlib.php index f218c0f7e40..179f26bc808 100644 --- a/lib/simpletest/testcompletionlib.php +++ b/lib/simpletest/testcompletionlib.php @@ -434,6 +434,7 @@ WHERE cm.course=? AND cmc.userid=?"),array(42,314159))); // There are two CMids in total, the one we had data for and another one + $modinfo = new stdClass(); $modinfo->cms=array((object)array('id'=>13),(object)array('id'=>14)); $result=$c->get_data($cm,true,0,$modinfo); @@ -615,8 +616,8 @@ WHERE $c->__construct((object)array('id'=>42)); $cm=(object)array('course'=>42,'id'=>13,'completion'=>0,'completiongradeitemnumber'=>null); - $item=(object)array('itemnumber'=>3); - $grade=(object)array('userid'=>31337); + $item=(object)array('itemnumber'=>3, 'gradepass'=>1, 'hidden'=>0); + $grade=(object)array('userid'=>31337, 'finalgrade'=>0, 'rawgrade'=>0); // Not enabled (should do nothing) $c->setReturnValueAt(0,'is_enabled',false); @@ -640,9 +641,8 @@ WHERE $cm->completiongradeitemnumber=3; $c->setReturnValueAt(3,'is_enabled',true); $c->expectAt(3,'is_enabled',array($cm)); - $c->expectAt(0,'internal_get_grade_state',array($item,$grade)); - $c->setReturnValueAt(0,'internal_get_grade_state',COMPLETION_COMPLETE_PASS); $c->expectAt(0,'update_state',array($cm,COMPLETION_COMPLETE_PASS,31337)); + $grade->finalgrade = 1; $c->inform_grade_changed($cm,$item,$grade,false); // Same as above but marked deleted. It is supposed to call update_state diff --git a/lib/simpletest/testconditionlib.php b/lib/simpletest/testconditionlib.php index 61f16c3fb83..7b7eba81ccc 100644 --- a/lib/simpletest/testconditionlib.php +++ b/lib/simpletest/testconditionlib.php @@ -181,7 +181,8 @@ class conditionlib_test extends UnitTestCaseUsingDatabase { )); // Okay sweet, now get modinfo - $modinfo=get_fast_modinfo($DB->get_record('course',array('id'=>$courseid))); + $course = $DB->get_record('course',array('id'=>$courseid)); + $modinfo=get_fast_modinfo($course); // Test basic data $this->assertEqual(1,$modinfo->cms[$cmid1]->showavailability); diff --git a/lib/simpletest/testeventslib.php b/lib/simpletest/testeventslib.php index 0c89a0a32c0..4d5fd7a6d9a 100644 --- a/lib/simpletest/testeventslib.php +++ b/lib/simpletest/testeventslib.php @@ -63,7 +63,7 @@ function sample_function_handler($eventdata) { // test handler class with static method class sample_handler_class { - function static_method($eventdata) { + static function static_method($eventdata) { static $called = 0; static $ignorefail = false; diff --git a/lib/simpletest/testmoodlelib.php b/lib/simpletest/testmoodlelib.php index 0142a665aa0..3cc7e598e8e 100644 --- a/lib/simpletest/testmoodlelib.php +++ b/lib/simpletest/testmoodlelib.php @@ -369,7 +369,7 @@ class moodlelib_test extends UnitTestCase { // make sure warning is displayed if array submitted - TODO: throw exception in Moodle 2.3 $debugging = isset($CFG->debug) ? $CFG->debug : null; $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null; - $CFG->debug = 38911; + $CFG->debug = DEBUG_DEVELOPER; $CFG->debugdisplay = true; ob_start(); @@ -441,7 +441,7 @@ class moodlelib_test extends UnitTestCase { // do not allow non-arrays $debugging = isset($CFG->debug) ? $CFG->debug : null; $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null; - $CFG->debug = 38911; + $CFG->debug = DEBUG_DEVELOPER; $CFG->debugdisplay = true; ob_start(); @@ -511,7 +511,7 @@ class moodlelib_test extends UnitTestCase { // make sure warning is displayed if array submitted - TODO: throw exception in Moodle 2.3 $debugging = isset($CFG->debug) ? $CFG->debug : null; $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null; - $CFG->debug = 38911; + $CFG->debug = DEBUG_DEVELOPER; $CFG->debugdisplay = true; ob_start(); @@ -583,7 +583,7 @@ class moodlelib_test extends UnitTestCase { // do not allow non-arrays $debugging = isset($CFG->debug) ? $CFG->debug : null; $debugdisplay = isset($CFG->debugdisplay) ? $CFG->debugdisplay : null; - $CFG->debug = 38911; + $CFG->debug = DEBUG_DEVELOPER; $CFG->debugdisplay = true; // make sure array keys are sanitised diff --git a/lib/simpletest/testnavigationlib.php b/lib/simpletest/testnavigationlib.php index be5493465ce..b10e02cf20e 100644 --- a/lib/simpletest/testnavigationlib.php +++ b/lib/simpletest/testnavigationlib.php @@ -95,10 +95,17 @@ class navigation_node_test extends UnitTestCase { $this->assertIsA($node2, 'navigation_node'); $this->assertIsA($node3, 'navigation_node'); - $this->assertReference($node1, $this->node->get('key')); - $this->assertReference($node2, $this->node->get($node2->key)); - $this->assertReference($node2, $this->node->get($node2->key, $node2->type)); - $this->assertReference($node3, $this->node->get($node3->key, $node3->type)); + $ref = $this->node->get('key'); + $this->assertReference($node1, $ref); + + $ref = $this->node->get($node2->key); + $this->assertReference($node2, $ref); + + $ref = $this->node->get($node2->key, $node2->type); + $this->assertReference($node2, $ref); + + $ref = $this->node->get($node3->key, $node3->type); + $this->assertReference($node3, $ref); } public function test_add_before() { @@ -170,7 +177,8 @@ class navigation_node_test extends UnitTestCase { $activenode2 = $this->node->get('demo1')->find_active_node(); if ($this->assertIsA($activenode1, 'navigation_node')) { - $this->assertReference($activenode1, $this->node->get('demo3')->get('demo5')->get('activity1')); + $ref = $this->node->get('demo3')->get('demo5')->get('activity1'); + $this->assertReference($activenode1, $ref); } $this->assertNotA($activenode2, 'navigation_node'); @@ -307,7 +315,7 @@ class mock_initialise_global_navigation extends global_navigation { return 0; } - public function load_for_user() { + public function load_for_user($user=null, $forceforcontext=false) { $this->add('load_for_user', null, null, null, 'initcall'.self::$count); self::$count++; return 0; diff --git a/lib/simpletest/testoutputcomponents.php b/lib/simpletest/testoutputcomponents.php index 6ad6ccc4e20..b37e50501d5 100644 --- a/lib/simpletest/testoutputcomponents.php +++ b/lib/simpletest/testoutputcomponents.php @@ -164,7 +164,8 @@ EOF; $this->assertEqual('Moodle company', $item->get_text()); $this->assertTrue(is_null($item->get_url())); - $subitem = array_shift($item->get_children()); + $children = $item->get_children(); + $subitem = array_shift($children); $this->assertFalse($subitem->has_children()); $this->assertEqual('Hosting', $subitem->get_text()); $this->assertEqual('Commercial hosting', $subitem->get_title()); @@ -183,11 +184,14 @@ EOF; $this->assertTrue($menu->has_children()); $this->assertEqual(2, count($menu->get_children())); - $infomenu = array_pop($menu->get_children()); + $children = $menu->get_children(); + $infomenu = array_pop($children); $this->assertTrue($infomenu->has_children()); - $this->assertEqual(2, count($infomenu->get_children())); + $children = $infomenu->get_children(); + $this->assertEqual(2, count($children)); - $langspecinfo = array_shift($infomenu->get_children()); + $children = $infomenu->get_children(); + $langspecinfo = array_shift($children); $this->assertEqual('Information in English', $langspecinfo->get_title()); // same menu for English language selected @@ -195,11 +199,13 @@ EOF; $this->assertTrue($menu->has_children()); $this->assertEqual(2, count($menu->get_children())); - $infomenu = array_pop($menu->get_children()); + $children = $menu->get_children(); + $infomenu = array_pop($children); $this->assertTrue($infomenu->has_children()); $this->assertEqual(1, count($infomenu->get_children())); - $langspecinfo = array_shift($infomenu->get_children()); + $children = $infomenu->get_children(); + $langspecinfo = array_shift($children); $this->assertEqual('Information in English', $langspecinfo->get_title()); // same menu for German (de_du) language selected @@ -207,11 +213,13 @@ EOF; $this->assertTrue($menu->has_children()); $this->assertEqual(2, count($menu->get_children())); - $infomenu = array_pop($menu->get_children()); + $children = $menu->get_children(); + $infomenu = array_pop($children); $this->assertTrue($infomenu->has_children()); $this->assertEqual(1, count($infomenu->get_children())); - $langspecinfo = array_shift($infomenu->get_children()); + $children = $infomenu->get_children(); + $langspecinfo = array_shift($children); $this->assertEqual('Informationen in deutscher Sprache', $langspecinfo->get_title()); // same menu for Czech language selected @@ -219,7 +227,8 @@ EOF; $this->assertTrue($menu->has_children()); $this->assertEqual(2, count($menu->get_children())); - $infomenu = array_pop($menu->get_children()); + $children = $infomenu->get_children(); + $infomenu = array_pop( $children); $this->assertFalse($infomenu->has_children()); } } diff --git a/lib/simpletest/testportfoliolib.php b/lib/simpletest/testportfoliolib.php index bda31f08c71..ca0819aa87c 100644 --- a/lib/simpletest/testportfoliolib.php +++ b/lib/simpletest/testportfoliolib.php @@ -45,3 +45,6 @@ foreach (get_list_of_plugins('mod') as $module) { } } +class empty_portfoliolib_test extends UnitTestCase { + // empty, this prevents warning in coverage report +} diff --git a/lib/spikephpcoverage/readme_moodle.txt b/lib/spikephpcoverage/readme_moodle.txt index 6cd68c799d1..0a99b63c722 100644 --- a/lib/spikephpcoverage/readme_moodle.txt +++ b/lib/spikephpcoverage/readme_moodle.txt @@ -20,5 +20,6 @@ Our changes: /// Look for "moodle" in code * removed deprecated "=& new" * src/phpcoverage.remote.bottom.inc.php | => Prevent execution (not used and unsecure) src/phpcoverage.remote.top.inc.php | + * E_STRICT fix - add static to "public function getLogger" in /src/src/util/Utility.php 20090621 - Eloy Lafuente (stronk7): Original import of 0.8.2 release diff --git a/lib/spikephpcoverage/src/util/Utility.php b/lib/spikephpcoverage/src/util/Utility.php index e6d9a52456c..127ce5e624c 100644 --- a/lib/spikephpcoverage/src/util/Utility.php +++ b/lib/spikephpcoverage/src/util/Utility.php @@ -208,13 +208,13 @@ /*}}}*/ /*{{{ public function getLogger() */ - public function getLogger($package=false) { + public static function getLogger($package=false) { global $spc_config; - if(!isset($this->logger) || $this->logger == NULL) { - $this->logger = new CoverageLogger(); - $this->logger->setLevel($spc_config["log_level"]); + if(!isset(self::$logger) || self::$logger == NULL) { + self::$logger = new CoverageLogger(); + self::$logger->setLevel($spc_config["log_level"]); } - return $this->logger; + return self::$logger; } /*}}}*/ diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 576bb27adc5..4736529825a 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -295,7 +295,7 @@ WHERE $DB->update_record("choice_answers", $newanswer); add_to_log($course->id, "choice", "choose again", "view.php?id=$cm->id", $choice->id, $cm->id); } else { - $newanswer = NULL; + $newanswer = stdClass(); $newanswer->choiceid = $choice->id; $newanswer->userid = $userid; $newanswer->optionid = $formanswer; diff --git a/mod/data/edit.php b/mod/data/edit.php index 1f76f8e59f3..ac2e702a0b5 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -216,6 +216,7 @@ if ($datarecord = data_submitted() and confirm_sesskey()) { /// Insert a whole lot of empty records to make sure we have them $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); foreach ($fields as $field) { + $content = new stdClass(); $content->recordid = $recordid; $content->fieldid = $field->id; $DB->insert_record('data_content',$content); diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 9e9df3d0087..f7bd7ac6f72 100644 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -149,7 +149,7 @@ class data_field_file extends data_field_base { // content: "a##b" where a is the file name, b is the display name - function update_content($recordid, $value, $name) { + function update_content($recordid, $value, $name='') { global $CFG, $DB, $USER; $fs = get_file_storage(); diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 269e916815f..e5874880080 100644 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -197,7 +197,7 @@ class data_field_picture extends data_field_base { return true; } - function update_content($recordid, $value, $name) { + function update_content($recordid, $value, $name='') { global $CFG, $DB, $USER; if (!$content = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) { diff --git a/mod/folder/backup/moodle1/lib.php b/mod/folder/backup/moodle1/lib.php index f3036e218ab..1e0a73d43af 100644 --- a/mod/folder/backup/moodle1/lib.php +++ b/mod/folder/backup/moodle1/lib.php @@ -38,7 +38,7 @@ class moodle1_mod_folder_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource($data) { + public function process_legacy_resource(array $data, array $raw = null) { // get the course module id and context id $instanceid = $data['id']; $currentcminfo = $this->get_cminfo($instanceid); diff --git a/mod/imscp/backup/moodle1/lib.php b/mod/imscp/backup/moodle1/lib.php index 90f77ba8817..1977312e42b 100644 --- a/mod/imscp/backup/moodle1/lib.php +++ b/mod/imscp/backup/moodle1/lib.php @@ -38,7 +38,7 @@ class moodle1_mod_imscp_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource($data) { + public function process_legacy_resource(array $data, array $raw = null) { $instanceid = $data['id']; $currentcminfo = $this->get_cminfo($instanceid); diff --git a/mod/page/backup/moodle1/lib.php b/mod/page/backup/moodle1/lib.php index c917a1693e1..468cd3484f3 100644 --- a/mod/page/backup/moodle1/lib.php +++ b/mod/page/backup/moodle1/lib.php @@ -38,7 +38,7 @@ class moodle1_mod_page_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource(array $data) { + public function process_legacy_resource(array $data, array $raw = null) { // get the course module id and context id $instanceid = $data['id']; diff --git a/mod/resource/backup/moodle1/lib.php b/mod/resource/backup/moodle1/lib.php index cb3fea39697..8dcc59673e2 100644 --- a/mod/resource/backup/moodle1/lib.php +++ b/mod/resource/backup/moodle1/lib.php @@ -113,6 +113,7 @@ class moodle1_mod_resource_handler extends moodle1_mod_handler { // use the version of the successor instead of the current mod/resource // beware - the version.php declares info via $module object, do not use // a variable of such name here + $module = new stdClass(); include $CFG->dirroot.'/mod/'.$successor->get_modname().'/version.php'; $cminfo['version'] = $module->version; diff --git a/mod/url/backup/moodle1/lib.php b/mod/url/backup/moodle1/lib.php index 862762021f1..9fa0d230216 100644 --- a/mod/url/backup/moodle1/lib.php +++ b/mod/url/backup/moodle1/lib.php @@ -38,7 +38,7 @@ class moodle1_mod_url_handler extends moodle1_resource_successor_handler { * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/RESOURCE data * Called by moodle1_mod_resource_handler::process_resource() */ - public function process_legacy_resource($data) { + public function process_legacy_resource(array $data, array $raw = null) { // get the course module id and context id $instanceid = $data['id']; diff --git a/mod/wiki/locallib.php b/mod/wiki/locallib.php index 2cda5032fa3..522f417ee33 100644 --- a/mod/wiki/locallib.php +++ b/mod/wiki/locallib.php @@ -145,7 +145,8 @@ function wiki_get_current_version($pageid) { FROM {wiki_versions} WHERE pageid = ? ORDER BY version DESC"; - return array_pop($DB->get_records_sql($sql, array($pageid), 0, 1)); + $records = $DB->get_records_sql($sql, array($pageid), 0, 1); + return array_pop($records); } diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 5841688401d..94eff9f4c7e 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -771,7 +771,7 @@ class page_wiki_editcomment extends page_wiki { } } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'comments', 'activetab' => 'comments')); } @@ -995,7 +995,7 @@ class page_wiki_preview extends page_wiki_edit { $PAGE->set_url($CFG->wwwroot . '/mod/wiki/edit.php', $params); } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'view', 'activetab' => 'view')); } @@ -1105,7 +1105,7 @@ class page_wiki_diff extends page_wiki { $PAGE->navbar->add(get_string('diff', 'wiki')); } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history')); } @@ -1863,7 +1863,7 @@ class page_wiki_restoreversion extends page_wiki { $PAGE->navbar->add(get_string('restoreversion', 'wiki')); } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history')); } @@ -1931,7 +1931,7 @@ class page_wiki_deletecomment extends page_wiki { $PAGE->navbar->add(get_string('deletecommentcheck', 'wiki')); } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'comments', 'activetab' => 'comments')); } @@ -2102,7 +2102,7 @@ class page_wiki_viewversion extends page_wiki { $PAGE->navbar->add(get_string('versionnum', 'wiki', $this->version->version)); } - protected function setup_tabs() { + protected function setup_tabs($options = array()) { parent::setup_tabs(array('linkedwhenactive' => 'history', 'activetab' => 'history', 'inactivetabs' => array('edit'))); } diff --git a/portfolio/boxnet/lib.php b/portfolio/boxnet/lib.php index d49de62d2a5..99c42ba940a 100644 --- a/portfolio/boxnet/lib.php +++ b/portfolio/boxnet/lib.php @@ -99,7 +99,7 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base { $mform->addElement('select', 'plugin_folder', get_string('existingfolder', 'portfolio_boxnet'), $folders); } - public function export_config_validation($data) { + public function export_config_validation(array $data) { $allfolders = $this->get_folder_list(); if (in_array($data['plugin_newfolder'], $allfolders)) { return array('plugin_newfolder' => get_string('folderclash', 'portfolio_boxnet')); diff --git a/question/behaviour/adaptivenopenalty/renderer.php b/question/behaviour/adaptivenopenalty/renderer.php index d82d73b446d..8b1e738cf36 100644 --- a/question/behaviour/adaptivenopenalty/renderer.php +++ b/question/behaviour/adaptivenopenalty/renderer.php @@ -38,7 +38,8 @@ require_once(dirname(__FILE__) . '/../adaptive/renderer.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qbehaviour_adaptivenopenalty_renderer extends qbehaviour_adaptive_renderer { - protected function penalty_info($qa, $mark) { + protected function penalty_info(question_attempt $qa, $mark, + question_display_options $options) { return ''; } protected function disregarded_info() { diff --git a/question/category_class.php b/question/category_class.php index 96b5efa32ab..fd65dbac81f 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -428,7 +428,7 @@ class question_category_object { } // Update the category record. - $cat = null; + $cat = new stdClass(); $cat->id = $updateid; $cat->name = $newname; $cat->info = $newinfo; diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index 46ea5cf3912..8c59bb97027 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -171,7 +171,8 @@ class question_usage_by_activity { } else { $this->questionattempts[] = $qa; } - $qa->set_slot(end(array_keys($this->questionattempts))); + $ids = array_keys($this->questionattempts); + $qa->set_slot(end($ids)); $this->observer->notify_attempt_added($qa); return $qa->get_slot(); } @@ -510,7 +511,14 @@ class question_usage_by_activity { * instead of the data from $_POST. */ public function process_all_actions($timestamp = null, $postdata = null) { - $slots = question_attempt::get_submitted_var('slots', PARAM_SEQUENCE, $postdata); + // note: we must not use "question_attempt::get_submitted_var()" because there is no attempt instance!!! + if (is_null($postdata)) { + $slots = optional_param('slots', null, PARAM_SEQUENCE); + } else if (array_key_exists('slots', $postdata)) { + $slots = clean_param($postdata['slots'], PARAM_SEQUENCE); + } else { + $slots = null; + } if (is_null($slots)) { $slots = $this->get_slots(); } else if (!$slots) { diff --git a/question/engine/simpletest/helpers.php b/question/engine/simpletest/helpers.php index 6b43ba35574..b7093ef71b9 100644 --- a/question/engine/simpletest/helpers.php +++ b/question/engine/simpletest/helpers.php @@ -36,7 +36,7 @@ require_once(dirname(__FILE__) . '/../lib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class testable_question_attempt extends question_attempt { - public function add_step($step) { + public function add_step(question_attempt_step $step) { parent::add_step($step); } public function set_min_fraction($fraction) { @@ -88,7 +88,7 @@ class test_question_maker { * @param number $maxmark the max mark to set. * @return question_attempt the question attempt. */ - public function get_a_qa($question, $maxmark = 3) { + public static function get_a_qa($question, $maxmark = 3) { return new question_attempt($question, 13, null, $maxmark); } diff --git a/question/engine/simpletest/testunitofwork.php b/question/engine/simpletest/testunitofwork.php index 68a99862d4c..5b385fb42ee 100644 --- a/question/engine/simpletest/testunitofwork.php +++ b/question/engine/simpletest/testunitofwork.php @@ -195,6 +195,12 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base { public function test_regrade_same_steps() { // Change the question in a minor way and regrade. + if (!isset($this->quba->get_question($this->slot)->answer)) { + $this->quba->get_question($this->slot)->answer = array(); + } + if (!isset($this->quba->get_question($this->slot)->answer[14])) { + $this->quba->get_question($this->slot)->answer[14] = new stdClass(); + } $this->quba->get_question($this->slot)->answer[14]->fraction = 0.5; $this->quba->regrade_all_questions(); diff --git a/question/format/xml/simpletest/testxmlformat.php b/question/format/xml/simpletest/testxmlformat.php index 1aaf50158f1..1b94015b322 100644 --- a/question/format/xml/simpletest/testxmlformat.php +++ b/question/format/xml/simpletest/testxmlformat.php @@ -116,6 +116,9 @@ class qformat_xml_test extends UnitTestCase { $q->name = 'Short answer question'; $q->questiontext = 'Name an amphibian: __________'; $q->generalfeedback = 'Generalfeedback: frog or toad would have been OK.'; + if (!isset($q->options)) { + $q->options = new stdClass(); + } $q->options->usecase = false; $q->options->answers = array( 13 => new question_answer(13, 'frog', 1.0, 'Frog is a very good answer.', FORMAT_HTML), @@ -144,6 +147,9 @@ class qformat_xml_test extends UnitTestCase { $q->generalfeedback = 'Frogs and toads are amphibians, the others are mammals.'; $q->qtype = 'match'; + if (!isset($q->options)) { + $q->options = new stdClass(); + } $q->options->shuffleanswers = 1; $q->options->correctfeedback = ''; $q->options->correctfeedbackformat = FORMAT_HTML; @@ -417,6 +423,7 @@ END; $qdata->length = 1; $qdata->penalty = 0; $qdata->hidden = 0; + $qdata->options = new stdClass(); $qdata->options->id = 456; $qdata->options->questionid = 123; $qdata->options->responseformat = 'monospaced'; @@ -973,6 +980,7 @@ END; $qdata->penalty = 0.1; $qdata->hidden = 0; + $qdata->options = new stdClass(); $qdata->options->answers = array( 13 => new qtype_numerical_answer(13, '42', 1, 'Well done!', FORMAT_HTML, 0.001), @@ -1102,6 +1110,7 @@ END; $qdata->penalty = 0.3333333; $qdata->hidden = 0; + $qdata->options = new stdClass(); $qdata->options->usecase = 0; $qdata->options->answers = array( @@ -1222,6 +1231,7 @@ END; $qdata->penalty = 1; $qdata->hidden = 0; + $qdata->options = new stdClass(); $qdata->options->answers = array( 1 => new question_answer(1, 'True', 1, 'Well done!', FORMAT_HTML), 2 => new question_answer(2, 'False', 0, 'Doh!', FORMAT_HTML), diff --git a/question/type/match/simpletest/testquestiontype.php b/question/type/match/simpletest/testquestiontype.php index 4ce42917fd7..4e5941ad093 100644 --- a/question/type/match/simpletest/testquestiontype.php +++ b/question/type/match/simpletest/testquestiontype.php @@ -71,6 +71,7 @@ class qtype_match_test extends UnitTestCase { $q->createdby = $USER->id; $q->modifiedby = $USER->id; + $q->options = new stdClass(); $q->options->shuffleanswers = false; test_question_maker::set_standard_combined_feedback_fields($q->options); diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 5196bd5ffa2..c87e8e7012e 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -299,6 +299,7 @@ function qtype_multianswer_extract_question($text) { $question->generalfeedback['format'] = FORMAT_HTML; $question->generalfeedback['itemid'] = ''; + $question->options = new stdClass(); $question->options->questions = array(); $question->defaultmark = 0; // Will be increased for each answer norm diff --git a/question/type/multichoice/simpletest/testquestiontype.php b/question/type/multichoice/simpletest/testquestiontype.php index 8123972fbb6..e28e17c3983 100644 --- a/question/type/multichoice/simpletest/testquestiontype.php +++ b/question/type/multichoice/simpletest/testquestiontype.php @@ -53,6 +53,7 @@ class qtype_multichoice_test extends UnitTestCase { protected function get_test_question_data() { $q = new stdClass(); $q->id = 1; + $q->options = new stdClass(); $q->options->single = true; $q->options->answers[1] = (object) array('answer' => 'frog', 'answerformat' => FORMAT_HTML, 'fraction' => 1); diff --git a/question/type/numerical/simpletest/testquestiontype.php b/question/type/numerical/simpletest/testquestiontype.php index 1f4581e7f0a..8923ef4ffde 100644 --- a/question/type/numerical/simpletest/testquestiontype.php +++ b/question/type/numerical/simpletest/testquestiontype.php @@ -55,6 +55,7 @@ class qtype_numerical_test extends UnitTestCase { protected function get_test_question_data() { $q = new stdClass; $q->id = 1; + $q->options = new stdClass(); $q->options->unitpenalty = 0; $q->options->answers[13] = (object) array( 'id' => 13, diff --git a/question/type/truefalse/simpletest/testquestiontype.php b/question/type/truefalse/simpletest/testquestiontype.php index d71aced0400..a7733a8ebdc 100644 --- a/question/type/truefalse/simpletest/testquestiontype.php +++ b/question/type/truefalse/simpletest/testquestiontype.php @@ -61,6 +61,7 @@ class qtype_truefalse_test extends UnitTestCase { public function test_get_possible_responses() { $q = new stdClass(); $q->id = 1; + $q->options = new stdClass(); $q->options->trueanswer = 1; $q->options->falseanswer = 2; $q->options->answers[1] = (object) array('fraction' => 1); diff --git a/webservice/lib.php b/webservice/lib.php index e889a328b5f..5364613be95 100644 --- a/webservice/lib.php +++ b/webservice/lib.php @@ -175,7 +175,7 @@ class webservice { */ public function add_ws_authorised_user($user) { global $DB; - $user->timecreated = mktime(); + $user->timecreated = time(); $DB->insert_record('external_services_users', $user); } @@ -628,7 +628,7 @@ class webservice { */ public function add_external_service($service) { global $DB; - $service->timecreated = mktime(); + $service->timecreated = time(); $serviceid = $DB->insert_record('external_services', $service); return $serviceid; } @@ -641,7 +641,7 @@ class webservice { */ public function update_external_service($service) { global $DB; - $service->timemodified = mktime(); + $service->timemodified = time(); $DB->update_record('external_services', $service); }