"; /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ $is_allowed_to_edit = api_is_allowed_to_edit(); $tbl_learnpath_item = Database::get_course_table(LEARNPATH_ITEM_TABLE); $tbl_learnpath_chapter = Database::get_course_table(LEARNPATH_CHAPTER_TABLE); $tbl_learnpath_main = Database::get_course_table(LEARNPATH_MAIN_TABLE); $tbl_learnpath_user = Database::get_course_table(LEARNPATH_USER_TABLE); $learnpath_id = mysql_real_escape_string($_GET['learnpath_id']); $chapter_id = $_GET['chapter_id']; $titel = $_POST['titel']; $omschrijving = $_POST['omschrijving']; $Submit = $_POST['Submit']; $Submititem = $_POST['Submititem']; $action = $_REQUEST['action']; $type = $_REQUEST['type']; $id = $_REQUEST['id']; $direction = $_REQUEST['direction']; $moduleid = $_REQUEST['moduleid']; $prereq = $_REQUEST['prereq']; $type = $_REQUEST['type']; $isStudentView = $_REQUEST['isStudentView']; /* ============================================================================== MAIN CODE ============================================================================== */ // using the resource linker as a tool for adding resources to the learning path if ($action=="add" and $type=="learnpathitem") { $htmlHeadXtra[] = ""; } if ( (! $is_allowed_to_edit) or ($isStudentView) ) { $htmlHeadXtra[] = ""; } $sql_query = "SELECT * FROM $tbl_learnpath_main WHERE learnpath_id = '$learnpath_id'"; $result=api_sql_query($sql_query); $therow=mysql_fetch_array($result); if (api_is_allowed_to_edit()) { $interbreadcrumb[]= array ("url"=>"../scorm/scormdocument.php", "name"=> get_lang("_learning_path")); /*----------------------------------------------------------- SPECIAL REDIRECTION IF NEEDED -----------------------------------------------------------*/ if (($action!="add" or $type!="learnpathcategory")) { //in case the user hasn't selected the "add module" link previously, first quick-check the database to remove the //useless step of asking the user to click on "add module" if the only possible action is to add a module $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE learnpath_id = $learnpath_id"; $result=api_sql_query($sql,__FILE__,__LINE__); if (Database::num_rows($result) == 0) { header('location:../learnpath/learnpath_handler.php?'.api_get_cidreq().'&learnpath_id='.$learnpath_id.'&action=add&type=learnpathcategory'); exit(); } }//otherwise proceed as usual } $interbreadcrumb[]= array ("url"=>$_SERVER['PHP_SELF']."?learnpath_id=$learnpath_id", "name" => "{$therow['learnpath_name']}"); //include(api_get_path(LIBRARY_PATH).'events.lib.inc.php'); //event_access_tool($nameTools); Display::display_header(null,'Path'); api_display_tool_title($therow['learnpath_name']); ?> /* */ "; /* ----------------------------------------------------------- Course admin section - all the functions not available for students ----------------------------------------------------------- */ if(api_is_allowed_to_edit()) { /*----------------------------------------------------------- DELETE A LEARNPATH chapter and all the items in it -----------------------------------------------------------*/ if ($action=="deletemodule" and !empty($id)) { deletemodule($id); Display :: display_normal_message(get_lang("_learnpath_module_deleted")); } /*----------------------------------------------------------- MOVING A LEARNPATH module -----------------------------------------------------------*/ if ($action=="movemodule" and !empty($direction) and !empty($id)) { movemodule($direction,$id); } /*----------------------------------------------------------- DELETE A LEARNPATH chapter and all the items in it -----------------------------------------------------------*/ if ($action=="deleteitem" and !empty($id)) { deleteitem($id); Display :: display_normal_message(get_lang("_learnpath_item_deleted")); } /*----------------------------------------------------------- MOVING A LEARNPATH ITEM -----------------------------------------------------------*/ if ($action=="moveitem" and !empty($direction) and !empty($id) and !empty($moduleid) and !empty($type)) { moveitem($direction,$id,$moduleid,$type); } /*----------------------------------------------------------- EDITING A NEW LEARNPATH ITEM: treating the form -----------------------------------------------------------*/ if ($Submititem and $id) { if ($prereq) { if ($prereq != "none") { $which=substr($prereq,0,1); //c=chapter, i=item $prereq=substr($prereq,1,strlen($prereq)); $prereq_completion_limit=$completion_limit[$prereq]; $sql ="UPDATE $tbl_learnpath_item SET prereq_id='$prereq', prereq_type='$which', prereq_completion_limit='$prereq_completion_limit' WHERE id=$id"; } else { $sql ="UPDATE $tbl_learnpath_item SET prereq_id=NULL, prereq_type=NULL, prereq_completion_limit=NULL WHERE id=$id"; } } else { if (($title) or ($description)) { $sql ="UPDATE $tbl_learnpath_item SET title='".domesticate(htmlspecialchars($title))."', description='".domesticate(htmlspecialchars($description))."' WHERE id=$id"; } } $result=api_sql_query($sql,__FILE__,__LINE__); Display :: display_normal_message(get_lang("_learnpath_item_edited")); } /*----------------------------------------------------------- ADDING A NEW LEARNPATH chapter: treating the form -----------------------------------------------------------*/ if ($action=="add" and $type=="learnpathcategory" and $Submit) { // getting the last order number of the chapters $sql="SELECT * FROM $tbl_learnpath_chapter WHERE learnpath_id=$learnpath_id ORDER BY display_order desc"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result); $last_order=$row["display_order"]; $new_order=$last_order+1; $sql ="INSERT INTO $tbl_learnpath_chapter (learnpath_id, chapter_name, chapter_description, display_order) VALUES ('".domesticate($learnpath_id)."', '".domesticate(htmlspecialchars($titel))."','".domesticate(htmlspecialchars($omschrijving))."', '".domesticate($new_order)."')"; $result=api_sql_query($sql,__FILE__,__LINE__); Display :: display_normal_message(get_lang("_learnpath_module_added")); } /*----------------------------------------------------------- EDITING A NEW LEARNPATH chapter: treating the form -----------------------------------------------------------*/ if ($action=="editmodule" and $Submit) { $sql ="UPDATE $tbl_learnpath_chapter SET chapter_name='".domesticate(htmlspecialchars($titel))."', chapter_description='".domesticate(htmlspecialchars($omschrijving))."' WHERE (id=$id and learnpath_id=$learnpath_id)"; $result=api_sql_query($sql,__FILE__,__LINE__); Display :: display_normal_message(get_lang("_learnpath_module_edited")); } /*================================================== SHOWING THE ADMIN TOOLS ==================================================*/ if (($action=="add" and $type=="learnpathcategory" and !$Submit)) { //this is when the user has selected the "add module" link previously, so we don't display it this time } else { //in case the user hasn't selected the "add module" link previously, first quick-check the database to remove the //useless step of asking the user to click on "add module" if the only possible action is to add a module $sql = "SELECT * FROM $tbl_learnpath_chapter WHERE learnpath_id = $learnpath_id"; $result=api_sql_query($sql,__FILE__,__LINE__); if (Database::num_rows($result) > 0) { echo "