Remove unused code.

1.10.x
Julio Montoya 9 years ago
parent 8ba03dabfc
commit ed494a70ae
  1. 44
      main/inc/lib/add_course.lib.inc.php
  2. 22
      main/inc/lib/course.lib.php
  3. 2
      main/inc/lib/display.lib.php
  4. 5
      main/inc/lib/exercise.lib.php
  5. 24
      main/inc/lib/fileManage.lib.php
  6. 42
      main/inc/lib/groupmanager.lib.php
  7. 59
      main/inc/lib/myspace.lib.php
  8. 11
      main/inc/lib/plugin.lib.php
  9. 9
      main/inc/lib/template.lib.php
  10. 44
      main/inc/lib/text.lib.php
  11. 116
      main/inc/lib/tracking.lib.php
  12. 18
      main/inc/lib/usermanager.lib.php
  13. 74
      main/session/session_import.php
  14. 2
      main/social/group_members.php
  15. 15
      tests/main/inc/lib/groupmanager.lib.test.php
  16. 17
      tests/main/inc/lib/text.lib.test.php
  17. 11
      tests/main/inc/lib/tracking.lib.test.php

@ -1432,50 +1432,6 @@ class AddCourse
return $course_id;
}
/**
* Extract properties of the files from a ZIP package, write them to disk and
* return them as an array.
* @todo this function seems not to be used
* @param string Absolute path to the ZIP file
* @param bool Whether the ZIP file is compressed (not implemented). Defaults to TRUE.
* @return array List of files properties from the ZIP package
* @deprecated seems not to be used
* @assert (null) === false
*/
public static function readPropertiesInArchive($archive, $is_compressed = true)
{
$uid = api_get_user_id();
/*
string tempnam (string dir, string prefix)
tempnam() creates a unique temporary file in the dir directory. If the
directory doesn't existm tempnam() will generate a filename in the system's
temporary directory.
Before PHP 4.0.6, the behaviour of tempnam() depended of the underlying OS.
Under Windows, the "TMP" environment variable replaces the dir parameter;
under Linux, the "TMPDIR" environment variable has priority, while for the
OSes based on system V R4, the dir parameter will always be used if the
directory which it represents exists. Consult your documentation for more
details.
tempnam() returns the temporary filename, or the string NULL upon failure.
*/
$zip_file = new PclZip($archive);
$tmp_dir_name = dirname($archive) . '/tmp' . $uid . uniqid($uid);
if (mkdir(
$tmp_dir_name,
api_get_permissions_for_new_directories(),
true
)) {
$unzipping_state = $zip_file->extract($tmp_dir_name);
} else {
die ('mkdir failed');
}
$path_to_archive_ini = dirname($tmp_dir_name) . '/archive.ini';
//echo $path_to_archive_ini;
$course_properties = parse_ini_file($path_to_archive_ini);
rmdir($tmp_dir_name);
return $course_properties;
}
/**
* Generate a new id for c_tool table
* @param int $courseId The course id

@ -1948,28 +1948,6 @@ class CourseManager
return $coaches_to_string;
}
/**
* @param int $courseId
* @param int $session_id
* @return string
* @deprecated seem not to be use
*/
public static function get_coach_list_from_course_code_to_string($courseId, $session_id)
{
$tutor_data = '';
if ($session_id != 0) {
$coaches = self::get_email_of_tutor_to_session($session_id, $courseId);
$coach_list = array();
foreach ($coaches as $coach) {
$coach_list[] = $coach['complete_name'];
}
if (!empty($coach_list)) {
$tutor_data = implode(self::USER_SEPARATOR, $coach_list);
}
}
return $tutor_data;
}
/**
* Return user info array of all users registered in the specified course
* this includes the users of the course itself and the users of all linked courses.

@ -82,7 +82,7 @@ class Display
}
}
self::$global_template->set_help($help);
self::$global_template->setHelp($help);
if (!empty(self::$preview_style)) {
self::$global_template->preview_theme = self::$preview_style;

@ -3277,11 +3277,6 @@ HTML;
if (($pos = api_strpos($temp, '[')) === false) {
// adds the end of the text
$answer = $temp;
/* // Deprecated code
// TeX parsing - replacement of texcode tags
$texstring = api_parse_tex($texstring);
$answer = str_replace("{texcode}", $texstring, $answer);
*/
$real_text[] = $answer;
break; //no more "blanks", quit the loop
}

