ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSuggestedSolutionSelectorGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2007 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php";
25 
34 {
35  protected $options;
36  protected $value;
37  protected $addCommand;
38  protected $intlink;
39  protected $intlinktext;
40 
47  function __construct($a_title = "", $a_postvar = "")
48  {
49  parent::__construct($a_title, $a_postvar);
50  $this->setType("select");
51  }
52 
58  function setOptions($a_options)
59  {
60  $this->options = $a_options;
61  }
62 
68  function getOptions()
69  {
70  return $this->options;
71  }
72 
78  function setValue($a_value)
79  {
80  $this->value = $a_value;
81  }
82 
88  function getValue()
89  {
90  return $this->value;
91  }
92 
98  function setInternalLink($a_value)
99  {
100  $this->intlink = $a_value;
101  }
102 
108  function getInternalLink()
109  {
110  return $this->intlink;
111  }
112 
118  function setInternalLinkText($a_value)
119  {
120  $this->intlinktext = $a_value;
121  }
122 
129  {
130  return $this->intlinktext;
131  }
132 
138  function setAddCommand($a_add_command)
139  {
140  $this->addCommand = $a_add_command;
141  }
142 
148  function getAddCommand()
149  {
150  return ($this->addCommand) ? $this->addCommand : "addInternalLink";
151  }
152 
158  function setValueByArray($a_values)
159  {
160  $this->setValue($a_values[$this->getPostVar()]);
161  }
162 
168  function checkInput()
169  {
170  global $lng;
171 
172  $_POST[$this->getPostVar()] =
174  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
175  {
176  $this->setAlert($lng->txt("msg_input_is_required"));
177 
178  return false;
179  }
180  return $this->checkSubItemsInput();
181  }
182 
188  function insert(&$a_tpl)
189  {
190  global $lng;
191 
192  $template = new ilTemplate("tpl.prop_suggestedsolutionselector.html", TRUE, TRUE, "Modules/TestQuestionPool");
193 
194  foreach($this->getOptions() as $option_value => $option_text)
195  {
196  $template->setCurrentBlock("prop_intlink_select_option");
197  $template->setVariable("VAL_SELECT_OPTION", $option_value);
198  if ($option_value == $this->getValue())
199  {
200  $template->setVariable("CHK_SEL_OPTION",
201  'selected="selected"');
202  }
203  $template->setVariable("TXT_SELECT_OPTION", $option_text);
204  $template->parseCurrentBlock();
205  }
206  if ($this->getInternalLink())
207  {
208  $template->setCurrentBlock("delete_internallink");
209  $template->setVariable("TEXT_DELETE_INTERNALLINK", $lng->txt("remove_solution"));
210  $template->setVariable("POST_VAR", $this->getPostVar());
211  $template->parseCurrentBlock();
212  $template->setCurrentBlock("internal_link");
213  $template->setVariable("HREF_INT_LINK", $this->getInternalLink());
214  $template->setVariable("TEXT_INT_LINK", $this->getInternalLinkText());
215  $template->parseCurrentBlock();
216  }
217  $template->setCurrentBlock("prop_internallink_selector");
218  $template->setVariable("POST_VAR", $this->getPostVar());
219  if ($this->getDisabled())
220  {
221  $template->setVariable("DISABLED",
222  " disabled=\"disabled\"");
223  }
224  $template->setVariable("TEXT_ADD_INTERNALLINK", ($this->getInternalLink()) ? $lng->txt("change") : $lng->txt("add"));
225  $template->setVariable("CMD_ADD_INTERNALLINK", $this->getAddCommand());
226  $template->parseCurrentBlock();
227  $a_tpl->setCurrentBlock("prop_generic");
228  $a_tpl->setVariable("PROP_GENERIC", $template->get());
229  $a_tpl->parseCurrentBlock();
230  }
231 
232 }