} if (!$confirmed) { echo $output->header(); echo $output->confirm(get_string('templatedeleteconfirm', 'core_grading', s($definition->name)), new moodle_url($PAGE->url, array('remove' => $remove, 'confirmed' => 1)), $PAGE->url); echo $output->box($sourcecontroller->render_preview($PAGE), 'template-preview-confirm'); echo $output->footer(); die; } else { require_sesskey(); $sourcecontroller->delete_definition(); redirect($PAGE->url); } } $searchform = new grading_search_template_form($PAGE->url, null, 'GET', '', array('class' => 'templatesearchform')); if ($searchdata = $searchform->get_data()) { $tokens = grading_manager::tokenize($searchdata->needle); $includeownforms = !empty($searchdata->mode); } else { $tokens = array(); $includeownforms = false; } // construct the SQL to find all matching templates $sql = "SELECT DISTINCT gd.id, gd.areaid, gd.name, gd.usercreated\n FROM {grading_definitions} gd\n JOIN {grading_areas} ga ON (gd.areaid = ga.id)\n JOIN {context} cx ON (ga.contextid = cx.id)"; // join method-specific tables from the plugin scope $sql .= $targetcontrollerclass::sql_search_from_tables('gd.id'); $sql .= " WHERE gd.method = ?"; $params = array($method); if (!$includeownforms) { // search for public templates only $sql .= " AND ga.contextid = ? AND ga.component = 'core_grading'"; $params[] = context_system::instance()->id;