From 1ede08ef433d810962eddb681602a1fcc2ea595b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 13 Feb 2015 10:56:10 +0100 Subject: [PATCH] Fixes class name LearnpathList --- main/admin/user_move_stats.php | 1 - main/exercice/exercise.lib.php | 2 +- main/exercice/exercise_submit_modal.php | 1 - main/exercice/hotspot_admin.inc.php | 3 +- main/exercice/unique_answer.class.php | 2 - main/inc/ajax/course_home.ajax.php | 3 - main/inc/ajax/model.ajax.php | 1 - main/inc/lib/myspace.lib.php | 1 - main/inc/lib/sessionmanager.lib.php | 4 +- main/newscorm/learnpathList.class.php | 4 +- main/tracking/course_session_report.php | 2 +- main/tracking/lp_results_by_user.php | 133 +++++++++++------------ main/tracking/question_course_report.php | 2 +- main/webservices/webservice_report.php | 1 - main/wiki/index.php | 1 - 15 files changed, 73 insertions(+), 88 deletions(-) diff --git a/main/admin/user_move_stats.php b/main/admin/user_move_stats.php index 27270d4a3f2..3f106be35cc 100755 --- a/main/admin/user_move_stats.php +++ b/main/admin/user_move_stats.php @@ -12,7 +12,6 @@ $this_section=SECTION_PLATFORM_ADMIN; api_protect_admin_script(); -require_once '../newscorm/learnpathList.class.php'; $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $debug = 0; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 68b036f8b89..a05ecf15979 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1404,7 +1404,7 @@ function get_exam_results_data( } } - $lp_list_obj = new learnpathList(api_get_user_id()); + $lp_list_obj = new LearnpathList(api_get_user_id()); $lp_list = $lp_list_obj->get_flat_list(); if (is_array($results)) { diff --git a/main/exercice/exercise_submit_modal.php b/main/exercice/exercise_submit_modal.php index 888f6329786..25c59c9e3c3 100755 --- a/main/exercice/exercise_submit_modal.php +++ b/main/exercice/exercise_submit_modal.php @@ -487,7 +487,6 @@ // the link to theory (a learning path) if (!empty($lp)) { $lp_url= api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp; - require_once('../newscorm/learnpathList.class.php'); $list = new LearnpathList(api_get_user_id()); $flat_list = $list->get_flat_list(); $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).''.get_lang('SeeTheory').'
'; diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 4a0336e60f8..379269df7ec 100755 --- a/main/exercice/hotspot_admin.inc.php +++ b/main/exercice/hotspot_admin.inc.php @@ -566,7 +566,7 @@ get_flat_list(); //loading list of LPs @@ -874,7 +874,6 @@ get_flat_list(); $select_lp_id = array(); diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index e271318d265..3faf31bce5f 100755 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -106,8 +106,6 @@ public function createAnswersForm($form) $question_list = $obj_ex->selectQuestionList(); $select_question = array(); $select_question[0] = get_lang('SelectTargetQuestion'); - - require_once '../newscorm/learnpathList.class.php'; if (is_array($question_list)) { foreach ($question_list as $key => $questionid) { //To avoid warning messages diff --git a/main/inc/ajax/course_home.ajax.php b/main/inc/ajax/course_home.ajax.php index 526fbb31d9a..c92535f1ac4 100755 --- a/main/inc/ajax/course_home.ajax.php +++ b/main/inc/ajax/course_home.ajax.php @@ -106,7 +106,6 @@ */ require_once '../global.inc.php'; - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $now = time(); $page = intval($_REQUEST['page']); //page $limit = intval($_REQUEST['rows']); // quantity of rows @@ -231,7 +230,6 @@ break; case 'session_courses_lp_by_week': require_once '../global.inc.php'; - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $now = time(); $page = intval($_REQUEST['page']); //page @@ -357,7 +355,6 @@ break; case 'session_courses_lp_by_course': require_once '../global.inc.php'; - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $now = time(); $page = intval($_REQUEST['page']); //page $limit = intval($_REQUEST['rows']); // quantity of rows diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 00b189eed41..008bb195cba 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -852,7 +852,6 @@ function getWhereClause($col, $oper, $val) 'firstname', 'lastname', ); - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $lessons = LearnpathList::get_course_lessons($course['code'], $sessionId); foreach ($lessons as $lesson_id => $lesson) { $columns[] = $lesson_id; diff --git a/main/inc/lib/myspace.lib.php b/main/inc/lib/myspace.lib.php index 7caaa2838ba..082479b1030 100644 --- a/main/inc/lib/myspace.lib.php +++ b/main/inc/lib/myspace.lib.php @@ -514,7 +514,6 @@ public static function display_tracking_lp_progress_overview($sessionId = '', $c get_lang('LastName'), ); //add lessons of course - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $lessons = LearnpathList::get_course_lessons($course['code'], $sessionId); //create columns array diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 0eacc2398bd..8312ba1d428 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -626,7 +626,6 @@ public static function get_session_lp_progress($sessionId = 0, $courseId = 0, $d } //Get lessons - require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpathList.class.php'; $lessons = LearnpathList::get_course_lessons($course['code'], $sessionId); $table = array(); @@ -3443,7 +3442,6 @@ public static function copy_session($id, $copy_courses = true, $copy_users = tru if ($course_info) { //By default new elements are invisible if ($set_exercises_lp_invisible) { - require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpathList.class.php'; $list = new LearnpathList('', $course_info['code'], $sid); $flat_list = $list->get_flat_list(); if (!empty($flat_list)) { @@ -5379,7 +5377,7 @@ public static function getAllCourseCoaches() } /** - * Calculate the total user time in the platform + * Calculate the total user time in the platform * @param int $userId The user id * @param string $from Optional. From date * @param string $until Optional. Until date diff --git a/main/newscorm/learnpathList.class.php b/main/newscorm/learnpathList.class.php index fb611151014..f94a4695e93 100755 --- a/main/newscorm/learnpathList.class.php +++ b/main/newscorm/learnpathList.class.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ /** - * Class learnpathList + * Class LearnpathList * This class is only a learning path list container with several practical methods for sorting the list and * provide links to specific paths * @uses Database.lib.php to use the database @@ -10,7 +10,7 @@ * @author Yannick Warnier * */ -class learnpathList +class LearnpathList { // Holds a flat list of learnpaths data from the database. public $list = array(); diff --git a/main/tracking/course_session_report.php b/main/tracking/course_session_report.php index 13b95ec6db7..88fee5d6385 100755 --- a/main/tracking/course_session_report.php +++ b/main/tracking/course_session_report.php @@ -94,7 +94,7 @@ $attempt_result = array(); //Getting LP list - $list = new learnpathList('', $current_course['code'], $session_id); + $list = new LearnpathList('', $current_course['code'], $session_id); $lp_list = $list->get_flat_list(); // Looping LPs diff --git a/main/tracking/lp_results_by_user.php b/main/tracking/lp_results_by_user.php index edee52e28af..8f87981864a 100755 --- a/main/tracking/lp_results_by_user.php +++ b/main/tracking/lp_results_by_user.php @@ -1,9 +1,9 @@ $course_item['db_name'],'code'=>$course_item['code'], 'title'=>$course_item['title']); + $course_item = CourseManager ::get_course_information($temp_course_item['code']); + $course_list[]= array('db_name' =>$course_item['db_name'],'code'=>$course_item['code'], 'title'=>$course_item['title']); } -} else { +} else { $current_course['db_name'] = $_course['dbName']; - $current_course['code'] = $_course['id']; + $current_course['code'] = $_course['id']; $course_list = array($current_course); } @@ -62,41 +62,41 @@ } else { //Get exam lists $course_id = api_get_course_int_id(); - $t_quiz = Database::get_course_table(TABLE_QUIZ_TEST); + $t_quiz = Database::get_course_table(TABLE_QUIZ_TEST); $sqlExercices = " SELECT quiz.title,id FROM ".$t_quiz." AS quiz WHERE c_id = $course_id AND active='1' ORDER BY quiz.title ASC"; - $resultExercices = Database::query($sqlExercices); + $resultExercices = Database::query($sqlExercices); $exercise_list[0] = get_lang('All'); while($a_exercices = Database::fetch_array($resultExercices)) { $exercise_list[$a_exercices['id']] = $a_exercices['title']; - } + } $form->addElement('select', 'exercise_id', get_lang('Exercise'), $exercise_list); } - + //$form->addElement('submit','submit',get_lang('Filter')); $form->addElement('style_submit_button','submit', get_lang('Filter'),'class="search"' ); -if (!empty($_REQUEST['course_code'])) +if (!empty($_REQUEST['course_code'])) $selected_course = $_REQUEST['course_code']; if (!empty($selected_course)) { $selected_course = api_get_course_info($selected_course); - $course_list = array($selected_course); + $course_list = array($selected_course); } if (!$export_to_csv) { Display :: display_header(get_lang('Reporting')); echo '
'; if ($global) { - + echo '
 '.get_lang('ExportAsCSV').'' . ' '.get_lang('Print').'
'; - + $menu_items[] = ''.get_lang('TeacherInterface').''; if (api_is_platform_admin()) { $menu_items[] = ''.get_lang('AdminInterface').''; } else { - $menu_items[] = ''.get_lang('AdminInterface').''; + $menu_items[] = ''.get_lang('AdminInterface').''; } - $menu_items[] = get_lang('ExamTracking'); + $menu_items[] = get_lang('ExamTracking'); $nb_menu_items = count($menu_items); if($nb_menu_items>1) { foreach($menu_items as $key=> $item) { @@ -108,37 +108,36 @@ echo '
'; } } else { - echo ''.get_lang('StudentsTracking').' | + echo ''.get_lang('StudentsTracking').' | '.get_lang('CourseTracking').' | '; echo ''.get_lang('ResourcesTracking').''; echo ' | '.get_lang('ExamTracking').''; - echo ' '.get_lang('ExportAsXLS').'

'; - - } - echo '
'; + echo ' '.get_lang('ExportAsXLS').'

'; + + } + echo ''; echo '

'; - $form->display(); + $form->display(); //echo '

'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%

'; } -require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $main_result = array(); $session_id = 0; $user_list = array(); //Getting course list foreach($course_list as $current_course ) { $course_info = api_get_course_info($current_course['code']); - $_course = $course_info; - - + $_course = $course_info; + + //Getting LP list - $list = new learnpathList('', $current_course['code'], $session_id); - $lp_list = $list->get_flat_list(); - + $list = new LearnpathList('', $current_course['code'], $session_id); + $lp_list = $list->get_flat_list(); + // Looping LPs $lps = array(); - foreach ($lp_list as $lp_id =>$lp) { + foreach ($lp_list as $lp_id =>$lp) { $exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']); - $attempt_result = array(); + $attempt_result = array(); //Looping Chamilo Exercises in LP foreach ($exercise_list as $exercise) { $exercise_stats = get_all_exercise_event_from_lp($exercise['path'], $course_info['id'], $session_id); @@ -147,13 +146,13 @@ //$attempt_result[$exercise['id']]['users'][$stats['exe_user_id']][$stats['exe_id']] = array('exe_result' =>$stats['exe_result'],'exe_weighting' =>$stats['exe_weighting']); $attempt_result[$exercise['id']]['users'][$stats['exe_user_id']][$stats['exe_id']] = $stats; $user_list[$stats['exe_user_id']] = $stats['exe_user_id']; - } + } $exercise_list_name[$exercise['id']] = $exercise['title']; } - $lps[$lp_id] = array('lp_name' =>$lp['lp_name'], 'exercises' =>$attempt_result); + $lps[$lp_id] = array('lp_name' =>$lp['lp_name'], 'exercises' =>$attempt_result); $lp_list_name[$lp_id] = $lp['lp_name']; } - $main_result[$current_course['code']] = $lps; + $main_result[$current_course['code']] = $lps; } //echo '
';print_r($main_result);
 if (!empty($user_list)) {
@@ -164,7 +163,7 @@
 }
 $export_array =  array();
 if (!empty($main_result)) {
-    
+
     $html_result .= '';
     $html_result .= '';
     $html_result .= '';
@@ -173,20 +172,20 @@
     $html_result .= '';
     $html_result .= '';
     $html_result .= '';
-    $html_result .= '';        
-    
+    $html_result .= '';
+
     foreach ($main_result as $course_code => $lps) {
         if (empty($lps)) {
             continue;
-        }   
-        
-        foreach($lps as $lp_id => $lp_data) { 
-            $exercises = $lp_data['exercises']; 
-            
+        }
+
+        foreach($lps as $lp_id => $lp_data) {
+            $exercises = $lp_data['exercises'];
+
             foreach($exercises as $exercise_id => $exercise_data) {
                 $users = $exercise_data['users'];
                 foreach($users as $user_id => $attempts) {
-                    $attempt = 1;         
+                    $attempt = 1;
                     foreach($attempts as $exe_id => $attempt_data) {
                         $html_result .= '';
                         $html_result .= Display::tag('td', $course_code);
@@ -194,77 +193,77 @@
                         $html_result .= Display::tag('td', $exercise_list_name[$exercise_id]);
                         $html_result .= Display::tag('td', $user_list_name[$user_id]);
                         $result = $attempt_data['exe_result'].' / '.$attempt_data['exe_weighting'];
-                        $html_result .= Display::tag('td', $attempt);                        
+                        $html_result .= Display::tag('td', $attempt);
                         $html_result .= Display::tag('td', api_get_local_time($attempt_data['exe_date']));
                         $html_result .= Display::tag('td', $result);
-                                                 
+
                         $html_result .= '';
                         $export_array[]= array($course_code, $lp_list_name[$lp_id], $exercise_list_name[$exercise_id], $user_list_name[$user_id], $attempt, api_get_local_time($attempt_data['exe_date']), $result);
                         $attempt++;
                     }
-                }    
-            }   
+                }
+            }
         }
     }
     $html_result .='
