Esempio n. 1
0
 /**
  * @param ilUnitConfigurationGUI         $controller
  * @param string                         $default_cmd
  * @param assFormulaQuestionUnitCategory $category
  */
 public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, assFormulaQuestionUnitCategory $category)
 {
     /**
      * @var $ilCtrl ilCtrl
      * @var $lng    ilLanguage
      */
     global $ilCtrl, $lng;
     $this->setId('units_' . $controller->getUniqueId());
     parent::__construct($controller, $default_cmd);
     if ($this->getParentObject()->isCRUDContext()) {
         $this->addColumn('', '', '1%', true);
         $this->setSelectAllCheckbox('unit_ids[]');
         $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
         $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
     }
     $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
     $this->addColumn($this->lng->txt('un_sequence'), '');
     $this->addColumn($this->lng->txt('unit'), '');
     $this->addColumn($this->lng->txt('baseunit'), '');
     $this->addColumn($this->lng->txt('factor'), '');
     $this->addColumn('', '', '1%', true);
     // Show all units because of sorting
     $this->setLimit(PHP_INT_MAX);
     $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
     $this->setDefaultOrderDirection('sequence');
     $this->setDefaultOrderDirection('ASC');
     $this->setRowTemplate('tpl.unit_row_html', 'Modules/TestQuestionPool');
 }
 /**
  *
  */
 protected function addCategory()
 {
     if (!$this->isCRUDContext()) {
         $this->{$this->getDefaultCommand()}();
         return;
     }
     $this->initUnitCategoryForm();
     if ($this->unit_cat_form->checkInput()) {
         try {
             $category = new assFormulaQuestionUnitCategory();
             $category->setCategory($this->unit_cat_form->getInput('category_name'));
             $this->repository->saveNewUnitCategory($category);
             ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
             $this->{$this->getUnitCategoryOverviewCommand()}();
             return;
         } catch (ilException $e) {
             $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
             ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
         }
     }
     $this->unit_cat_form->setValuesByPost();
     $this->tpl->setContent($this->unit_cat_form->getHtml());
 }
 /**
  * @return array
  */
 public function getAllUnitCategories()
 {
     /**
      * @var $ilDB ilDB
      */
     global $ilDB;
     $categories = array();
     $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s OR question_fi = %s ORDER BY category", array('integer', 'integer'), array($this->getConsumerId(), 0));
     if ($result->numRows()) {
         while ($row = $ilDB->fetchAssoc($result)) {
             $category = new assFormulaQuestionUnitCategory();
             $category->initFormArray($row);
             $categories[] = $category;
         }
     }
     return $categories;
 }