lp_controller.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php //$id: $
  2. /**
  3. * Controller script. Prepares the common background variables to give to the scripts corresponding to
  4. * the requested action
  5. * @package dokeos.learnpath
  6. * @author Yannick Warnier <ywarnier@beeznest.org>
  7. */
  8. /**
  9. * Initialisations
  10. */
  11. $debug = 0;
  12. if($debug>0) error_log('New LP -+- Entered lp_controller.php -+-',0);
  13. $langFile[] = "scormdocument";
  14. $langFile[] = "scorm";
  15. $langFile[] = "learnpath";
  16. //include class definitions before session_start() to ensure availability when touching
  17. //session vars containing learning paths
  18. require_once('learnpath.class.php');
  19. if($debug>0) error_log('New LP - Included learnpath',0);
  20. require_once('learnpathItem.class.php');
  21. if($debug>0) error_log('New LP - Included learnpathItem',0);
  22. require_once('scorm.class.php');
  23. if($debug>0) error_log('New LP - Included scorm',0);
  24. require_once('scormItem.class.php');
  25. if($debug>0) error_log('New LP - Included scormItem',0);
  26. require_once('aicc.class.php');
  27. if($debug>0) error_log('New LP - Included aicc',0);
  28. require_once('aiccItem.class.php');
  29. if($debug>0) error_log('New LP - Included aiccItem',0);
  30. require_once('back_compat.inc.php');
  31. if($debug>0) error_log('New LP - Included back_compat',0);
  32. api_protect_course_script();
  33. //TODO @TODO define tool, action and task to give as parameters to:
  34. //$is_allowed_to_edit = api_is_allowed_to_edit();
  35. if ($is_allowed_in_course == false){
  36. Display::display_header('');
  37. api_not_allowed();
  38. Display::display_footer();
  39. }
  40. require_once(api_get_path(LIBRARY_PATH) . "/fckeditor.lib.php");
  41. $lpfound = false;
  42. $myrefresh = 0;
  43. $myrefresh_id = 0;
  44. if(!empty($_SESSION['refresh']) && $_SESSION['refresh']==1){
  45. //check if we should do a refresh of the oLP object (for example after editing the LP)
  46. //if refresh is set, we regenerate the oLP object from the database (kind of flush)
  47. api_session_unregister('refresh');
  48. $myrefresh = 1;
  49. if($debug>0) error_log('New LP - Refresh asked',0);
  50. }
  51. if($debug>0) error_log('New LP - Passed refresh check',0);
  52. if(!empty($_REQUEST['dialog_box'])){
  53. $dialog_box = learnpath::escape_string(urldecode($_REQUEST['dialog_box']));
  54. }
  55. $lp_controller_touched = 1;
  56. if(isset($_SESSION['lpobject']))
  57. {
  58. if($debug>0) error_log('New LP - SESSION[lpobject] is defined',0);
  59. $oLP = unserialize($_SESSION['lpobject']);
  60. if(is_object($oLP)){
  61. if($debug>0) error_log('New LP - oLP is object',0);
  62. if($myrefresh == 1 OR $oLP->cc != api_get_course_id()){
  63. if($debug>0) error_log('New LP - Course has changed, discard lp object',0);
  64. if($myrefresh == 1){$myrefresh_id = $oLP->get_id();}
  65. $oLP = null;
  66. api_session_unregister('oLP');
  67. api_session_unregister('lpobject');
  68. }else{
  69. $_SESSION['oLP'] = $oLP;
  70. $lp_found = true;
  71. }
  72. }
  73. }
  74. if($debug>0) error_log('New LP - Passed data remains check',0);
  75. if($lp_found == false
  76. || ($_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])
  77. )
  78. {
  79. if($debug>0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new',0);
  80. //regenerate a new lp object? Not always as some pages don't need the object (like upload?)
  81. if(!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)){
  82. if($debug>0) error_log('New LP - lp_id is defined',0);
  83. //select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
  84. //right object
  85. $lp_table = Database::get_course_table('lp');
  86. if(!empty($_REQUEST['lp_id'])){
  87. $lp_id = learnpath::escape_string($_REQUEST['lp_id']);
  88. }else{
  89. $lp_id = $myrefresh_id;
  90. }
  91. $sel = "SELECT * FROM $lp_table WHERE id = $lp_id";
  92. if($debug>0) error_log('New LP - querying '.$sel,0);
  93. $res = api_sql_query($sel);
  94. if(Database::num_rows($res))
  95. {
  96. $row = Database::fetch_array($res);
  97. $type = $row['lp_type'];
  98. if($debug>0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
  99. switch($type){
  100. case 1:
  101. if($debug>0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
  102. $oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
  103. if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
  104. break;
  105. case 2:
  106. if($debug>0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
  107. $oLP = new scorm(api_get_course_id(),$lp_id,api_get_user_id());
  108. if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
  109. break;
  110. case 3:
  111. if($debug>0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
  112. $oLP = new aicc(api_get_course_id(),$lp_id,api_get_user_id());
  113. if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
  114. break;
  115. default:
  116. if($debug>0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);
  117. $oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
  118. if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);}
  119. break;
  120. }
  121. }
  122. }else{
  123. if($debug>0) error_log('New LP - Request[lp_id] and refresh_id were empty',0);
  124. }
  125. if($lp_found)
  126. {
  127. $_SESSION['oLP'] = $oLP;
  128. }
  129. }
  130. if($debug>0) error_log('New LP - Passed oLP creation check',0);
  131. /**
  132. * Actions switching
  133. */
  134. $_SESSION['oLP']->update_queue = array(); //reinitialises array used by javascript to update items in the TOC
  135. $_SESSION['oLP']->message = ''; //should use ->clear_message() method but doesn't work
  136. if($_GET['isStudentView'] == 'true')
  137. $_REQUEST['action'] = 'view';
  138. switch($_REQUEST['action'])
  139. {
  140. case 'add_item':
  141. if($debug > 0) error_log('New LP - add item action triggered', 0);
  142. if(!$lp_found){ error_log('New LP - No learnpath given for add item', 0); require('lp_list.php'); }
  143. else
  144. {
  145. $_SESSION['refresh'] = 1;
  146. if(isset($_POST['submit_button']) && !empty($_POST['title']))
  147. {
  148. if(isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time'])
  149. {
  150. require('kevin_lp_add_item.php');
  151. }
  152. else
  153. {
  154. $_SESSION['post_time'] = $_POST['post_time'];
  155. /*if($_REQUEST['type'] != 'dokeos_chapter' && $_REQUEST['type'] != 'dokeos_module' && $_REQUEST['type'] != 'dokeos_step')
  156. {
  157. $_REQUEST['type'] = 'dokeos_module';
  158. }*/
  159. if($_POST['type'] == TOOL_DOCUMENT)
  160. {
  161. if(isset($_POST['path']) && $_GET['edit'] != 'true')
  162. {
  163. $document_id = $_POST['path'];
  164. }
  165. else
  166. {
  167. $document_id = $_SESSION['oLP']->create_document($_course);
  168. }
  169. $new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $document_id, $_POST['title'], $_POST['description']);
  170. }
  171. else
  172. {
  173. $new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $_POST['path'], $_POST['title'], $_POST['description']);
  174. }
  175. require('kevin_lp_add_item.php');
  176. }
  177. }
  178. else
  179. {
  180. require('kevin_lp_add_item.php');
  181. }
  182. }
  183. break;
  184. case 'add_lp':
  185. if($debug > 0) error_log('New LP - add_lp action triggered', 0);
  186. $_REQUEST['learnpath_name'] = trim($_REQUEST['learnpath_name']);
  187. if(!empty($_REQUEST['learnpath_name']))
  188. {
  189. $_SESSION['refresh'] = 1;
  190. if(isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time'])
  191. {
  192. require('kevin_lp_add.php');
  193. }
  194. else
  195. {
  196. $_SESSION['post_time'] = $_REQUEST['post_time'];
  197. //Kevin Van Den Haute: changed $_REQUEST['learnpath_description'] by '' because it's not used
  198. //old->$new_lp_id = learnpath::add_lp(api_get_course_id(), $_REQUEST['learnpath_name'], $_REQUEST['learnpath_description'], 'dokeos', 'manual', '');
  199. $new_lp_id = learnpath::add_lp(api_get_course_id(), $_REQUEST['learnpath_name'], '', 'dokeos', 'manual', '');
  200. //Kevin Van Den Haute: only go further if learnpath::add_lp has returned an id
  201. if(is_numeric($new_lp_id))
  202. {
  203. //TODO maybe create a first module directly to avoid bugging the user with useless queries
  204. $_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
  205. //$_SESSION['oLP']->add_item(0,-1,'dokeos_chapter',$_REQUEST['path'],'Default');
  206. require('kevin_lp_build.php');
  207. }
  208. }
  209. }
  210. else
  211. require('kevin_lp_add.php');
  212. break;
  213. case 'admin_view':
  214. if($debug>0) error_log('New LP - admin_view action triggered',0);
  215. if(!$lp_found){ error_log('New LP - No learnpath given for admin_view', 0); require('lp_list.php'); }
  216. else
  217. {
  218. $_SESSION['refresh'] = 1;
  219. require('kevin_lp_admin_view.php');
  220. }
  221. break;
  222. case 'build':
  223. if($debug > 0) error_log('New LP - build action triggered', 0);
  224. if(!$lp_found){ error_log('New LP - No learnpath given for build', 0); require('lp_list.php'); }
  225. else
  226. {
  227. $_SESSION['refresh'] = 1;
  228. require('kevin_lp_build.php');
  229. }
  230. break;
  231. case 'delete_item':
  232. if($debug > 0) error_log('New LP - delete item action triggered', 0);
  233. if(!$lp_found){ error_log('New LP - No learnpath given for delete item', 0); require('lp_list.php'); }
  234. else
  235. {
  236. $_SESSION['refresh'] = 1;
  237. if(is_numeric($_GET['id']))
  238. {
  239. $_SESSION['oLP']->delete_item($_GET['id']);
  240. $is_success = true;
  241. }
  242. if(isset($_GET['view']) && $_GET['view'] == 'build')
  243. {
  244. require('kevin_lp_build.php');
  245. }
  246. else
  247. {
  248. require('kevin_lp_admin_view.php');
  249. }
  250. }
  251. break;
  252. case 'edit_item':
  253. if($debug > 0) error_log('New LP - edit item action triggered', 0);
  254. if(!$lp_found){ error_log('New LP - No learnpath given for edit item', 0); require('lp_list.php'); }
  255. else
  256. {
  257. $_SESSION['refresh'] = 1;
  258. if(isset($_POST['submit_button']) && !empty($_POST['title']))
  259. {
  260. $_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description']);
  261. if(isset($_POST['content']))
  262. {
  263. $_SESSION['oLP']->edit_document($_course);
  264. }
  265. $is_success = true;
  266. }
  267. if(isset($_GET['view']) && $_GET['view'] == 'build')
  268. {
  269. require('kevin_lp_edit_item.php');
  270. }
  271. else
  272. {
  273. require('kevin_lp_admin_view.php');
  274. }
  275. }
  276. break;
  277. case 'edit_item_prereq':
  278. if($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
  279. if(!$lp_found){ error_log('New LP - No learnpath given for edit item prereq', 0); require('lp_list.php'); }
  280. else
  281. {
  282. if(isset($_POST['submit_button']))
  283. {
  284. $_SESSION['refresh'] = 1;
  285. $_SESSION['oLP']->edit_item_prereq($_GET['id'], $_POST['prerequisites'], $_POST['min_' . $_POST['prerequisites']], $_POST['max_' . $_POST['prerequisites']]);
  286. }
  287. require('kevin_lp_edit_item_prereq.php');
  288. }
  289. break;
  290. case 'move_item':
  291. if($debug > 0) error_log('New LP - move item action triggered', 0);
  292. if(!$lp_found){ error_log('New LP - No learnpath given for move item', 0); require('lp_list.php'); }
  293. else
  294. {
  295. $_SESSION['refresh'] = 1;
  296. if(isset($_POST['submit_button']))
  297. {
  298. $_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description']);
  299. $is_success = true;
  300. }
  301. if(isset($_GET['view']) && $_GET['view'] == 'build')
  302. {
  303. require('kevin_lp_move_item.php');
  304. }
  305. else
  306. {
  307. $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
  308. require('kevin_lp_admin_view.php');
  309. }
  310. }
  311. break;
  312. case 'view_item':
  313. if($debug>0) error_log('New LP - view_item action triggered', 0);
  314. if(!$lp_found){ error_log('New LP - No learnpath given for view item', 0); require('lp_list.php'); }
  315. else
  316. {
  317. $_SESSION['refresh'] = 1;
  318. require('kevin_lp_view_item.php');
  319. }
  320. break;
  321. case 'upload':
  322. if($debug>0) error_log('New LP - upload action triggered',0);
  323. $cwdir = getcwd();
  324. require('lp_upload.php');
  325. //reinit current working directory as many functions in upload change it
  326. chdir($cwdir);
  327. require('lp_list.php');
  328. break;
  329. case 'export':
  330. if($debug>0) error_log('New LP - export action triggered',0);
  331. if(!$lp_found){ error_log('New LP - No learnpath given for export',0); require('lp_list.php'); }
  332. else{
  333. if($_SESSION['oLP']->get_type()==2){
  334. $_SESSION['oLP']->export_zip();
  335. }
  336. //require('lp_list.php');
  337. }
  338. break;
  339. case 'delete':
  340. if($debug>0) error_log('New LP - delete action triggered',0);
  341. if(!$lp_found){ error_log('New LP - No learnpath given for delete',0); require('lp_list.php'); }
  342. else{
  343. $_SESSION['refresh'] = 1;
  344. $_SESSION['oLP']->delete(null,null,'remove');
  345. api_session_unregister('oLP');
  346. //require('lp_delete.php');
  347. require('lp_list.php');
  348. }
  349. break;
  350. case 'toggle_visible': //change lp visibility
  351. if($debug>0) error_log('New LP - publish action triggered',0);
  352. if(!$lp_found){ error_log('New LP - No learnpath given for publish',0); require('lp_list.php'); }
  353. else{
  354. learnpath::toggle_visibility($_REQUEST['lp_id'],$_REQUEST['new_status']);
  355. require('lp_list.php');
  356. }
  357. break;
  358. case 'edit':
  359. if($debug>0) error_log('New LP - edit action triggered',0);
  360. if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); }
  361. else{
  362. $_SESSION['refresh'] = 1;
  363. require('lp_edit.php');
  364. //require('lp_admin_view.php');
  365. }
  366. break;
  367. case 'update_lp':
  368. if($debug>0) error_log('New LP - update_lp action triggered',0);
  369. if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); }
  370. else{
  371. $_SESSION['refresh'] = 1;
  372. $_SESSION['oLP']->set_name($_REQUEST['lp_name']);
  373. $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
  374. $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
  375. $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
  376. require('lp_list.php');
  377. }
  378. break;
  379. /*case 'add_lp':
  380. if($debug>0) error_log('New LP - add_lp action triggered',0);
  381. //call learnpath creation abstract method with course_id, learnpath_name, learnpath_description, type_of_lp, origin_of_creation, file_name
  382. if(!empty($_REQUEST['learnpath_name'])){
  383. $_SESSION['refresh'] = 1;
  384. $new_lp_id = learnpath::add_lp(api_get_course_id(),$_REQUEST['learnpath_name'],$_REQUEST['learnpath_description'],'dokeos','manual','');
  385. //TODO maybe create a first module directly to avoid bugging the user with useless queries
  386. $_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
  387. $_SESSION['oLP']->add_item(0,-1,'dokeos_chapter',$_REQUEST['path'],'Default');
  388. }
  389. require('lp_list.php');
  390. break;*/
  391. case 'add_sub_item': //add an item inside a chapter
  392. if($debug>0) error_log('New LP - add sub item action triggered',0);
  393. if(!$lp_found){ error_log('New LP - No learnpath given for add sub item',0); require('lp_list.php'); }
  394. else{
  395. $_SESSION['refresh'] = 1;
  396. if(!empty($_REQUEST['parent_item_id'])){
  397. $_SESSION['from_learnpath']='yes';
  398. $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.$_REQUEST['lp_id'];
  399. require('resourcelinker.php');
  400. //$_SESSION['oLP']->add_sub_item($_REQUEST['parent_item_id'],$_REQUEST['previous'],$_REQUEST['type'],$_REQUEST['path'],$_REQUEST['title']);
  401. }else{
  402. require('lp_admin_view.php');
  403. }
  404. }
  405. break;
  406. case 'deleteitem':
  407. case 'delete_item':
  408. if($debug>0) error_log('New LP - delete item action triggered',0);
  409. if(!$lp_found){ error_log('New LP - No learnpath given for delete item',0); require('lp_list.php'); }
  410. else{
  411. $_SESSION['refresh'] = 1;
  412. if(!empty($_REQUEST['id'])){
  413. $_SESSION['oLP']->delete_item($_REQUEST['id']);
  414. }
  415. require('lp_admin_view.php');
  416. }
  417. break;
  418. /*case 'edititem':
  419. case 'edit_item':
  420. if($debug>0) error_log('New LP - edit item action triggered',0);
  421. if(!$lp_found){ error_log('New LP - No learnpath given for edit item',0); require('lp_list.php'); }
  422. else{
  423. if(!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])){
  424. $_SESSION['refresh'] = 1;
  425. $_SESSION['oLP']->edit_item($_REQUEST['id'], $_REQUEST['title']);
  426. }
  427. require('lp_admin_view.php');
  428. }
  429. break;
  430. */
  431. case 'edititemprereq':
  432. case 'edit_item_prereq':
  433. if($debug>0) error_log('New LP - edit item prereq action triggered',0);
  434. if(!$lp_found){ error_log('New LP - No learnpath given for edit item prereq',0); require('lp_list.php'); }
  435. else{
  436. if(!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])){
  437. $_SESSION['refresh'] = 1;
  438. $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'],$_REQUEST['prereq']);
  439. }
  440. require('lp_admin_view.php');
  441. }
  442. break;
  443. case 'restart':
  444. if($debug>0) error_log('New LP - restart action triggered',0);
  445. if(!$lp_found){ error_log('New LP - No learnpath given for restart',0); require('lp_list.php'); }
  446. else{
  447. $_SESSION['oLP']->restart();
  448. require('lp_view.php');
  449. }
  450. break;
  451. case 'last':
  452. if($debug>0) error_log('New LP - last action triggered',0);
  453. if(!$lp_found){ error_log('New LP - No learnpath given for last',0); require('lp_list.php'); }
  454. else{
  455. $_SESSION['oLP']->last();
  456. require('lp_view.php');
  457. }
  458. break;
  459. case 'first':
  460. if($debug>0) error_log('New LP - first action triggered',0);
  461. if(!$lp_found){ error_log('New LP - No learnpath given for first',0); require('lp_list.php'); }
  462. else{
  463. $_SESSION['oLP']->first();
  464. require('lp_view.php');
  465. }
  466. break;
  467. case 'next':
  468. if($debug>0) error_log('New LP - next action triggered',0);
  469. if(!$lp_found){ error_log('New LP - No learnpath given for next',0); require('lp_list.php'); }
  470. else{
  471. $_SESSION['oLP']->next();
  472. require('lp_view.php');
  473. }
  474. break;
  475. case 'previous':
  476. if($debug>0) error_log('New LP - previous action triggered',0);
  477. if(!$lp_found){ error_log('New LP - No learnpath given for previous',0); require('lp_list.php'); }
  478. else{
  479. $_SESSION['oLP']->previous();
  480. require('lp_view.php');
  481. }
  482. break;
  483. case 'content':
  484. if($debug>0) error_log('New LP - content action triggered',0);
  485. if($debug>0) error_log('New LP - Item id is '.$_GET['item_id'],0);
  486. if(!$lp_found){ error_log('New LP - No learnpath given for content',0); require('lp_list.php'); }
  487. else{
  488. $_SESSION['oLP']->set_current_item($_GET['item_id']);
  489. $_SESSION['oLP']->start_current_item();
  490. require('lp_content.php');
  491. }
  492. break;
  493. case 'view':
  494. if($debug > 0)
  495. error_log('New LP - view action triggered', 0);
  496. if(!$lp_found)
  497. {
  498. error_log('New LP - No learnpath given for view', 0);
  499. require('lp_list.php');
  500. }
  501. else
  502. {
  503. if($debug > 0){error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0);}
  504. $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
  505. require('lp_view.php');
  506. }
  507. break;
  508. case 'save':
  509. if($debug>0) error_log('New LP - save action triggered',0);
  510. if(!$lp_found){ error_log('New LP - No learnpath given for save',0); require('lp_list.php'); }
  511. else{
  512. $_SESSION['oLP']->save_item();
  513. require('lp_save.php');
  514. }
  515. break;
  516. case 'stats':
  517. if($debug>0) error_log('New LP - stats action triggered',0);
  518. if(!$lp_found){ error_log('New LP - No learnpath given for stats',0); require('lp_list.php'); }
  519. else{
  520. $_SESSION['oLP']->save_current();
  521. $_SESSION['oLP']->save_last();
  522. require('lp_stats.php');
  523. }
  524. break;
  525. case 'list':
  526. if($debug>0) error_log('New LP - list action triggered',0);
  527. if($lp_found){
  528. $_SESSION['refresh'] = 1;
  529. $_SESSION['oLP']->save_last();
  530. }
  531. require('lp_list.php');
  532. break;
  533. case 'mode':
  534. //switch between fullscreen and embedded mode
  535. if($debug>0) error_log('New LP - mode change triggered',0);
  536. $mode = $_REQUEST['mode'];
  537. if($mode == 'fullscreen'){
  538. $_SESSION['oLP']->mode = 'fullscreen';
  539. }else{
  540. $_SESSION['oLP']->mode = 'embedded';
  541. }
  542. require('lp_view.php');
  543. break;
  544. case 'switch_view_mode':
  545. if($debug>0) error_log('New LP - switch_view_mode action triggered',0);
  546. if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
  547. $_SESSION['refresh'] = 1;
  548. $_SESSION['oLP']->update_default_view_mode();
  549. require('lp_list.php');
  550. break;
  551. case 'switch_force_commit':
  552. if($debug>0) error_log('New LP - switch_force_commit action triggered',0);
  553. if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
  554. $_SESSION['refresh'] = 1;
  555. $_SESSION['oLP']->update_default_scorm_commit();
  556. require('lp_list.php');
  557. break;
  558. case 'switch_reinit':
  559. if($debug>0) error_log('New LP - switch_reinit action triggered',0);
  560. if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
  561. $_SESSION['refresh'] = 1;
  562. $_SESSION['oLP']->update_reinit();
  563. require('lp_list.php');
  564. break;
  565. case 'switch_scorm_debug':
  566. if($debug>0) error_log('New LP - switch_scorm_debug action triggered',0);
  567. if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); }
  568. $_SESSION['refresh'] = 1;
  569. $_SESSION['oLP']->update_scorm_debug();
  570. require('lp_list.php');
  571. break;
  572. case 'intro_cmdAdd':
  573. if($debug>0) error_log('New LP - intro_cmdAdd action triggered',0);
  574. //add introduction section page
  575. break;
  576. /*
  577. case 'moveitem':
  578. case 'move_item':
  579. if($debug > 0)
  580. error_log('New LP - move_item action triggered', 0);
  581. if(!$lp_found)
  582. {
  583. error_log('New LP - No learnpath given for move_item', 0);
  584. require('lp_list.php');
  585. }
  586. if(!empty($_REQUEST['direction']) && !empty($_REQUEST['id']))
  587. {
  588. $_SESSION['refresh'] = 1;
  589. $_SESSION['oLP']->move_item($_REQUEST['id'], $_REQUEST['direction']);
  590. }
  591. require('lp_admin_view.php');
  592. break;
  593. */
  594. case 'js_api_refresh':
  595. if($debug>0) error_log('New LP - js_api_refresh action triggered',0);
  596. if(!$lp_found){ error_log('New LP - No learnpath given for js_api_refresh',0); require('lp_message.php'); }
  597. if(isset($_REQUEST['item_id'])){
  598. $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
  599. }
  600. require('lp_message.php');
  601. break;
  602. default:
  603. if($debug>0) error_log('New LP - default action triggered',0);
  604. //$_SESSION['refresh'] = 1;
  605. require('lp_list.php');
  606. break;
  607. }
  608. if(!empty($_SESSION['oLP'])){
  609. $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
  610. if($debug>0) error_log('New LP - lpobject is serialized in session',0);
  611. }
  612. ?>