parent
db29e45a48
commit
d219848c56
@ -1,437 +0,0 @@ |
||||
<?php |
||||
/* |
||||
============================================================================== |
||||
Dokeos - elearning and course management software |
||||
|
||||
Copyright (c) 2004 Dokeos S.A. |
||||
Copyright (c) 2003 Ghent University (UGent) |
||||
Copyright (c) 2001 Universite catholique de Louvain (UCL) |
||||
Copyright (c) Patrick Cool |
||||
Copyright (c) Denes Nagy |
||||
Copyright (c) Yannick Warnier |
||||
|
||||
For a full list of contributors, see "credits.txt". |
||||
The full license can be read in "license.txt". |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License |
||||
as published by the Free Software Foundation; either version 2 |
||||
of the License, or (at your option) any later version. |
||||
|
||||
See the GNU General Public License for more details. |
||||
|
||||
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com |
||||
============================================================================== |
||||
*/ |
||||
/** |
||||
============================================================================== |
||||
* This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php |
||||
* |
||||
* @author Patrick Cool |
||||
* @author Denes Nagy |
||||
* @author Roan Embrechts, refactoring and code cleaning |
||||
* @author Yannick Warnier <ywarnier@beeznest.org> - 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[] = "<link rel='stylesheet' type='text/css' href='../css/learnpath.css' />"; |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
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[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>"; |
||||
} |
||||
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 = ' |
||||
<form name="form1" method="post" action="lp_controller"> |
||||
<input type="hidden" name="action" value="add_item"> |
||||
<input type="hidden" name="lp_id" value="'.$learnpath_id.'"> |
||||
<input type="hidden" name="parent" value="0"> |
||||
<input type="hidden" name="previous" value="-1"> |
||||
<input type="hidden" name="type" value="dokeos_module"> |
||||
<input type="hidden" name="path" value=""> |
||||
<h4>'.get_lang('_add_learnpath_module').'</h4> |
||||
<table width="400" border="0" cellspacing="2" cellpadding="0"> |
||||
<tr> |
||||
<td align="right">'.get_lang('_title').'</td> |
||||
<td><input name="title" type="text" value="" size="50"></td> |
||||
</tr> |
||||
<tr> |
||||
<td align="right"> </td> |
||||
<td><input type="submit" name="submit_button" value="'.get_lang('Ok').'"></td> |
||||
</tr> |
||||
</table> |
||||
</form>'; |
||||
|
||||
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 .= "<br />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.<br />"; |
||||
$admin_output .= $add_module_form; |
||||
}else{ |
||||
$admin_output .= "<ul>\n"; |
||||
$admin_output .= "<li><a href='lp_controller.php?action=add_item&lp_id=$learnpath_id&type=dokeos_module&parent=0&previous=-1&path='>" . get_lang("_add_learnpath_module") . "</a></li>\n"; |
||||
$admin_output .= "</ul>\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 .= '<h4>'.get_lang('_edit_learnpath_item').'</h4> |
||||
<form name="edititem" method="post" action=""> |
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
||||
<input type="hidden" name="action" value="edititem"> |
||||
<tr> |
||||
<td align="right" valign="top">'.get_lang('_title').'</td> |
||||
<td><input name="title" type="text" id="title3" size="50" value="'.$title.'"></td> |
||||
</tr>'; |
||||
//<tr> |
||||
// <td align="right" valign="top">'.get_lang('_description').'</td> |
||||
// <td><textarea name="description" cols="45" id="textarea">'.$row["description"].'</textarea></td> |
||||
//</tr> |
||||
$admin_output .= ' <tr> |
||||
<td align="right" valign="top"> </td> |
||||
<td><input name="submit_item" type="submit" id="Submititem" value="'.get_lang('Ok').'"></td> |
||||
</tr> |
||||
</table> |
||||
</form>'; |
||||
} |
||||
/*================================================== |
||||
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 .= "<h4>"; |
||||
$admin_output .= get_lang('_add_prereq')." : "; |
||||
$admin_output .= $title; |
||||
$admin_output .= '</h4> |
||||
<form name="edititemprereq" method="post" action=""> |
||||
<input type="hidden" name="action" value="edititemprereq"> |
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
||||
<tr> |
||||
<td align="right" valign="top"></td> |
||||
<td><table border="0" cellspacing="1" cellpadding="0">'; |
||||
//$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<count($learnpath_items); $i++) |
||||
{ |
||||
if ((($learnpath_items[$i]["item_type"]==TOOL_QUIZ) |
||||
or ($learnpath_items[$i]["item_type"]=='HotPotatoes')) |
||||
and ($row["display_order"] > $learnpath_items[$i]["display_order"])) |
||||
{ |
||||
$teststhere = true; |
||||
} |
||||
} |
||||
|
||||
if ($teststhere) |
||||
{ |
||||
$admin_output .= "<tr><td colspan='2'></td><td>".get_lang('CompletionLimit')."</td></tr>"; |
||||
} |
||||
*/ |
||||
$checked=''; |
||||
if (empty($row["prerequisite"])) { $checked = 'checked'; } |
||||
$admin_output .= "<tr><td><input class=\"checkbox\" type=\"radio\" name=\"prereq\" value=\"\" $checked></td><td>- ".get_lang('_none')." -</td></tr>"; |
||||
|
||||
for ($i=0; $i<count($learnpath_items); $i++) |
||||
{ |
||||
if ($row["display_order"] > $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 .= '<tr><td><input class="checkbox" type="radio" name="prereq" value="'.$learnpath_items[$i]['id'].'" '.$checked.' ></td><td>'; |
||||
$admin_output .= rl_get_resource_name(api_get_course_id(), $learnpath_id, $learnpath_items[$i]['id']); |
||||
$admin_output .= "</td>"; |
||||
/* |
||||
if ($testrow) |
||||
{ |
||||
//if (!$checked) { $disabled='disabled'; } |
||||
$admin_output .= "<td align=center><input type=text name='completion_limit[{$learnpath_items[$i]['id']}]' size=4 maxlength=20 $disabled value=$completion_limit></td>"; |
||||
} |
||||
*/ |
||||
$admin_output .= "</tr>"; |
||||
} |
||||
} |
||||
|
||||
$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<count($learnpath_chapters); $i++) |
||||
{ |
||||
if ($row_chapter["display_order"] > $learnpath_chapters[$i]["display_order"]) |
||||
{ |
||||
$checked=''; |
||||
if (($row["prereq_id"]==$learnpath_chapters[$i]["id"]) and ($row["prereq_type"]=='c')) { $checked='checked'; } |
||||
$admin_output .= "<tr><td bgcolor='#cccccc'><input type='radio' name='prereq' value='".$learnpath_chapters[$i]["id"]."' $checked ></td><td bgcolor='#cccccc'>".$learnpath_chapters[$i]['title']."</td></tr>"; |
||||
} |
||||
} |
||||
$admin_output .= ' |
||||
</table></td> |
||||
</tr> |
||||
<tr> |
||||
<td align="right" valign="top"> </td> |
||||
<td><input name="submit_item" type="submit" id="Submititem" value="'.get_lang('Ok').'"></td> |
||||
</tr> |
||||
</table> |
||||
</form>'; |
||||
} |
||||
|
||||
/*================================================== |
||||
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 .= ' |
||||
<form name="form1" method="post" action=""> |
||||
<h4>'; |
||||
if ($action=="add") |
||||
{ $admin_output .= get_lang('_add_learnpath_module'); } |
||||
else |
||||
{ $admin_output .= get_lang('_edit_learnpath_module'); } |
||||
$admin_output .= ' |
||||
</h4> |
||||
<table width="400" border="0" cellspacing="2" cellpadding="0"> |
||||
<tr> |
||||
<td align="right">'.get_lang('_title').'</td> |
||||
<td><input name="title" type="text" value="'.$row["chapter_name"].'" size="50"></td> |
||||
</tr>'; |
||||
if ( $action=='editmodule' ) |
||||
{ |
||||
// on edition, allow the user to modify the description (if he really wants it) |
||||
$admin_output .= '<tr> |
||||
<td align="right" valign="top">'.get_lang('_description').'</td>' |
||||
.'<td><textarea name="description" cols="45">'.$row["chapter_description"].'</textarea></td>' |
||||
.'</tr>'; |
||||
}else |
||||
{ |
||||
//on addition, only give a title field, so ignore the description field |
||||
$admin_output .= "<input type='hidden' name='description' value='' />"; |
||||
} |
||||
$admin_output .= ' |
||||
<tr> |
||||
<td align="right"> </td> |
||||
<td><input type="submit" name="submit_button" value="'.get_lang('Ok').'"></td> |
||||
</tr> |
||||
</table> |
||||
</form>'; |
||||
} // 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'); |
||||
?> |
||||
<script type='text/javascript'> |
||||
/* <![CDATA[ */ |
||||
function confirmation (name) |
||||
{ |
||||
if (name!='Users' && name!='Assignments' && name!='Document' && name!='Forum' && name!='Agenda' && name!='Groups' && name!='Link _self' && name!='Dropbox' && name!='Course_description' && name!='Exercise' && name!='Introduction_text') |
||||
{ |
||||
if (confirm("<?php echo $suredel; ?> "+ name + " <?php echo $suredelstep;?>?"))
|
||||
{return true;} |
||||
else |
||||
{return false;} |
||||
} |
||||
else |
||||
{ |
||||
if (confirm("<?php echo $suredel; ?> "+ name + "?"))
|
||||
{return true;} |
||||
else |
||||
{return false;} |
||||
} |
||||
} |
||||
</script> |
||||
<?php |
||||
|
||||
echo $admin_output; |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
DISPLAY SECTION |
||||
----------------------------------------------------------- |
||||
*/ |
||||
?> |
||||
<table border="0" cellspacing="0" cellpadding="1" width="100%" class="data_table"> |
||||
<tr> |
||||
<td colspan='8'> |
||||
</td> |
||||
</tr> |
||||
<?php
|
||||
|
||||
|
||||
display_learnpath_chapters(); |
||||
|
||||
echo "</table>"; |
||||
|
||||
$learnpath_has_chapters = learnpath_chapters($learnpath_id); |
||||
if ($learnpath_has_chapters) |
||||
{ |
||||
echo "<br /><br /><font color='#999999' size='1'>".get_lang('_short_help')."</font>"; |
||||
} |
||||
|
||||
/* |
||||
============================================================================== |
||||
FOOTER |
||||
============================================================================== |
||||
*/ |
||||
Display::display_footer(); |
||||
?> |
@ -1,514 +0,0 @@ |
||||
<?php //$id: $
|
||||
/** |
||||
* Controller script. Prepares the common background variables to give to the scripts corresponding to |
||||
* the requested action |
||||
* @package dokeos.learnpath |
||||
* @author Yannick Warnier <ywarnier@beeznest.org> |
||||
* @author Kevin Van Den Haute <kevin@develop-it.be> |
||||
*/ |
||||
/** |
||||
* Initialisations |
||||
*/ |
||||
$debug = 0; |
||||
if($debug>0) error_log('New LP -+- Entered lp_controller.php -+-',0); |
||||
// name of the language file that needs to be included |
||||
$language_file[] = "scormdocument"; |
||||
$language_file[] = "scorm"; |
||||
$language_file[] = "learnpath"; |
||||
|
||||
//include class definitions before session_start() to ensure availability when touching |
||||
//session vars containing learning paths |
||||
require_once('learnpath.class.php'); |
||||
if($debug>0) error_log('New LP - Included learnpath',0); |
||||
require_once('learnpathItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included learnpathItem',0); |
||||
require_once('scorm.class.php'); |
||||
if($debug>0) error_log('New LP - Included scorm',0); |
||||
require_once('scormItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included scormItem',0); |
||||
require_once('aicc.class.php'); |
||||
if($debug>0) error_log('New LP - Included aicc',0); |
||||
require_once('aiccItem.class.php'); |
||||
if($debug>0) error_log('New LP - Included aiccItem',0); |
||||
require_once('temp.lib.php'); |
||||
if($debug>0) error_log('New LP - Included temp',0); |
||||
|
||||
|
||||
require_once('back_compat.inc.php'); |
||||
if($debug>0) error_log('New LP - Included back_compat',0); |
||||
api_protect_course_script(); |
||||
//TODO @TODO define tool, action and task to give as parameters to: |
||||
//$is_allowed_to_edit = api_is_allowed_to_edit(); |
||||
|
||||
if ($is_allowed_in_course == false){ |
||||
Display::display_header(''); |
||||
api_not_allowed(); |
||||
Display::display_footer(); |
||||
} |
||||
|
||||
require_once(api_get_path(LIBRARY_PATH) . "/fckeditor.lib.php"); |
||||
$lpfound = false; |
||||
|
||||
$myrefresh = 0; |
||||
$myrefresh_id = 0; |
||||
if(!empty($_SESSION['refresh']) && $_SESSION['refresh']==1){ |
||||
//check if we should do a refresh of the oLP object (for example after editing the LP) |
||||
//if refresh is set, we regenerate the oLP object from the database (kind of flush) |
||||
api_session_unregister('refresh'); |
||||
$myrefresh = 1; |
||||
if($debug>0) error_log('New LP - Refresh asked',0); |
||||
} |
||||
if($debug>0) error_log('New LP - Passed refresh check',0); |
||||
|
||||
if(!empty($_REQUEST['dialog_box'])){ |
||||
$dialog_box = learnpath::escape_string(urldecode($_REQUEST['dialog_box'])); |
||||
} |
||||
|
||||
$lp_controller_touched = 1; |
||||
|
||||
if(isset($_SESSION['lpobject'])) |
||||
{ |
||||
if($debug>0) error_log('New LP - SESSION[lpobject] is defined',0); |
||||
$oLP = unserialize($_SESSION['lpobject']); |
||||
if(is_object($oLP)){ |
||||
if($debug>0) error_log('New LP - oLP is object',0); |
||||
if($myrefresh == 1 OR $oLP->cc != api_get_course_id()){ |
||||
if($debug>0) error_log('New LP - Course has changed, discard lp object',0); |
||||
if($myrefresh == 1){$myrefresh_id = $oLP->get_id();} |
||||
$oLP = null; |
||||
api_session_unregister('oLP'); |
||||
api_session_unregister('lpobject'); |
||||
}else{ |
||||
$_SESSION['oLP'] = $oLP; |
||||
$lp_found = true; |
||||
} |
||||
} |
||||
} |
||||
if($debug>0) error_log('New LP - Passed data remains check',0); |
||||
|
||||
if($lp_found == false |
||||
|| ($_SESSION['oLP']->get_id() != $_REQUEST['lp_id']) |
||||
) |
||||
{ |
||||
if($debug>0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new',0); |
||||
//regenerate a new lp object? Not always as some pages don't need the object (like upload?) |
||||
if(!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)){ |
||||
if($debug>0) error_log('New LP - lp_id is defined',0); |
||||
//select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the |
||||
//right object |
||||
$lp_table = Database::get_course_table('lp'); |
||||
if(!empty($_REQUEST['lp_id'])){ |
||||
$lp_id = escape_txt($_REQUEST['lp_id']); |
||||
}else{ |
||||
$lp_id = $myrefresh_id; |
||||
} |
||||
$sel = "SELECT * FROM $lp_table WHERE id = $lp_id"; |
||||
if($debug>0) error_log('New LP - querying '.$sel,0); |
||||
$res = api_sql_query($sel); |
||||
if(Database::num_rows($res)) |
||||
{ |
||||
$row = Database::fetch_array($res); |
||||
$type = $row['lp_type']; |
||||
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); |
||||
switch($type){ |
||||
case 1: |
||||
$oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id()); |
||||
if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);} |
||||
break; |
||||
case 2: |
||||
$oLP = new scorm(api_get_course_id(),$lp_id,api_get_user_id()); |
||||
if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);} |
||||
break; |
||||
default: |
||||
$oLP = new learnpath(api_get_course_id(),$lp_id,api_get_user_id()); |
||||
if($oLP !== false){ $lp_found = true; }else{eror_log($oLP->error,0);} |
||||
break; |
||||
} |
||||
} |
||||
}else{ |
||||
if($debug>0) error_log('New LP - Request[lp_id] and refresh_id were empty',0); |
||||
} |
||||
if($lp_found) |
||||
{ |
||||
$_SESSION['oLP'] = $oLP; |
||||
} |
||||
} |
||||
if($debug>0) error_log('New LP - Passed oLP creation check',0); |
||||
|
||||
|
||||
/** |
||||
* Actions switching |
||||
*/ |
||||
$_SESSION['oLP']->update_queue = array(); //reinitialises array used by javascript to update items in the TOC |
||||
$_SESSION['oLP']->message = ''; //should use ->clear_message() method but doesn't work |
||||
switch($_REQUEST['action']) |
||||
{ |
||||
case 'admin_view': |
||||
if($debug>0) error_log('New LP - admin_view action triggered',0); |
||||
$_SESSION['refresh'] = 1; |
||||
require('lp_admin_view.php'); |
||||
break; |
||||
case 'upload': |
||||
if($debug>0) error_log('New LP - upload action triggered',0); |
||||
$cwdir = getcwd(); |
||||
require('lp_upload.php'); |
||||
//reinit current working directory as many functions in upload change it |
||||
chdir($cwdir); |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'export': |
||||
if($debug>0) error_log('New LP - export action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for export',0); require('lp_list.php'); } |
||||
else{ |
||||
if($_SESSION['oLP']->get_type()==2){ |
||||
$_SESSION['oLP']->export_zip(); |
||||
} |
||||
//require('lp_list.php'); |
||||
} |
||||
break; |
||||
case 'delete': |
||||
if($debug>0) error_log('New LP - delete action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for delete',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->delete(null,null,'remove'); |
||||
api_session_unregister('oLP'); |
||||
//require('lp_delete.php'); |
||||
require('lp_list.php'); |
||||
} |
||||
break; |
||||
case 'toggle_visible': //change lp visibility |
||||
if($debug>0) error_log('New LP - publish action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for publish',0); require('lp_list.php'); } |
||||
else{ |
||||
learnpath::toggle_visibility($_REQUEST['lp_id'],$_REQUEST['new_status']); |
||||
require('lp_list.php'); |
||||
} |
||||
break; |
||||
case 'edit': |
||||
if($debug>0) error_log('New LP - edit action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
require('lp_edit.php'); |
||||
//require('lp_admin_view.php'); |
||||
} |
||||
break; |
||||
case 'update_lp': |
||||
if($debug>0) error_log('New LP - update_lp action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for edit',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->set_name($_REQUEST['lp_name']); |
||||
$_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']); |
||||
$_SESSION['oLP']->set_maker($_REQUEST['lp_maker']); |
||||
$_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']); |
||||
require('lp_list.php'); |
||||
} |
||||
break; |
||||
case 'add_lp': |
||||
if($debug>0) error_log('New LP - add_lp action triggered',0); |
||||
|
||||
//call learnpath creation abstract method with course_id, learnpath_name, learnpath_description, type_of_lp, origin_of_creation, file_name |
||||
if(!empty($_REQUEST['learnpath_name'])){ |
||||
$_SESSION['refresh'] = 1; |
||||
$new_lp_id = learnpath::add_lp(api_get_course_id(),$_REQUEST['learnpath_name'],$_REQUEST['learnpath_description'],'dokeos','manual',''); |
||||
//TODO maybe create a first module directly to avoid bugging the user with useless queries |
||||
$_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id()); |
||||
$_SESSION['oLP']->add_item(0,-1,'dokeos_chapter',$_REQUEST['path'],'Default'); |
||||
} |
||||
require('lp_list.php'); |
||||
|
||||
|
||||
break; |
||||
|
||||
case 'add_item': |
||||
if($debug>0) error_log('New LP - add item action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for add item',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
if(!empty($_REQUEST['submit_button']) && !empty($_REQUEST['title'])){ |
||||
$_SESSION['oLP']->add_item($_REQUEST['parent'],$_REQUEST['previous'],$_REQUEST['type'],$_REQUEST['path'],$_REQUEST['title']); |
||||
} |
||||
require('lp_admin_view.php'); |
||||
} |
||||
break; |
||||
|
||||
case 'add_module': |
||||
if($debug > 0) |
||||
error_log('New LP - add item action triggered', 0); |
||||
|
||||
if(!$lp_found) |
||||
{ |
||||
error_log('New LP - No learnpath given for add item', 0); |
||||
|
||||
require('lp_list.php'); |
||||
} |
||||
else |
||||
{ |
||||
//$_SESSION['refresh'] = 1; |
||||
|
||||
if(isset($_POST['cmdSubmit'])) |
||||
{ |
||||
$_SESSION['oLP']->add_item(0, -1, 'dokeos_module', '', $_POST['txtTitle']); |
||||
} |
||||
|
||||
require('lp_view.php'); |
||||
} |
||||
|
||||
break; |
||||
case 'add_document': |
||||
if($debug > 0) |
||||
error_log('New LP - add item action triggered', 0); |
||||
|
||||
if(!$lp_found) |
||||
{ |
||||
error_log('New LP - No learnpath given for add item', 0); |
||||
|
||||
require('lp_list.php'); |
||||
} |
||||
else |
||||
{ |
||||
//$_SESSION['refresh'] = 1; |
||||
|
||||
if(isset($_POST['cmdSubmit'])) |
||||
{ |
||||
$_SESSION['oLP']->add_item(0, -1, 'dokeos_document', '', $_POST['txtTitle']); |
||||
} |
||||
|
||||
require('lp_view.php'); |
||||
} |
||||
|
||||
break; |
||||
|
||||
case 'add_sub_item': //add an item inside a chapter |
||||
if($debug>0) error_log('New LP - add sub item action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for add sub item',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
if(!empty($_REQUEST['parent_item_id'])){ |
||||
$_SESSION['from_learnpath']='yes'; |
||||
$_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.$_REQUEST['lp_id']; |
||||
require('resourcelinker.php'); |
||||
//$_SESSION['oLP']->add_sub_item($_REQUEST['parent_item_id'],$_REQUEST['previous'],$_REQUEST['type'],$_REQUEST['path'],$_REQUEST['title']); |
||||
}else{ |
||||
require('lp_admin_view.php'); |
||||
} |
||||
} |
||||
break; |
||||
case 'deleteitem': |
||||
case 'delete_item': |
||||
if($debug>0) error_log('New LP - delete item action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for delete item',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['refresh'] = 1; |
||||
if(!empty($_REQUEST['id'])){ |
||||
$_SESSION['oLP']->delete_item($_REQUEST['id']); |
||||
} |
||||
require('lp_admin_view.php'); |
||||
} |
||||
break; |
||||
case 'edititem': |
||||
case 'edit_item': |
||||
if($debug>0) error_log('New LP - edit item action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for edit item',0); require('lp_list.php'); } |
||||
else{ |
||||
if(!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])){ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->edit_item($_REQUEST['id'], $_REQUEST['title']); |
||||
} |
||||
require('lp_admin_view.php'); |
||||
} |
||||
break; |
||||
case 'edititemprereq': |
||||
case 'edit_item_prereq': |
||||
if($debug>0) error_log('New LP - edit item prereq action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for edit item prereq',0); require('lp_list.php'); } |
||||
else{ |
||||
if(!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])){ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->edit_item_prereq($_REQUEST['id'],$_REQUEST['prereq']); |
||||
} |
||||
require('lp_admin_view.php'); |
||||
} |
||||
break; |
||||
case 'restart': |
||||
if($debug>0) error_log('New LP - restart action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for restart',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->restart(); |
||||
require('lp_view.php'); |
||||
} |
||||
break; |
||||
case 'last': |
||||
if($debug>0) error_log('New LP - last action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for last',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->last(); |
||||
require('lp_view.php'); |
||||
} |
||||
break; |
||||
case 'first': |
||||
if($debug>0) error_log('New LP - first action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for first',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->first(); |
||||
require('lp_view.php'); |
||||
} |
||||
break; |
||||
case 'next': |
||||
if($debug>0) error_log('New LP - next action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for next',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->next(); |
||||
require('lp_view.php'); |
||||
} |
||||
break; |
||||
case 'previous': |
||||
if($debug>0) error_log('New LP - previous action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for previous',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->previous(); |
||||
require('lp_view.php'); |
||||
} |
||||
break; |
||||
case 'content': |
||||
if($debug>0) error_log('New LP - content action triggered',0); |
||||
if($debug>0) error_log('New LP - Item id is '.$_GET['item_id'],0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for content',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->set_current_item($_GET['item_id']); |
||||
$_SESSION['oLP']->start_current_item(); |
||||
require('lp_content.php'); |
||||
} |
||||
break; |
||||
case 'view': |
||||
if($debug > 0) |
||||
error_log('New LP - view action triggered', 0); |
||||
|
||||
if(!$lp_found) |
||||
{ |
||||
error_log('New LP - No learnpath given for view', 0); |
||||
|
||||
require('lp_list.php'); |
||||
} |
||||
else |
||||
{ |
||||
if($debug > 0) |
||||
error_log('New LP - trying to set current item to ' . $_REQUEST['item_id'], 0); |
||||
|
||||
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
||||
|
||||
require('lp_view.php'); |
||||
} |
||||
|
||||
break; |
||||
case 'save': |
||||
if($debug>0) error_log('New LP - save action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for save',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->save_item(); |
||||
require('lp_save.php'); |
||||
} |
||||
break; |
||||
case 'stats': |
||||
if($debug>0) error_log('New LP - stats action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for stats',0); require('lp_list.php'); } |
||||
else{ |
||||
$_SESSION['oLP']->save_current(); |
||||
$_SESSION['oLP']->save_last(); |
||||
require('lp_stats.php'); |
||||
} |
||||
break; |
||||
case 'list': |
||||
if($debug>0) error_log('New LP - list action triggered',0); |
||||
if($lp_found){ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->save_last(); |
||||
} |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'mode': |
||||
//switch between fullscreen and embedded mode |
||||
if($debug>0) error_log('New LP - mode change triggered',0); |
||||
$mode = $_REQUEST['mode']; |
||||
if($mode == 'fullscreen'){ |
||||
$_SESSION['oLP']->mode = 'fullscreen'; |
||||
}else{ |
||||
$_SESSION['oLP']->mode = 'embedded'; |
||||
} |
||||
require('lp_view.php'); |
||||
break; |
||||
case 'switch_view_mode': |
||||
if($debug>0) error_log('New LP - switch_view_mode action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); } |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->update_default_view_mode(); |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'switch_force_commit': |
||||
if($debug>0) error_log('New LP - switch_force_commit action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); } |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->update_default_scorm_commit(); |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'switch_reinit': |
||||
if($debug>0) error_log('New LP - switch_reinit action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); } |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->update_reinit(); |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'switch_scorm_debug': |
||||
if($debug>0) error_log('New LP - switch_scorm_debug action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require('lp_list.php'); } |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->update_scorm_debug(); |
||||
require('lp_list.php'); |
||||
break; |
||||
case 'intro_cmdAdd': |
||||
if($debug>0) error_log('New LP - intro_cmdAdd action triggered',0); |
||||
//add introduction section page |
||||
break; |
||||
case 'moveitem': |
||||
case 'move_item': |
||||
if($debug > 0) |
||||
error_log('New LP - move_item action triggered', 0); |
||||
|
||||
if(!$lp_found) |
||||
{ |
||||
error_log('New LP - No learnpath given for move_item', 0); |
||||
|
||||
require('lp_list.php'); |
||||
} |
||||
|
||||
if(!empty($_REQUEST['direction']) && !empty($_REQUEST['id'])) |
||||
{ |
||||
$_SESSION['refresh'] = 1; |
||||
$_SESSION['oLP']->move_item($_REQUEST['id'], $_REQUEST['direction']); |
||||
} |
||||
|
||||
require('lp_admin_view.php'); |
||||
|
||||
break; |
||||
case 'js_api_refresh': |
||||
if($debug>0) error_log('New LP - js_api_refresh action triggered',0); |
||||
if(!$lp_found){ error_log('New LP - No learnpath given for js_api_refresh',0); require('lp_message.php'); } |
||||
if(isset($_REQUEST['item_id'])){ |
||||
$htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']); |
||||
} |
||||
require('lp_message.php'); |
||||
break; |
||||
|
||||
default: |
||||
if($debug>0) error_log('New LP - default action triggered',0); |
||||
//$_SESSION['refresh'] = 1; |
||||
require('lp_list.php'); |
||||
break; |
||||
} |
||||
if(!empty($_SESSION['oLP'])){ |
||||
$_SESSION['lpobject'] = serialize($_SESSION['oLP']); |
||||
if($debug>0) error_log('New LP - lpobject is serialized in session',0); |
||||
} |
||||
?> |
Loading…
Reference in new issue