MDL-47146 core_grades: fix class names (contd)
authorMarina Glancy <marina@moodle.com>
Fri, 3 Oct 2014 02:35:32 +0000 (10:35 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 3 Oct 2014 05:55:25 +0000 (13:55 +0800)
Part of: MDL-46576

grade/report/grader/lib.php
grade/tests/report_graderlib_test.php

index 94687c6..6aabf4c 100644 (file)
@@ -1696,11 +1696,11 @@ class grade_report_grader extends grade_report {
     public static function do_process_action($target, $action, $courseid = null) {
         global $DB;
         // TODO: this code should be in some grade_tree static method
-        $targettype = substr($target, 0, 1);
-        $targetid = substr($target, 1);
+        $targettype = substr($target, 0, 2);
+        $targetid = substr($target, 2);
         // TODO: end
 
-        if ($targettype !== 'c') {
+        if ($targettype !== 'cg') {
             // The following code only works with categories.
             return true;
         }
index 9faf37e..8c39066 100644 (file)
@@ -121,17 +121,17 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
         $this->assertEquals($emptypreferences, $report->collapsed);
 
         // Validating preferences set/get for one course.
-        $report->process_action('c13', 'switch_minus');
+        $report->process_action('cg13', 'switch_minus');
         $report = $this->create_report($course1);
         $this->assertEquals(array(13), $report->collapsed['aggregatesonly']);
         $this->assertEmpty($report->collapsed['gradesonly']);
 
-        $report->process_action('c13', 'switch_plus');
+        $report->process_action('cg13', 'switch_plus');
         $report = $this->create_report($course1);
         $this->assertEmpty($report->collapsed['aggregatesonly']);
         $this->assertEquals(array(13), $report->collapsed['gradesonly']);
 
-        $report->process_action('c13', 'switch_whole');
+        $report->process_action('cg13', 'switch_whole');
         $report = $this->create_report($course1);
         $this->assertEquals($emptypreferences, $report->collapsed);
 
@@ -146,18 +146,18 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
 
         $report1 = $this->create_report($course1);
         foreach ($course1cats as $catid) {
-            $report1->process_action('c'.$catid, 'switch_minus');
+            $report1->process_action('cg'.$catid, 'switch_minus');
         }
         $report2 = $this->create_report($course2);
         foreach ($course2cats as $catid) {
-            $report2->process_action('c'.$catid, 'switch_minus');
-            $report2->process_action('c'.$catid, 'switch_plus');
+            $report2->process_action('cg'.$catid, 'switch_minus');
+            $report2->process_action('cg'.$catid, 'switch_plus');
         }
         $report3 = $this->create_report($course3);
         foreach ($course3cats as $catid) {
-            $report3->process_action('c'.$catid, 'switch_minus');
+            $report3->process_action('cg'.$catid, 'switch_minus');
             if (($i++)%2) {
-                $report3->process_action('c'.$catid, 'switch_plus');
+                $report3->process_action('cg'.$catid, 'switch_plus');
             }
         }
 
@@ -201,7 +201,7 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
         set_user_preference('grade_report_grader_collapsed_categories'.$course1->id, json_encode($toobigvalue));
 
         $report1 = $this->create_report($course1);
-        $report1->process_action('c'.$lastvalue, 'switch_minus');
+        $report1->process_action('cg'.$lastvalue, 'switch_minus');
 
         $report1 = $this->create_report($course1);
         $this->assertEquals($expectedvalue, $report1->collapsed);
@@ -218,7 +218,7 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
         $toobigvalue['aggregatesonly'][] = $lastcatid;
 
         $report1 = $this->create_report($course1);
-        $report1->process_action('c'.$lastcatid, 'switch_minus');
+        $report1->process_action('cg'.$lastcatid, 'switch_minus');
 
         // One last value should be removed from both arrays.
         $report1 = $this->create_report($course1);