Browse Source

course report by session refs BT#7016

César Perales 11 years ago
parent
commit
693d2bccbd

+ 70 - 1
main/inc/ajax/model.ajax.php

@@ -228,7 +228,14 @@ switch ($action) {
         $count = SessionManager::get_count_admin($where_condition);
         break;
     case 'get_session_lp_progress':
-        $count = SessionManager::get_count_session_lp_progress($_GET['session_id']);
+        $count = SessionManager::get_count_session_lp_progress(intval($_GET['session_id']));
+        break;
+    case 'get_session_progress':
+        $courses = SessionManager::get_course_list_by_session_id(intval($_GET['session_id']));
+        //TODO let select course
+        $course = current($courses);
+        $users = CourseManager::get_student_list_from_course_code($course['code'], true, intval($_GET['session_id']));
+        $count = count($users);
         break;
     /*case 'get_extra_fields':
         $type = $_REQUEST['type'];
@@ -512,6 +519,67 @@ switch ($action) {
             )
         );
         break;
+    case 'get_session_progress':
+        $columns = array(
+            'lastname',
+            'firstname',
+            'username',
+            #'profile',
+            'total',
+            'courses',
+            'lessons',
+            'exercises',
+            'forums',
+            'homeworks',
+            'wikis',
+            'surveys',
+            //course description
+            'course_description_progress',
+            //exercises
+            'lessons_total' ,
+            'lessons_done' ,
+            'lessons_left' ,
+            'lessons_progress',
+            //exercises
+            'exercises_total' ,
+            'exercises_done' ,
+            'exercises_left' ,
+            'exercises_progress' ,
+            //forums
+            'forums_total' ,
+            'forums_done' ,
+            'forums_left' ,
+            'forums_progress' ,
+            //assignments
+            'assignments_total' ,
+            'assignments_done' ,
+            'assignments_left' ,
+            'assignments_progress' ,
+            //Wiki
+            'wiki_total',
+            'wiki_revisions',
+            'wiki_read',
+            'wiki_unread',
+            'wiki_progress',
+            //surveys
+            'surveys_total' ,
+            'surveys_done' ,
+            'surveys_left' ,
+            'surveys_progress' ,
+            );
+        $sessionId = 0;
+        if (isset($_GET['session_id']) && !empty($_GET['session_id']))
+        {
+            $sessionId = intval($_GET['session_id']);
+        }
+        $result = SessionManager::get_session_progress($sessionId,
+            array(
+                'where' => $where_condition,
+                'order' => "$sidx $sord",
+                'limit'=> "$start , $limit"
+            )
+        );
+        break;
     case 'get_timelines':
         $columns = array('headline', 'actions');
 
@@ -712,6 +780,7 @@ $allowed_actions = array(
     'get_gradebooks',
     'get_sessions',
     'get_session_lp_progress',
+    'get_session_progress',
     'get_exercise_results',
     'get_hotpotatoes_exercise_results',
     'get_work_teacher',

+ 237 - 3
main/inc/lib/sessionmanager.lib.php

@@ -544,12 +544,246 @@ class SessionManager
             while ($row = Database::fetch_assoc($result)) {
                 $formatted_sessions[] = $row;
             }
-            /*foreach ($lps as $lp) {
-                error_log(print_r($lp,1));
-            }*/
         }
         return $formatted_sessions;
     }
