ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestRandomQuestionSetNonAvailablePoolsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  public const IDENTIFIER = 'NonAvailPoolsTbl';
28 
29  public function __construct(ilCtrl $ctrl, ilLanguage $lng, $parentGUI, $parentCMD)
30  {
31  parent::__construct($parentGUI, $parentCMD);
32 
33  $this->ctrl = $ctrl;
34  $this->lng = $lng;
35  }
36 
37  private function setTableIdentifiers(): void
38  {
39  $this->setId(self::IDENTIFIER);
40  $this->setPrefix(self::IDENTIFIER);
41  $this->setFormName(self::IDENTIFIER);
42  }
43 
44  public function build(): void
45  {
46  $this->setTableIdentifiers();
47 
48  $this->setTitle($this->lng->txt('tst_non_avail_pools_table'));
49 
50  $this->setRowTemplate('tpl.il_tst_non_avail_pools_row.html', 'Modules/Test');
51 
52  $this->enable('header');
53  $this->disable('sort');
54 
55  $this->setExternalSegmentation(true);
56  $this->setLimit(PHP_INT_MAX);
57 
58  $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
59 
60  $this->addColumns();
61  }
62 
63  protected function addColumns(): void
64  {
65  $this->addColumn($this->lng->txt('title'), '', '30%');
66  $this->addColumn($this->lng->txt('path'), '', '30%');
67  $this->addColumn($this->lng->txt('status'), '', '40%');
68  $this->addColumn($this->lng->txt('actions'), '', '');
69  }
70 
71  public function init(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList): void
72  {
73  $rows = array();
74 
75  $pools = $sourcePoolDefinitionList->getNonAvailablePools();
76 
77  foreach ($pools as $nonAvailablePool) {
80  $set = array();
81 
82  $set['id'] = $nonAvailablePool->getId();
83  $set['title'] = $nonAvailablePool->getTitle();
84  $set['path'] = $nonAvailablePool->getPath();
85  $set['status'] = $nonAvailablePool->getUnavailabilityStatus();
86 
87  $rows[] = $set;
88  }
89 
90  $this->setData($rows);
91  }
92 
93  protected function getDerivePoolLink($poolId): string
94  {
95  $this->ctrl->setParameter($this->parent_obj, 'derive_pool_id', $poolId);
96 
97  $link = $this->ctrl->getLinkTarget(
98  $this->parent_obj,
100  );
101 
102  return $link;
103  }
104 
105  public function fillRow(array $a_set): void
106  {
108  $link = $this->getDerivePoolLink($a_set['id']);
109  $this->tpl->setCurrentBlock('single_action');
110  $this->tpl->setVariable('ACTION_HREF', $link);
111  $this->tpl->setVariable('ACTION_TEXT', $this->lng->txt('tst_derive_new_pool'));
112  $this->tpl->parseCurrentBlock();
113  }
114 
115  $this->tpl->setVariable('TITLE', $a_set['title']);
116  $this->tpl->setVariable('PATH', $a_set['path']);
117  $this->tpl->setVariable('STATUS', $this->getStatusText($a_set['status']));
118  }
119 
120  protected function getStatusText($status): string
121  {
122  return $this->lng->txt('tst_non_avail_pool_msg_status_' . $status);
123  }
124 }
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
$rows
Definition: xhr_table.php:10
__construct(Container $dic, ilPlugin $plugin)
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)