Add node.
126 {
128
129
130 $lng->loadLanguageModule(
"content");
131
133 "" =>
$lng->txt(
"cont_assign_to_parent"),
134 "chap" =>
$lng->txt(
"obj_chap"),
135 "sco" =>
$lng->txt(
"obj_sco"),
136 "ass" =>
$lng->txt(
"obj_ass")
137 );
138
139 if (!$this->confirm)
140 {
141 $sel = ($a_node["type"] != "pg")
143 : "";
145 }
146 else
147 {
148
149
150 if (in_array(
$_POST[
"node"][$a_node[
"id"]], array(
"sco",
"ass")) && in_array(
$_POST[
"node"][$a_parent[
"id"]], array(
"sco",
"ass")))
151 {
152
153
154
155 $a_parent = $a_parent["parent"];
156 $a_depth--;
157 }
158
159 $sel = ($a_node["type"] != "pg")
160 ? $sel =
"<strong>".
$lng->txt(
"obj_".$_POST[
"node"][$a_node[
"id"]]).
"</strong>"
161 : "";
162 $ctype = ($a_node["type"] != "pg")
163 ?
$_POST[
"node"][$a_node[
"id"]]
164 : "pg";
165
166 $parent_type = $a_parent["type"];
167 if (isset(
$_POST[
"node"][$a_parent[
"id"]]))
168 {
169 $parent_type =
$_POST[
"node"][$a_parent[
"id"]];
170 }
171
173
174 $error = "";
175 switch ($a_depth)
176 {
177 case 0:
178 case 1:
179 $this->correct = false;
180 break;
181
182 case 2:
183 if (!in_array($ctype, array("", "chap", "sco", "ass")))
184 {
185 $error =
'<span class="alert">'.$lng->txt(
"cont_type_not_allowed").
": ".
$lng->txt(
"obj_".$ctype).
"</span>";
186 if (
$_POST[
"node"][$a_node[
"id"]] !=
"" || $a_node[
"type"] ==
"pg")
187 {
188 $this->correct = false;
189 }
190 }
191 break;
192
193 default:
194 if ($parent_type == "chap" && !in_array($ctype, array("sco", "ass")) ||
195 ($parent_type != "chap" && !in_array($ctype, array("pg"))))
196 {
197 $error =
'<span class="alert">'.$lng->txt(
"cont_type_not_allowed").
": ".
$lng->txt(
"obj_".$ctype).
"</span>";
198 if (
$_POST[
"node"][$a_node[
"id"]] !=
"" || $a_node[
"type"] ==
"pg")
199 {
200 $this->correct = false;
201 }
202 }
203 break;
204 }
205 }
206
207
208 if (!$this->confirm ||
$_POST[
"node"][$a_node[
"id"]] !=
"" || $a_node[
"type"] ==
"pg")
209 {
210 if (!$this->perform)
211 {
212 $this->list->addListNode(
214 $a_node["title"]." ".
215 $sel." ".$error,
216 $a_node["id"], $a_parent["id"]);
217 }
218 else
219 {
220 if ($a_parent["insert_id"] > 0)
221 {
222 $target = $this->target[$a_parent["insert_id"]];
223
224
225 switch ($ctype)
226 {
227 case "chap":
228 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
230 $chap->setTitle($a_node["title"]);
231 $chap->setSLMId($this->slm->getId());
232 $chap->create();
234 $a_node["insert_id"] = $chap->getId();
235 break;
236
237 case "ass":
238 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
240 $ass->setTitle($a_node["title"]);
241 $ass->setSLMId($this->slm->getId());
242 $ass->create();
244 $a_node["insert_id"] = $ass->getId();
245 break;
246
247 case "sco":
248 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
250 $sco->setTitle($a_node["title"]);
251 $sco->setSLMId($this->slm->getId());
252 $sco->create();
254 $a_node["insert_id"] = $sco->getId();
255 break;
256
257 case "pg":
258 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
259 $copied_nodes = array();
261 $a_node["insert_time"], $copied_nodes,
262 true, true, "lm");
263 break;
264 }
265
266 $this->target[$a_parent["insert_id"]] = $a_node["insert_id"];
267
268
269
270 }
271 }
272
273 $a_depth++;
274 $parent = $a_node;
275 }
276 else
277 {
278 $parent = $a_parent;
279 }
280
281 $childs =
$ilUser->getClipboardChilds($a_node[
"id"], $a_node[
"insert_time"]);
282 foreach ($childs as $c)
283 {
284 $c["parent"] = $a_node;
285
286
287 $this->
addNode($c, $parent, $a_depth);
288 }
289 }
Class ilSCORM2004Chapter.
static pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_from_clipboard=true, $a_source_parent_type="")
Paste item (tree) from clipboard or other learning module to target scorm learning module.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
if(!is_array($argv)) $options