+    /**
+     * Gets the progress of the given session
+     * @param int   session id
+     * @param array options order and limit keys
+     * @return array table with user name, lp name, progress
+     */
+    public static function get_session_progress($sessionId, $options)
+    {
+
+        //tables
+        $session_course_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+        $user                   = Database::get_main_table(TABLE_MAIN_USER);
+        $workTable              = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+        $workTableAssignment    = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
+        $forum                  = Database::get_course_table(TABLE_FORUM);
+        $forum_post             = Database::get_course_table(TABLE_FORUM_POST);
+        $tbl_course_lp          = Database::get_course_table(TABLE_LP_MAIN);
+        $wiki                   = Database::get_course_table(TABLE_WIKI);
+
+        $courses = SessionManager::get_course_list_by_session_id($sessionId);
+        //TODO let select course
+        $course = current($courses);
+        //TODO fix this
+        $course_info = array('real_id' => $course['id']);
+
+        //getting all the students of the course
+        //we are not using this because it only returns user ids
+        /*if (empty($sessionId)
+        {
+            // Registered students in a course outside session.
+            $users = CourseManager :: get_student_list_from_course_code($course_code);
+        } else {
+            // Registered students in session.
+            $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId);
+        }*/
+        $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code FROM $session_course_user s
+        INNER JOIN $user u ON u.user_id = s.id_user
+        WHERE course_code = '%s'
+        AND s.status <> 2 and id_session = %s";
+
+        $sql_query = sprintf($sql, $course['code'], $sessionId);
+
+        $rs = Database::query($sql_query);
+        while ($user = Database::fetch_array($rs))
+        {
+            $users[$user['user_id']] = $user;
+        }
+
+        /**
+         *  Lessons
+         */
+        $sql = "SELECT * FROM $tbl_course_lp
+        WHERE c_id = %s ";  //AND session_id = %s
+        $sql_query = sprintf($sql, $course_info['real_id']);
+        $result = Database::query($sql_query);
+        $lessons_total = 0;
+        while ($row = Database::fetch_array($result))
+        {
+            if (api_get_item_visibility(api_get_course_info($course['code']), 'learnpath', $row['id'], $sessionId))
+            {
+                $lessons_total++;
+            }
+        }
+
+        /**
+         *  Exercises
+         */
+        require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
+        $exercises = get_all_exercises($course_info, $sessionId);
+        $exercises_total = count($exercises);
+
+        /**
+         *  Assignments
+         */
+        //total
+        $sql = "SELECT count(w.id) as count
+        FROM $workTable w
+        LEFT JOIN  $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
+        WHERE w.c_id = %s
+        AND parent_id = 0
+        AND active IN (1, 0)
+        AND  session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $assignments_total = $row['count'];
+
+        /**
+         * Wiki
+         */
+        $sql = "SELECT count(distinct page_id)  as count FROM $wiki
+            WHERE c_id = %s and session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $wiki_total = $row['count'];
+
+        /**
+         * Surveys
+         */
+        $survey_user_list = array();
+        $survey_list = survey_manager::get_surveys($course['code'], $sessionId);
+
+        $surveys_total = count($survey_list);
+        $survey_data = array();
+        foreach ($survey_list as $survey)
+        {
+            $user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']);
+            foreach ($user_list as $user_id)
+            {
+                isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : $survey_user_list[$user_id] = 1;
+            }
+        }
+        /**
+         * Forums
+         */
+        //total
+        $sql = "SELECT count(*) as count
+        FROM $forum f
+        where f.c_id = %s and f.session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $forums_total = $row['count'];
+
+
+        //process table info
+        foreach ($users as $user)
+        {
+            //Course description
+            $sql = "SELECT count(*) as count
+            FROM track_e_access
+            WHERE access_tool = 'course_description'
+            AND access_cours_code = '%s'
+            AND access_session_id = %s
+            AND access_user_id = %s ";
+            $sql_query  = sprintf($sql, $course['code'], $sessionId, $user['user_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+            $course_description_progress = ($row['count'] > 0) ? 100 : 0;
+
+            //Lessons
+            //TODO: Lessons done and left is calculated by progress per item in lesson, maybe we should calculate it only per completed lesson?
+            $lessons_progress   = Tracking::get_avg_student_progress($user['user_id'], $course['code'], array(), $sessionId);
+            $lessons_done       = ($lessons_progress * $lessons_total) / 100;
+            $lessons_left       = $lessons_total - $lessons_done;
+
+            //Exercises
+            $exercises_progress     = str_replace('%', '', Tracking::get_exercise_student_progress($exercises, $user['user_id'], $course['code'], $sessionId));
+            $exercises_done         = ($exercises_progress * $exercises_total) / 100;
+            $exercises_left         = $exercises_total - $exercises_done;
+
+            //Assignments
+            $assignments_done       = Tracking::count_student_assignments($user['user_id'], $course['code'], $sessionId);
+            $assignments_left       = $assignments_total - $assignments_done;
+            $assignments_progress   =  round((( $assignments_done * 100 ) / $assignments_total ), 2);
+
+            //Wiki
+            $sql = "SELECT count(*) as count
+            FROM $wiki
+            where c_id = %s and session_id = %s and user_id = %s";
+            $sql_query  = sprintf($sql, $course_info['real_id'], $sessionId, $user['user_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+            $wiki_revisions =  $row['count'];
+
+            //Surveys
+            $surveys_done       = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0);
+            $surveys_left       = $surveys_total - $surveys_done;
+            $surveys_progress   = round((( $surveys_done * 100 ) /  $surveys_total), 2);
+
+            //Forums
+            #$forums_done = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
+            $sql = "SELECT count(distinct f.forum_id) as count FROM $forum_post p
+            INNER JOIN $forum f ON f.forum_id = p.forum_id
+            WHERE p.poster_id = %s and f.session_id = %s and p.c_id = %s";
+            $sql_query  = sprintf($sql, $user['user_id'], $sessionId, $course_info['real_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+
+            $forums_done        = $row['count'];
+            $forums_left        = $forums_total - $forums_done;
+            $forums_progress    = round((( $forums_done * 100 ) /  $forums_total), 2);
+
+            //Overall Total
+            $overall_total =  ($course_description_progress + $exercises_progress + $forums_progress + $assignments_progress + $wiki_progress + $surveys_progress) / 6;
+
+            $table[] = array(
+                'lastname'  => $user[1],
+                'firstname' => $user[2],
+                'username'  => $user[3],
+                #'profile'   => '',
+                'total'     => round($overall_total,2) . '%',
+                'courses'   => $course_description_progress . '%',
+                'lessons'   => $lessons_progress . '%',
+                'exercises' => $exercises_progress . '%',
+                'forums'    => $forums_progress . '%',
+                'homeworks' => $assignments_progress . '%',
+                'wikis'     => $wiki_progress . '%',
+                'surveys'   => $surveys_progress . '%',
+                //course description
+                'course_description_progress' => $course_description_progress . '%',
+                //lessons
+                'lessons_total'      => $lessons_total,
+                'lessons_done'       => $lessons_done,
+                'lessons_left'       => $lessons_left,
+                'lessons_progress'   => $lessons_progress . '%',
+                //exercises
+                'exercises_total'       => $exercises_total,
+                'exercises_done'        => $exercises_done,
+                'exercises_left'        => $exercises_left,
+                'exercises_progress'    => $exercises_progress . '%',
+                //forums
+                'forums_total'      => $forums_total,
+                'forums_done'       => $forums_done,
+                'forums_left'       => $forums_left,
+                'forums_progress'   => $forums_progress . '%',
+                //assignments
+                'assignments_total'     => $assignments_total,
+                'assignments_done'      => $assignments_done,
+                'assignments_left'      => $assignments_left,
+                'assignments_progress'  => $assignments_progress . '%',
+                //wiki
+                'wiki_total'        => $wiki_total,
+                'wiki_revisions'    => $wiki_revisions,
+                'wiki_read'         => $wiki_read,
+                'wiki_unread'       => $wiki_unread,
+                'wiki_progress'     => $wiki_progress . '%',
+                //survey
+                'surveys_total'     => $surveys_total,
+                'surveys_done'      => $surveys_done,
+                'surveys_left'      => $surveys_left,
+                'surveys_progress'  => $surveys_progress . '%',
+                );
+        }
+        return $table;
+    }
     /**
      * Creates a new course code based in given code
      *

+ 11 - 4
main/mySpace/index.php

@@ -162,7 +162,7 @@ echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
       Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
 echo '</span>';
 
-if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview'))) {
+if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview'))) {
 	echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
     if (!api_is_platform_admin()) {
         if (api_get_setting('add_users_by_coach') == 'true') {
@@ -186,7 +186,7 @@ if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogres
 
 // Actions menu
 $nb_menu_items = count($menu_items);
-if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview'))) {
+if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
 	if ($nb_menu_items > 1) {
     	foreach ($menu_items as $key => $item) {
 	    	echo $item;
@@ -207,7 +207,7 @@ if (empty($session_id) || in_array($display, array('accessoverview','lpprogresso
     $courseListUrl = api_get_self();
 
     #show filter by session
-    if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview'))) {
+    if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
         echo '<div class="pull-right">';
         echo $sessionFilter->return_form();
         echo '</div>';
@@ -634,7 +634,8 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
 	}
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=accessoverview">'.get_lang('DisplayAccessOverview').'</a>';
-    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=lpprogressoverview">'.get_lang('Displaylpprogressoverview').'</a>';
+    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=lpprogressoverview">'.get_lang('DisplayLpProgressOverview').'</a>';
+    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=progressoverview">'.get_lang('DisplayProgressOverview').'</a>';
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
     echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin">'.get_lang('LPQuestionListResults').'</a>';
     echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';
@@ -657,6 +658,12 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
         } else {
             Display::display_warning_message(get_lang('ChooseSession'));
         }
+    } else if($display == 'progressoverview') {
+        if (!empty($_GET['session_id'])) {
+            echo MySpace::display_tracking_progress_overview($_GET['session_id']);
+        } else {
+            Display::display_warning_message(get_lang('ChooseSession'));
+        }
 	} else if($display == 'courseoverview') {
 		MySpace::display_tracking_course_overview();
 	} else {

+ 114 - 0
main/mySpace/myspace.lib.php

@@ -293,6 +293,120 @@ class MySpace {
         $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
 
 
+        $return = '<script>$(function() {'. $table . '});</script>';
+        $return .= Display::grid_html('lps');
+        return $return;
+    }
+    /**
+     * Display a sortable table that contains an overview off all the progress of the user in a session
+     * @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
+     */
+    function display_tracking_progress_overview($sessionId = 0) {
+
+       //The order is important you need to check the the $column variable in the model.ajax.php file
+        $columns = array(
+            get_lang('LastName'),
+            get_lang('FirstName'),
+            get_lang('Username'),
+            #get_lang('Profile'),
+            get_lang('Total'),
+            get_lang('CourseDescription'),
+            get_lang('Lessons'),
+            get_lang('Exercises'),
+            get_lang('Forums'),
+            get_lang('Homeworks'),
+            get_lang('Wikis'),
+            get_lang('Surveys'),
+            //course description
+            get_lang('CourseDescriptionProgress'),
+            //Exercises
+            get_lang('LessonsTotal'),
+            get_lang('LessonsDone'),
+            get_lang('LessonsLeft'),
+            get_lang('LessonsProgress'),
+            //Exercises
+            get_lang('ExercisesTotal'),
+            get_lang('ExercisesDone'),
+            get_lang('ExercisesLeft'),
+            get_lang('ExercisesProgress'),
+            //Forums
+            get_lang('ForumsTotal'),
+            get_lang('ForumsDone'),
+            get_lang('ForumsLeft'),
+            get_lang('ForumsProgress'),
+            //Assignments
+            get_lang('AssignmentsTotal'),
+            get_lang('AssignmentsDone'),
+            get_lang('AssignmentsLeft'),
+            get_lang('AssignmentsProgress'),
+            //Wiki
+            get_lang('WikiTotal'),
+            get_lang('WikiRevisions'),
+            get_lang('WikiRead'),
+            get_lang('WikiUnread'),
+            get_lang('WikiProgress'),
+            //Surveys
+            get_lang('SurveysTotal'),
+            get_lang('SurveysDone'),
+            get_lang('SurveysLeft'),
+            get_lang('SurveysProgress'),
+        );
+
+        //Column config
+        $column_model   = array(
+            array('name'=>'lastname',   'index'=>'lastname',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'firstname',  'index'=>'firstname',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'username',   'index'=>'username',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            #array('name'=>'profile',   'index'=>'username',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'total',      'index'=>'total',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'courses',    'index'=>'courses',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons',    'index'=>'lessons',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises',  'index'=>'exercises',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums',     'index'=>'forums',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'homeworks',  'index'=>'homeworks',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wikis',      'index'=>'wikis',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys',    'index'=>'surveys',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Course description
+            array('name'=>'course_description_progress',    'index'=>'course_description_progress',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Lessons
+            array('name'=>'lessons_total',    'index'=>'lessons_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_done',     'index'=>'lessons_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_left',     'index'=>'lessons_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_progress', 'index'=>'lessons_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Exercises
+            array('name'=>'exercises_total',    'index'=>'exercises_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_done',     'index'=>'exercises_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_left',     'index'=>'exercises_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_progress', 'index'=>'exercises_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'forums_total',    'index'=>'forums_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_done',     'index'=>'forums_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_left',     'index'=>'forums_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_progress', 'index'=>'forums_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'assigments_total',    'index'=>'assigments_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_done',     'index'=>'assigments_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_left',     'index'=>'assigments_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_progress', 'index'=>'assigments_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'wiki_total',         'index'=>'wiki_total',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_revisions',     'index'=>'wiki_revisions',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_read',          'index'=>'wiki_read',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_unread',        'index'=>'wiki_unread',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_progress',      'index'=>'wiki_progress',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Surveys
+            array('name'=>'surveys_total',    'index'=>'surveys_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_done',     'index'=>'surveys_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_left',     'index'=>'surveys_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_progress', 'index'=>'surveys_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+        );
+
+        $action_links = '';
+        // jqgrid will use this URL to do the selects
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id=' . intval($sessionId);
+        $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
+
+
         $return = '<script>$(function() {'. $table . '});</script>';
         $return .= Display::grid_html('lps');
         return $return;

+ 2 - 6
main/survey/survey.lib.php

@@ -1265,7 +1265,6 @@ class survey_manager
 	 */
 	static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null)
     {
-
 		// Database table definition
 		$table_survey_answer 		= Database :: get_course_table(TABLE_SURVEY_ANSWER);
 		$table_user					= Database :: get_main_table(TABLE_MAIN_USER);
@@ -1273,9 +1272,6 @@ class survey_manager
 		// Variable initialisation
 		$return = array();
 
-		// Getting the survey information
-		$survey_data	= survey_manager::get_survey($survey_id);
-
 		if (empty($course_id)) {
             $course_id  = api_get_course_int_id();
         } else {
@@ -1288,11 +1284,11 @@ class survey_manager
 						FROM $table_survey_answer answered_user
 						LEFT JOIN $table_user as user ON answered_user.user = user.user_id
 						WHERE 	answered_user.c_id = $course_id AND
-								survey_id= '".Database::escape_string($survey_data['survey_id'])."' ".
+								survey_id= '".Database::escape_string($survey_id)."' ".
                         $order_clause;
 		} else {
 			$sql = "SELECT DISTINCT user FROM $table_survey_answer
-			        WHERE c_id = $course_id AND survey_id= '".Database::escape_string($survey_data['survey_id'])."'  ";
+			        WHERE c_id = $course_id AND survey_id= '".Database::escape_string($survey_id)."'  ";
 		}
 
 		$res = Database::query($sql);