ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function ilPCQuestionOverviewGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
24  {
25  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
26  }
27 
28 
32  function &executeCommand()
33  {
34  // get next class that processes or forwards current command
35  $next_class = $this->ctrl->getNextClass($this);
36 
37  // get current command
38  $cmd = $this->ctrl->getCmd();
39 
40  switch($next_class)
41  {
42  default:
43  $ret =& $this->$cmd();
44  break;
45  }
46 
47  return $ret;
48  }
49 
53  function insert()
54  {
55  $this->edit(true);
56  }
57 
61  function edit($a_insert = false)
62  {
63  global $ilCtrl, $tpl, $lng;
64 
65  $this->displayValidationError();
66 
67  // edit form
68  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
69  $form = new ilPropertyFormGUI();
70  $form->setFormAction($ilCtrl->getFormAction($this));
71  if ($a_insert)
72  {
73  $form->setTitle($this->lng->txt("cont_ed_insert_qover"));
74  }
75  else
76  {
77  $form->setTitle($this->lng->txt("cont_edit_qover"));
78  }
79 
80  // short message
81  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_qover_short_message"), "short");
82  $cb->setInfo($this->lng->txt("cont_qover_short_message_info"));
83  if (!$a_insert)
84  {
85  $cb->setChecked($this->content_obj->getShortMessage());
86  }
87  else
88  {
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  {
98  $cb->setChecked($this->content_obj->getListWrongQuestions());
99  }
100  $form->addItem($cb);
101 
102  // save/cancel buttons
103  if ($a_insert)
104  {
105  $form->addCommandButton("create_qover", $lng->txt("save"));
106  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
107  }
108  else
109  {
110  $form->addCommandButton("update", $lng->txt("save"));
111  $form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
112  }
113  $html = $form->getHTML();
114  $tpl->setContent($html);
115  return $ret;
116  }
117 
121  function create()
122  {
123  $this->content_obj = new ilPCQuestionOverview($this->getPage());
124  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
125  $this->content_obj->setShortMessage(ilUtil::stripSlashes($_POST["short"]));
126  $this->content_obj->setListWrongQuestions(ilUtil::stripSlashes($_POST["wrong_questions"]));
127  $this->updated = $this->pg_obj->update();
128  if ($this->updated === true)
129  {
130  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
131  }
132  else
133  {
134  $this->insert();
135  }
136  }
137 
141  function update()
142  {
143  $this->content_obj->setShortMessage(ilUtil::stripSlashes($_POST["short"]));
144  $this->content_obj->setListWrongQuestions(ilUtil::stripSlashes($_POST["wrong_questions"]));
145  $this->updated = $this->pg_obj->update();
146  if ($this->updated === true)
147  {
148  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
149  }
150  else
151  {
152  $this->pg_obj->addHierIDs();
153  $this->edit();
154  }
155  }
156 }
157 ?>