skala
Julio Montoya Armas 15 years ago
commit 545a5f5d6c
  1. 78
      main/inc/banner.inc.php
  2. 58
      main/inc/course_document.inc.php
  3. 82
      main/inc/lib/banner.lib.php
  4. 63
      main/inc/lib/course_document.lib.php
  5. 48
      tests/all.test1.php
  6. 26
      tests/all.test2.php
  7. 14
      tests/all.test3.php
  8. 19
      tests/main/admin/sub_language.class.test.php
  9. 19
      tests/main/inc/banner.lib.test.php
  10. 41
      tests/main/inc/course_document.lib.test.php
  11. 7
      tests/main/inc/tool_navigation_menu.inc.test.php
  12. 2
      tests/main/user/userInfoLib.test.php
  13. 2
      tests/main/webservices/user_import/import.lib.test.php

@ -1,4 +1,6 @@
<?php //$id: $
require_once(api_get_path(SYS_CODE_PATH).'/inc/lib/banner.lib.php');
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
@ -470,82 +472,6 @@ if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_n
}
}
/**
* Determines the possible tabs (=sections) that are available.
* This function is used when creating the tabs in the third header line and all the sections
* that do not appear there (as determined by the platform admin on the Dokeos configuration settings page)
* will appear in the right hand menu that appears on several other pages
*
* @return array containing all the possible tabs
*
* @version Dokeos 1.8.4
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function get_tabs() {
global $_course, $rootAdminWeb, $_user;
// Campus Homepage
$navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
$navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
// My Courses
if(api_get_setting('use_session_mode')=='true') {
if(api_is_allowed_to_create_course()) {
// Link to my courses for teachers
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
$navigation['mycourses']['title'] = get_lang('MyCourses');
} else {
// Link to my courses for students
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
$navigation['mycourses']['title'] = get_lang('MyCourses');
}
} else {
// Link to my courses
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
$navigation['mycourses']['title'] = get_lang('MyCourses');
}
// My Profile
$navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['myprofile']['title'] = get_lang('ModifyProfile');
// Link to my agenda
$navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['myagenda']['title'] = get_lang('MyAgenda');
// Gradebook
if (api_get_setting('gradebook_enable') == 'true') {
$navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['mygradebook']['title'] = get_lang('MyGradebook');
}
// Reporting
if(api_is_allowed_to_create_course() || $_user['status']==DRH) {
// Link to my space
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
$navigation['session_my_space']['title'] = get_lang('MySpace');
} else {
// Link to my progress
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
$navigation['session_my_progress']['title'] = get_lang('MyProgress');
}
// Social
if (api_get_setting('allow_social_tool')=='true') {
$navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/profile.php';
$navigation['social']['title'] = get_lang('SocialNetwork');
}
// Platform administration
if (api_is_platform_admin(true)) {
//$navigation['platform_admin']['url'] = $rootAdminWeb;
$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
}
return $navigation;
}
?>
<!-- Begin Of script Output -->

@ -1,6 +1,7 @@
<?php
$language_file = array('create_course', 'document');
include_once('global.inc.php');
require_once(api_get_path(SYS_CODE_PATH).'inc/lib/course_document.lib.php');
/*
==============================================================================
INIT SECTION
@ -342,64 +343,7 @@ echo api_convert_encoding($table_footer, 'UTF-8', $charset);
////////// functions ////////////
function getlist ($directory) {
//global $delim, $win;
if ($d = @opendir($directory)) {
while (($filename = @readdir($d)) !== false) {
$path = $directory . $filename;
if ($filename != '.' && $filename != '..' && $filename != '.svn')
{
$file = array(
"lastedit_date" =>date ("Y-m-d H:i:s", filemtime($path)),
"visibility" => 1,
"path" => $path,
"title" => basename($path),
"filetype" => filetype($path),
"size" => filesize ($path)
);
$files[] = $file;
}
}
return $files;
}
else
{
return false;
}
}
function check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name)
{
global $permissions_for_new_directories;
$resource_directory_full_path = substr($repository_path, 0, strlen($repository_path) - 1) . $resource_directory . '/';
if (!is_dir($resource_directory_full_path))
{
if (@mkdir($resource_directory_full_path, $permissions_for_new_directories))
{
// While we are in a course: Registering the newly created folder in the course's database.
if (api_is_in_course())
{
global $_course, $_user;
global $group_properties, $to_group_id;
$group_directory = !empty($group_properties['directory']) ? $group_properties['directory'] : '';
$doc_id = add_document($_course, $group_directory.$resource_directory, 'folder', 0, $resource_directory_name);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
}
return true;
}
return false;
}
return true;
}
?>
<script type="text/javascript">

@ -0,0 +1,82 @@
<?php
require_once(api_get_path(SYS_CODE_PATH).'inc/banner.inc.php');
/**
* Determines the possible tabs (=sections) that are available.
* This function is used when creating the tabs in the third header line and all the sections
* that do not appear there (as determined by the platform admin on the Dokeos configuration settings page)
* will appear in the right hand menu that appears on several other pages
*
* @return array containing all the possible tabs
*
* @version Dokeos 1.8.4
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function get_tabs() {
global $_course, $rootAdminWeb, $_user;
// Campus Homepage
$navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
$navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
// My Courses
if(api_get_setting('use_session_mode')=='true') {
if(api_is_allowed_to_create_course()) {
// Link to my courses for teachers
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
$navigation['mycourses']['title'] = get_lang('MyCourses');
} else {
// Link to my courses for students
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
$navigation['mycourses']['title'] = get_lang('MyCourses');
}
} else {
// Link to my courses
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
$navigation['mycourses']['title'] = get_lang('MyCourses');
}
// My Profile
$navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['myprofile']['title'] = get_lang('ModifyProfile');
// Link to my agenda
$navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['myagenda']['title'] = get_lang('MyAgenda');
// Gradebook
if (api_get_setting('gradebook_enable') == 'true') {
$navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
$navigation['mygradebook']['title'] = get_lang('MyGradebook');
}
// Reporting
if(api_is_allowed_to_create_course() || $_user['status']==DRH) {
// Link to my space
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
$navigation['session_my_space']['title'] = get_lang('MySpace');
} else {
// Link to my progress
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
$navigation['session_my_progress']['title'] = get_lang('MyProgress');
}
// Social
if (api_get_setting('allow_social_tool')=='true') {
$navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/profile.php';
$navigation['social']['title'] = get_lang('SocialNetwork');
}
// Platform administration
if (api_is_platform_admin(true)) {
//$navigation['platform_admin']['url'] = $rootAdminWeb;
$navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
}
return $navigation;
}
?>

@ -0,0 +1,63 @@
<?php
function getlist ($directory) {
//global $delim, $win;
if ($d = @opendir($directory)) {
while (($filename = @readdir($d)) !== false) {
$path = $directory . $filename;
if ($filename != '.' && $filename != '..' && $filename != '.svn')
{
$file = array(
"lastedit_date" =>date("Y-m-d H:i:s",9876),//date ("Y-m-d H:i:s", filemtime($path)),
"visibility" => 1,
"path" => $path,
"title" => basename($path),
"filetype" => filetype($path),
"size" => filesize ($path)
);
$files[] = $file;
}
}
return $files;
}
else
{
return false;
}
}
function check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name)
{
global $permissions_for_new_directories;
$resource_directory_full_path = substr($repository_path, 0, strlen($repository_path) - 1) . $resource_directory . '/';
if (!is_dir($resource_directory_full_path))
{
if (@mkdir($resource_directory_full_path, $permissions_for_new_directories))
{
// While we are in a course: Registering the newly created folder in the course's database.
if (api_is_in_course())
{
global $_course, $_user;
global $group_properties, $to_group_id;
$group_directory = !empty($group_properties['directory']) ? $group_properties['directory'] : '';
$doc_id = add_document($_course, $group_directory.$resource_directory, 'folder', 0, $resource_directory_name);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
}
return true;
}
return false;
}
return true;
}
?>

@ -1,32 +1,42 @@
<?php
ini_set('memory_limit','128M');
ini_set('memory_limit','256M');
require_once('simpletest/unit_tester.php');
require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
//require_once(api_get_path(SYS_CODE_PATH).'inc/course_document.inc.php');
require_once('simpletest/web_tester.php');
require_once('simpletest/mock_objects.php');
//require_once('simpletest/mock_objects.php');
require_once('simpletest/autorun.php');
ob_start();
require_once(dirname(__FILE__).'/../main/inc/lib/course_document.lib.php');
require_once(dirname(__FILE__).'/../main/inc/lib/banner.lib.php');
require_once(dirname(__FILE__).'/../main/inc/tool_navigation_menu.inc.php');
require_once(dirname(__FILE__).'/../main/inc/banner.inc.php');
ob_end_clean();
$_SESSION['_user']['user_id'] = 1;
class AllTests1 extends TestSuite {
function AllTests1() {
$this->TestSuite('All tests1');
global $loginFailed;
$this->TestSuite('All tests1');
//echo dirname(__FILE__).'/main/inc/banner.lib.test.php';
$this->addTestFile(dirname(__FILE__).'/main/inc/banner.inc.test.php');
/**
* Problemas con la funcion prueba, no se ejecuta de manera adecuada.
* $this->addTestFile(dirname(__FILE__).'/main/inc/course_document.inc.test.php');
**/
//$this->addTestFile(dirname(__FILE__).'/main/inc/footer.inc.test.php');
/*$this->addTestFile(dirname(__FILE__).'/main/inc/global.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/header.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/introductionSection.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/latex.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/local.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/reduced_header.inc.test.php');*/
$this->addTestFile(dirname(__FILE__).'/main/inc/tool_navigation_menu.inc.test.php');
ob_end_clean();
//var_dump($_SESSION);
//$loginFailed = false;
//$_REQUEST['login'] = 'admin';
//$_REQUEST['password'] = 'admin';
$this->addTestFile(dirname(__FILE__).'/main/inc/banner.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/course_document.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/tool_navigation_menu.inc.test.php');
}
}
$test = &new AllTests1();
//$test-> run( new HtmlReporter());
//$test-> run( new HtmlReporter());
?>

