- cleaning and update for new SCORM tool * @package dokeos.learnpath ============================================================================== */ /* ============================================================================== INIT SECTION ============================================================================== */ $this_section=SECTION_COURSES; api_protect_course_script(); /* ----------------------------------------------------------- Libraries ----------------------------------------------------------- */ //the main_api.lib.php, database.lib.php and display.lib.php //libraries are included by default include('learnpath_functions.inc.php'); //include('../resourcelinker/resourcelinker.inc.php'); include('resourcelinker.inc.php'); //rewrite the language file, sadly overwritten by resourcelinker.inc.php $language_file = "learnpath"; /* ----------------------------------------------------------- Header and action code ----------------------------------------------------------- */ $htmlHeadXtra[] = ""; /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ $is_allowed_to_edit = api_is_allowed_to_edit(); $tbl_lp = Database::get_course_table('lp'); $tbl_lp_item = Database::get_course_table('lp_item'); $tbl_lp_view = Database::get_course_table('lp_view'); $isStudentView = (int) $_REQUEST['isStudentView']; $learnpath_id = (int) $_REQUEST['lp_id']; $submit = $_POST['submit_button']; /* $chapter_id = $_GET['chapter_id']; $title = $_POST['title']; $description = $_POST['description']; $Submititem = $_POST['Submititem']; $action = $_REQUEST['action']; $id = (int) $_REQUEST['id']; $type = $_REQUEST['type']; $direction = $_REQUEST['direction']; $moduleid = $_REQUEST['moduleid']; $prereq = $_REQUEST['prereq']; $type = $_REQUEST['type']; */ /* ============================================================================== 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) ) { error_log('New LP - User not authorized in lp_admin_view.php'); header('location:lp_controller.php?action=view&lp_id='.$learnpath_id); } //from here on, we are admin because of the previous condition, so don't check anymore $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"; $result=api_sql_query($sql_query); $therow=Database::fetch_array($result); $admin_output = ''; /* ----------------------------------------------------------- Course admin section - all the functions not available for students - always available in this case (page only shown to admin) ----------------------------------------------------------- */ /*================================================== SHOWING THE ADMIN TOOLS ==================================================*/ //Preparing the form to add a new module $add_module_form = '

'.get_lang('_add_learnpath_module').'

'.get_lang('_title').'
 
'; if (($_REQUEST['action']=="add_item" and $type=="dokeos_module" 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_lp_item WHERE lp_id = $learnpath_id AND item_type = 'dokeos_module'"; $result=api_sql_query($sql,__FILE__,__LINE__); if (Database::num_rows($result) <= 0) { $admin_output .= "
There is no main chapter at the moment. Please add one using the following form. This is a required step in the learning path building process.
"; $admin_output .= $add_module_form; }else{ $admin_output .= "\n\n"; } } /*================================================== EDITING A LEARNPATH ITEM: showing one of the forms ==================================================*/ if ($_REQUEST['action']=="edititem" and !empty($_REQUEST['id']) AND empty($_REQUEST['submit_item'])) { error_log('New LP - edit_item action in lp_admin_view',0); $id = (int) $_REQUEST['id']; $sql="SELECT * FROM $tbl_lp_item WHERE id=$id"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=Database::fetch_array($result); $id=$row['id']; $title = $row['title']; if(empty($title)){ $title = rl_get_resource_name(api_get_course_id(),$learnpath_id,$_REQUEST['id']); } $admin_output .= '

'.get_lang('_edit_learnpath_item').'

'; // // // // $admin_output .= '
'.get_lang('_title').'
'.get_lang('_description').'
 
'; } /*================================================== prerequisites setting start ==================================================*/ if ($_REQUEST['action']=="edititemprereq" and !empty($_REQUEST['id']) AND empty($_REQUEST['submit_item'])) { $id = (int) $_REQUEST['id']; $sql="SELECT * FROM $tbl_lp_item WHERE id=$id"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=Database::fetch_array($result); $id=$row['id']; $title = $row['title']; if(empty($title)){ $title = rl_get_resource_name(api_get_course_id(), $learnpath_id, $id); } $admin_output .= "

