Skip to content

Commit

Permalink
MDL-50049 deprecation: Remove usage of deprecated api and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Jun 29, 2015
1 parent 8322ed4 commit 2149326
Show file tree
Hide file tree
Showing 18 changed files with 232 additions and 349 deletions.
2 changes: 1 addition & 1 deletion admin/tool/generator/lib.php
Expand Up @@ -53,7 +53,7 @@ function tool_generator_pluginfile($course, $cm, $context, $filearea, $args, $fo
$file = $fs->get_file($context->id, 'tool_generator', $filearea, $args[0], '/', $args[1]);

// Send the file, always forcing download, we don't want options.
session_get_instance()->write_close();
\core\session\manager::write_close();
send_stored_file($file, 0, 0, true);
}

2 changes: 1 addition & 1 deletion admin/tool/phpunit/webrunner.php
Expand Up @@ -35,7 +35,7 @@
admin_externalpage_setup('toolphpunitwebrunner');

if (!$CFG->debugdeveloper) {
error('Not available on production sites, sorry.');
print_error('notlocalisederrormessage', 'error', '', null, 'Not available on production sites, sorry.');
}

core_php_time_limit::raise(60*30);
Expand Down
6 changes: 3 additions & 3 deletions calendar/lib.php
Expand Up @@ -2174,8 +2174,8 @@ public function count_repeats() {
* Pass in a object containing the event properties and this function will
* insert it into the database and deal with any associated files
*
* @see add_event()
* @see update_event()
* @see self::create()
* @see self::update()
*
* @param stdClass $data object of event
* @param bool $checkcapability if moodle should check calendar managing capability or not
Expand Down Expand Up @@ -2391,7 +2391,7 @@ public function update($data, $checkcapability=true) {
* This function deletes an event, any associated events if $deleterepeated=true,
* and cleans up any files associated with the events.
*
* @see delete_event()
* @see self::delete()
*
* @param bool $deleterepeated delete event repeatedly
* @return bool succession of deleting event
Expand Down
89 changes: 0 additions & 89 deletions cohort/tests/cohortlib_test.php
Expand Up @@ -343,95 +343,6 @@ public function test_cohort_is_member() {
$this->assertTrue(cohort_is_member($cohort->id, $user->id));
}

public function test_cohort_get_visible_list() {
global $DB;

$this->resetAfterTest();

$category1 = $this->getDataGenerator()->create_category();
$category2 = $this->getDataGenerator()->create_category();

$course1 = $this->getDataGenerator()->create_course(array('category'=>$category1->id));
$course2 = $this->getDataGenerator()->create_course(array('category'=>$category2->id));
$course3 = $this->getDataGenerator()->create_course();

$cohort1 = $this->getDataGenerator()->create_cohort(array('contextid'=>context_coursecat::instance($category1->id)->id));
$cohort2 = $this->getDataGenerator()->create_cohort(array('contextid'=>context_coursecat::instance($category2->id)->id));
$cohort3 = $this->getDataGenerator()->create_cohort(array('contextid'=>context_system::instance()->id));
$cohort4 = $this->getDataGenerator()->create_cohort(array('contextid'=>context_system::instance()->id));

$user1 = $this->getDataGenerator()->create_user();
$user2 = $this->getDataGenerator()->create_user();
$user3 = $this->getDataGenerator()->create_user();
$user4 = $this->getDataGenerator()->create_user();
$user5 = $this->getDataGenerator()->create_user();

$manualenrol = enrol_get_plugin('manual');
$enrol1 = $DB->get_record('enrol', array('courseid'=>$course1->id, 'enrol'=>'manual'));
$enrol2 = $DB->get_record('enrol', array('courseid'=>$course2->id, 'enrol'=>'manual'));

$manualenrol->enrol_user($enrol1, $user1->id);
$manualenrol->enrol_user($enrol1, $user3->id);
$manualenrol->enrol_user($enrol1, $user4->id);
$manualenrol->enrol_user($enrol2, $user2->id);

cohort_add_member($cohort1->id, $user1->id);
cohort_add_member($cohort3->id, $user1->id);
cohort_add_member($cohort1->id, $user3->id);
cohort_add_member($cohort2->id, $user2->id);

// Cohort1 (Cat1) has 2 users total, 2 user enrolled in course1, 0 users enrolled in course2.
// Cohort2 (Cat2) has 1 users total, 0 user enrolled in course1, 1 users enrolled in course2.
// Cohort3 (Syst) has 1 users total, 1 user enrolled in course1, 0 users enrolled in course2.
// Cohort4 (Syst) has 0 users total.

$list = cohort_get_visible_list($course1);
$this->assertDebuggingCalled();
$this->assertEquals(2, count($list));
$this->assertNotEmpty($list[$cohort1->id]);
$this->assertRegExp('/\(2\)$/', $list[$cohort1->id]);
$this->assertNotEmpty($list[$cohort3->id]);
$this->assertRegExp('/\(1\)$/', $list[$cohort3->id]);

$list = cohort_get_visible_list($course1, false);
$this->assertDebuggingCalled();
$this->assertEquals(3, count($list));
$this->assertNotEmpty($list[$cohort1->id]);
$this->assertRegExp('/\(2\)$/', $list[$cohort1->id]);
$this->assertNotEmpty($list[$cohort3->id]);
$this->assertRegExp('/\(1\)$/', $list[$cohort3->id]);
$this->assertNotEmpty($list[$cohort4->id]);
$this->assertRegExp('/[^\)]$/', $list[$cohort4->id]);

$list = cohort_get_visible_list($course2);
$this->assertDebuggingCalled();
$this->assertEquals(1, count($list));
$this->assertNotEmpty($list[$cohort2->id]);
$this->assertRegExp('/\(1\)$/', $list[$cohort2->id]);

$list = cohort_get_visible_list($course2, false);
$this->assertDebuggingCalled();
$this->assertEquals(3, count($list));
$this->assertNotEmpty($list[$cohort2->id]);
$this->assertRegExp('/\(1\)$/', $list[$cohort2->id]);
$this->assertNotEmpty($list[$cohort3->id]);
$this->assertRegExp('/[^\)]$/', $list[$cohort3->id]);
$this->assertNotEmpty($list[$cohort4->id]);
$this->assertRegExp('/[^\)]$/', $list[$cohort4->id]);

$list = cohort_get_visible_list($course3);
$this->assertDebuggingCalled();
$this->assertEquals(0, count($list));

$list = cohort_get_visible_list($course3, false);
$this->assertDebuggingCalled();
$this->assertEquals(2, count($list));
$this->assertNotEmpty($list[$cohort3->id]);
$this->assertRegExp('/[^\)]$/', $list[$cohort3->id]);
$this->assertNotEmpty($list[$cohort4->id]);
$this->assertRegExp('/[^\)]$/', $list[$cohort4->id]);
}

public function test_cohort_get_cohorts() {
global $DB;

Expand Down
2 changes: 1 addition & 1 deletion completion/criteria/completion_criteria.php
Expand Up @@ -168,7 +168,7 @@ public static function factory($params) {
global $CFG, $COMPLETION_CRITERIA_TYPES;

if (!isset($params['criteriatype']) || !isset($COMPLETION_CRITERIA_TYPES[$params['criteriatype']])) {
error('invalidcriteriatype', 'completion');
print_error('invalidcriteriatype', 'completion');
}

$class = 'completion_criteria_'.$COMPLETION_CRITERIA_TYPES[$params['criteriatype']];
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/tree/lib.php
Expand Up @@ -861,7 +861,7 @@ public function get_category_cell($category, $levelclass, $params) {

public function get_item_cell($item, $params) {
if (empty($params['itemtype']) || empty($params['eid'])) {
error('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
print_error('missingitemtypeoreid', 'core_grades');
}
$itemcell = parent::get_item_cell($item, $params);

Expand Down
1 change: 1 addition & 0 deletions lang/en/grades.php
Expand Up @@ -463,6 +463,7 @@
$string['minmaxupgradewarning'] = 'Note: An inconsistency has been detected with some grades due to a change in the minimum and maximum grades used when calculating the grade displayed in the gradebook. It is recommended that the inconsistency is resolved by clicking the button below, though this will result in some grades being changed.';
$string['minimum_show'] = 'Show minimum grade';
$string['minimum_show_help'] = 'Minimum grade is used in calculating grades and weights. If not shown, minimum grade will default to zero and cannot be edited.';
$string['missingitemtypeoreid'] = 'Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)';
$string['missingscale'] = 'Scale must be selected';
$string['mode'] = 'Mode';
$string['modgradeerrorbadpoint'] = 'Invalid Grade Value. This must be an integer between 0 and {$a}';
Expand Down

0 comments on commit 2149326

Please sign in to comment.