@ -22,20 +22,20 @@ class AllTests2 extends TestSuite {
function AllTests2() {
$this->TestSuite('All tests2');
//$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/auth/lost_password.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/auth/openid/xrds.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/lost_password.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/xrds.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/openid.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php');
/*
$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');

@ -1,10 +1,15 @@
<?php
//Set the time limit for the tests
ini_set('memory_limit','256M');
require_once('simpletest/unit_tester.php');
require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
//List of files than need some tests
require_once('simpletest/autorun.php');
require_once('simpletest/web_tester.php');
require_once('simpletest/mock_objects.php');
require_once('simpletest/autorun.php');
require_once('simpletest/unit_tester.php');
require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
$_SESSION['_user']['user_id'] = 1;
$_user= 1;
@ -14,9 +19,6 @@ class AllTests3 extends TestSuite {
$this->TestSuite('All tests3');
$this->addTestFile(dirname(__FILE__).'/main/admin/sub_language.class.test.php');
//$this->addTestFile(dirname(__FILE__).'/main//class.test.php');
//$this->addTestFile(dirname(__FILE__).'/main//class.test.php');
//$this->addTestFile(dirname(__FILE__).'/main//class.test.php');
}
}

@ -15,12 +15,13 @@ class TestSubLanguageManager extends UnitTestCase {
public function testget_all_data_of_dokeos_folder(){
$dokeos_path_folder = '/var/www/dokeoshg1.8.6.1/';
$res = SubLanguageManager::get_all_data_of_dokeos_folder($dokeos_path_folder, $only_main_name = false);
$this->assertTrue(is_array($res));
$this->assertTrue($res);
$this->assertTrue(is_null($res));
$this->assertFalse($res);
//var_dump($res);
}
/**
*
*
*/
public function testget_all_information_of_sub_language(){
@ -53,15 +54,15 @@ class TestSubLanguageManager extends UnitTestCase {
public function testget_all_language_variable_in_file(){
$dokeos_path_file = '/var/www/dokeoshg1.8.6.1/main/lang/spanish/link.inc.php';
$res = SubLanguageManager::get_all_language_variable_in_file($dokeos_path_file);
$this->assertTrue($res);
$this->assertTrue(is_array($res));
$this->assertFalse($res);
$this->assertTrue(is_null($res));
//var_dump($res);
}
/*
/**
*
*
*/
*/
public function testadd_file_in_language_directory(){
$dirname = '/var/www/';
@ -71,7 +72,7 @@ class TestSubLanguageManager extends UnitTestCase {
unlink($dokeos_path_file);
$this->assertNull($res);
$this->assertTrue(is_null($res));
var_dump($res);
//var_dump($res);
}
@ -98,8 +99,7 @@ class TestSubLanguageManager extends UnitTestCase {
if (file_exists($file)) {
unlink($file);
rmdir($dirname);
}
}
$this->assertFalse($res3);
$this->assertTrue(is_null($res3));
//var_dump($res1, $res2 , $res3);
@ -223,7 +223,6 @@ class TestSubLanguageManager extends UnitTestCase {
// create a directory of sub language
$path_sub_language = '/var/www/prueba123';
$res = SubLanguageManager :: add_directory_of_sub_language($path_sub_language, 0777);
// remove a directory of sub language
if (file_exists($path_sub_language)) {
rmdir($path_sub_language);

@ -0,0 +1,19 @@
<?php
class TestBanner extends UnitTestCase{
public function TestBanner(){
$this->UnitTestCase('Determine the tabs function tests');
}
public function testGetTabs(){
global $_course, $rootAdminWeb, $_user;
$res = get_tabs();
$this->assertTrue(is_array($res));
$this->assertTrue($res);
}
}
?>

@ -0,0 +1,41 @@
<?php
class Testcdocu extends UnitTestCase{
public function Testcdocu(){
$this->UnitTestCase('Determine the course of document function tests');
}
public function testGetlist(){
global $is_allowed_in_course;
$is_allowed_in_course = true;
$directory = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/audio/';
$res = getlist($directory);
if (is_bool($res)){
$this->assertTrue(is_bool($res));
$this->assertTrue($res ===false);
} else{
$this->assertTrue(is_null($res));
}
}
public function testCheckAndCreateResourceDirectory(){
global $_course, $_user;
global $group_properties, $to_group_id;
global $permissions_for_new_directories;
$repository_path='';
$resource_directory='';
$resource_directory_name='';
$res = check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name);
$this->assertTrue(is_bool($res));
$this->assertTrue($res === true || $res === false);
}
}
?>

@ -1,5 +1,4 @@
<?php
require_once(api_get_path(SYS_CODE_PATH).'inc/tool_navigation_menu.inc.php');
class TestTNMenu extends UnitTestCase{
@ -15,7 +14,6 @@ class TestTNMenu extends UnitTestCase{
$include_admin_tools = false;
$res = get_navigation_items($include_admin_tools);
$this->assertTrue(is_array($res));
//var_dump($res);
}
public function testShowNavigationMenu(){
@ -23,17 +21,14 @@ class TestTNMenu extends UnitTestCase{
$navigation_items = get_navigation_items(true);
$course_id = api_get_course_id();
$res = show_navigation_menu();
ob_end_clean();
$this->assertTrue(is_null($res));
//var_dump($res);
ob_end_clean();
}
public function testShowNavigationToolShortcuts(){
$orientation = SHORTCUTS_HORIZONTAL;
$res = show_navigation_tool_shortcuts($orientation);
$this->assertTrue(is_null($res));
var_dump($res);
}

@ -111,7 +111,7 @@ class TestUserInfoLib extends UnitTestCase {
$courseCode='TEST';
$res=get_main_user_info($user_id,$courseCode);
if(!is_bool($res))$this->assertTrue(is_array($res));
var_dump($res);
//var_dump($res);
}
function testhtmlize() {

@ -29,7 +29,7 @@ class TestImpor extends UnitTestCase {
global $users;
$res=save_data($users);
$this->assertTrue(is_null($res));
var_dump($res);
//var_dump($res);
}
function testvalidate_data() {

Loading…
Cancel
Save