/** * Get question columns needed for the new question pool page * @param int course code * @return array */ public static function getQuestionColumns($courseCode = null, $extraFields = array(), $questionFields = array(), $checkFields = false) { // The order is important you need to check the the $column variable in the model.ajax.php file $columns = array('id', get_lang('Name')); // Column config. $columnModel = array(array('name' => 'iid', 'index' => 'iid', 'width' => '20', 'align' => 'left'), array('name' => 'question', 'index' => 'question', 'width' => '200', 'align' => 'left')); // Extra field rules. $extraField = new \ExtraField('question'); $rules = $extraField->getRules($columns, $columnModel, $extraFields, $checkFields); // Exercise rules. self::getRules($courseCode, $rules, $columns, $columnModel, $questionFields, $checkFields); // Adding actions. $columns[] = get_lang('Actions'); $columnModel[] = array('name' => 'actions', 'index' => 'actions', 'width' => '30'); foreach ($columnModel as $col) { $simple_column_name[] = $col['name']; } $return_array = array('columns' => $columns, 'column_model' => $columnModel, 'rules' => $rules, 'simple_column_name' => $simple_column_name); return $return_array; }
/** * @param string $list_type * @return array */ public static function getGridColumns($list_type = 'simple') { // Column config $operators = array('cn', 'nc'); $date_operators = array('gt', 'ge', 'lt', 'le'); switch ($list_type) { case 'simple': $columns = array(get_lang('Name'), get_lang('Category'), get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayEndDate'), get_lang('Visibility')); $column_model = array(array('name' => 'name', 'index' => 's.name', 'width' => '160', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), array('name' => 'category_name', 'index' => 'category_name', 'width' => '40', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), array('name' => 'display_start_date', 'index' => 'display_start_date', 'width' => '50', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), array('name' => 'display_end_date', 'index' => 'display_end_date', 'width' => '50', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), array('name' => 'visibility', 'index' => 'visibility', 'width' => '40', 'align' => 'left', 'search' => 'false')); break; case 'complete': $columns = array(get_lang('Name'), get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayEndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('CourseTitle')); $column_model = array(array('name' => 'name', 'index' => 's.name', 'width' => '200', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('sopt' => $operators)), array('name' => 'display_start_date', 'index' => 'display_start_date', 'width' => '70', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_today', 'sopt' => $date_operators)), array('name' => 'display_end_date', 'index' => 'display_end_date', 'width' => '70', 'align' => 'left', 'search' => 'true', 'searchoptions' => array('dataInit' => 'date_pick_one_month', 'sopt' => $date_operators)), array('name' => 'coach_name', 'index' => 'coach_name', 'width' => '70', 'align' => 'left', 'search' => 'false', 'searchoptions' => array('sopt' => $operators)), array('name' => 'session_active', 'index' => 'session_active', 'width' => '25', 'align' => 'left', 'search' => 'true', 'stype' => 'select', 'searchoptions' => array('defaultValue' => '1', 'value' => '1:' . get_lang('Active') . ';0:' . get_lang('Inactive')), 'editoptions' => array('value' => '" ":' . get_lang('All') . ';1:' . get_lang('Active') . ';0:' . get_lang('Inactive'))), array('name' => 'visibility', 'index' => 'visibility', 'width' => '40', 'align' => 'left', 'search' => 'false'), array('name' => 'course_title', 'index' => 'course_title', 'width' => '50', 'hidden' => 'true', 'search' => 'true', 'searchoptions' => array('searchhidden' => 'true', 'sopt' => $operators))); break; } // Inject extra session fields $session_field = new ExtraField('session'); $rules = $session_field->getRules($columns, $column_model); $column_model[] = array('name' => 'actions', 'index' => 'actions', 'width' => '80', 'align' => 'left', 'formatter' => 'action_formatter', 'sortable' => 'false', 'search' => 'false'); $columns[] = get_lang('Actions'); foreach ($column_model as $col_model) { $simple_column_name[] = $col_model['name']; } $return_array = array('columns' => $columns, 'column_model' => $column_model, 'rules' => $rules, 'simple_column_name' => $simple_column_name); return $return_array; }