@ -479,28 +479,4 @@ class FileManager
}
Database::query($query);
}
} //end class FileManager
/* DEPRECATED FUNCTIONS */
/**
* Like in Java, creates the directory named by this abstract pathname,
* including any necessary but nonexistent parent directories.
*
* @author Hugues Peeters <peeters@ipm.ucl.ac.be>
* @author Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param string $path - path to create
* @param string $mode - directory permission (default is '770')
*
* @return boolean TRUE if succeeds FALSE otherwise
*/
function mkdirs($path, $mode = '0770') {
if (file_exists($path)) {
return false;
} else {
FileManager :: mkdirs(dirname($path), $mode);
//mkdir($path, $mode);
return true;
}
}

@ -1707,48 +1707,6 @@ class GroupManager
}
}
/**
* Get all tutors for the current course.
* @return array An array with firstname, lastname and user_id for all
* tutors in the current course.
* @deprecated this function uses the old tutor implementation
*/
public static function get_all_tutors()
{
$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user.user_id AS user_id, user.lastname AS lastname, user.firstname AS firstname
FROM ".$user_table." user, ".$course_user_table." cu
WHERE cu.user_id=user.user_id
AND cu.is_tutor='1'
AND cu.c_id='".api_get_course_int_id()."'";
$resultTutor = Database::query($sql);
$tutors = array();
while ($tutor = Database::fetch_array($resultTutor)) {
$tutors[] = $tutor;
}
return $tutors;
}
/**
* Is user a tutor in current course
* @param int $user_id
* @return bool TRUE if given user is a tutor in the current course.
* @deprecated this function uses the old tutor implementation
*/
public static function is_tutor($user_id)
{
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$user_id = intval($user_id);
$sql = "SELECT is_tutor FROM ".$course_user_table."
WHERE user_id = '".$user_id."' AND c_id ='".api_get_course_int_id()."'"." AND is_tutor=1";
$db_result = Database::query($sql);
$result = Database::num_rows($db_result) > 0;
return $result;
}
/**
* Get all group's from a given course in which a given user is unsubscribed
* @author Patrick Cool

@ -1078,65 +1078,6 @@ class MySpace
$return .= Display::grid_html($tableId);
return $return;
}
/**
* Display a sortable table that contains an overview off all the access to a session
* @deprecated seem not to be used
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
* @version Chamilo 1.9.6
*/
static function display_tracking_access_overview($sessionId = 0, $courseId = 0, $studentId = '', $profile = '', $date_from, $date_to)
{
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(
get_lang('LoginDate'),
get_lang('UserName'),
get_lang('LastName'),
get_lang('FirstName'),
get_lang('Clicks'),
get_lang('IP'),
get_lang('TimeLoggedIn'),
get_lang('Section'),
);
$column_model = array(
array('name'=>'logindate', 'index'=>'loginDate', 'align'=>'left', 'search' => 'true'),
array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true'),
array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'),
array('name'=>'clicks', 'index'=>'clicks', 'align'=>'left', 'search' => 'true'),
array('name'=>'ip', 'index'=>'ip', 'align'=>'left', 'search' => 'true'),
array('name'=>'timeloggedin', 'index'=>'timeLoggedIn', 'align'=>'left', 'search' => 'true'),
array('name'=>'session', 'index'=>'session', 'align'=>'left')
);
$action_links = '';
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_access_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&student_id=' . $studentId . '&profile=' . $profile . '&date_to=' . $date_to . '&date_from=' . $date_from;
//Table Id
$tableId = 'accessOverview';
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$return = '<script>$(function() {'. $table .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
caption:"",
title:"' . get_lang('ExportExcel') . '",
onClickButton : function () {
jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
}
});
});</script>';
$return .= Display::grid_html($tableId);
return $return;
}
/**
* Displays a form with all the additionally defined user fields of the profile

@ -398,17 +398,6 @@ class AppPlugin
return true;
}
/**
* @param string $plugin_name
* @param bool $forced
*
* @deprecated
*/
public function get_plugin_info($plugin_name, $forced = false)
{
return $this->getPluginInfo($plugin_name, $forced);
}
/**
* Loads plugin info
*

@ -235,15 +235,6 @@ class Template
return $result;
}
/**
* @deprecated
* @param null $helpInput
*/
public function set_help($helpInput = null)
{
$this->setHelp($helpInput);
}
/**
* @param string $helpInput
*/

