ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestResultsToolbarGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
5 
13 {
17  public $ctrl = null;
18 
22  public $tpl = null;
23 
27  public $lng = null;
28 
32  private $pdfExportLinkTarget = null;
33 
37  private $certificateLinkTarget = null;
38 
43 
48 
52  private $participantSelectorOptions = array();
53 
55  {
56  $this->ctrl = $ctrl;
57  $this->tpl = $tpl;
58  $this->lng = $lng;
59 
61  }
62 
63  public function build()
64  {
65  $this->setId('tst_results_toolbar');
66 
67  $this->addButton($this->lng->txt('print'), 'javascript:window.print();');
68 
69  if( strlen($this->getPdfExportLinkTarget()) )
70  {
71  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
72  $link = ilLinkButton::getInstance(); // always returns a new instance
73  $link->setUrl($this->getPdfExportLinkTarget());
74  $link->setCaption($this->getPdfExportLabel(), false);
75  $link->setOmitPreventDoubleSubmission(true);
76  $this->addButtonInstance($link);
77  }
78 
79  if( strlen($this->getCertificateLinkTarget()) )
80  {
81  $this->addButton( $this->lng->txt('certificate'), $this->getCertificateLinkTarget() );
82  }
83 
84  if( strlen($this->getShowBestSolutionsLinkTarget()) )
85  {
86  $this->addSeparator();
87  $this->addButton( $this->lng->txt('tst_btn_show_best_solutions'), $this->getShowBestSolutionsLinkTarget() );
88  }
89  elseif( strlen($this->getHideBestSolutionsLinkTarget()) )
90  {
91  $this->addSeparator();
92  $this->addButton( $this->lng->txt('tst_btn_hide_best_solutions'), $this->getHideBestSolutionsLinkTarget() );
93  }
94 
95  if( count($this->getParticipantSelectorOptions()) )
96  {
97  $this->addSeparator();
98 
99  require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
100  $sel = new ilSelectInputGUI('', 'active_id');
101  $sel->setOptions($this->getParticipantSelectorOptionsWithHintOption());
102  $this->addInputItem($sel);
103 
104  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
105  $link = ilLinkButton::getInstance(); // always returns a new instance
106  $link->setUrl('#');
107  $link->setId('ilTestResultParticipantJumper');
108  $link->setCaption($this->lng->txt('tst_res_jump_to_participant_btn'), false);
109  $this->addButtonInstance($link);
110 
111  $this->tpl->addJavaScript('Modules/Test/js/ilTestResultParticipantSelector.js');
112  }
113  }
114 
115  private function getPdfExportLabel()
116  {
117  return $this->lng->txt('pdf_export');
118  }
119 
121  {
122  $this->pdfExportLinkTarget = $pdfExportLinkTarget;
123  }
124 
125  public function getPdfExportLinkTarget()
126  {
128  }
129 
131  {
132  $this->certificateLinkTarget = $certificateLinkTarget;
133  }
134 
135  public function getCertificateLinkTarget()
136  {
138  }
139 
141  {
142  $this->showBestSolutionsLinkTarget = $showBestSolutionsLinkTarget;
143  }
144 
146  {
148  }
149 
151  {
152  $this->hideBestSolutionsLinkTarget = $hideBestSolutionsLinkTarget;
153  }
154 
156  {
158  }
159 
161  {
162  $this->participantSelectorOptions = $participantSelectorOptions;
163  }
164 
166  {
168  }
169 
171  {
172  $options = array($this->lng->txt('tst_res_jump_to_participant_hint_opt'));
173 
174  if( function_exists('array_replace') )
175  {
176  return array_replace($options, $this->getParticipantSelectorOptions());
177  }
178 
179  foreach($this->getParticipantSelectorOptions() as $key => $val)
180  {
181  $options[$key] = $val;
182  }
183 
184  return $options;
185  }
186 }