MDL-52266 tool_lp: Cohorts can be removed from template synced cohorts

This commit is contained in:
Frederic Massart 2015-11-30 15:58:21 +08:00
parent dd1df08248
commit 13ef20f65c
3 changed files with 11 additions and 2 deletions

View file

@ -80,8 +80,11 @@ class template_cohorts_table extends table_sql {
* @return string
*/
protected function col_actions($row) {
// TODO MDL-52266 Add delete action icon.
return '';
global $OUTPUT;
$action = new \confirm_action(get_string('areyousure'));
$url = new moodle_url($this->baseurl);
$url->params(array('removecohort' => $row->id, 'sesskey' => sesskey()));
return $OUTPUT->action_link($url, '', $action, null, new \pix_icon('t/delete', get_string('stopsyncingcohort', 'tool_lp')));
}
/**

View file

@ -164,6 +164,7 @@ $string['selectuserstocreateplansfor'] = 'Select users to create plans for';
$string['shortname'] = 'Name';
$string['state'] = 'State';
$string['status'] = 'Status';
$string['stopsyncingcohort'] = 'Stop syncing cohort';
$string['taxonomies'] = 'Taxonomies';
$string['taxonomy_add_behaviour'] = 'Add behaviour';
$string['taxonomy_add_competency'] = 'Add competency';

View file

@ -41,6 +41,11 @@ $url = new moodle_url('/admin/tool/lp/template_cohorts.php', array(
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template,
get_string('cohortssyncedtotemplate', 'tool_lp'));
// Remove cohort.
if (($removecohort = optional_param('removecohort', false, PARAM_INT)) !== false && confirm_sesskey()) {
\tool_lp\api::delete_template_cohort($template, $removecohort);
}
// Capture the form submission.
$form = new \tool_lp\form\template_cohorts($url->out(false), array('pagecontextid' => $pagecontextid));
if (($data = $form->get_data()) && !empty($data->cohorts)) {