"; $admin_output .= get_lang('_add_prereq')." : "; $admin_output .= $title; $admin_output .= '

'; //$learnpath_items = learnpath_items($id); the LP object should be available here $learnpath_items = learnpath::get_brother_items($id); //if there is any test before the current item, we show the completion limit column //TODO //This section has been made inactive for now because it should use the prerequisite's //mastery score as a limit. Also, this script should instead use the new prerequisites //language from AICC (see wiki), so it should actually be completely different /* $teststhere = false; for ($i=0; $i $learnpath_items[$i]["display_order"])) { $teststhere = true; } } if ($teststhere) { $admin_output .= ""; } */ $checked=''; if (empty($row["prerequisite"])) { $checked = 'checked'; } $admin_output .= ""; for ($i=0; $i $learnpath_items[$i]["display_order"]) { /* $testrow = false; if (($learnpath_items[$i]["item_type"]==TOOL_QUIZ) or ($learnpath_items[$i]["item_type"]=='HotPotatoes')) { $testrow = true; } */ $checked = ''; if ($row["prerequisite"]==$learnpath_items[$i]["id"]) { $checked='checked'; } $admin_output .= '"; /* if ($testrow) { //if (!$checked) { $disabled='disabled'; } $admin_output .= ""; } */ $admin_output .= ""; } } $learnpath_chapters = learnpath::get_brother_chapters($row['parent_item_id']); $c=$row['parent_item_id']; //we are now in this chapter $sql="SELECT * FROM $tbl_lp_item WHERE id=$c AND item_type='dokeos_module'"; $result=api_sql_query($sql,__FILE__,__LINE__); $row_chapter=Database::fetch_array($result); for ($i=0; $i $learnpath_chapters[$i]["display_order"]) { $checked=''; if (($row["prereq_id"]==$learnpath_chapters[$i]["id"]) and ($row["prereq_type"]=='c')) { $checked='checked'; } $admin_output .= ""; } } $admin_output .= '
".get_lang('CompletionLimit')."
- ".get_lang('_none')." -
'; $admin_output .= rl_get_resource_name(api_get_course_id(), $learnpath_id, $learnpath_items[$i]['id']); $admin_output .= "
".$learnpath_chapters[$i]['title']."
 
'; } /*================================================== prerequisites setting end ==================================================*/ /*================================================== EDITING / ADDING A NEW LEARNPATH chapter: showing the form ==================================================*/ if (($_REQUEST['action']=="add_item")) // and $type=="learnpathcategory") or $action=="editmodule") { if (!$submit) { /* if ($action=="editmodule") { $sql="SELECT * FROM $tbl_lp_item WHERE (id='$id' and lp_id=$learnpath_id AND item_type='dokeos_chapter')"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=Database::fetch_array($result); } */ $admin_output .= '

'; if ($action=="add") { $admin_output .= get_lang('_add_learnpath_module'); } else { $admin_output .= get_lang('_edit_learnpath_module'); } $admin_output .= '

'; if ( $action=='editmodule' ) { // on edition, allow the user to modify the description (if he really wants it) $admin_output .= '' .'' .''; }else { //on addition, only give a title field, so ignore the description field $admin_output .= ""; } $admin_output .= '
'.get_lang('_title').'
'.get_lang('_description').'
 
'; } // if (!$submit) } // if ($action=="add" and $type=="learnpathcategory") $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path")); $interbreadcrumb[]= array ("url"=>$_SERVER['PHP_SELF']."?action=admin_view&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}")); Display::display_header(null,'Path'); //api_display_tool_title($therow['name']); $suredel = get_lang('AreYouSureToDelete'); $suredelstep = get_lang('AreYouSureToDeleteSteps'); ?> "; $learnpath_has_chapters = learnpath_chapters($learnpath_id); if ($learnpath_has_chapters) { echo "

".get_lang('_short_help').""; } /* ============================================================================== FOOTER ============================================================================== */ Display::display_footer(); ?>