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;
}
$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);
$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');
}
}
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);
$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);