/** * Unassign the usersets from the track. * @param array $elements An array of userset information to unassign from the track. * @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; $trackid = required_param('id', PARAM_INT); foreach ($elements as $classid => $label) { if ($this->can_unassign($trackid, $classid) === true) { $assignrec = $DB->get_record(trackassignment::TABLE, array('trackid' => $trackid, 'classid' => $classid)); $trackassignment = new trackassignment($assignrec); $trackassignment->delete(); } } return array('result' => 'success', 'msg' => 'Success'); }