ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestRandomQuestionSetNonAvailablePoolsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  public const IDENTIFIER = 'NonAvailPoolsTbl';
30 
31  public function __construct(ilCtrl $ctrl, ilLanguage $lng, $parentGUI, $parentCMD)
32  {
33  parent::__construct($parentGUI, $parentCMD);
34 
35  $this->ctrl = $ctrl;
36  $this->lng = $lng;
37  }
38 
39  private function setTableIdentifiers(): void
40  {
41  $this->setId(self::IDENTIFIER);
42  $this->setPrefix(self::IDENTIFIER);
43  $this->setFormName(self::IDENTIFIER);
44  }
45 
46  public function build(): void
47  {
48  $this->setTableIdentifiers();
49 
50  $this->setTitle($this->lng->txt('tst_non_avail_pools_table'));
51 
52  $this->setRowTemplate('tpl.il_tst_non_avail_pools_row.html', 'Modules/Test');
53 
54  $this->enable('header');
55  $this->disable('sort');
56 
57  $this->setExternalSegmentation(true);
58  $this->setLimit(PHP_INT_MAX);
59 
60  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
61 
62  $this->addColumns();
63  }
64 
65  protected function addColumns(): void
66  {
67  $this->addColumn($this->lng->txt('title'), '', '30%');
68  $this->addColumn($this->lng->txt('path'), '', '30%');
69  $this->addColumn($this->lng->txt('status'), '', '40%');
70  $this->addColumn($this->lng->txt('actions'), '', '');
71  }
72 
73  public function init(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList): void
74  {
75  $rows = array();
76 
77  $pools = $sourcePoolDefinitionList->getNonAvailablePools();
78 
79  foreach ($pools as $nonAvailablePool) {
82  $set = array();
83 
84  $set['id'] = $nonAvailablePool->getId();
85  $set['title'] = $nonAvailablePool->getTitle();
86  $set['path'] = $nonAvailablePool->getPath();
87  $set['status'] = $nonAvailablePool->getUnavailabilityStatus();
88 
89  $rows[] = $set;
90  }
91 
92  $this->setData($rows);
93  }
94 
95  protected function getDerivePoolLink($poolId): string
96  {
97  $this->ctrl->setParameter($this->parent_obj, 'derive_pool_id', $poolId);
98 
99  $link = $this->ctrl->getLinkTarget(
100  $this->parent_obj,
102  );
103 
104  return $link;
105  }
106 
107  public function fillRow(array $a_set): void
108  {
110  $link = $this->getDerivePoolLink($a_set['id']);
111  $this->tpl->setCurrentBlock('single_action');
112  $this->tpl->setVariable('ACTION_HREF', $link);
113  $this->tpl->setVariable('ACTION_TEXT', $this->lng->txt('tst_derive_new_pool'));
114  $this->tpl->parseCurrentBlock();
115  }
116 
117  $this->tpl->setVariable('TITLE', $a_set['title']);
118  $this->tpl->setVariable('PATH', $a_set['path']);
119  $this->tpl->setVariable('STATUS', $this->getStatusText($a_set['status']));
120  }
121 
122  protected function getStatusText($status): string
123  {
124  return $this->lng->txt('tst_non_avail_pool_msg_status_' . $status);
125  }
126 }
setData(array $a_data)
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
setFormName(string $a_name="")
ilLanguage $lng
setId(string $a_val)
__construct(VocabulariesInterface $vocabularies)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setLimit(int $a_limit=0, int $a_default_limit=0)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
setExternalSegmentation(bool $a_val)
setPrefix(string $a_prefix)