|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
use ChamiloSession as Session; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Controller script. Prepares the common background variables to give to the scripts corresponding to |
|
9
|
|
|
* the requested action. |
|
10
|
|
|
* |
|
11
|
|
|
* @todo remove repeated if $lp_found redirect |
|
12
|
|
|
* |
|
13
|
|
|
* @author Yannick Warnier <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
// Flag to allow for anonymous user - needs to be set before global.inc.php. |
|
17
|
|
|
$use_anonymous = true; |
|
18
|
|
|
$debug = 0; |
|
19
|
|
|
|
|
20
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
21
|
|
|
|
|
22
|
|
|
api_protect_course_script(true); |
|
23
|
|
|
|
|
24
|
|
|
$current_course_tool = TOOL_LEARNPATH; |
|
25
|
|
|
$_course = api_get_course_info(); |
|
26
|
|
|
|
|
27
|
|
|
$glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools'); |
|
28
|
|
|
$showGlossary = in_array($glossaryExtraTools, ['true', 'lp', 'exercise_and_lp']); |
|
29
|
|
|
if ($showGlossary) { |
|
30
|
|
|
if ('ismanual' === api_get_setting('show_glossary_in_documents') || |
|
31
|
|
|
'isautomatic' === api_get_setting('show_glossary_in_documents') |
|
32
|
|
|
) { |
|
33
|
|
|
$htmlHeadXtra[] = '<script> |
|
34
|
|
|
<!-- |
|
35
|
|
|
var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\'; |
|
36
|
|
|
--> |
|
37
|
|
|
</script>'; |
|
38
|
|
|
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js" type="text/javascript" language="javascript"></script>'; |
|
39
|
|
|
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js" type="text/javascript" language="javascript"></script>'; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
$htmlHeadXtra[] = '<script> |
|
44
|
|
|
function setFocus(){ |
|
45
|
|
|
$("#idTitle").focus(); |
|
46
|
|
|
} |
|
47
|
|
|
$(window).on("load", function () { |
|
48
|
|
|
setFocus(); |
|
49
|
|
|
}); |
|
50
|
|
|
</script>'; |
|
51
|
|
|
$ajax_url = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?'.api_get_cidreq(); |
|
52
|
|
|
$htmlHeadXtra[] = ' |
|
53
|
|
|
<script> |
|
54
|
|
|
/* |
|
55
|
|
|
Script to manipulate Learning Path items with Drag and drop |
|
56
|
|
|
*/ |
|
57
|
|
|
var newOrderData = ""; |
|
58
|
|
|
function buildLPtree(in_elem, in_parent_id) { |
|
59
|
|
|
var item_tag = in_elem.get(0).tagName; |
|
60
|
|
|
var item_id = in_elem.attr("id"); |
|
61
|
|
|
var parent_id = item_id; |
|
62
|
|
|
|
|
63
|
|
|
if (item_tag == "LI" && item_id != undefined) { |
|
64
|
|
|
// in_parent_id de la forme UL_x |
|
65
|
|
|
newOrderData += item_id+"|"+get_UL_integer_id(in_parent_id)+"^"; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
in_elem.children().each(function () { |
|
69
|
|
|
buildLPtree($(this), parent_id); |
|
70
|
|
|
}); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
// return the interge part of an UL id |
|
74
|
|
|
// (0 for lp_item_list) |
|
75
|
|
|
function get_UL_integer_id(in_ul_id) { |
|
76
|
|
|
in_parent_integer_id = in_ul_id; |
|
77
|
|
|
in_parent_integer_id = in_parent_integer_id.replace("lp_item_list", "0"); |
|
78
|
|
|
in_parent_integer_id = in_parent_integer_id.replace("UL_", ""); |
|
79
|
|
|
return in_parent_integer_id; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$(function() { |
|
83
|
|
|
$(".lp_resource").sortable({ |
|
84
|
|
|
items: ".lp_resource_element ", |
|
85
|
|
|
handle: ".moved", //only the class "moved" |
|
86
|
|
|
cursor: "move", |
|
87
|
|
|
connectWith: "#lp_item_list", |
|
88
|
|
|
placeholder: "ui-state-highlight", //defines the yellow highlight |
|
89
|
|
|
start: function(event, ui) { |
|
90
|
|
|
$(ui.item).css("width", "350px"); |
|
91
|
|
|
$(ui.item).find(".item_data").attr("style", ""); |
|
92
|
|
|
}, |
|
93
|
|
|
stop: function(event, ui) { |
|
94
|
|
|
$(ui.item).css("width", "100%"); |
|
95
|
|
|
} |
|
96
|
|
|
}); |
|
97
|
|
|
|
|
98
|
|
|
$(".li_container .order_items").click(function(e) { |
|
99
|
|
|
var dir = $(this).data("dir"); |
|
100
|
|
|
var itemId = $(this).data("id"); |
|
101
|
|
|
var jItems = $("#lp_item_list li.li_container"); |
|
102
|
|
|
var jItem = $("#"+ itemId); |
|
103
|
|
|
var index = jItems.index(jItem); |
|
104
|
|
|
var total = jItems.length; |
|
105
|
|
|
|
|
106
|
|
|
switch (dir) { |
|
107
|
|
|
case "up": |
|
108
|
|
|
if (index != 0 && jItems[index - 1]) { |
|
109
|
|
|
/*var subItems = $(jItems[index - 1]).find("li.sub_item"); |
|
110
|
|
|
if (subItems.length >= 0) { |
|
111
|
|
|
index = index - 1; |
|
112
|
|
|
}*/ |
|
113
|
|
|
var subItems = $(jItems[index - 1]).find("li.sub_item"); |
|
114
|
|
|
var parentClass = $(jItems[index - 1]).parent().parent().attr("class"); |
|
115
|
|
|
var parentId = $(jItems[index]).parent().parent().attr("id"); |
|
116
|
|
|
var myParentId = $(jItems[index - 1]).parent().parent().attr("id"); |
|
117
|
|
|
//console.log(parentId + " - " + myParentId); |
|
118
|
|
|
|
|
119
|
|
|
// We are brothers! |
|
120
|
|
|
if (parentId == myParentId) { |
|
121
|
|
|
if (subItems.length > 0) { |
|
122
|
|
|
var lastItem = $(jItems[index - 1]).find("li.sub_item"); |
|
123
|
|
|
parentIndex = jItems.index(lastItem); |
|
124
|
|
|
jItem.detach().insertAfter(lastItem); |
|
125
|
|
|
//console.log("not classic"); |
|
126
|
|
|
} else { |
|
127
|
|
|
//console.log("classic"); |
|
128
|
|
|
jItem.detach().insertBefore(jItems[index - 1]); |
|
129
|
|
|
} |
|
130
|
|
|
break; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
//console.log(parentClass); |
|
134
|
|
|
if (parentClass == "record li_container") { |
|
135
|
|
|
// previous is a chapter |
|
136
|
|
|
var lastItem = $(jItems[index - 1]).parent().parent().find("li.li_container").last(); |
|
137
|
|
|
parentIndex = jItems.index(lastItem); |
|
138
|
|
|
//console.log(parentIndex); |
|
139
|
|
|
jItem.detach().insertAfter(jItems[parentIndex]); |
|
140
|
|
|
} else { |
|
141
|
|
|
jItem.detach().insertBefore(jItems[index - 1]); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
break; |
|
145
|
|
|
case "down": |
|
146
|
|
|
if (index != total - 1) { |
|
147
|
|
|
const originIndex = index; |
|
148
|
|
|
// The element is a chapter with items |
|
149
|
|
|
var subItems = jItem.find("li.li_container"); |
|
150
|
|
|
if (subItems.length > 0) { |
|
151
|
|
|
index = subItems.length + index; |
|
152
|
|
|
//console.log("element is a chapter with items"); |
|
153
|
|
|
//console.log("new index = " + index); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
var subItems = $(jItems[index + 1]).find("li.sub_item"); |
|
157
|
|
|
//console.log("next subItems.length: "+subItems.length); |
|
158
|
|
|
// This is an element entering in a chapter |
|
159
|
|
|
if (subItems.length > 0) { |
|
160
|
|
|
// Check if im a child |
|
161
|
|
|
var parentClass = jItem.parent().parent().attr("class"); |
|
162
|
|
|
//console.log(parentClass); |
|
163
|
|
|
if (parentClass == "record li_container") { |
|
164
|
|
|
// Parent position |
|
165
|
|
|
var parentIndex = jItems.index(jItem.parent().parent()); |
|
166
|
|
|
//console.log(jItem.parent().parent().attr("id")); |
|
167
|
|
|
//console.log(parentIndex); |
|
168
|
|
|
jItem.detach().insertAfter(jItems[parentIndex]); |
|
169
|
|
|
} else { |
|
170
|
|
|
jItem.detach().insertAfter(subItems); |
|
171
|
|
|
} |
|
172
|
|
|
break; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
var currentSubItems = $(jItems[index]).parent().find("li.sub_item"); |
|
176
|
|
|
//console.log("currentSubItems"+currentSubItems.length); |
|
177
|
|
|
|
|
178
|
|
|
var parentId = $(jItems[originIndex]).parent().parent().attr("id"); |
|
179
|
|
|
var myParentId = $(jItems[index + 1]).parent().parent().attr("id"); |
|
180
|
|
|
//console.log("parent ids: "+ parentId + " - " + myParentId); |
|
181
|
|
|
|
|
182
|
|
|
// We are brothers! |
|
183
|
|
|
if (parentId == myParentId) { |
|
184
|
|
|
if ((index + 1) < total) { |
|
185
|
|
|
//console.log(index + 1); |
|
186
|
|
|
//console.log("We are brothers"); |
|
187
|
|
|
jItem.detach().insertAfter(jItems[index + 1]); |
|
188
|
|
|
} |
|
189
|
|
|
break; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
if (currentSubItems.length > 0) { |
|
193
|
|
|
var parentIndex = jItems.index(jItem.parent().parent()); |
|
194
|
|
|
//console.log("has currentSubItems"); |
|
195
|
|
|
//console.log("id " + jItem.parent().parent().attr("id")); |
|
196
|
|
|
//console.log("parentIndex: " + parentIndex); |
|
197
|
|
|
if (parentIndex >= 0) { |
|
198
|
|
|
jItem.detach().insertAfter(jItems[parentIndex]); |
|
199
|
|
|
break; |
|
200
|
|
|
} |
|
201
|
|
|
//jItem.detach().insertAfter($(jItems[index]).parent().parent()); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
//var lastItem = $(jItems[index + 1]).parent().parent().find("li.li_container").last(); |
|
205
|
|
|
if (subItems.length > 0) { |
|
206
|
|
|
index = originIndex; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
if ((index + 1) < total) { |
|
210
|
|
|
//console.log(index + 1); |
|
211
|
|
|
//console.log("changed"); |
|
212
|
|
|
jItem.detach().insertAfter(jItems[index + 1]); |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
break; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
//console.log("rebuild"); |
|
219
|
|
|
buildLPtree($("#lp_item_list"), 0); |
|
220
|
|
|
|
|
221
|
|
|
var order = "new_order="+ newOrderData + "&a=update_lp_item_order"; |
|
222
|
|
|
$.post( |
|
223
|
|
|
"'.$ajax_url.'", |
|
224
|
|
|
order, |
|
225
|
|
|
function(reponse) { |
|
226
|
|
|
$("#message").html(reponse); |
|
227
|
|
|
order = ""; |
|
228
|
|
|
newOrderData = ""; |
|
229
|
|
|
} |
|
230
|
|
|
); |
|
231
|
|
|
}); |
|
232
|
|
|
|
|
233
|
|
|
$("#lp_item_list").sortable({ |
|
234
|
|
|
items: "li", |
|
235
|
|
|
handle: ".moved", //only the class "moved" |
|
236
|
|
|
cursor: "move", |
|
237
|
|
|
placeholder: "ui-state-highlight", //defines the yellow highlight |
|
238
|
|
|
update: function(event, ui) { |
|
239
|
|
|
buildLPtree($("#lp_item_list"), 0); |
|
240
|
|
|
var order = "new_order="+ newOrderData + "&a=update_lp_item_order"; |
|
241
|
|
|
$.post( |
|
242
|
|
|
"'.$ajax_url.'", |
|
243
|
|
|
order, |
|
244
|
|
|
function(reponse) { |
|
245
|
|
|
$("#message").html(reponse); |
|
246
|
|
|
order = ""; |
|
247
|
|
|
newOrderData = ""; |
|
248
|
|
|
} |
|
249
|
|
|
); |
|
250
|
|
|
}, |
|
251
|
|
|
receive: function(event, ui) { |
|
252
|
|
|
var id = $(ui.item).attr("data_id"); |
|
253
|
|
|
var type = $(ui.item).attr("data_type"); |
|
254
|
|
|
var title = $(ui.item).attr("title"); |
|
255
|
|
|
processReceive = true; |
|
256
|
|
|
|
|
257
|
|
|
if (ui.item.parent()[0]) { |
|
258
|
|
|
var parent_id = $(ui.item.parent()[0]).attr("id"); |
|
259
|
|
|
var previous_id = $(ui.item.prev()).attr("id"); |
|
260
|
|
|
|
|
261
|
|
|
if (parent_id) { |
|
262
|
|
|
parent_id = parent_id.split("_")[1]; |
|
263
|
|
|
var params = { |
|
264
|
|
|
"a": "add_lp_item", |
|
265
|
|
|
"id": id, |
|
266
|
|
|
"parent_id": parent_id, |
|
267
|
|
|
"previous_id": previous_id, |
|
268
|
|
|
"type": type, |
|
269
|
|
|
"title" : title |
|
270
|
|
|
}; |
|
271
|
|
|
|
|
272
|
|
|
$.ajax({ |
|
273
|
|
|
type: "GET", |
|
274
|
|
|
url: "'.$ajax_url.'", |
|
275
|
|
|
data: params, |
|
276
|
|
|
success: function(data) { |
|
277
|
|
|
$("#lp_item_list").html(data); |
|
278
|
|
|
} |
|
279
|
|
|
}); |
|
280
|
|
|
} |
|
281
|
|
|
} |
|
282
|
|
|
} // End receive |
|
283
|
|
|
}); |
|
284
|
|
|
processReceive = false; |
|
285
|
|
|
}); |
|
286
|
|
|
</script>'; |
|
287
|
|
|
|
|
288
|
|
|
$session_id = api_get_session_id(); |
|
289
|
|
|
$lpfound = false; |
|
290
|
|
|
$myrefresh = 0; |
|
291
|
|
|
$myrefresh_id = 0; |
|
292
|
|
|
$refresh = Session::read('refresh'); |
|
293
|
|
|
if (1 == $refresh) { |
|
294
|
|
|
// Check if we should do a refresh of the oLP object (for example after editing the LP). |
|
295
|
|
|
// If refresh is set, we regenerate the oLP object from the database (kind of flush). |
|
296
|
|
|
Session::erase('refresh'); |
|
297
|
|
|
$myrefresh = 1; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
$lp_controller_touched = 1; |
|
301
|
|
|
$lp_found = false; |
|
302
|
|
|
$lpObject = Session::read('lpobject'); |
|
303
|
|
|
if (!empty($lpObject)) { |
|
304
|
|
|
/** @var learnpath $oLP */ |
|
305
|
|
|
$oLP = UnserializeApi::unserialize('lp', $lpObject); |
|
306
|
|
|
if (isset($oLP) && is_object($oLP)) { |
|
307
|
|
|
if ($debug) { |
|
308
|
|
|
error_log(' oLP is object'); |
|
309
|
|
|
} |
|
310
|
|
|
if ($myrefresh == 1 || |
|
311
|
|
|
empty($oLP->cc) || |
|
312
|
|
|
$oLP->cc != api_get_course_id() || |
|
313
|
|
|
$oLP->lp_view_session_id != $session_id |
|
314
|
|
|
) { |
|
315
|
|
|
if ($debug) { |
|
316
|
|
|
error_log('Course has changed, discard lp object'); |
|
317
|
|
|
error_log('$oLP->lp_view_session_id: '.$oLP->lp_view_session_id); |
|
318
|
|
|
error_log('api_get_session_id(): '.$session_id); |
|
319
|
|
|
error_log('$oLP->cc: '.$oLP->cc); |
|
320
|
|
|
error_log('api_get_course_id(): '.api_get_course_id()); |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
if ($myrefresh == 1) { |
|
324
|
|
|
$myrefresh_id = $oLP->get_id(); |
|
325
|
|
|
} |
|
326
|
|
|
$oLP = null; |
|
327
|
|
|
Session::erase('oLP'); |
|
328
|
|
|
Session::erase('lpobject'); |
|
329
|
|
|
} else { |
|
330
|
|
|
Session::write('oLP', $oLP); |
|
331
|
|
|
$lp_found = true; |
|
332
|
|
|
} |
|
333
|
|
|
} |
|
334
|
|
|
} |
|
335
|
|
|
if ($debug) { |
|
336
|
|
|
error_log('$lp_found: '.$lp_found); |
|
337
|
|
|
error_log('$myrefresh_id: '.$myrefresh_id); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
$course_id = api_get_course_int_id(); |
|
341
|
|
|
|
|
342
|
|
|
if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) { |
|
343
|
|
|
if ($debug > 0) { |
|
344
|
|
|
error_log(' oLP is not object, has changed or refresh been asked, getting new'); |
|
345
|
|
|
} |
|
346
|
|
|
// Regenerate a new lp object? Not always as some pages don't need the object (like upload?) |
|
347
|
|
|
if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) { |
|
348
|
|
|
// Select the lp in the database and check which type it is (scorm/chamilo/aicc) to generate the |
|
349
|
|
|
// right object. |
|
350
|
|
|
if (!empty($_REQUEST['lp_id'])) { |
|
351
|
|
|
$lp_id = $_REQUEST['lp_id']; |
|
352
|
|
|
} else { |
|
353
|
|
|
$lp_id = $myrefresh_id; |
|
354
|
|
|
} |
|
355
|
|
|
$lp_id = (int) $lp_id; |
|
356
|
|
|
|
|
357
|
|
|
$lp_table = Database::get_course_table(TABLE_LP_MAIN); |
|
358
|
|
|
if (!empty($lp_id)) { |
|
359
|
|
|
$sel = "SELECT iid, lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id"; |
|
360
|
|
|
if ($debug > 0) { |
|
361
|
|
|
error_log(' querying '.$sel); |
|
362
|
|
|
} |
|
363
|
|
|
$res = Database::query($sel); |
|
364
|
|
|
if (Database::num_rows($res)) { |
|
365
|
|
|
$row = Database::fetch_array($res); |
|
366
|
|
|
$lpIid = $row['iid']; |
|
367
|
|
|
$type = $row['lp_type']; |
|
368
|
|
|
if ($debug > 0) { |
|
369
|
|
|
error_log('Found row type '.$type); |
|
370
|
|
|
error_log('Calling constructor: '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id()); |
|
371
|
|
|
} |
|
372
|
|
|
$logInfo = [ |
|
373
|
|
|
'tool' => TOOL_LEARNPATH, |
|
374
|
|
|
'tool_id' => 0, |
|
375
|
|
|
'tool_id_detail' => 0, |
|
376
|
|
|
'action' => 'lp_load', |
|
377
|
|
|
]; |
|
378
|
|
|
Event::registerLog($logInfo); |
|
379
|
|
|
|
|
380
|
|
|
switch ($type) { |
|
381
|
|
|
case 1: |
|
382
|
|
|
$oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id()); |
|
383
|
|
|
if ($oLP !== false) { |
|
384
|
|
|
$lp_found = true; |
|
385
|
|
|
} |
|
386
|
|
|
break; |
|
387
|
|
|
case 2: |
|
388
|
|
|
$oLP = new scorm(api_get_course_id(), $lpIid, api_get_user_id()); |
|
389
|
|
|
if ($oLP !== false) { |
|
390
|
|
|
$lp_found = true; |
|
391
|
|
|
} |
|
392
|
|
|
break; |
|
393
|
|
|
case 3: |
|
394
|
|
|
$oLP = new aicc(api_get_course_id(), $lpIid, api_get_user_id()); |
|
395
|
|
|
if ($oLP !== false) { |
|
396
|
|
|
$lp_found = true; |
|
397
|
|
|
} |
|
398
|
|
|
break; |
|
399
|
|
|
default: |
|
400
|
|
|
$oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id()); |
|
401
|
|
|
if ($oLP !== false) { |
|
402
|
|
|
$lp_found = true; |
|
403
|
|
|
} |
|
404
|
|
|
break; |
|
405
|
|
|
} |
|
406
|
|
|
} |
|
407
|
|
|
} else { |
|
408
|
|
|
if ($debug > 0) { |
|
409
|
|
|
error_log(' Request[lp_id] is not numeric'); |
|
410
|
|
|
} |
|
411
|
|
|
} |
|
412
|
|
|
} else { |
|
413
|
|
|
if ($debug > 0) { |
|
414
|
|
|
error_log(' Request[lp_id] and refresh_id were empty'); |
|
415
|
|
|
} |
|
416
|
|
|
} |
|
417
|
|
|
if ($lp_found) { |
|
418
|
|
|
Session::write('oLP', $oLP); |
|
419
|
|
|
} |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
if ($debug > 0) { |
|
423
|
|
|
error_log('Passed oLP creation check'); |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
$is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false); |
|
427
|
|
|
|
|
428
|
|
|
if (isset($_SESSION['oLP'])) { |
|
429
|
|
|
// Reinitialises array used by javascript to update items in the TOC. |
|
430
|
|
|
$_SESSION['oLP']->update_queue = []; |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|
434
|
|
|
|
|
435
|
|
|
if ($debug) { |
|
436
|
|
|
error_log('Entered lp_controller.php -+- (action: '.$action.')'); |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
$eventLpId = $lp_id = !empty($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0; |
|
440
|
|
|
if (empty($lp_id)) { |
|
441
|
|
|
if (isset($_SESSION['oLP'])) { |
|
442
|
|
|
$eventLpId = $_SESSION['oLP']->get_id(); |
|
443
|
|
|
} |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
$lp_detail_id = 0; |
|
447
|
|
|
$attemptId = 0; |
|
448
|
|
|
switch ($action) { |
|
449
|
|
|
case '': |
|
450
|
|
|
case 'list': |
|
451
|
|
|
$eventLpId = 0; |
|
452
|
|
|
break; |
|
453
|
|
|
case 'view': |
|
454
|
|
|
case 'content': |
|
455
|
|
|
$lp_detail_id = $oLP->get_current_item_id(); |
|
456
|
|
|
$attemptId = $oLP->getCurrentAttempt(); |
|
457
|
|
|
break; |
|
458
|
|
|
default: |
|
459
|
|
|
$lp_detail_id = (!empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0); |
|
460
|
|
|
break; |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
$logInfo = [ |
|
464
|
|
|
'tool' => TOOL_LEARNPATH, |
|
465
|
|
|
'tool_id' => $eventLpId, |
|
466
|
|
|
'tool_id_detail' => $lp_detail_id, |
|
467
|
|
|
'action_details' => $attemptId, |
|
468
|
|
|
'action' => !empty($action) ? $action : 'list', |
|
469
|
|
|
]; |
|
470
|
|
|
Event::registerLog($logInfo); |
|
471
|
|
|
|
|
472
|
|
|
// format title to be displayed correctly if QUIZ |
|
473
|
|
|
$post_title = ''; |
|
474
|
|
|
if (isset($_POST['title'])) { |
|
475
|
|
|
$post_title = Security::remove_XSS($_POST['title']); |
|
476
|
|
|
if (isset($_POST['type']) && |
|
477
|
|
|
isset($_POST['title']) && |
|
478
|
|
|
TOOL_QUIZ == $_POST['type'] && |
|
479
|
|
|
!empty($_POST['title']) |
|
480
|
|
|
) { |
|
481
|
|
|
$post_title = Exercise::format_title_variable($_POST['title']); |
|
482
|
|
|
if (api_get_configuration_value('save_titles_as_html')) { |
|
483
|
|
|
$post_title = $_POST['title']; |
|
484
|
|
|
} |
|
485
|
|
|
} |
|
486
|
|
|
} |
|
487
|
|
|
|
|
488
|
|
|
$redirectTo = ''; |
|
489
|
|
|
if ($debug > 0) { |
|
490
|
|
|
error_log('action "'.$action.'" triggered'); |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
function SendReminderLp($toUser, $fromUser, $courseName, $lpName, $link) |
|
494
|
|
|
{ |
|
495
|
|
|
$toUserId = $toUser['user_id']; |
|
496
|
|
|
$subjectTemplate = new Template( |
|
497
|
|
|
null, |
|
498
|
|
|
false, |
|
499
|
|
|
false, |
|
500
|
|
|
false, |
|
501
|
|
|
false, |
|
502
|
|
|
false); |
|
503
|
|
|
$subjectLayout = $subjectTemplate->get_template( |
|
504
|
|
|
'mail/learning_path_reminder_subject.tpl' |
|
505
|
|
|
); |
|
506
|
|
|
$bodyTemplate = new Template( |
|
507
|
|
|
null, |
|
508
|
|
|
false, |
|
509
|
|
|
false, |
|
510
|
|
|
false, |
|
511
|
|
|
false, |
|
512
|
|
|
false); |
|
513
|
|
|
$bodyTemplate->assign('courseName', $courseName); |
|
514
|
|
|
$bodyTemplate->assign('lpName', $lpName); |
|
515
|
|
|
$bodyTemplate->assign('link', $link); |
|
516
|
|
|
$bodyLayout = $bodyTemplate->get_template( |
|
517
|
|
|
'mail/learning_path_reminder_body.tpl' |
|
518
|
|
|
); |
|
519
|
|
|
$tittle = $subjectTemplate->fetch($subjectLayout); |
|
520
|
|
|
$content = $bodyTemplate->fetch($bodyLayout); |
|
521
|
|
|
MessageManager::send_message_simple( |
|
522
|
|
|
$toUserId, |
|
523
|
|
|
$tittle, |
|
524
|
|
|
$content, |
|
525
|
|
|
$fromUser, |
|
526
|
|
|
true |
|
527
|
|
|
); |
|
528
|
|
|
|
|
529
|
|
|
return null; |
|
530
|
|
|
} |
|
531
|
|
|
|
|
532
|
|
|
$lpListUrl = api_get_self().'?action=list&'.api_get_cidreq(); |
|
533
|
|
|
|
|
534
|
|
|
switch ($action) { |
|
535
|
|
|
case 'author_view': |
|
536
|
|
|
$teachers = []; |
|
537
|
|
|
$field = new ExtraField('user'); |
|
538
|
|
|
$authorLp = $field->get_handler_field_info_by_field_variable('authorlp'); |
|
539
|
|
|
$idExtraField = isset($authorLp['id']) ? (int) $authorLp['id'] : 0; |
|
540
|
|
|
if ($idExtraField != 0) { |
|
541
|
|
|
$extraFieldValueUser = new ExtraFieldValue('user'); |
|
542
|
|
|
$arrayExtraFieldValueUser = $extraFieldValueUser->get_item_id_from_field_variable_and_field_value( |
|
543
|
|
|
'authorlp', |
|
544
|
|
|
1, |
|
545
|
|
|
true, |
|
546
|
|
|
false, |
|
547
|
|
|
true |
|
548
|
|
|
); |
|
549
|
|
|
if (!empty($arrayExtraFieldValueUser)) { |
|
550
|
|
|
foreach ($arrayExtraFieldValueUser as $item) { |
|
551
|
|
|
$teacher = api_get_user_info($item['item_id']); |
|
552
|
|
|
$teachers[] = $teacher; |
|
553
|
|
|
} |
|
554
|
|
|
} |
|
555
|
|
|
} |
|
556
|
|
|
Session::write('oLP', $_SESSION['oLP']); |
|
557
|
|
|
if (!$is_allowed_to_edit) { |
|
558
|
|
|
api_not_allowed(true); |
|
559
|
|
|
} |
|
560
|
|
|
if (!$lp_found) { |
|
561
|
|
|
// Check if the learnpath ID was defined, otherwise send back to list |
|
562
|
|
|
require 'lp_list.php'; |
|
563
|
|
|
} else { |
|
564
|
|
|
require 'lp_add_author.php'; |
|
565
|
|
|
} |
|
566
|
|
|
break; |
|
567
|
|
|
case 'send_notify_teacher': |
|
568
|
|
|
// Send notification to the teacher |
|
569
|
|
|
$studentInfo = api_get_user_info(); |
|
570
|
|
|
$course_info = api_get_course_info(); |
|
571
|
|
|
$sessionId = api_get_session_id(); |
|
572
|
|
|
|
|
573
|
|
|
$courseName = $course_info['title']; |
|
574
|
|
|
$courseUrl = $course_info['course_public_url']; |
|
575
|
|
|
if (!empty($sessionId)) { |
|
576
|
|
|
$sessionInfo = api_get_session_info($sessionId); |
|
577
|
|
|
$courseName = $sessionInfo['name']; |
|
578
|
|
|
$courseUrl .= '?id_session='.$sessionId; |
|
579
|
|
|
} |
|
580
|
|
|
|
|
581
|
|
|
$url = Display::url($courseName, $courseUrl, ['title' => get_lang('GoToCourse')]); |
|
582
|
|
|
$coachList = CourseManager::get_coachs_from_course($sessionId, api_get_course_int_id()); |
|
583
|
|
|
foreach ($coachList as $coach_course) { |
|
584
|
|
|
$recipientName = $coach_course['full_name']; |
|
585
|
|
|
$coachInfo = api_get_user_info($coach_course['user_id']); |
|
586
|
|
|
|
|
587
|
|
|
if (empty($coachInfo)) { |
|
588
|
|
|
continue; |
|
589
|
|
|
} |
|
590
|
|
|
$email = $coachInfo['email']; |
|
591
|
|
|
|
|
592
|
|
|
$tplContent = new Template(null, false, false, false, false, false); |
|
593
|
|
|
$tplContent->assign('name_teacher', $recipientName); |
|
594
|
|
|
$tplContent->assign('name_student', $studentInfo['complete_name']); |
|
595
|
|
|
$tplContent->assign('course_name', $courseName); |
|
596
|
|
|
$tplContent->assign('course_url', $url); |
|
597
|
|
|
$layoutContent = $tplContent->get_template('mail/content_ending_learnpath.tpl'); |
|
598
|
|
|
$emailBody = $tplContent->fetch($layoutContent); |
|
599
|
|
|
|
|
600
|
|
|
MessageManager::send_message_simple( |
|
601
|
|
|
$coachInfo['user_id'], |
|
602
|
|
|
sprintf(get_lang('StudentXFinishedLp'), $studentInfo['complete_name']), |
|
603
|
|
|
$emailBody, |
|
604
|
|
|
$studentInfo['user_id'] |
|
605
|
|
|
); |
|
606
|
|
|
} |
|
607
|
|
|
Display::addFlash(Display::return_message(get_lang('MessageSent'))); |
|
608
|
|
|
$url = api_get_self().'?action=list&'.api_get_cidreq(); |
|
609
|
|
|
header('Location: '.$url); |
|
610
|
|
|
exit; |
|
611
|
|
|
break; |
|
612
|
|
|
case 'add_item': |
|
613
|
|
|
if (!$is_allowed_to_edit) { |
|
614
|
|
|
api_not_allowed(true); |
|
615
|
|
|
} |
|
616
|
|
|
if (!$lp_found) { |
|
617
|
|
|
// Check if the learnpath ID was defined, otherwise send back to list |
|
618
|
|
|
require 'lp_list.php'; |
|
619
|
|
|
} else { |
|
620
|
|
|
Session::write('refresh', 1); |
|
621
|
|
|
|
|
622
|
|
|
if (isset($_POST['submit_button']) && !empty($post_title)) { |
|
623
|
|
|
// If a title was submitted: |
|
624
|
|
|
|
|
625
|
|
|
// Updating the lp.modified_on |
|
626
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
627
|
|
|
|
|
628
|
|
|
if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) { |
|
629
|
|
|
// Check post_time to ensure ??? (counter-hacking measure?) |
|
630
|
|
|
require 'lp_add_item.php'; |
|
631
|
|
|
} else { |
|
632
|
|
|
Session::write('post_time', $_POST['post_time']); |
|
633
|
|
|
$directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0; |
|
634
|
|
|
$courseInfo = api_get_course_info(); |
|
635
|
|
|
if (empty($directoryParentId)) { |
|
636
|
|
|
$_SESSION['oLP']->generate_lp_folder($courseInfo); |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
|
|
$parent = isset($_POST['parent']) ? $_POST['parent'] : ''; |
|
640
|
|
|
$previous = isset($_POST['previous']) ? $_POST['previous'] : ''; |
|
641
|
|
|
$type = isset($_POST['type']) ? $_POST['type'] : ''; |
|
642
|
|
|
$path = isset($_POST['path']) ? $_POST['path'] : ''; |
|
643
|
|
|
$description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
644
|
|
|
$prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
645
|
|
|
$maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
646
|
|
|
|
|
647
|
|
|
if ($_POST['type'] == TOOL_DOCUMENT) { |
|
648
|
|
|
if (isset($_POST['path']) && $_GET['edit'] != 'true') { |
|
649
|
|
|
$document_id = $_POST['path']; |
|
650
|
|
|
} else { |
|
651
|
|
|
if ($_POST['content_lp']) { |
|
652
|
|
|
$document_id = $_SESSION['oLP']->create_document( |
|
653
|
|
|
$_course, |
|
654
|
|
|
$_POST['content_lp'], |
|
655
|
|
|
$_POST['title'], |
|
656
|
|
|
'html', |
|
657
|
|
|
$directoryParentId |
|
658
|
|
|
); |
|
659
|
|
|
} |
|
660
|
|
|
} |
|
661
|
|
|
|
|
662
|
|
|
$_SESSION['oLP']->add_item( |
|
663
|
|
|
$parent, |
|
664
|
|
|
$previous, |
|
665
|
|
|
$type, |
|
666
|
|
|
$document_id, |
|
667
|
|
|
$post_title, |
|
668
|
|
|
$description, |
|
669
|
|
|
$prerequisites |
|
670
|
|
|
); |
|
671
|
|
|
} elseif ($_POST['type'] == TOOL_READOUT_TEXT) { |
|
672
|
|
|
if (isset($_POST['path']) && $_GET['edit'] != 'true') { |
|
673
|
|
|
$document_id = $_POST['path']; |
|
674
|
|
|
} else { |
|
675
|
|
|
$document_id = $_SESSION['oLP']->createReadOutText( |
|
676
|
|
|
$_course, |
|
677
|
|
|
$_POST['content_lp'], |
|
678
|
|
|
$_POST['title'], |
|
679
|
|
|
$directoryParentId |
|
680
|
|
|
); |
|
681
|
|
|
} |
|
682
|
|
|
|
|
683
|
|
|
$_SESSION['oLP']->add_item( |
|
684
|
|
|
$parent, |
|
685
|
|
|
$previous, |
|
686
|
|
|
TOOL_READOUT_TEXT, |
|
687
|
|
|
$document_id, |
|
688
|
|
|
$post_title, |
|
689
|
|
|
$description, |
|
690
|
|
|
$prerequisites |
|
691
|
|
|
); |
|
692
|
|
|
} else { |
|
693
|
|
|
// For all other item types than documents, |
|
694
|
|
|
// load the item using the item type and path rather than its ID. |
|
695
|
|
|
$_SESSION['oLP']->add_item( |
|
696
|
|
|
$parent, |
|
697
|
|
|
$previous, |
|
698
|
|
|
$type, |
|
699
|
|
|
$path, |
|
700
|
|
|
$post_title, |
|
701
|
|
|
$description, |
|
702
|
|
|
$prerequisites, |
|
703
|
|
|
$maxTimeAllowed |
|
704
|
|
|
); |
|
705
|
|
|
} |
|
706
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
707
|
|
|
header('Location: '.$url); |
|
708
|
|
|
exit; |
|
709
|
|
|
} |
|
710
|
|
|
} else { |
|
711
|
|
|
require 'lp_add_item.php'; |
|
712
|
|
|
} |
|
713
|
|
|
} |
|
714
|
|
|
break; |
|
715
|
|
|
case 'add_users_to_category': |
|
716
|
|
|
if (!$is_allowed_to_edit) { |
|
717
|
|
|
api_not_allowed(true); |
|
718
|
|
|
} |
|
719
|
|
|
require 'lp_subscribe_users_to_category.php'; |
|
720
|
|
|
break; |
|
721
|
|
|
case 'add_audio': |
|
722
|
|
|
if (!$is_allowed_to_edit) { |
|
723
|
|
|
api_not_allowed(true); |
|
724
|
|
|
} |
|
725
|
|
|
if (!$lp_found) { |
|
726
|
|
|
// Check if the learnpath ID was defined, otherwise send back to list |
|
727
|
|
|
require 'lp_list.php'; |
|
728
|
|
|
} else { |
|
729
|
|
|
Session::write('refresh', 1); |
|
730
|
|
|
|
|
731
|
|
|
if (isset($_REQUEST['id'])) { |
|
732
|
|
|
$lp_item_obj = new learnpathItem($_REQUEST['id']); |
|
733
|
|
|
|
|
734
|
|
|
// Remove audio |
|
735
|
|
|
if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) { |
|
736
|
|
|
$lp_item_obj->removeAudio(); |
|
737
|
|
|
Display::addFlash(Display::return_message(get_lang('FileDeleted'))); |
|
738
|
|
|
|
|
739
|
|
|
$url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq(); |
|
740
|
|
|
header('Location: '.$url); |
|
741
|
|
|
exit; |
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
// Upload audio |
|
745
|
|
|
if (isset($_FILES['file']) && !empty($_FILES['file'])) { |
|
746
|
|
|
// Updating the lp.modified_on |
|
747
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
748
|
|
|
$lp_item_obj->addAudio(); |
|
749
|
|
|
Display::addFlash(Display::return_message(get_lang('UplUploadSucceeded'))); |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
//Add audio file from documents |
|
753
|
|
|
if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) { |
|
754
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
755
|
|
|
$lp_item_obj->add_audio_from_documents($_REQUEST['document_id']); |
|
756
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
757
|
|
|
} |
|
758
|
|
|
|
|
759
|
|
|
require 'lp_add_audio.php'; |
|
760
|
|
|
} else { |
|
761
|
|
|
require 'lp_add_audio.php'; |
|
762
|
|
|
} |
|
763
|
|
|
} |
|
764
|
|
|
break; |
|
765
|
|
|
case 'add_lp_category': |
|
766
|
|
|
if (!$is_allowed_to_edit) { |
|
767
|
|
|
api_not_allowed(true); |
|
768
|
|
|
} |
|
769
|
|
|
require 'lp_add_category.php'; |
|
770
|
|
|
break; |
|
771
|
|
|
case 'move_up_category': |
|
772
|
|
|
if (!$is_allowed_to_edit) { |
|
773
|
|
|
api_not_allowed(true); |
|
774
|
|
|
} |
|
775
|
|
|
if (isset($_REQUEST['id'])) { |
|
776
|
|
|
learnpath::moveUpCategory($_REQUEST['id']); |
|
777
|
|
|
} |
|
778
|
|
|
require 'lp_list.php'; |
|
779
|
|
|
break; |
|
780
|
|
|
case 'move_down_category': |
|
781
|
|
|
if (!$is_allowed_to_edit) { |
|
782
|
|
|
api_not_allowed(true); |
|
783
|
|
|
} |
|
784
|
|
|
if (isset($_REQUEST['id'])) { |
|
785
|
|
|
learnpath::moveDownCategory($_REQUEST['id']); |
|
786
|
|
|
} |
|
787
|
|
|
require 'lp_list.php'; |
|
788
|
|
|
break; |
|
789
|
|
|
case 'delete_lp_category': |
|
790
|
|
|
if (!$is_allowed_to_edit) { |
|
791
|
|
|
api_not_allowed(true); |
|
792
|
|
|
} |
|
793
|
|
|
if (isset($_REQUEST['id'])) { |
|
794
|
|
|
$result = learnpath::deleteCategory($_REQUEST['id']); |
|
795
|
|
|
if ($result) { |
|
796
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
797
|
|
|
} |
|
798
|
|
|
} |
|
799
|
|
|
require 'lp_list.php'; |
|
800
|
|
|
break; |
|
801
|
|
|
case 'add_lp': |
|
802
|
|
|
if (!$is_allowed_to_edit) { |
|
803
|
|
|
api_not_allowed(true); |
|
804
|
|
|
} |
|
805
|
|
|
if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) { |
|
806
|
|
|
$_REQUEST['lp_name'] = trim($_REQUEST['lp_name']); |
|
807
|
|
|
Session::write('refresh', 1); |
|
808
|
|
|
|
|
809
|
|
|
if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) { |
|
810
|
|
|
require 'lp_add.php'; |
|
811
|
|
|
} else { |
|
812
|
|
|
Session::write('post_time', $_POST['post_time']); |
|
813
|
|
|
|
|
814
|
|
|
$publicated_on = null; |
|
815
|
|
|
if (isset($_REQUEST['activate_start_date_check']) && |
|
816
|
|
|
$_REQUEST['activate_start_date_check'] == 1 |
|
817
|
|
|
) { |
|
818
|
|
|
$publicated_on = $_REQUEST['publicated_on']; |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
|
|
$expired_on = null; |
|
822
|
|
|
if (isset($_REQUEST['activate_end_date_check']) && |
|
823
|
|
|
$_REQUEST['activate_end_date_check'] == 1 |
|
824
|
|
|
) { |
|
825
|
|
|
$expired_on = $_REQUEST['expired_on']; |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
$new_lp_id = learnpath::add_lp( |
|
829
|
|
|
api_get_course_id(), |
|
830
|
|
|
$_REQUEST['lp_name'], |
|
831
|
|
|
'', |
|
832
|
|
|
'chamilo', |
|
833
|
|
|
'manual', |
|
834
|
|
|
'', |
|
835
|
|
|
$publicated_on, |
|
836
|
|
|
$expired_on, |
|
837
|
|
|
$_REQUEST['category_id'] |
|
838
|
|
|
); |
|
839
|
|
|
|
|
840
|
|
|
if (is_numeric($new_lp_id)) { |
|
841
|
|
|
// Create temp form validator to save skills |
|
842
|
|
|
$form = new FormValidator('lp_add'); |
|
843
|
|
|
$form->addSelect('skills', 'skills'); |
|
844
|
|
|
Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $new_lp_id); |
|
845
|
|
|
|
|
846
|
|
|
$extraFieldValue = new ExtraFieldValue('lp'); |
|
847
|
|
|
$_REQUEST['item_id'] = $new_lp_id; |
|
848
|
|
|
$extraFieldValue->saveFieldValues($_REQUEST); |
|
849
|
|
|
|
|
850
|
|
|
// TODO: Maybe create a first directory directly to avoid bugging the user with useless queries |
|
851
|
|
|
$_SESSION['oLP'] = new learnpath( |
|
852
|
|
|
api_get_course_id(), |
|
853
|
|
|
$new_lp_id, |
|
854
|
|
|
api_get_user_id() |
|
855
|
|
|
); |
|
856
|
|
|
|
|
857
|
|
|
$subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0; |
|
858
|
|
|
$_SESSION['oLP']->setSubscribeUsers($subscribeUsers); |
|
859
|
|
|
|
|
860
|
|
|
$accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true'; |
|
861
|
|
|
$_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime); |
|
862
|
|
|
|
|
863
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq(); |
|
864
|
|
|
header("Location: $url&isStudentView=false"); |
|
865
|
|
|
exit; |
|
866
|
|
|
} |
|
867
|
|
|
} |
|
868
|
|
|
} else { |
|
869
|
|
|
require 'lp_add.php'; |
|
870
|
|
|
} |
|
871
|
|
|
break; |
|
872
|
|
|
case 'admin_view': |
|
873
|
|
|
if (!$is_allowed_to_edit) { |
|
874
|
|
|
api_not_allowed(true); |
|
875
|
|
|
} |
|
876
|
|
|
if (!$lp_found) { |
|
877
|
|
|
require 'lp_list.php'; |
|
878
|
|
|
} else { |
|
879
|
|
|
Session::write('refresh', 1); |
|
880
|
|
|
require 'lp_admin_view.php'; |
|
881
|
|
|
} |
|
882
|
|
|
break; |
|
883
|
|
|
case 'auto_launch': |
|
884
|
|
|
// Redirect to a specific LP |
|
885
|
|
|
if (api_get_course_setting('enable_lp_auto_launch') == 1) { |
|
886
|
|
|
if (!$is_allowed_to_edit) { |
|
887
|
|
|
api_not_allowed(true); |
|
888
|
|
|
} |
|
889
|
|
|
if (!$lp_found) { |
|
890
|
|
|
require 'lp_list.php'; |
|
891
|
|
|
} else { |
|
892
|
|
|
$_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']); |
|
893
|
|
|
require 'lp_list.php'; |
|
894
|
|
|
exit; |
|
895
|
|
|
} |
|
896
|
|
|
} |
|
897
|
|
|
break; |
|
898
|
|
|
case 'build': |
|
899
|
|
|
if (!$is_allowed_to_edit) { |
|
900
|
|
|
api_not_allowed(true); |
|
901
|
|
|
} |
|
902
|
|
|
if (!$lp_found) { |
|
903
|
|
|
require 'lp_list.php'; |
|
904
|
|
|
} else { |
|
905
|
|
|
Session::write('refresh', 1); |
|
906
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
907
|
|
|
header('Location: '.$url); |
|
908
|
|
|
exit; |
|
909
|
|
|
} |
|
910
|
|
|
break; |
|
911
|
|
|
case 'edit_item': |
|
912
|
|
|
if (!$is_allowed_to_edit) { |
|
913
|
|
|
api_not_allowed(true); |
|
914
|
|
|
} |
|
915
|
|
|
if (!$lp_found) { |
|
916
|
|
|
require 'lp_list.php'; |
|
917
|
|
|
} else { |
|
918
|
|
|
Session::write('refresh', 1); |
|
919
|
|
|
if (isset($_POST) && !empty($post_title)) { |
|
920
|
|
|
// Updating the lp.modified_on |
|
921
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
922
|
|
|
|
|
923
|
|
|
// TODO: mp3 edit |
|
924
|
|
|
$audio = []; |
|
925
|
|
|
if (isset($_FILES['mp3'])) { |
|
926
|
|
|
$audio = $_FILES['mp3']; |
|
927
|
|
|
} |
|
928
|
|
|
|
|
929
|
|
|
$description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
930
|
|
|
$prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
931
|
|
|
$maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
932
|
|
|
$url = isset($_POST['url']) ? $_POST['url'] : ''; |
|
933
|
|
|
|
|
934
|
|
|
$_SESSION['oLP']->edit_item( |
|
935
|
|
|
$_REQUEST['id'], |
|
936
|
|
|
$_POST['parent'], |
|
937
|
|
|
$_POST['previous'], |
|
938
|
|
|
$post_title, |
|
939
|
|
|
$description, |
|
940
|
|
|
$prerequisites, |
|
941
|
|
|
$audio, |
|
942
|
|
|
$maxTimeAllowed, |
|
943
|
|
|
$url |
|
944
|
|
|
); |
|
945
|
|
|
|
|
946
|
|
|
if (isset($_POST['content_lp'])) { |
|
947
|
|
|
$_SESSION['oLP']->edit_document($_course); |
|
948
|
|
|
} |
|
949
|
|
|
$is_success = true; |
|
950
|
|
|
$extraFieldValues = new ExtraFieldValue('lp_item'); |
|
951
|
|
|
$extraFieldValues->saveFieldValues($_POST, true); |
|
952
|
|
|
|
|
953
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
954
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
955
|
|
|
header('Location: '.$url); |
|
956
|
|
|
exit; |
|
957
|
|
|
} |
|
958
|
|
|
if (isset($_GET['view']) && $_GET['view'] === 'build') { |
|
959
|
|
|
require 'lp_edit_item.php'; |
|
960
|
|
|
} else { |
|
961
|
|
|
require 'lp_admin_view.php'; |
|
962
|
|
|
} |
|
963
|
|
|
} |
|
964
|
|
|
break; |
|
965
|
|
|
case 'edit_item_prereq': |
|
966
|
|
|
if (!$is_allowed_to_edit) { |
|
967
|
|
|
api_not_allowed(true); |
|
968
|
|
|
} |
|
969
|
|
|
if (!$lp_found) { |
|
970
|
|
|
require 'lp_list.php'; |
|
971
|
|
|
} else { |
|
972
|
|
|
if (isset($_POST['submit_button'])) { |
|
973
|
|
|
// Updating the lp.modified_on |
|
974
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
975
|
|
|
Session::write('refresh', 1); |
|
976
|
|
|
$min = isset($_POST['min_'.$_POST['prerequisites']]) ? $_POST['min_'.$_POST['prerequisites']] : ''; |
|
977
|
|
|
$max = isset($_POST['max_'.$_POST['prerequisites']]) ? $_POST['max_'.$_POST['prerequisites']] : ''; |
|
978
|
|
|
|
|
979
|
|
|
$editPrerequisite = $_SESSION['oLP']->edit_item_prereq( |
|
980
|
|
|
$_GET['id'], |
|
981
|
|
|
$_POST['prerequisites'], |
|
982
|
|
|
$min, |
|
983
|
|
|
$max |
|
984
|
|
|
); |
|
985
|
|
|
|
|
986
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
987
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
988
|
|
|
header('Location: '.$url); |
|
989
|
|
|
exit; |
|
990
|
|
|
} else { |
|
991
|
|
|
require 'lp_edit_item_prereq.php'; |
|
992
|
|
|
} |
|
993
|
|
|
} |
|
994
|
|
|
break; |
|
995
|
|
|
case 'move_item': |
|
996
|
|
|
if (!$is_allowed_to_edit) { |
|
997
|
|
|
api_not_allowed(true); |
|
998
|
|
|
} |
|
999
|
|
|
|
|
1000
|
|
|
if (!$lp_found) { |
|
1001
|
|
|
require 'lp_list.php'; |
|
1002
|
|
|
} else { |
|
1003
|
|
|
Session::write('refresh', 1); |
|
1004
|
|
|
if (isset($_POST['submit_button'])) { |
|
1005
|
|
|
//Updating the lp.modified_on |
|
1006
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
1007
|
|
|
$_SESSION['oLP']->edit_item( |
|
1008
|
|
|
$_GET['id'], |
|
1009
|
|
|
$_POST['parent'], |
|
1010
|
|
|
$_POST['previous'], |
|
1011
|
|
|
$post_title, |
|
1012
|
|
|
$_POST['description'] |
|
1013
|
|
|
); |
|
1014
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
1015
|
|
|
header('Location: '.$url); |
|
1016
|
|
|
exit; |
|
1017
|
|
|
} |
|
1018
|
|
|
if (isset($_GET['view']) && $_GET['view'] == 'build') { |
|
1019
|
|
|
require 'lp_move_item.php'; |
|
1020
|
|
|
} else { |
|
1021
|
|
|
// Avoids weird behaviours see CT#967. |
|
1022
|
|
|
$check = Security::check_token('get'); |
|
1023
|
|
|
if ($check) { |
|
1024
|
|
|
$_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']); |
|
1025
|
|
|
} |
|
1026
|
|
|
Security::clear_token(); |
|
1027
|
|
|
require 'lp_admin_view.php'; |
|
1028
|
|
|
} |
|
1029
|
|
|
} |
|
1030
|
|
|
break; |
|
1031
|
|
|
case 'view_item': |
|
1032
|
|
|
if (!$is_allowed_to_edit) { |
|
1033
|
|
|
api_not_allowed(true); |
|
1034
|
|
|
} |
|
1035
|
|
|
if (!$lp_found) { |
|
1036
|
|
|
require 'lp_list.php'; |
|
1037
|
|
|
} else { |
|
1038
|
|
|
Session::write('refresh', 1); |
|
1039
|
|
|
require 'lp_view_item.php'; |
|
1040
|
|
|
} |
|
1041
|
|
|
break; |
|
1042
|
|
|
case 'upload': |
|
1043
|
|
|
if (!$is_allowed_to_edit) { |
|
1044
|
|
|
api_not_allowed(true); |
|
1045
|
|
|
} |
|
1046
|
|
|
$cwdir = getcwd(); |
|
1047
|
|
|
require 'lp_upload.php'; |
|
1048
|
|
|
// Reinit current working directory as many functions in upload change it. |
|
1049
|
|
|
chdir($cwdir); |
|
1050
|
|
|
require 'lp_list.php'; |
|
1051
|
|
|
break; |
|
1052
|
|
|
case 'copy': |
|
1053
|
|
|
if (!$is_allowed_to_edit) { |
|
1054
|
|
|
api_not_allowed(true); |
|
1055
|
|
|
} |
|
1056
|
|
|
|
|
1057
|
|
|
$hideScormCopyLink = api_get_setting('hide_scorm_copy_link'); |
|
1058
|
|
|
if ($hideScormCopyLink === 'true') { |
|
1059
|
|
|
api_not_allowed(true); |
|
1060
|
|
|
} |
|
1061
|
|
|
|
|
1062
|
|
|
if (!$lp_found) { |
|
1063
|
|
|
api_location($lpListUrl); |
|
1064
|
|
|
} |
|
1065
|
|
|
|
|
1066
|
|
|
$_SESSION['oLP']->copy(); |
|
1067
|
|
|
Display::addFlash(Display::return_message(get_lang('ItemCopied'))); |
|
1068
|
|
|
api_location($lpListUrl); |
|
1069
|
|
|
break; |
|
1070
|
|
|
case 'export': |
|
1071
|
|
|
if (!$is_allowed_to_edit) { |
|
1072
|
|
|
api_not_allowed(true); |
|
1073
|
|
|
} |
|
1074
|
|
|
$hideScormExportLink = api_get_setting('hide_scorm_export_link'); |
|
1075
|
|
|
if ($hideScormExportLink === 'true') { |
|
1076
|
|
|
api_not_allowed(true); |
|
1077
|
|
|
} |
|
1078
|
|
|
if (!$lp_found) { |
|
1079
|
|
|
require 'lp_list.php'; |
|
1080
|
|
|
} else { |
|
1081
|
|
|
$_SESSION['oLP']->scormExport(); |
|
1082
|
|
|
exit(); |
|
1083
|
|
|
} |
|
1084
|
|
|
break; |
|
1085
|
|
|
case 'export_to_pdf': |
|
1086
|
|
|
$hideScormPdfLink = api_get_setting('hide_scorm_pdf_link'); |
|
1087
|
|
|
if ($hideScormPdfLink === 'true') { |
|
1088
|
|
|
api_not_allowed(true); |
|
1089
|
|
|
} |
|
1090
|
|
|
|
|
1091
|
|
|
// Teachers can export to PDF |
|
1092
|
|
|
if (!$is_allowed_to_edit) { |
|
1093
|
|
|
if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id(), $_course)) { |
|
1094
|
|
|
api_not_allowed(); |
|
1095
|
|
|
} |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
if (!$lp_found) { |
|
1099
|
|
|
require 'lp_list.php'; |
|
1100
|
|
|
} else { |
|
1101
|
|
|
$result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']); |
|
1102
|
|
|
if (!$result) { |
|
1103
|
|
|
require 'lp_list.php'; |
|
1104
|
|
|
} |
|
1105
|
|
|
exit; |
|
1106
|
|
|
} |
|
1107
|
|
|
break; |
|
1108
|
|
|
case 'export_to_course_build': |
|
1109
|
|
|
$allowExport = api_get_configuration_value('allow_lp_chamilo_export'); |
|
1110
|
|
|
if (api_is_allowed_to_edit() && $allowExport) { |
|
1111
|
|
|
if (!$lp_found) { |
|
1112
|
|
|
require 'lp_list.php'; |
|
1113
|
|
|
} else { |
|
1114
|
|
|
$result = $_SESSION['oLP']->exportToCourseBuildFormat($_GET['lp_id']); |
|
1115
|
|
|
if (!$result) { |
|
1116
|
|
|
require 'lp_list.php'; |
|
1117
|
|
|
} |
|
1118
|
|
|
exit; |
|
1119
|
|
|
} |
|
1120
|
|
|
} |
|
1121
|
|
|
require 'lp_list.php'; |
|
1122
|
|
|
break; |
|
1123
|
|
|
case 'delete': |
|
1124
|
|
|
if (!$is_allowed_to_edit) { |
|
1125
|
|
|
api_not_allowed(true); |
|
1126
|
|
|
} |
|
1127
|
|
|
if (!$lp_found) { |
|
1128
|
|
|
require 'lp_list.php'; |
|
1129
|
|
|
} else { |
|
1130
|
|
|
Session::write('refresh', 1); |
|
1131
|
|
|
$_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove'); |
|
1132
|
|
|
Skill::deleteSkillsFromItem($_GET['lp_id'], ITEM_TYPE_LEARNPATH); |
|
1133
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
1134
|
|
|
Session::erase('oLP'); |
|
1135
|
|
|
api_location($lpListUrl); |
|
1136
|
|
|
} |
|
1137
|
|
|
break; |
|
1138
|
|
|
case 'toggle_category_visibility': |
|
1139
|
|
|
if (!$is_allowed_to_edit) { |
|
1140
|
|
|
api_not_allowed(true); |
|
1141
|
|
|
} |
|
1142
|
|
|
|
|
1143
|
|
|
learnpath::toggleCategoryVisibility($_REQUEST['id'], $_REQUEST['new_status']); |
|
1144
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1145
|
|
|
api_location($lpListUrl); |
|
1146
|
|
|
break; |
|
1147
|
|
|
case 'toggle_visible': |
|
1148
|
|
|
// Change lp visibility (inside lp tool). |
|
1149
|
|
|
if (!$is_allowed_to_edit) { |
|
1150
|
|
|
api_not_allowed(true); |
|
1151
|
|
|
} |
|
1152
|
|
|
|
|
1153
|
|
|
learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
1154
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1155
|
|
|
api_location($lpListUrl); |
|
1156
|
|
|
|
|
1157
|
|
|
break; |
|
1158
|
|
|
case 'toggle_category_publish': |
|
1159
|
|
|
if (!$is_allowed_to_edit) { |
|
1160
|
|
|
api_not_allowed(true); |
|
1161
|
|
|
} |
|
1162
|
|
|
|
|
1163
|
|
|
learnpath::toggleCategoryPublish($_REQUEST['id'], $_REQUEST['new_status']); |
|
1164
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1165
|
|
|
api_location($lpListUrl); |
|
1166
|
|
|
break; |
|
1167
|
|
|
case 'toggle_publish': |
|
1168
|
|
|
// Change lp published status (visibility on homepage). |
|
1169
|
|
|
if (!$is_allowed_to_edit) { |
|
1170
|
|
|
api_not_allowed(true); |
|
1171
|
|
|
} |
|
1172
|
|
|
|
|
1173
|
|
|
learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
1174
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1175
|
|
|
api_location($lpListUrl); |
|
1176
|
|
|
|
|
1177
|
|
|
break; |
|
1178
|
|
|
case 'move_lp_up': |
|
1179
|
|
|
// Change lp published status (visibility on homepage) |
|
1180
|
|
|
if (!$is_allowed_to_edit) { |
|
1181
|
|
|
api_not_allowed(true); |
|
1182
|
|
|
} |
|
1183
|
|
|
if (!$lp_found) { |
|
1184
|
|
|
require 'lp_list.php'; |
|
1185
|
|
|
} else { |
|
1186
|
|
|
learnpath::move_up($_REQUEST['lp_id'], $_REQUEST['category_id']); |
|
1187
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1188
|
|
|
require 'lp_list.php'; |
|
1189
|
|
|
} |
|
1190
|
|
|
break; |
|
1191
|
|
|
case 'move_lp_down': |
|
1192
|
|
|
// Change lp published status (visibility on homepage) |
|
1193
|
|
|
if (!$is_allowed_to_edit) { |
|
1194
|
|
|
api_not_allowed(true); |
|
1195
|
|
|
} |
|
1196
|
|
|
if (!$lp_found) { |
|
1197
|
|
|
require 'lp_list.php'; |
|
1198
|
|
|
} else { |
|
1199
|
|
|
learnpath::move_down($_REQUEST['lp_id'], $_REQUEST['category_id']); |
|
1200
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1201
|
|
|
require 'lp_list.php'; |
|
1202
|
|
|
} |
|
1203
|
|
|
break; |
|
1204
|
|
|
case 'edit': |
|
1205
|
|
|
if (!$is_allowed_to_edit) { |
|
1206
|
|
|
api_not_allowed(true); |
|
1207
|
|
|
} |
|
1208
|
|
|
|
|
1209
|
|
|
if (!$lp_found) { |
|
1210
|
|
|
require 'lp_list.php'; |
|
1211
|
|
|
} else { |
|
1212
|
|
|
Session::write('refresh', 1); |
|
1213
|
|
|
require 'lp_edit.php'; |
|
1214
|
|
|
} |
|
1215
|
|
|
break; |
|
1216
|
|
|
case 'update_lp': |
|
1217
|
|
|
if (!$is_allowed_to_edit) { |
|
1218
|
|
|
api_not_allowed(true); |
|
1219
|
|
|
} |
|
1220
|
|
|
if (!$lp_found) { |
|
1221
|
|
|
require 'lp_list.php'; |
|
1222
|
|
|
} else { |
|
1223
|
|
|
Session::write('refresh', 1); |
|
1224
|
|
|
$_SESSION['oLP']->set_name($_REQUEST['lp_name']); |
|
1225
|
|
|
$author = $_REQUEST['lp_author']; |
|
1226
|
|
|
$_SESSION['oLP']->set_author($author); |
|
1227
|
|
|
// TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed. |
|
1228
|
|
|
$_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']); |
|
1229
|
|
|
|
|
1230
|
|
|
if (isset($_REQUEST['lp_maker'])) { |
|
1231
|
|
|
$_SESSION['oLP']->set_maker($_REQUEST['lp_maker']); |
|
1232
|
|
|
} |
|
1233
|
|
|
if (isset($_REQUEST['lp_proximity'])) { |
|
1234
|
|
|
$_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']); |
|
1235
|
|
|
} |
|
1236
|
|
|
$_SESSION['oLP']->set_theme($_REQUEST['lp_theme']); |
|
1237
|
|
|
|
|
1238
|
|
|
$hide_toc_frame = null; |
|
1239
|
|
|
if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) { |
|
1240
|
|
|
$hide_toc_frame = $_REQUEST['hide_toc_frame']; |
|
1241
|
|
|
} |
|
1242
|
|
|
$_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame); |
|
1243
|
|
|
$_SESSION['oLP']->set_prerequisite(isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0); |
|
1244
|
|
|
$_SESSION['oLP']->setAccumulateWorkTime(isset($_REQUEST['accumulate_work_time']) ? $_REQUEST['accumulate_work_time'] : 0); |
|
1245
|
|
|
$_SESSION['oLP']->set_use_max_score(isset($_POST['use_max_score']) ? 1 : 0); |
|
1246
|
|
|
|
|
1247
|
|
|
$subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0; |
|
1248
|
|
|
$_SESSION['oLP']->setSubscribeUsers($subscribeUsers); |
|
1249
|
|
|
|
|
1250
|
|
|
$accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true'; |
|
1251
|
|
|
$_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime); |
|
1252
|
|
|
|
|
1253
|
|
|
$publicated_on = null; |
|
1254
|
|
|
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) { |
|
1255
|
|
|
$publicated_on = $_REQUEST['publicated_on']; |
|
1256
|
|
|
} |
|
1257
|
|
|
|
|
1258
|
|
|
$expired_on = null; |
|
1259
|
|
|
if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) { |
|
1260
|
|
|
$expired_on = $_REQUEST['expired_on']; |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
$_SESSION['oLP']->setCategoryId($_REQUEST['category_id']); |
|
1264
|
|
|
$_SESSION['oLP']->set_modified_on(); |
|
1265
|
|
|
$_SESSION['oLP']->set_publicated_on($publicated_on); |
|
1266
|
|
|
$_SESSION['oLP']->set_expired_on($expired_on); |
|
1267
|
|
|
|
|
1268
|
|
|
if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) { |
|
1269
|
|
|
$_SESSION['oLP']->delete_lp_image(); |
|
1270
|
|
|
} |
|
1271
|
|
|
|
|
1272
|
|
|
$extraFieldValue = new ExtraFieldValue('lp'); |
|
1273
|
|
|
$_REQUEST['item_id'] = $_SESSION['oLP']->lp_id; |
|
1274
|
|
|
$extraFieldValue->saveFieldValues($_REQUEST); |
|
1275
|
|
|
|
|
1276
|
|
|
if ($_FILES['lp_preview_image']['size'] > 0) { |
|
1277
|
|
|
$_SESSION['oLP']->upload_image($_FILES['lp_preview_image']); |
|
1278
|
|
|
} |
|
1279
|
|
|
|
|
1280
|
|
|
$form = new FormValidator('form1'); |
|
1281
|
|
|
$form->addSelect('skills', 'skills'); |
|
1282
|
|
|
Skill::saveSkills($form, ITEM_TYPE_LEARNPATH, $_SESSION['oLP']->get_id()); |
|
1283
|
|
|
|
|
1284
|
|
|
if (api_get_setting('search_enabled') === 'true') { |
|
1285
|
|
|
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
1286
|
|
|
$specific_fields = get_specific_field_list(); |
|
1287
|
|
|
foreach ($specific_fields as $specific_field) { |
|
1288
|
|
|
$_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']); |
|
1289
|
|
|
$new_values = explode(',', trim($_REQUEST[$specific_field['code']])); |
|
1290
|
|
|
if (!empty($new_values)) { |
|
1291
|
|
|
array_walk($new_values, 'trim'); |
|
1292
|
|
|
delete_all_specific_field_value( |
|
1293
|
|
|
api_get_course_id(), |
|
1294
|
|
|
$specific_field['id'], |
|
1295
|
|
|
TOOL_LEARNPATH, |
|
1296
|
|
|
$_SESSION['oLP']->lp_id |
|
1297
|
|
|
); |
|
1298
|
|
|
|
|
1299
|
|
|
foreach ($new_values as $value) { |
|
1300
|
|
|
if (!empty($value)) { |
|
1301
|
|
|
add_specific_field_value( |
|
1302
|
|
|
$specific_field['id'], |
|
1303
|
|
|
api_get_course_id(), |
|
1304
|
|
|
TOOL_LEARNPATH, |
|
1305
|
|
|
$_SESSION['oLP']->lp_id, |
|
1306
|
|
|
$value |
|
1307
|
|
|
); |
|
1308
|
|
|
} |
|
1309
|
|
|
} |
|
1310
|
|
|
} |
|
1311
|
|
|
} |
|
1312
|
|
|
} |
|
1313
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
1314
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
1315
|
|
|
header('Location: '.$url); |
|
1316
|
|
|
exit; |
|
1317
|
|
|
} |
|
1318
|
|
|
break; |
|
1319
|
|
|
case 'add_sub_item': |
|
1320
|
|
|
// Add an item inside a dir/chapter. |
|
1321
|
|
|
// @todo check if this is @deprecated |
|
1322
|
|
|
if (!$is_allowed_to_edit) { |
|
1323
|
|
|
api_not_allowed(true); |
|
1324
|
|
|
} |
|
1325
|
|
|
if (!$lp_found) { |
|
1326
|
|
|
require 'lp_list.php'; |
|
1327
|
|
|
} else { |
|
1328
|
|
|
Session::write('refresh', 1); |
|
1329
|
|
|
if (!empty($_REQUEST['parent_item_id'])) { |
|
1330
|
|
|
$_SESSION['from_learnpath'] = 'yes'; |
|
1331
|
|
|
$_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.intval($_REQUEST['lp_id']); |
|
1332
|
|
|
} else { |
|
1333
|
|
|
require 'lp_admin_view.php'; |
|
1334
|
|
|
} |
|
1335
|
|
|
} |
|
1336
|
|
|
break; |
|
1337
|
|
|
case 'deleteitem': |
|
1338
|
|
|
case 'delete_item': |
|
1339
|
|
|
if (!$is_allowed_to_edit) { |
|
1340
|
|
|
api_not_allowed(true); |
|
1341
|
|
|
} |
|
1342
|
|
|
if (!$lp_found) { |
|
1343
|
|
|
require 'lp_list.php'; |
|
1344
|
|
|
} else { |
|
1345
|
|
|
if (!empty($_REQUEST['id'])) { |
|
1346
|
|
|
$_SESSION['oLP']->delete_item($_REQUEST['id']); |
|
1347
|
|
|
} |
|
1348
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).'&'.api_get_cidreq(); |
|
1349
|
|
|
header('Location: '.$url); |
|
1350
|
|
|
exit; |
|
1351
|
|
|
} |
|
1352
|
|
|
break; |
|
1353
|
|
|
case 'restart': |
|
1354
|
|
|
if (!$lp_found) { |
|
1355
|
|
|
require 'lp_list.php'; |
|
1356
|
|
|
} else { |
|
1357
|
|
|
$_SESSION['oLP']->restart(); |
|
1358
|
|
|
require 'lp_view.php'; |
|
1359
|
|
|
} |
|
1360
|
|
|
break; |
|
1361
|
|
|
case 'last': |
|
1362
|
|
|
if (!$lp_found) { |
|
1363
|
|
|
require 'lp_list.php'; |
|
1364
|
|
|
} else { |
|
1365
|
|
|
$_SESSION['oLP']->last(); |
|
1366
|
|
|
require 'lp_view.php'; |
|
1367
|
|
|
} |
|
1368
|
|
|
break; |
|
1369
|
|
|
case 'first': |
|
1370
|
|
|
if (!$lp_found) { |
|
1371
|
|
|
require 'lp_list.php'; |
|
1372
|
|
|
} else { |
|
1373
|
|
|
$_SESSION['oLP']->first(); |
|
1374
|
|
|
require 'lp_view.php'; |
|
1375
|
|
|
} |
|
1376
|
|
|
break; |
|
1377
|
|
|
case 'next': |
|
1378
|
|
|
if (!$lp_found) { |
|
1379
|
|
|
require 'lp_list.php'; |
|
1380
|
|
|
} else { |
|
1381
|
|
|
$_SESSION['oLP']->next(); |
|
1382
|
|
|
require 'lp_view.php'; |
|
1383
|
|
|
} |
|
1384
|
|
|
break; |
|
1385
|
|
|
case 'previous': |
|
1386
|
|
|
if (!$lp_found) { |
|
1387
|
|
|
require 'lp_list.php'; |
|
1388
|
|
|
} else { |
|
1389
|
|
|
$_SESSION['oLP']->previous(); |
|
1390
|
|
|
require 'lp_view.php'; |
|
1391
|
|
|
} |
|
1392
|
|
|
break; |
|
1393
|
|
|
case 'content': |
|
1394
|
|
|
if (!$lp_found) { |
|
1395
|
|
|
require 'lp_list.php'; |
|
1396
|
|
|
} else { |
|
1397
|
|
|
$_SESSION['oLP']->save_last(); |
|
1398
|
|
|
$_SESSION['oLP']->set_current_item($_GET['item_id']); |
|
1399
|
|
|
$_SESSION['oLP']->start_current_item(); |
|
1400
|
|
|
require 'lp_content.php'; |
|
1401
|
|
|
} |
|
1402
|
|
|
break; |
|
1403
|
|
|
case 'view': |
|
1404
|
|
|
if (!$lp_found) { |
|
1405
|
|
|
require 'lp_list.php'; |
|
1406
|
|
|
} else { |
|
1407
|
|
|
if (!empty($_REQUEST['item_id'])) { |
|
1408
|
|
|
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
1409
|
|
|
} |
|
1410
|
|
|
require 'lp_view.php'; |
|
1411
|
|
|
} |
|
1412
|
|
|
break; |
|
1413
|
|
|
case 'save': |
|
1414
|
|
|
if (!$lp_found) { |
|
1415
|
|
|
require 'lp_list.php'; |
|
1416
|
|
|
} else { |
|
1417
|
|
|
$_SESSION['oLP']->save_item(); |
|
1418
|
|
|
require 'lp_save.php'; |
|
1419
|
|
|
} |
|
1420
|
|
|
break; |
|
1421
|
|
|
case 'stats': |
|
1422
|
|
|
if (!$lp_found) { |
|
1423
|
|
|
require 'lp_list.php'; |
|
1424
|
|
|
} else { |
|
1425
|
|
|
$_SESSION['oLP']->save_current(); |
|
1426
|
|
|
$_SESSION['oLP']->save_last(); |
|
1427
|
|
|
$output = require 'lp_stats.php'; |
|
1428
|
|
|
echo $output; |
|
1429
|
|
|
} |
|
1430
|
|
|
break; |
|
1431
|
|
|
case 'list': |
|
1432
|
|
|
if ($lp_found) { |
|
1433
|
|
|
Session::write('refresh', 1); |
|
1434
|
|
|
$_SESSION['oLP']->save_last(); |
|
1435
|
|
|
} |
|
1436
|
|
|
require 'lp_list.php'; |
|
1437
|
|
|
break; |
|
1438
|
|
|
case 'mode': |
|
1439
|
|
|
// Switch between fullscreen and embedded mode. |
|
1440
|
|
|
$mode = $_REQUEST['mode']; |
|
1441
|
|
|
if ($mode == 'fullscreen') { |
|
1442
|
|
|
$_SESSION['oLP']->mode = 'fullscreen'; |
|
1443
|
|
|
} elseif ($mode == 'embedded') { |
|
1444
|
|
|
$_SESSION['oLP']->mode = 'embedded'; |
|
1445
|
|
|
} elseif ($mode == 'embedframe') { |
|
1446
|
|
|
$_SESSION['oLP']->mode = 'embedframe'; |
|
1447
|
|
|
} elseif ($mode == 'impress') { |
|
1448
|
|
|
$_SESSION['oLP']->mode = 'impress'; |
|
1449
|
|
|
} |
|
1450
|
|
|
require 'lp_view.php'; |
|
1451
|
|
|
break; |
|
1452
|
|
|
case 'switch_view_mode': |
|
1453
|
|
|
if (!$lp_found) { |
|
1454
|
|
|
require 'lp_list.php'; |
|
1455
|
|
|
} |
|
1456
|
|
|
if (Security::check_token('get')) { |
|
1457
|
|
|
Session::write('refresh', 1); |
|
1458
|
|
|
$_SESSION['oLP']->update_default_view_mode(); |
|
1459
|
|
|
} |
|
1460
|
|
|
require 'lp_list.php'; |
|
1461
|
|
|
break; |
|
1462
|
|
|
case 'switch_force_commit': |
|
1463
|
|
|
if (!$lp_found) { |
|
1464
|
|
|
require 'lp_list.php'; |
|
1465
|
|
|
} |
|
1466
|
|
|
Session::write('refresh', 1); |
|
1467
|
|
|
$_SESSION['oLP']->update_default_scorm_commit(); |
|
1468
|
|
|
require 'lp_list.php'; |
|
1469
|
|
|
break; |
|
1470
|
|
|
case 'switch_attempt_mode': |
|
1471
|
|
|
if (!$lp_found) { |
|
1472
|
|
|
require 'lp_list.php'; |
|
1473
|
|
|
} |
|
1474
|
|
|
Session::write('refresh', 1); |
|
1475
|
|
|
$_SESSION['oLP']->switch_attempt_mode(); |
|
1476
|
|
|
require 'lp_list.php'; |
|
1477
|
|
|
break; |
|
1478
|
|
|
case 'switch_scorm_debug': |
|
1479
|
|
|
if (!$lp_found) { |
|
1480
|
|
|
require 'lp_list.php'; |
|
1481
|
|
|
} |
|
1482
|
|
|
Session::write('refresh', 1); |
|
1483
|
|
|
$_SESSION['oLP']->update_scorm_debug(); |
|
1484
|
|
|
require 'lp_list.php'; |
|
1485
|
|
|
break; |
|
1486
|
|
|
case 'intro_cmdAdd': |
|
1487
|
|
|
// Add introduction section page. |
|
1488
|
|
|
break; |
|
1489
|
|
|
case 'return_to_course_homepage': |
|
1490
|
|
|
if (!$lp_found) { |
|
1491
|
|
|
require 'lp_list.php'; |
|
1492
|
|
|
} else { |
|
1493
|
|
|
$_SESSION['oLP']->save_current(); |
|
1494
|
|
|
$_SESSION['oLP']->save_last(); |
|
1495
|
|
|
if ($debug > 0) { |
|
1496
|
|
|
error_log('save_current()'); |
|
1497
|
|
|
error_log('save_last()'); |
|
1498
|
|
|
} |
|
1499
|
|
|
$url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id(); |
|
1500
|
|
|
$redirectTo = isset($_GET['redirectTo']) ? $_GET['redirectTo'] : ''; |
|
1501
|
|
|
switch ($redirectTo) { |
|
1502
|
|
|
case 'lp_list': |
|
1503
|
|
|
$url = 'lp_controller.php?'.api_get_cidreq(); |
|
1504
|
|
|
break; |
|
1505
|
|
|
case 'my_courses': |
|
1506
|
|
|
$url = api_get_path(WEB_PATH).'user_portal.php'; |
|
1507
|
|
|
break; |
|
1508
|
|
|
case 'portal_home': |
|
1509
|
|
|
$url = api_get_path(WEB_PATH); |
|
1510
|
|
|
break; |
|
1511
|
|
|
} |
|
1512
|
|
|
header('location: '.$url); |
|
1513
|
|
|
exit; |
|
1514
|
|
|
} |
|
1515
|
|
|
break; |
|
1516
|
|
|
case 'search': |
|
1517
|
|
|
/* Include the search script, it's smart enough to know when we are |
|
1518
|
|
|
* searching or not. |
|
1519
|
|
|
*/ |
|
1520
|
|
|
require 'lp_list_search.php'; |
|
1521
|
|
|
break; |
|
1522
|
|
|
case 'impress': |
|
1523
|
|
|
if (!$lp_found) { |
|
1524
|
|
|
require 'lp_list.php'; |
|
1525
|
|
|
} else { |
|
1526
|
|
|
if (!empty($_REQUEST['item_id'])) { |
|
1527
|
|
|
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
1528
|
|
|
} |
|
1529
|
|
|
require 'lp_impress.php'; |
|
1530
|
|
|
} |
|
1531
|
|
|
break; |
|
1532
|
|
|
case 'set_previous_step_as_prerequisite': |
|
1533
|
|
|
$_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items(); |
|
1534
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq(); |
|
1535
|
|
|
Display::addFlash(Display::return_message(get_lang('ItemUpdated'))); |
|
1536
|
|
|
header('Location: '.$url); |
|
1537
|
|
|
exit; |
|
1538
|
|
|
break; |
|
1539
|
|
|
case 'clear_prerequisites': |
|
1540
|
|
|
$_SESSION['oLP']->clear_prerequisites(); |
|
1541
|
|
|
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq(); |
|
1542
|
|
|
Display::addFlash(Display::return_message(get_lang('ItemUpdated'))); |
|
1543
|
|
|
header('Location: '.$url); |
|
1544
|
|
|
exit; |
|
1545
|
|
|
break; |
|
1546
|
|
|
case 'toggle_seriousgame': |
|
1547
|
|
|
// activate/deactive seriousgame_mode |
|
1548
|
|
|
if (!$is_allowed_to_edit) { |
|
1549
|
|
|
api_not_allowed(true); |
|
1550
|
|
|
} |
|
1551
|
|
|
|
|
1552
|
|
|
if (!$lp_found) { |
|
1553
|
|
|
require 'lp_list.php'; |
|
1554
|
|
|
} |
|
1555
|
|
|
|
|
1556
|
|
|
Session::write('refresh', 1); |
|
1557
|
|
|
$_SESSION['oLP']->set_seriousgame_mode(); |
|
1558
|
|
|
require 'lp_list.php'; |
|
1559
|
|
|
break; |
|
1560
|
|
|
case 'create_forum': |
|
1561
|
|
|
if (!isset($_GET['id'])) { |
|
1562
|
|
|
break; |
|
1563
|
|
|
} |
|
1564
|
|
|
|
|
1565
|
|
|
$selectedItem = null; |
|
1566
|
|
|
foreach ($_SESSION['oLP']->items as $item) { |
|
1567
|
|
|
if ($item->db_id == $_GET['id']) { |
|
1568
|
|
|
$selectedItem = $item; |
|
1569
|
|
|
} |
|
1570
|
|
|
} |
|
1571
|
|
|
|
|
1572
|
|
|
if (!empty($selectedItem)) { |
|
1573
|
|
|
$forumThread = $selectedItem->getForumThread( |
|
1574
|
|
|
$_SESSION['oLP']->course_int_id, |
|
1575
|
|
|
$_SESSION['oLP']->lp_session_id |
|
1576
|
|
|
); |
|
1577
|
|
|
|
|
1578
|
|
|
if (empty($forumThread)) { |
|
1579
|
|
|
require '../forum/forumfunction.inc.php'; |
|
1580
|
|
|
|
|
1581
|
|
|
$forumCategory = getForumCategoryByTitle( |
|
1582
|
|
|
get_lang('LearningPaths'), |
|
1583
|
|
|
$_SESSION['oLP']->course_int_id, |
|
1584
|
|
|
$_SESSION['oLP']->lp_session_id |
|
1585
|
|
|
); |
|
1586
|
|
|
|
|
1587
|
|
|
$forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id'] : 0; |
|
1588
|
|
|
|
|
1589
|
|
|
if (empty($forumCategoryId)) { |
|
1590
|
|
|
$forumCategoryId = store_forumcategory( |
|
1591
|
|
|
[ |
|
1592
|
|
|
'lp_id' => 0, |
|
1593
|
|
|
'forum_category_title' => get_lang('LearningPaths'), |
|
1594
|
|
|
'forum_category_comment' => null, |
|
1595
|
|
|
], |
|
1596
|
|
|
[], |
|
1597
|
|
|
false |
|
1598
|
|
|
); |
|
1599
|
|
|
} |
|
1600
|
|
|
|
|
1601
|
|
|
if (!empty($forumCategoryId)) { |
|
1602
|
|
|
$forum = $_SESSION['oLP']->getForum( |
|
1603
|
|
|
$_SESSION['oLP']->lp_session_id |
|
1604
|
|
|
); |
|
1605
|
|
|
|
|
1606
|
|
|
$forumId = !empty($forum) ? $forum['forum_id'] : 0; |
|
1607
|
|
|
|
|
1608
|
|
|
if (empty($forumId)) { |
|
1609
|
|
|
$forumId = $_SESSION['oLP']->createForum($forumCategoryId); |
|
1610
|
|
|
} |
|
1611
|
|
|
|
|
1612
|
|
|
if (!empty($forumId)) { |
|
1613
|
|
|
$selectedItem->createForumThread($forumId); |
|
1614
|
|
|
} |
|
1615
|
|
|
} |
|
1616
|
|
|
} |
|
1617
|
|
|
} |
|
1618
|
|
|
|
|
1619
|
|
|
header('Location:'.api_get_self().'?'.http_build_query([ |
|
1620
|
|
|
'action' => 'add_item', |
|
1621
|
|
|
'type' => 'step', |
|
1622
|
|
|
'lp_id' => $_SESSION['oLP']->lp_id, |
|
1623
|
|
|
])); |
|
1624
|
|
|
exit; |
|
1625
|
|
|
|
|
1626
|
|
|
break; |
|
1627
|
|
|
case 'report': |
|
1628
|
|
|
require 'lp_report.php'; |
|
1629
|
|
|
break; |
|
1630
|
|
|
case 'dissociate_forum': |
|
1631
|
|
|
if (!isset($_GET['id'])) { |
|
1632
|
|
|
break; |
|
1633
|
|
|
} |
|
1634
|
|
|
|
|
1635
|
|
|
$selectedItem = null; |
|
1636
|
|
|
foreach ($_SESSION['oLP']->items as $item) { |
|
1637
|
|
|
if ($item->db_id != $_GET['id']) { |
|
1638
|
|
|
continue; |
|
1639
|
|
|
} |
|
1640
|
|
|
$selectedItem = $item; |
|
1641
|
|
|
} |
|
1642
|
|
|
|
|
1643
|
|
|
if (!empty($selectedItem)) { |
|
1644
|
|
|
$forumThread = $selectedItem->getForumThread( |
|
1645
|
|
|
$_SESSION['oLP']->course_int_id, |
|
1646
|
|
|
$_SESSION['oLP']->lp_session_id |
|
1647
|
|
|
); |
|
1648
|
|
|
|
|
1649
|
|
|
if (!empty($forumThread)) { |
|
1650
|
|
|
$dissociated = $selectedItem->dissociateForumThread($forumThread['iid']); |
|
1651
|
|
|
|
|
1652
|
|
|
if ($dissociated) { |
|
1653
|
|
|
Display::addFlash( |
|
1654
|
|
|
Display::return_message(get_lang('ForumDissociate'), 'success') |
|
1655
|
|
|
); |
|
1656
|
|
|
} |
|
1657
|
|
|
} |
|
1658
|
|
|
} |
|
1659
|
|
|
|
|
1660
|
|
|
header('Location:'.api_get_self().'?'.http_build_query([ |
|
1661
|
|
|
'action' => 'add_item', |
|
1662
|
|
|
'type' => 'step', |
|
1663
|
|
|
'lp_id' => $_SESSION['oLP']->lp_id, |
|
1664
|
|
|
])); |
|
1665
|
|
|
exit; |
|
1666
|
|
|
break; |
|
1667
|
|
|
case 'add_final_item': |
|
1668
|
|
|
if (!$lp_found) { |
|
1669
|
|
|
Display::addFlash( |
|
1670
|
|
|
Display::return_message(get_lang('NoLPFound'), 'error') |
|
1671
|
|
|
); |
|
1672
|
|
|
break; |
|
1673
|
|
|
} |
|
1674
|
|
|
|
|
1675
|
|
|
Session::write('refresh', 1); |
|
1676
|
|
|
if (!isset($_POST['submit']) || empty($post_title)) { |
|
1677
|
|
|
break; |
|
1678
|
|
|
} |
|
1679
|
|
|
|
|
1680
|
|
|
$_SESSION['oLP']->getFinalItemForm(); |
|
1681
|
|
|
$redirectTo = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([ |
|
1682
|
|
|
'action' => 'add_item', |
|
1683
|
|
|
'type' => 'step', |
|
1684
|
|
|
'lp_id' => intval($_SESSION['oLP']->lp_id), |
|
1685
|
|
|
]); |
|
1686
|
|
|
break; |
|
1687
|
|
|
default: |
|
1688
|
|
|
require 'lp_list.php'; |
|
1689
|
|
|
break; |
|
1690
|
|
|
} |
|
1691
|
|
|
|
|
1692
|
|
|
if (!empty($_SESSION['oLP'])) { |
|
1693
|
|
|
$_SESSION['lpobject'] = serialize($_SESSION['oLP']); |
|
1694
|
|
|
if ($debug > 0) { |
|
1695
|
|
|
error_log('lpobject is serialized in session', 0); |
|
1696
|
|
|
} |
|
1697
|
|
|
} |
|
1698
|
|
|
|
|
1699
|
|
|
if (!empty($redirectTo)) { |
|
1700
|
|
|
header("Location: $redirectTo"); |
|
1701
|
|
|
exit; |
|
1702
|
|
|
} |
|
1703
|
|
|
|