'.get_lang('Course').''.get_lang('LearningPath').''.get_lang('Attempt').''.get_lang('Date').''.get_lang('Results').'
'; } if (!$export_to_csv) { - echo $html_result; + echo $html_result; } $filename = 'learning_path_results-'.date('Y-m-d-h:i:s').'.xls'; if ($export_to_csv) { export_complete_report_csv($filename, $export_array); exit; } -function export_complete_report_csv($filename, $array) { +function export_complete_report_csv($filename, $array) { require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php'; $header[] = array(get_lang('Course'),get_lang('LearningPath'), get_lang('Exercise'), get_lang('User'),get_lang('Attempt'), get_lang('Date'),get_lang('Results')); if (!empty($array)) { - $array = array_merge($header, $array); + $array = array_merge($header, $array); Export :: export_table_csv($array, $filename); } exit; - /* - * Too much encoding problems while exporting to XLS, keep it simple - * - * + /* + * Too much encoding problems while exporting to XLS, keep it simple + * + * global $global, $filter_score; $workbook = new Spreadsheet_Excel_Writer(); $workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); $workbook->send($filename); $workbook->setVersion(8); // BIFF8 $worksheet =& $workbook->addWorksheet('Report'); - $worksheet->setInputEncoding(api_get_system_encoding()); - + $worksheet->setInputEncoding(api_get_system_encoding()); + $line = 0; - $column = 0; //skip the first column (row titles) + $column = 0; //skip the first column (row titles) $worksheet->write($line,$column,get_lang('Course')); $column++; $worksheet->write($line,$column,get_lang('LearningPath')); $column++; $worksheet->write($line,$column,get_lang('Exercise')); - $column++; + $column++; $worksheet->write($line,$column,get_lang('User')); $column++; $worksheet->write($line,$column,get_lang('Attempt')); $column++; $worksheet->write($line,$column,get_lang('Date')); - $column++; + $column++; $worksheet->write($line,$column,get_lang('Results')); - $column++; - $line++; + $column++; + $line++; foreach ($array as $row) { $column = 0; - foreach ($row as $item) { + foreach ($row as $item) { $worksheet->write($line,$column,html_entity_decode(strip_tags($item))); $column++; } $line++; - } - $line++; - + } + $line++; + $workbook->close(); exit;*/ } diff --git a/main/tracking/question_course_report.php b/main/tracking/question_course_report.php index 798fdb4732a..bafa852b7c0 100755 --- a/main/tracking/question_course_report.php +++ b/main/tracking/question_course_report.php @@ -86,7 +86,7 @@ function load_courses() { $course_info = api_get_course_info($course_code); //var_dump($session_id); if (!empty($course_info)) { - $list = new learnpathList('', $course_code); + $list = new LearnpathList('', $course_code); $lp_list = $list->get_flat_list(); $_course = $course_info; $main_question_list = array(); diff --git a/main/webservices/webservice_report.php b/main/webservices/webservice_report.php index 5268c1dc77c..c087f3dbaac 100755 --- a/main/webservices/webservice_report.php +++ b/main/webservices/webservice_report.php @@ -97,7 +97,6 @@ public function GetLearnpathsByCourse($secret_key, $user_id_field_name, $user_id $course_code = CourseManager::get_course_code_from_course_id($course_id); } - require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php'; $lp = new LearnpathList($user_id,$course_code); $list = $lp->list; $return = array(); diff --git a/main/wiki/index.php b/main/wiki/index.php index 668b51b1f58..355ee86c324 100755 --- a/main/wiki/index.php +++ b/main/wiki/index.php @@ -23,7 +23,6 @@ // section (for the tabs) $this_section = SECTION_COURSES; $current_course_tool = TOOL_WIKI; -require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; $course_id = api_get_course_int_id(); $session_id = api_get_session_id();