Removing old code scorm.lib.php, scorm_admin.php see #4716
parent
f088d75e21
commit
f55d0cb514
@ -1,156 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
// TODO: Migrate this into the scorm.class.php file. |
||||
|
||||
/** |
||||
* This file is a container for functions related to SCORM and other |
||||
* standard or common course content types. It might later become a class |
||||
* instead of a functions library, as several components are likely to be |
||||
* re-used for different content types. |
||||
* @package chamilo.learnpath.scorm |
||||
* @author Yannick Warnier <ywarnier@beeznest.org> |
||||
* @author Based on work from Denes NAgy, Isthvan Mandak and Roan Embrechts |
||||
*/ |
||||
|
||||
/** |
||||
* Delete a scorm directory (check for imsmanifest and if found, deletes the related rows in scorm tables also) |
||||
* @param string Dir path |
||||
* @return boolean True on success, false otherwise |
||||
*/ |
||||
/* |
||||
function removescormDir($dir) { |
||||
global $_course; |
||||
if(!@$opendir = opendir($dir)) { |
||||
return false; |
||||
} |
||||
while($readdir = readdir($opendir)) { |
||||
if($readdir != '..' && $readdir != '.') { |
||||
if(is_file($dir.'/'.$readdir)) { |
||||
$pos = strpos('/'.$readdir, 'imsmanifest.xml'); |
||||
if ($pos) { // So we have the imsmanifest in this dir |
||||
// from d:/myworks/dokeos/dokeos_cvs/dokeos/dokeos/courses/CVSCODE4/scorm/LP2/LP2 |
||||
// We have to get /LP2/LP2 |
||||
$path = api_get_path(SYS_COURSE_PATH).$_course['official_code'].'/scorm'; |
||||
$pos = strpos($dir, $path); |
||||
if ($pos == 0) { |
||||
$scormdir = substr($dir, strlen($path), strlen($dir) - strlen($path)); |
||||
$courseid = $_course['official_code']; |
||||
$sql = "SELECT * FROM ".Database::get_scorm_table(TABLE_SCORM_MAIN)." where (contentTitle='$scormdir' and dokeosCourse='$courseid')"; |
||||
$result = Database::query($sql); |
||||
while ($row = Database::fetch_array($result)) { |
||||
$c = $row['contentId']; |
||||
$sql2 = "DELETE FROM ".Database::get_scorm_table(TABLE_SCORM_SCO_DATA)." where contentId=$c"; |
||||
$result2 = Database::query($sql2); |
||||
} |
||||
$sql = "DELETE FROM ".Database::get_scorm_table(TABLE_SCORM_MAIN)." where (contentTitle='$scormdir' and dokeosCourse='$courseid')"; |
||||
$result = Database::query($sql); |
||||
} |
||||
} |
||||
if (!@unlink($dir.'/'.$readdir)) { |
||||
return false; |
||||
} |
||||
} elseif (is_dir($dir.'/'.$readdir)) { |
||||
if(!removescormDir($dir.'/'.$readdir)) { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
closedir($opendir); |
||||
if (!@rmdir($dir)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
}*/ |
||||
|
||||
/** |
||||
* This function removes a directory if it exists |
||||
* @param string Dir path |
||||
* @return boolean True on success, false otherwise |
||||
* @deprecated |
||||
* @uses removescormDir() to actually remove the directory |
||||
*/ |
||||
function scorm_delete($file) { |
||||
if (check_name_exist($file)) { |
||||
if (is_dir($file)) { |
||||
return removescormDir($file); |
||||
} |
||||
} else { |
||||
return false; // No file or directory to delete. |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* This function gets a list of scorm paths located in a given directory |
||||
* @param string Base directory path |
||||
* @param string Current directory |
||||
* @param array Reference to a list of paths that exist in the database |
||||
* @return array Array(type=>array(),size=>array(),date=>array()) |
||||
*/ |
||||
function get_scorm_paths_from_dir($basedir, $curdir, &$attribute){ |
||||
$scormcontent = false; |
||||
$saved_dir = getcwd(); |
||||
$res = @chdir (realpath($basedir.$curdir)); |
||||
if ($res === false) { return(null); } |
||||
$handle = opendir('.'); |
||||
|
||||
define('A_DIRECTORY', 1); |
||||
define('A_FILE', 2); |
||||
|
||||
$fileList = array(); |
||||
// Fill up $fileList for displaying the files list later on. |
||||
while ($file = readdir($handle)) { |
||||
if ($file == '.' || $file == '..' || $file == '.htaccess') { |
||||
continue; // Skip current and parent directories |
||||
} |
||||
|
||||
$fileList['name'][] = $file; |
||||
|
||||
//if ($file=='imsmanifest.xml') { $scormcontent=true; } |
||||
|
||||
if(is_dir($file)) { |
||||
$fileList['type'][] = A_DIRECTORY; |
||||
$fileList['size'][] = false; |
||||
$fileList['date'][] = false; |
||||
} elseif (is_file($file)) { |
||||
$fileList['type'][] = A_FILE; |
||||
$fileList['size'][] = filesize($file); |
||||
$fileList['date'][] = filectime($file); |
||||
} |
||||
|
||||
/* |
||||
* Make the correspondance between |
||||
* info given by the file system |
||||
* and info given by the DB |
||||
*/ |
||||
if (is_array($attribute) && count($attribute['path']) > 0) { |
||||
$keyAttribute = array_search($curdir.'/'.$file, $attribute['path']); |
||||
} |
||||
|
||||
if ($keyAttribute !== false) { |
||||
$fileList['comment' ][] = $attribute['comment' ][$keyAttribute]; |
||||
$fileList['visibility'][] = $attribute['visibility'][$keyAttribute]; |
||||
unset ($attribute['comment' ][$keyAttribute], |
||||
$attribute['visibility'][$keyAttribute], |
||||
$attribute['path' ][$keyAttribute]); |
||||
} else { |
||||
$fileList['comment' ][] = false; |
||||
$fileList['visibility'][] = false; |
||||
} |
||||
} |
||||
closedir($handle); |
||||
chdir($saved_dir); |
||||
return $fileList; |
||||
} |
||||
|
||||
/** |
||||
* Detects the SCORM version from an imsmanifest.xml file |
||||
* @param string Path to imsmanifest.xml |
||||
* @return string SCORM version (1.0,1.1,1.2,1.3) |
||||
* @todo Implement this function |
||||
*/ |
||||
function get_scorm_version($path){ |
||||
return '1.2'; |
||||
} |
||||
|
@ -1,328 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
// This file is probably deprecated - 2009-05-14 - ywarnier |
||||
// No calls found in Chamilo file is deprecated. Adding an exit - 2011-06 jmontoya |
||||
/** |
||||
* This script handles SCO administration features |
||||
* @package chamilo.learnpath.scorm |
||||
* @author Denes Nagy, principal author |
||||
* @author Isthvan Mandak, several new features |
||||
* @author Roan Embrechts, code improvements and refactoring |
||||
* @author Yannick Warnier, complete refactoring <ywarnier@beeznest.org> |
||||
*/ |
||||
/** |
||||
* Code (exit) |
||||
*/ |
||||
exit; |
||||
|
||||
// Flag to allow for anonymous user - needs to be set before global.inc.php. |
||||
$use_anonymous = true; |
||||
|
||||
// Name of the language file that needs to be included. |
||||
$language_file = 'scormdocument'; |
||||
|
||||
$uncompress = 1; // TODO: This variable shouldn't be found here (find its usage before removal). |
||||
|
||||
require_once 'back_compat.inc.php'; |
||||
include 'learnpath_functions.inc.php'; |
||||
include_once 'scorm.lib.php'; |
||||
|
||||
$is_allowedToEdit = api_is_allowed_to_edit(); |
||||
|
||||
/* Variables */ |
||||
|
||||
// Escapable integers. |
||||
if ($_REQUEST['id'] != strval(intval($_REQUEST['id']))) { $id = $_REQUEST['id']; } else { $id = null; } |
||||
|
||||
// Imported strings. |
||||
$path = (!empty($_REQUEST['path']) ? $_REQUEST['path'] : null); |
||||
$Submit = (!empty($_POST['Submit']) ? $_POST['Submit'] : null); |
||||
$submitImage = (!empty($_POST['submitImage']) ? $_POST['submitImage'] : null); |
||||
$cancelSubmitImage = (!empty($_POST['cancelSubmitImage']) ? $_POST['cancelSubmitImage'] : null); |
||||
$action = (!empty($_REQUEST['action']) ? $_REQUEST['action'] : null); |
||||
$delete = (!empty($_REQUEST['delete']) ? $_REQUEST['delete'] : null); |
||||
$createDir = (!empty($_REQUEST['createDir']) ? $_REQUEST['createDir'] : null); |
||||
$make_directory_visible = (!empty($_REQUEST['make_directory_visible']) ? $_REQUEST['make_directory_visible'] : ''); |
||||
$make_directory_invisible = (!empty($_REQUEST['make_directory_invisible']) ? $_REQUEST['make_directory_invisible'] : ''); |
||||
|
||||
// Values from POST form to add directory. |
||||
$newDirPath = (!empty($_POST['newDirPath']) ? $_POST['newDirPath'] : null); |
||||
$newDirName = (!empty($_POST['newDirName']) ? $_POST['newDirName'] : null); |
||||
// Initialising internal variables. |
||||
$dialogbox = ''; |
||||
|
||||
$course_id = api_get_course_int_id(); |
||||
|
||||
api_protect_course_script(); |
||||
|
||||
//if (! $is_allowed_in_course) api_not_allowed(); |
||||
$is_allowedToUnzip = $is_courseAdmin; |
||||
|
||||
/* Main code */ |
||||
|
||||
switch ($action) { |
||||
case 'exportpath': |
||||
if (!empty($id)) { |
||||
$export = exportpath($id); |
||||
$dialogBox .= "This LP has been exported to the Document folder " |
||||
."of your course."; |
||||
} |
||||
break; |
||||
case 'exportscorm': |
||||
exportSCORM($path); |
||||
break; |
||||
case 'deletepath': |
||||
/* |
||||
DELETE A DOKEOS LEARNPATH |
||||
and all the items in it |
||||
*/ |
||||
if (!empty($id)){ |
||||
$l="learnpath/learnpath_handler.php?learnpath_id=$id"; |
||||
$sql="DELETE FROM $tbl_tool where (link='$l' AND image='scormbuilder.gif')"; |
||||
$result=Database::query($sql); |
||||
$sql="SELECT * FROM $tbl_learnpath_chapter where learnpath_id=$id"; |
||||
$result=Database::query($sql); |
||||
while ($row=Database::fetch_array($result)) |
||||
{ |
||||
$c=$row['id']; |
||||
$sql2="DELETE FROM $tbl_learnpath_item where chapter_id=$c"; |
||||
$result2=Database::query($sql2); |
||||
} |
||||
$sql="DELETE FROM $tbl_learnpath_chapter where learnpath_id=$id"; |
||||
$result=Database::query($sql); |
||||
deletepath($id); |
||||
$dialogBox=get_lang('_learnpath_deleted'); |
||||
} |
||||
break; |
||||
case 'publishpath': |
||||
/* PUBLISHING (SHOWING) A DOKEOS LEARNPATH */ |
||||
if (!empty($id)){ |
||||
$sql = "SELECT * FROM $tbl_learnpath_main where learnpath_id=$id"; |
||||
$result = Database::query($sql); |
||||
$row = Database::fetch_array($result); |
||||
$name = domesticate($row['learnpath_name']); |
||||
if ($set_visibility == 'i') { |
||||
$s = $name.' '.get_lang('_no_published'); |
||||
$dialogBox = $s; |
||||
$v = 0; |
||||
} |
||||
if ($set_visibility == 'v') { |
||||
$s=$name.' '.get_lang('_published'); |
||||
$dialogBox = $s; |
||||
$v = 1; |
||||
} |
||||
$sql = "SELECT * FROM $tbl_tool where (name='$name' and image='scormbuilder.gif')"; |
||||
$result = Database::query($sql); |
||||
$row2 = Database::fetch_array($result); |
||||
$num = Database::num_rows($result); |
||||
if (($set_visibility == 'i') && ($num > 0)) { |
||||
// It is visible or hidden but once was published. |
||||
if (($row2['visibility']) == 1) { |
||||
$sql = "DELETE FROM $tbl_tool WHERE (name='$name' and image='scormbuilder.gif' AND c_id = $course_id )"; |
||||
} else { |
||||
$sql = "UPDATE $tbl_tool set visibility=1 WHERE (name='$name' and image='scormbuilder.gif' AND c_id = $course_id)"; |
||||
} |
||||
} elseif (($set_visibility == 'v') && ($num == 0)) { |
||||
$sql ="INSERT INTO $tbl_tool (c_id, id, name, link, image, visibility, admin, address, added_tool) VALUES |
||||
($course_id, '$theid','$name','learnpath/learnpath_handler.php?learnpath_id=$id','scormbuilder.gif','$v','0','pastillegris.gif',0)"; |
||||
} else { |
||||
// Parameter and database incompatible, do nothing. |
||||
} |
||||
$result = Database::query($sql); |
||||
} |
||||
break; |
||||
case 'editpath': |
||||
/* EDITING A DOKEOS NEW LEARNPATH */ |
||||
if (!empty($Submit)) { |
||||
$l = "learnpath/learnpath_handler.php?learnpath_id=$id"; |
||||
$sql = "UPDATE $tbl_tool set name='".domesticate($learnpath_name)."' where (link='$l' and image='scormbuilder.gif')"; |
||||
$result = Database::query($sql); |
||||
$sql = "UPDATE $tbl_learnpath_main SET learnpath_name='".domesticate($learnpath_name)."', learnpath_description='".domesticate($learnpath_description)."' WHERE learnpath_id=$id"; |
||||
$result = Database::query($sql); |
||||
$dialogBox = get_lang('_learnpath_edited'); |
||||
} |
||||
break; |
||||
case 'add': |
||||
/* ADDING A NEW LEARNPATH : treating the form */ |
||||
if (!empty($Submit)) { |
||||
$sql = "INSERT INTO $tbl_learnpath_main (c_id, learnpath_name, learnpath_description) VALUES ($course_id , '".domesticate($learnpath_name)."','".domesticate($learnpath_description)."')"; |
||||
Database::query($sql); |
||||
$my_lp_id = Database::insert_id(); |
||||
$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool) VALUES ($course_id , '".domesticate($learnpath_name)."','learnpath/learnpath_handler.php?learnpath_id=$my_lp_id','scormbuilder.gif','1','0','pastillegris.gif',0)"; |
||||
Database::query($sql); |
||||
// Instead of displaying this info text, get the user directly to the learnpath edit page. |
||||
//$dialogBox = get_lang('_learnpath_added'); |
||||
header('location:../learnpath/learnpath_handler.php?'.api_get_cidreq().'&learnpath_id='.$my_lp_id); |
||||
exit(); |
||||
} |
||||
break; |
||||
case 'editscorm': |
||||
/* EDITING A SCORM PACKAGE */ |
||||
if (!empty($Submit)) { |
||||
$sql = "UPDATE $tbl_document SET comment='".domesticate($learnpath_description)."', name='".domesticate($learnpath_name)."' WHERE path='$path' AND c_id = $course_id "; |
||||
$result = Database::query($sql); |
||||
$dialogBox = get_lang('_learnpath_edited'); |
||||
} |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
if ($is_allowedToEdit) { // TEACHER ONLY |
||||
|
||||
/* UPLOAD SCORM */ |
||||
|
||||
/* |
||||
* Check the request method instead of a variable from POST |
||||
* because if the file size exceeds the maximum file upload |
||||
* size set in php.ini, all variables from POST are cleared ! |
||||
*/ |
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && empty($submitImage) && empty($cancelSubmitImage) && empty($action)) { |
||||
|
||||
// A SCORM upload has been detected, now deal with the file... |
||||
// Directory creation. |
||||
$s = $_FILES['userFile']['name']; |
||||
$pathInfo = pathinfo($s); |
||||
// Check the filename has at least several letters in it :-) |
||||
// This is a very loose check as later on we might accept other formats of packages. |
||||
// Sent than just "zip". |
||||
if (preg_match('/[\w-_]+/', $pathInfo['basename'])) { |
||||
// get the basename without extension. |
||||
$newDirName = substr($pathInfo['basename'], 0, strlen($pathInfo['basename']) - (strlen($pathInfo['extension']) + 1)); |
||||
$newDirName = replace_dangerous_char(trim($newDirName), 'strict'); |
||||
if (check_name_exist($baseWorkDir.$newDirPath.$openDir.'/'.$newDirName)) { |
||||
/** @todo change this output. Inaccurate at least in french. In this case, the |
||||
* file might not exist or the transfer might have been wrong (no $_FILES at all) |
||||
* but we still get the error message |
||||
*/ |
||||
$dialogBox = get_lang('FileExists'); |
||||
$createDir = $newDirPath; unset($newDirPath); // Return to step 1. |
||||
} else { |
||||
if (mkdir($baseWorkDir.$newDirPath.$openDir.'/'.$newDirName, api_get_permissions_for_new_directories())) { |
||||
FileManager::set_default_settings($newDirPath.$openDir, $newDirName, 'folder', $tbl_document); |
||||
// RH: was: set_default_settings($newDirPath.$openDir, $newDirName, 'folder'); |
||||
$dialogBox = get_lang('DirCr'); |
||||
} else { |
||||
//Display msg "could not create dir..." |
||||
//exit(); |
||||
} |
||||
// Directory creation end. |
||||
|
||||
$uploadPath = $openDir.'/'.$newDirName; |
||||
if (!$_FILES['userFile']['size']) { |
||||
$dialogBox .= get_lang('FileError').'<br />'.get_lang('Notice').' : '.get_lang('MaxFileSize').' '.ini_get('upload_max_filesize'); |
||||
} else { // The file size is alright, we can assume the file is OK too. |
||||
if ($uncompress == 1 && $is_allowedToUnzip) { |
||||
$unzip = 'unzip'; |
||||
} else { |
||||
$unzip = ''; |
||||
} |
||||
if (treat_uploaded_file($_FILES['userFile'], $baseWorkDir, $uploadPath, $maxFilledSpace, $unzip)) { |
||||
if ($uncompress == 1) { |
||||
//$dialogBox .= get_lang('DownloadAndZipEnd'); |
||||
// Modified by darkden : I omitted this part, so the user can see |
||||
// the scorm content message at once. |
||||
} else { |
||||
$dialogBox = get_lang('DownloadEnd'); |
||||
} |
||||
// "WHAT'S NEW" notification: update table last_tooledit. |
||||
//update_last_tooledit($_course, $nameTools, $id, get_lang('_new_document'), $_user['user_id']); |
||||
item_property_update($_course, TOOL_LEARNPATH, $id, "LearnpathAdded", $_user['user_id']); |
||||
} else { |
||||
if (api_failure::get_last_failure() == 'not_enough_space') { |
||||
$dialogBox = get_lang('NoSpace'); |
||||
} elseif (api_failure::get_last_failure() == 'php_file_in_zip_file') { |
||||
$dialogBox = get_lang('ZipNoPhp'); |
||||
} elseif (api_failure::get_last_failure() == 'not_scorm_content') { |
||||
$dialogBox = get_lang('NotScormContent'); |
||||
} |
||||
} |
||||
} |
||||
$uploadPath = ''; |
||||
if (api_failure::get_last_failure()) { |
||||
rmdir($baseWorkDir.$newDirPath.$openDir.'/'.$newDirName); |
||||
} |
||||
|
||||
} |
||||
} else { // The filename doesn't contain any alphanum chars (empty filename?) |
||||
// Get a more detailed message? |
||||
$dialogBox .= get_lang('FileError').'<br />'; |
||||
} |
||||
|
||||
/* DELETE FILE OR DIRECTORY */ |
||||
|
||||
if (isset($delete)) { |
||||
if ( scorm_delete($baseWorkDir.$delete)) { |
||||
//$tbl_document = substr($tbl_document, 1, strlen($tbl_document) - 2); // RH... |
||||
update_db_info('delete', $delete); |
||||
$dialogBox = get_lang('DocDeleted'); |
||||
} |
||||
} |
||||
|
||||
/* CREATE DIRECTORY */ |
||||
|
||||
/* |
||||
* The code begin with STEP 2 so it allows to return to STEP 1 if STEP 2 unsucceds. |
||||
*/ |
||||
|
||||
/* STEP 2 */ |
||||
|
||||
if (isset($newDirPath) && isset($newDirName)) { |
||||
// echo $newDirPath . $newDirName; |
||||
$newDirName = replace_dangerous_char(trim(stripslashes($newDirName)), 'strict'); |
||||
if (check_name_exist($baseWorkDir.$newDirPath.'/'.$newDirName)) { |
||||
$dialogBox = get_lang('FileExists'); |
||||
$createDir = $newDirPath; unset($newDirPath);// return to step 1 |
||||
} else { |
||||
if (mkdir($baseWorkDir.$newDirPath.'/'.$newDirName, api_get_permissions_for_new_directories())) |
||||
FileManager::set_default_settings($newDirPath, $newDirName, 'folder', $tbl_document); |
||||
// RH: was: set_default_settings($newDirPath, $newDirName, 'folder'); |
||||
$dialogBox = get_lang('DirCr'); |
||||
} |
||||
} |
||||
|
||||
/* STEP 1 */ |
||||
|
||||
if (isset($createDir)) { |
||||
$dialogBox .= "<!-- create dir -->\n" |
||||
."<form name='createdir' action='' method='POST'>\n" |
||||
."<input type=\"hidden\" name=\"newDirPath\" value=\"$createDir\" />\n" |
||||
.get_lang('NameDir')." : \n" |
||||
."<input type=\"text\" name=\"newDirName\" />\n" |
||||
."<input type=\"submit\" value=\"".get_lang('Ok')."\" />\n" |
||||
."</form>\n"; |
||||
} |
||||
|
||||
/* VISIBILITY COMMANDS */ |
||||
|
||||
if (!empty($make_directory_visible) || !empty($make_directory_invisible)) { |
||||
$visibilityPath = $make_directory_visible.$make_directory_invisible; |
||||
// At least one of these variables are empty. So it's okay to proceed this way |
||||
/* Check if there is yet a record for this file in the DB */ |
||||
$result = Database::query ("SELECT * FROM $tbl_document WHERE path LIKE '".$visibilityPath."' "); |
||||
while($row = Database::fetch_array($result, 'ASSOC')) { |
||||
$attribute['path' ] = $row['path' ]; |
||||
$attribute['visibility'] = $row['visibility']; |
||||
$attribute['comment' ] = $row['comment' ]; |
||||
} |
||||
|
||||
if ($make_directory_visible) { |
||||
$newVisibilityStatus = 'v'; |
||||
} elseif ($make_directory_invisible) { |
||||
$newVisibilityStatus = 'i'; |
||||
} |
||||
$query = "UPDATE $tbl_document SET visibility='$newVisibilityStatus' WHERE path=\"".$visibilityPath."\" AND c_id = $course_id "; // Added by Toon. |
||||
Database::query($query); |
||||
if (Database::affected_rows() == 0) { // Extra check added by Toon, normally not necessary anymore because all files are in the db. |
||||
Database::query("INSERT INTO $tbl_document SET |
||||
c_id = $course_id, |
||||
path=\"".$visibilityPath."\", |
||||
visibility=\"".$newVisibilityStatus."\""); |
||||
} |
||||
unset($attribute); |
||||
$dialogBox = get_lang('ViMod'); |
||||
} |
||||
} // END is Allowed to edit;. |
||||
} |
@ -1,38 +0,0 @@ |
||||
<?php |
||||
require_once api_get_path(SYS_CODE_PATH).'newscorm/scorm.lib.php'; |
||||
|
||||
class TestScormLib extends UnitTestCase { |
||||
|
||||
public function __construct() { |
||||
$this->UnitTestCase('SCORM library - main/newscorm/scorm.lib.test.php'); |
||||
} |
||||
|
||||
/** |
||||
* This public function gets a list of scorm paths located in a given directory |
||||
* @param string Base directory path |
||||
* @param string Current directory |
||||
* @param array Reference to a list of paths that exist in the database |
||||
* @return array Array(type=>array(),size=>array(),date=>array()) |
||||
*/ |
||||
public function testget_scorm_paths_from_dir() { |
||||
$basedir=''; |
||||
$curdir=''; |
||||
$attribute=array('abc'); |
||||
$res=get_scorm_paths_from_dir($basedir, $curdir, &$attribute); |
||||
$this->assertTrue(is_array($res)); |
||||
} |
||||
|
||||
/** |
||||
* Detects the SCORM version from an imsmanifest.xml file |
||||
* @param string Path to imsmanifest.xml |
||||
* @return string SCORM version (1.0,1.1,1.2,1.3) |
||||
* @todo Implement this public function |
||||
*/ |
||||
public function testget_scorm_version() { |
||||
$path_name = api_get_path(SYS_COURSE_PATH); |
||||
$path=$path_name.'scorm/'; |
||||
$res=get_scorm_version($path); |
||||
$this->assertTrue(is_string($res)); |
||||
//var_dump($res); |
||||
} |
||||
} |
@ -1,70 +0,0 @@ |
||||
<?php |
||||
require_once(api_get_path(SYS_CODE_PATH).'newscorm/scorm.lib.php'); |
||||
|
||||
class TestScorm extends UnitTestCase { |
||||
|
||||
/** |
||||
* This function gets a list of scorm paths located in a given directory |
||||
* @param string Base directory path |
||||
* @param string Current directory |
||||
* @param array Reference to a list of paths that exist in the database |
||||
* @return array Array(type=>array(),size=>array(),date=>array()) |
||||
*/ |
||||
function testget_scorm_paths_from_dir(){ |
||||
$basedir=''; |
||||
$curdir=''; |
||||
$attribute=array('abc'); |
||||
$res=get_scorm_paths_from_dir($basedir, $curdir, &$attribute); |
||||
$this->assertTrue(is_array($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Detects the SCORM version from an imsmanifest.xml file |
||||
* @param string Path to imsmanifest.xml |
||||
* @return string SCORM version (1.0,1.1,1.2,1.3) |
||||
* @todo Implement this function |
||||
*/ |
||||
function testget_scorm_version(){ |
||||
$path='/main/erxercice/'; |
||||
$res=get_scorm_version($path); |
||||
$this->assertTrue(is_string($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* Delete a scorm directory (check for imsmanifest and if found, deletes the related rows in scorm tables also) |
||||
* @param string Dir path |
||||
* @return boolean True on success, false otherwise |
||||
*/ |
||||
function testremovescormDirFalse() { |
||||
global $_course; |
||||
$dir='/main/exercice'; |
||||
$res=removescormDir($dir); |
||||
$this->assertFalse($res); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testremovescormDirTrue() { |
||||
global $_course; |
||||
$dir=api_get_path(SYS_CODE_PATH).'upload/users/'; |
||||
$res=removescormDir($dir); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
/** |
||||
* This function removes a directory if it exists |
||||
* @param string Dir path |
||||
* @return boolean True on success, false otherwise |
||||
* @uses removescormDir() to actually remove the directory |
||||
*/ |
||||
function testscorm_delete() { |
||||
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; |
||||
$file='/tmp/'; |
||||
$res=scorm_delete($file); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
} |
||||
} |
||||
?> |
Loading…
Reference in new issue