ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCQuestionOverviewGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPCQuestionOverview.php");
5 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6 
18 {
19 
23  public function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
24  {
25  global $DIC;
26 
27  $this->ctrl = $DIC->ctrl();
28  $this->tpl = $DIC["tpl"];
29  $this->lng = $DIC->language();
30  parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
31  }
32 
33 
37  public function executeCommand()
38  {
39  // get next class that processes or forwards current command
40  $next_class = $this->ctrl->getNextClass($this);
41 
42  // get current command
43  $cmd = $this->ctrl->getCmd();
44 
45  switch ($next_class) {
46  default:
47  $ret = $this->$cmd();
48  break;
49  }
50 
51  return $ret;
52  }
53 
57  public function insert()
58  {
59  $this->edit(true);
60  }
61 
65  public function edit($a_insert = false)
66  {
68  $tpl = $this->tpl;
69  $lng = $this->lng;
70 
71  $this->displayValidationError();
72 
73  // edit form
74  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
75  $form = new ilPropertyFormGUI();
76  $form->setFormAction($ilCtrl->getFormAction($this));
77  if ($a_insert) {
78  $form->setTitle($this->lng->txt("cont_ed_insert_qover"));
79  } else {
80  $form->setTitle($this->lng->txt("cont_edit_qover"));
81  }
82 
83  // short message
84  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_qover_short_message"), "short");
85  $cb->setInfo($this->lng->txt("cont_qover_short_message_info"));
86  if (!$a_insert) {
87  $cb->setChecked($this->content_obj->getShortMessage());
88  } else {
89  $cb->setChecked(true);
90  }
91  $form->addItem($cb);
92 
93  // list wrong questions
94  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_qover_list_wrong_q"), "wrong_questions");
95  $cb->setInfo($this->lng->txt("cont_qover_list_wrong_q_info"));
96  if (!$a_insert) {
97  $cb->setChecked($this->content_obj->getListWrongQuestions());
98  }
99  $form->addItem($cb);
100 
101  // save/cancel buttons
102  if ($a_insert) {
103  $form->addCommandButton("create_qover", $lng->txt("save"));
104  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
105  } else {
106  $form->addCommandButton("update", $lng->txt("save"));
107  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
108  }
109  $html = $form->getHTML();
110  $tpl->setContent($html);
111  return $ret;
112  }
113 
117  public function create()
118  {
119  $this->content_obj = new ilPCQuestionOverview($this->getPage());
120  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
121  $this->content_obj->setShortMessage(ilUtil::stripSlashes($_POST["short"]));
122  $this->content_obj->setListWrongQuestions(ilUtil::stripSlashes($_POST["wrong_questions"]));
123  $this->updated = $this->pg_obj->update();
124  if ($this->updated === true) {
125  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
126  } else {
127  $this->insert();
128  }
129  }
130 
134  public function update()
135  {
136  $this->content_obj->setShortMessage(ilUtil::stripSlashes($_POST["short"]));
137  $this->content_obj->setListWrongQuestions(ilUtil::stripSlashes($_POST["wrong_questions"]));
138  $this->updated = $this->pg_obj->update();
139  if ($this->updated === true) {
140  $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
141  } else {
142  $this->pg_obj->addHierIDs();
143  $this->edit();
144  }
145  }
146 }
create()
Create new question overview.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
Question overview page content element.
edit($a_insert=false)
Edit question overview form.
Class ilPCQuestionOverviewGUI.
This class represents a checkbox property in a property form.
update()
Update question overview.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
if(isset($_POST['submit'])) $form
displayValidationError()
display validation errors
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$ret
Definition: parser.php:6
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor.
$_POST["username"]
$html
Definition: example_001.php:87
insert()
Insert new question overview.