/** * Config nodes need some stuff to be returned from the config tables so we can have settings * adjusted based on existing values. * * @param block_ajax_marking_query $query * @param string $nextnodefilter * @return void */ private static function attach_config_settings(block_ajax_marking_query $query, $nextnodefilter) { $nodesthatneedconfigsettings = array('courseid', 'coursemoduleid'); if (!in_array($nextnodefilter, $nodesthatneedconfigsettings)) { return; } // The inner query joins to the config tables already for the WHERE clauses, so we // make use of them to get the settings for those nodes that are not filtered out. $countwrapper = $query->get_subquery('countwrapperquery'); switch ($nextnodefilter) { // This is for the ordinary nodes. We need to work out what to request for the next node // so groupsdisplay has to be sent through. Also for the config context menu to work. // COALESCE is no good here as we need the actual settings, so we work out that stuff // in JavaScript. case 'courseid': $countwrapper->add_select(array('table' => 'courseconfig', 'column' => 'display')); $countwrapper->add_select(array('table' => 'courseconfig', 'column' => 'groupsdisplay')); break; case 'coursemoduleid': // The inner query joins to the config tables already for the WHERE clauses, so we // make use of them to get the settings for those nodes that are not filtered out. $countwrapper = $query->get_subquery('countwrapperquery'); $countwrapper->add_select(array('table' => 'cmconfig', 'column' => 'display')); $countwrapper->add_select(array('table' => 'cmconfig', 'column' => 'groupsdisplay')); break; } // The outer query (we need one because we have to do a join between the numeric // fields that can be fed into a GROUP BY and the text fields that we display) pulls // through the display fields, which were sent through from the middle query using the // stuff above. $query->add_select(array('table' => 'countwrapperquery', 'column' => 'display')); $query->add_select(array('table' => 'countwrapperquery', 'column' => 'groupsdisplay')); }