/** * Unassign the usersets from the program. * @param array $elements An array of userset information to unassign from the program. * @param bool $bulkaction Whether this is a bulk-action or not. * @return array An array to format as JSON and return to the Javascript. */ protected function _respond_to_js(array $elements, $bulkaction) { global $DB; $programid = required_param('id', PARAM_INT); foreach ($elements as $usersetid => $label) { if ($this->can_unassign($programid, $usersetid) === true) { $assignrecfilters = array('clusterid' => $usersetid, 'curriculumid' => $programid); $assignrec = $DB->get_record(clustercurriculum::TABLE, $assignrecfilters); $clustercurriculum = new clustercurriculum($assignrec); $clustercurriculum->delete(); } } return array('result' => 'success', 'msg' => 'Success'); }