api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq(), 'name' => get_lang('Exercises'), ]; $courseId = api_get_course_int_id(); $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_categories&c_id='.$courseId.'&'.api_get_cidreq(); $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $obj = new ExerciseCategoryManager(); $check = Security::check_token('request'); $token = Security::get_token(); //Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); //The order is important you need to check the the $column variable in the model.ajax.php file $columns = [ get_lang('Name'), get_lang('Actions'), ]; // Column config $column_model = [ [ 'name' => 'name', 'index' => 'name', 'width' => '140', 'align' => 'left', ], [ 'name' => 'actions', 'index' => 'actions', 'width' => '40', 'align' => 'left', 'formatter' => 'action_formatter', 'sortable' => 'false', ], ]; // Autowidth $extra_params['autowidth'] = 'true'; // height auto $extra_params['height'] = 'auto'; $action_links = $obj->getJqgridActionLinks($token); $htmlHeadXtra[] = ''; $url = api_get_self().'?'.api_get_cidreq(); switch ($action) { case 'add': $interbreadcrumb[] = ['url' => $url, 'name' => get_lang('Categories')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; $form = $obj->return_form($url.'&action=add', 'add'); // The validation or display if ($form->validate()) { $values = $form->exportValues(); unset($values['id']); $res = $obj->save($values); if ($res) { Display::addFlash(Display::return_message(get_lang('ItemAdded'), 'confirmation')); } header('Location: '.$url); exit; } else { $content = '