/**
  * @param        $parent
  * @param string $cmd
  */
 public function __construct($parent, $cmd, $template_context = '', ilMarkSchemaAware $object = null)
 {
     /**
      * @var $ilCtrl ilCtrl
      */
     global $ilCtrl;
     $this->object = $object;
     $this->ctrl = $ilCtrl;
     $this->is_editable = $this->object->canEditMarks();
     $this->setId('mark_schema_gui_' . $this->object->getMarkSchemaForeignId());
     parent::__construct($parent, $cmd);
     $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $cmd));
     $this->setRowTemplate('tpl.il_as_tst_mark_schema_row.html', 'Modules/Test');
     $this->setNoEntriesText($this->lng->txt('tst_no_marks_defined'));
     if ($this->object->canEditMarks()) {
         $this->addCommandButton('addMarkStep', $this->lng->txt('tst_mark_create_new_mark_step'));
         $this->addCommandButton('saveMarks', $this->lng->txt('save'));
         $this->addMultiCommand('deleteMarkSteps', $this->lng->txt('delete'));
         $this->setSelectAllCheckbox('marks[]');
     } else {
         $this->disable('select_all');
     }
     $this->setLimit(PHP_INT_MAX);
     $this->initColumns();
     $this->initData();
 }
Exemplo n.º 2
0
 /**
  * Save the mark schema
  */
 protected function saveMarks()
 {
     $this->ensureMarkSchemaCanBeEdited();
     try {
         $this->saveMarkSchemaFormData();
         $result = $this->object->checkMarks();
     } catch (Exception $e) {
         $result = $this->lng->txt('mark_schema_invalid');
     }
     if (is_string($result)) {
         ilUtil::sendFailure($this->lng->txt($result), true);
     } else {
         $this->object->getMarkSchema()->saveToDb($this->object->getMarkSchemaForeignId());
         $this->object->onMarkSchemaSaved();
         ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
     }
     $this->ctrl->redirect($this);
 }