lp_controller.php 23 KB

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