@ -832,50 +832,6 @@ function get_week_from_day($date) {
}
}
/**
* Deprecated functions
*/
/**
* Applies parsing the content for tex commands that are separated by [tex]
* [/tex] to make it readable for techexplorer plugin.
* @param string $text The text to parse
* @return string The text after parsing.
* @author Patrick Cool <patrick.cool@UGent.be>
* @version June 2004
*/
function api_parse_tex($textext) {
/*
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
return str_replace(array('[tex]', '[/tex]'), array("<object classid=\"clsid:5AFAB315-AD87-11D3-98BB-002035EFB1A4\"><param name=\"autosize\" value=\"true\" /><param name=\"DataType\" value=\"0\" /><param name=\"Data\" value=\"", "\" /></object>"), $textext);
}
return str_replace(array('[tex]', '[/tex]'), array("<embed type=\"application/x-techexplorer\" texdata=\"", "\" autosize=\"true\" pluginspage=\"http://www.integretechpub.com/techexplorer/\">"), $textext);
*/
return $textext;
}
/**
* Applies parsing for tex commandos that are seperated by [tex]
* [/tex] to make it readable for techexplorer plugin.
* This function should not be accessed directly but should be accesse through the text_filter function
* @param string $text The text to parse
* @return string The text after parsing.
* @author Patrick Cool <patrick.cool@UGent.be>
* @version June 2004
*/
function _text_parse_texexplorer($textext) {
/*
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
$textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array("<object classid=\"clsid:5AFAB315-AD87-11D3-98BB-002035EFB1A4\"><param name=\"autosize\" value=\"true\" /><param name=\"DataType\" value=\"0\" /><param name=\"Data\" value=\"", "\" /></object>"), $textext);
} else {
$textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array("<embed type=\"application/x-techexplorer\" texdata=\"", "\" autosize=\"true\" pluginspage=\"http://www.integretechpub.com/techexplorer/\">"), $textext);
}
return $textext;
*/
return $textext;
}
/**
* This function splits the string into words and then joins them back together again one by one.
* Example: "Test example of a long string"

@ -3782,123 +3782,7 @@ class Tracking
return $a_students;
}
/**
* Gets the average of test and scorm inside a learning path
* @param int User id
* @param string Course id
* @return float average of test
* @author isaac flores paz
* @deprecated get_avg_student_score should be use
*/
public static function get_average_test_scorm_and_lp($user_id, $course_id)
{
//the score inside the Reporting table
$course_info = api_get_course_info($course_id);
$course_id = $course_info['real_id'];
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
$lp_item_table = Database :: get_course_table(TABLE_LP_ITEM);
$sql_type = "SELECT id, lp_type FROM $lp_table WHERE c_id = $course_id";
$rs_type=Database::query($sql_type);
$count_loop=0;
$average_data_sum = 0;
$lp_list = array();
while ($row_type = Database::fetch_array($rs_type)) {
$lp_list[] = $row_type['id'];
if ($row_type['lp_type']==1) {
//lp chamilo
$sql = "SELECT id FROM $lp_view_table
WHERE c_id = $course_id AND user_id = '".intval($user_id)."' and lp_id='".$row_type['id']."'";
$rs_last_lp_view_id = Database::query($sql);
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id'));
$sql_list_view="SELECT li.max_score,lv.user_id,liw.score,(liw.score/li.max_score) as sum_data
FROM $lp_item_table li
INNER JOIN $lp_view_table lv
ON li.lp_id=lv.lp_id
INNER JOIN $lp_item_view_table liw
ON liw.lp_item_id=li.id
WHERE li.c_id = $course_id AND
liw.c_id = $course_id AND
lv.c_id = $course_id AND
lv.user_id= $user_id AND
li.item_type = 'quiz' AND
liw.lp_view_id= $lp_view_id";
$sum=0;
$tot=0;
$rs_list_view1=Database::query($sql_list_view);
while ($row_list_view=Database::fetch_array($rs_list_view1)) {
$sum=$sum+$row_list_view['sum_data'];
$tot++;
}
if ($tot==0) {
$tot=1;
}
$average_data1=$sum/$tot;
} elseif ($row_type['lp_type']==2) {
//lp scorm
$sql = "SELECT id FROM $lp_view_table
WHERE c_id = $course_id AND user_id = '".intval($user_id)."' and lp_id='".$row_type['id']."'";
$rs_last_lp_view_id = Database::query($sql);
$lp_view_id = intval(Database::result($rs_last_lp_view_id,0,'id'));
$sql_list_view = "SELECT li.max_score,lv.user_id,liw.score,((liw.score/li.max_score)*100) as sum_data
FROM $lp_item_table li
INNER JOIN $lp_view_table lv
ON li.lp_id=lv.lp_id
INNER JOIN $lp_item_view_table liw ON liw.lp_item_id=li.id
WHERE li.c_id = $course_id AND
liw.c_id = $course_id AND
lv.c_id = $course_id AND
lv.user_id= $user_id AND
(li.item_type = 'sco' OR li.item_type='quiz') AND
liw.lp_view_id = $lp_view_id";
$tot = 0;
$sum = 0;
$rs_list_view2=Database::query($sql_list_view);
while ($row_list_view = Database::fetch_array($rs_list_view2)) {
$sum = $sum + $row_list_view['sum_data'];
$tot++;
}
if ($tot == 0) {
$tot = 1;
}
$average_data2=$sum/$tot;
}
$average_data_sum = $average_data_sum+$average_data1+$average_data2;
$average_data2=0;
$average_data1=0;
$count_loop++;
}
//We only count the LP that have an exercise to get the average
$lp_with_quiz = 0;
foreach ($lp_list as $lp_id) {
//check if LP have a score
$sql = "SELECT count(id) as count FROM $lp_item_table
WHERE c_id = $course_id AND item_type = 'quiz' AND lp_id = ".$lp_id." ";
$result_have_quiz = Database::query($sql);
if (Database::num_rows($result_have_quiz) > 0 ) {
$row = Database::fetch_array($result_have_quiz,'ASSOC');
if (is_numeric($row['count']) && $row['count'] != 0) {
$lp_with_quiz++;
}
}
}
if ($lp_with_quiz > 0) {
$avg_student_score = round(($average_data_sum / $lp_with_quiz * 100), 2);
}
return $avg_student_score;
}
/**
* get count clicks about tools most used by course

@ -1324,24 +1324,6 @@ class UserManager
return $return_array;
}
/**
* Get user information
* @param string The username
* @deprecated use api_get_user_info
* @return array All user information as an associative array
*/
public static function get_user_info($username)
{
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$username = Database::escape_string($username);
$sql = "SELECT * FROM $user_table WHERE username='".$username."'";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
return Database::fetch_array($res);
}
return false;
}
/**
* Get user picture URL or path from user ID (returns an array).
* The return format is a complete path, enabling recovery of the directory

@ -388,84 +388,10 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$sql = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE c_id='$courseId'";
Database::query($sql);
$inserted_in_course[$course_code] = $course_info['title'];
}
if (CourseManager::course_exists($course_code, true)) {
// If the course exists we continue.
// Also subscribe to virtual courses through check on visual code.
$list = CourseManager :: get_courses_info_from_visual_code($course_code);
foreach ($list as $vcourse) {
if ($vcourse['code'] == $course_code) {
// Ignore, this has already been inserted.
} else {
$course_info = api_get_course_info_by_id($course['id']);
$courseId = $course['real_id'];
$sql_course = "INSERT INTO $tbl_session_course SET
c_id = $courseId,
session_id = $session_id";
$rs_course = Database::query($sql_course);
SessionManager::installCourse($id_session, $courseId);
$course_coaches = explode(",",$node_course->Coach);
// adding coachs to session course user
foreach ($course_coaches as $course_coach) {
$coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
$coach_id = UserManager::get_user_id_from_username($course_coach);
if ($coach_id !== false) {
$sql = "INSERT IGNORE INTO $tbl_session_course_user SET
user_id='$coach_id',
c_id = $courseId,
session_id = '$session_id',
status = 2 ";
$rs_coachs = Database::query($sql);
} else {
$error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
}
}
// adding users
$course_counter++;
$users_in_course_counter = 0;
foreach ($node_course->User as $node_user) {
$username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
$user_id = UserManager::get_user_id_from_username($username);
if ($user_id !== false) {
// Adding to session_rel_user table.
$sql = "INSERT IGNORE INTO $tbl_session_user SET
user_id ='$user_id',
session_id = '$session_id'";
$rs_user = Database::query($sql);
$user_counter++;
// Adding to session_rel_user_rel_course table.
$sql = "INSERT IGNORE INTO $tbl_session_course_user SET
user_id ='$user_id',
c_id ='$courseId',
session_id = '$session_id'";
$rs_users = Database::query($sql);
$users_in_course_counter++;
} else {
$error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
}
}
$sql = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE c_id='$courseId'";
Database::query($sql);
$inserted_in_course[$course_code] = $course_info['title'];
}
$inserted_in_course[$vcourse['code']] = $vcourse['title'];
}
} else {
// The course does not exist.
$error_message .= get_lang('CourseDoesNotExist').' : '.$course_code.'<br />';
}
}
Database::query("UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'");
}
}
if (empty($root->Users->User) && empty($root->Courses->Course) && empty($root->Session)) {
$error_message = get_lang('NoNeededData');

@ -188,7 +188,7 @@ if (count($new_member_list) > 0) {
}
$tpl = new Template(null);
$tpl->set_help('Groups');
$tpl->setHelp('Groups');
$tpl->assign('social_avatar_block', $social_avatar_block);
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);

@ -385,21 +385,6 @@ class TestGroupManager extends UnitTestCase {
//var_dump($res);
}
public function testGetAllTutors(){
$res =GroupManager::get_all_tutors();
$this->assertTrue(is_array($res));
//var_dump($res);
}
public function testIsTutor(){
global $user_id, $_course;
$res = GroupManager::is_tutor($user_id);
$this->assertTrue(is_bool($res));
$this->assertTrue($res === false);
//var_dump($res);
}
public function testGetGroupIds(){
global $user_id;
$course_db= 'chamilo_COURSETEST';

@ -51,13 +51,6 @@ class TestText extends UnitTestCase {
//var_dump($res);
}
function test_text_parse_texexplorer() {
$textext='';
$res=_text_parse_texexplorer($textext);
$this->assertTrue(is_string($res));
//var_dump($res);
}
function test_text_parse_tool() {
$input='';
$res=_text_parse_tool($input);
@ -112,12 +105,4 @@ class TestText extends UnitTestCase {
$this->assertTrue(is_string($res));
//var_dump($res);
}
function testApiParseTex(){
$textext = 'abc';
$res = api_parse_tex($textext); //this function is practically deprecated now, it doesn't do anything
$this->assertEqual($textext,$res);
}
}
?>
}

@ -131,17 +131,6 @@ class TestTracking extends UnitTestCase {
//var_dump($res);
}
function testget_average_test_scorm_and_lp () {
global $_user,$_course;
$user_id=$_user;
$course_id=$_course;
$this->tracking = new Tracking();
$res=$this->tracking->get_average_test_scorm_and_lp($user_id,$course_id);
$this->assertTrue(is_object($this->tracking));
if(!is_numeric($res))$this->assertTrue(is_null($res));
//var_dump($res);
}
function testget_avg_student_exercise_score() {
global $_user,$_course;

Loading…
Cancel
Save