Browse Source

Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

Yannick Warnier 9 years ago
parent
commit
1a9c4ee355

+ 55 - 16
main/forum/reply.php

@@ -67,7 +67,11 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
 }
 
 if ($current_forum['forum_of_group'] != 0) {
-    $show_forum = GroupManager::user_has_access(api_get_user_id(), $current_forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM);
+    $show_forum = GroupManager::user_has_access(
+        api_get_user_id(),
+        $current_forum['forum_of_group'],
+        GroupManager::GROUP_TOOL_FORUM
+    );
     if (!$show_forum) {
         api_not_allowed();
     }
@@ -90,25 +94,52 @@ if (!empty($gradebook) && $gradebook == 'view') {
 if ($origin == 'group') {
     $_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
     $group_properties  = GroupManager :: get_group_properties($_clean['toolgroup']);
-    $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
-    $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
-    $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
-    $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']);
-    $interbreadcrumb[] = array('url' => 'javascript: void(0);', 'name' => get_lang('Reply'));
+    $interbreadcrumb[] = array(
+        'url' => '../group/group.php?'.api_get_cidreq(),
+        'name' => get_lang('Groups'),
+    );
+    $interbreadcrumb[] = array(
+        'url' => '../group/group_space.php?'.api_get_cidreq(),
+        'name' => get_lang('GroupSpace').' '.$group_properties['name'],
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(),
+        'name' => $current_forum['forum_title'],
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(),
+        'name' => $current_thread['thread_title'],
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'javascript: void(0);',
+        'name' => get_lang('Reply'),
+    );
 } else {
-    $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools);
-    $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']);
-    $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
-    $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']);
+    $interbreadcrumb[] = array(
+        'url' => 'index.php?gradebook='.$gradebook,
+        'name' => $nameTools,
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&'.api_get_cidreq(),
+        'name' => $current_forum_category['cat_title'],
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewforum.php?origin='.$origin.'&forum='.intval($_GET['forum']).'&'.api_get_cidreq(),
+        'name' => $current_forum['forum_title'],
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewthread.php?origin='.$origin.'&gradebook='.$gradebook.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread']).'&'.api_get_cidreq(),
+        'name' => $current_thread['thread_title'],
+    );
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Reply'));
 }
 
 /* Resource Linker */
 
-if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Resources')) {
-    $_SESSION['formelements']  = $_POST;
-    $_SESSION['origin']        = $_SERVER['REQUEST_URI'];
-    $_SESSION['breadcrumbs']   = $interbreadcrumb;
+if (isset($_POST['add_resources']) && $_POST['add_resources'] == get_lang('Resources')) {
+    $_SESSION['formelements'] = $_POST;
+    $_SESSION['origin'] = $_SERVER['REQUEST_URI'];
+    $_SESSION['breadcrumbs'] = $interbreadcrumb;
     header('Location: ../resourcelinker/resourcelinker.php');
     exit;
 }
@@ -151,7 +182,9 @@ if ($origin != 'learnpath') {
 }
 /*New display forum div*/
 echo '<div class="forum_title">';
-echo '<h1><a href="viewforum.php?&origin='.$origin.'&forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a></h1>';
+echo '<h1><a href="viewforum.php?&origin='.$origin.'&forum='.$current_forum['forum_id'].'" '.
+    class_visible_invisible($current_forum['visibility']).'>'.
+    prepare4display($current_forum['forum_title']).'</a></h1>';
 echo '<p class="forum_description">'.prepare4display($current_forum['forum_comment']).'</p>';
 echo '</div>';
 /* End new display forum */
@@ -159,7 +192,13 @@ echo '</div>';
 $my_action   = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
 $my_post     = isset($_GET['post']) ?   Security::remove_XSS($_GET['post']) : '';
 $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '';
-$values = show_add_post_form($current_forum, $forum_setting, $my_action, $my_post, $my_elements);
+$values = show_add_post_form(
+    $current_forum,
+    $forum_setting,
+    $my_action,
+    $my_post,
+    $my_elements
+);
 if (!empty($values) AND isset($_POST['SubmitPost'])) {
     $result = store_reply($current_forum, $values);
     //@todo split the show_add_post_form function

BIN
main/img/icons/32/group_na.png


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

@@ -186,6 +186,11 @@ if (!$sidx) {
 //@todo rework this
 
 switch ($action) {
+    case 'get_group_reporting':
+        $course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : null;
+        $group_id = isset($_REQUEST['gidReq']) ? $_REQUEST['gidReq'] : null;
+        $count = Tracking::get_group_reporting($course_id, $group_id, 'count');
+        break;
     case 'get_user_course_report':
     case 'get_user_course_report_resumed':
         $userId = api_get_user_id();
@@ -563,6 +568,20 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit
 $columns = array();
 
 switch ($action) {
+    case 'get_group_reporting':
+        $columns = array('name', 'time', 'progress', 'score', 'works', 'messages', 'actions');
+
+        $result = Tracking::get_group_reporting(
+            $course_id,
+            $group_id,
+            'all',
+            $start,
+            $limit,
+            $sidx,
+            $sord,
+            $whereCondition
+        );
+        break;
     case 'get_course_exercise_medias':
         $columns = array('question');
         $result = Question::get_course_medias(
@@ -1555,7 +1574,8 @@ $allowed_actions = array(
     //'get_course_exercise_medias',
     'get_user_course_report',
     'get_user_course_report_resumed',
-    'get_exercise_grade'
+    'get_exercise_grade',
+    'get_group_reporting'
 );
 
 //5. Creating an obj to return a json

+ 6 - 6
main/inc/lib/agenda.lib.php

@@ -2997,7 +2997,7 @@ class Agenda
 
             // if the student has specified a course we a add a link to that course
             if ($item['course'] <> "") {
-                $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($item['course'])."&amp;day=$day&amp;month=$month&amp;year=$year#$day"; // RH  //Patrick Cool: to highlight the relevant agenda item
+                $url = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($item['course'])."&day=$day&month=$month&year=$year#$day"; // RH  //Patrick Cool: to highlight the relevant agenda item
                 $course_link = "<a href=\"$url\" title=\"".$item['course']."\">".$item['course']."</a>";
             } else {
                 $course_link = "";
@@ -3008,7 +3008,7 @@ class Agenda
                 // This is the array construction for the WEEK or MONTH view
 
                 //Display events in agenda
-                $agendaitems[$day] .= "<div><i>$time_minute</i> $course_link <a href=\"myagenda.php?action=view&amp;view=personal&amp;day=$day&amp;month=$month&amp;year=$year&amp;id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div><br />";
+                $agendaitems[$day] .= "<div><i>$time_minute</i> $course_link <a href=\"myagenda.php?action=view&view=personal&day=$day&month=$month&year=$year&id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div><br />";
 
             } else {
                 // this is the array construction for the DAY view
@@ -3018,7 +3018,7 @@ class Agenda
                 }
 
                 //Display events by list
-                $agendaitems[$halfhour] .= "<div><i>$time_minute</i> $course_link <a href=\"myagenda.php?action=view&amp;view=personal&amp;day=$day&amp;month=$month&amp;year=$year&amp;id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div>";
+                $agendaitems[$halfhour] .= "<div><i>$time_minute</i> $course_link <a href=\"myagenda.php?action=view&view=personal&day=$day&month=$month&year=$year&id=".$item['id']."#".$item['id']."\" class=\"personal_agenda\">".$item['title']."</a></div>";
             }
         }
         return $agendaitems;
@@ -3057,8 +3057,8 @@ class Agenda
         $prev_year = ($month == 12 ? $year +1 : $year);
 
         if ($show_content)  {
-            $back_url = Display::url($prev_icon, api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;action=view&amp;view=month&amp;month=".$next_month."&amp;year=".$next_year);
-            $next_url = Display::url($next_icon, api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;action=view&amp;view=month&amp;month=".$prev_month."&amp;year=".$prev_year);
+            $back_url = Display::url($prev_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$next_month."&year=".$next_year);
+            $next_url = Display::url($next_icon, api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($g_cc)."&action=view&view=month&month=".$prev_month."&year=".$prev_year);
         } else {
             $back_url = Display::url($prev_icon, '', array('onclick'=>"load_calendar('".$user_id."','".$next_month."', '".$next_year."'); "));
             $next_url = Display::url($next_icon, '', array('onclick'=>"load_calendar('".$user_id."','".$prev_month."', '".$prev_year."'); "));
@@ -3249,7 +3249,7 @@ class Agenda
                 $agendaday = date("j",strtotime($item['start_date']));
                 $month = date("n",strtotime($item['start_date']));
                 $year = date("Y",strtotime($item['start_date']));
-                $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday";
+                $URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($course["code"])."&day=$agendaday&month=$month&year=$year#$agendaday";
                 list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['start_date']);
                 $start_date = $year.$month.$day.$hour.$min;
                 list($year,$month,$day,$hour,$min,$sec) = split('[-: ]',$item['end_date']);

+ 35 - 35
main/inc/lib/blog.lib.php

@@ -757,7 +757,7 @@ class Blog
 			if (Database::num_rows($result) > 0) {
 				echo '<ul>';
 				while ($mytask = Database::fetch_array($result)) {
-					echo '<li><a href="blog.php?action=execute_task&amp;blog_id=' . $mytask['blog_id'] . '&amp;task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
+					echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
 				}
 				echo '<ul>';
 			} else {
@@ -873,8 +873,8 @@ class Blog
 				$introduction_text = stripslashes($introduction_text);
 
 				echo '<div class="blogpost">';
-				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
-				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
+				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
+				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
 				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
 				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
 
@@ -889,7 +889,7 @@ class Blog
 					echo '</span>';
 				}
 				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
+				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
 				echo '</div>';
 			}
 		} else {
@@ -987,10 +987,10 @@ class Blog
 		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
 
 		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
-			$blog_post_actions .= '<a href="blog.php?action=edit_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $post_id . '&amp;article_id=' . $blog_post['post_id'] . '&amp;task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '"><img src="../img/edit.gif" /></a>';
+			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '"><img src="../img/edit.gif" /></a>';
 
 		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
-			$blog_post_actions .= '<a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $post_id . '&amp;do=delete_article&amp;article_id=' . $blog_post['post_id'] . '&amp;task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
+			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
 
 		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
 			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
@@ -999,7 +999,7 @@ class Blog
 
 		// Display post
 		echo '<div class="blogpost">';
-		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
+		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
 		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
 		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
 
@@ -1206,7 +1206,7 @@ class Blog
 			$comment_text = make_clickable(stripslashes($comment['comment']));
 			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
 			$blog_comment_actions = "";
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&amp;blog_id=' . $blog_id . '&amp;post_id=' . $post_id . '&amp;do=delete_comment&amp;comment_id=' . $comment['comment_id'] . '&amp;task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
+			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
 			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
 
 			if (!is_null($comment['task_id'])) {
@@ -1349,10 +1349,10 @@ class Blog
 			global $color2;
 
 			echo '<div class="actions">';
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&amp;blog_id=' . $blog_id . '&amp;do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&amp;blog_id=' . $blog_id . '&amp;do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
+			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
+			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
 			?>
-				<a href="<?php echo api_get_self(); ?>?action=manage_rights&amp;blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
+				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
 			<?php
 			echo '</div>';
 
@@ -1385,7 +1385,7 @@ class Blog
 				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
 				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
 				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&amp;blog_id=' . $task['blog_id'] . '&amp;do=delete&amp;task_id=' . $task['task_id'];
+				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
 				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
 
 				echo	'<tr class="' . $css_class . '" valign="top">',
@@ -1393,7 +1393,7 @@ class Blog
 							 '<td>' . Security::remove_XSS($task['description']) . '</td>',
 							 '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
 							 '<td width="50">',
-							 	'<a href="' .api_get_self(). '?action=manage_tasks&amp;blog_id=' . $task['blog_id'] . '&amp;do=edit&amp;task_id=' . $task['task_id'] . '">',
+							 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
 								'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
 								"</a>\n",
 								'<a href="' . $delete_link . '"',
@@ -1449,7 +1449,7 @@ class Blog
 			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
 			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
 			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&amp;blog_id=' . $assignment['blog_id'] . '&amp;do=delete&amp;task_id=' . $assignment['task_id'];
+			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
 			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
 
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
@@ -1460,10 +1460,10 @@ class Blog
 						 '<td>'.stripslashes($assignment['description']) . '</td>',
 						 '<td>' . $assignment['target_date'] . '</td>',
 						 '<td width="50">',
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&amp;blog_id=' . $assignment['blog_id'] . '&amp;do=edit_assignment&amp;task_id=' . $assignment['task_id'] . '&amp;user_id=' . $assignment['user_id'] . '">',
+						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
 							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
 							"</a>\n",
-							'<a href="' .api_get_self(). '?action=manage_tasks&amp;blog_id=' . $assignment['blog_id'] . '&amp;do=delete_assignment&amp;task_id=' . $assignment['task_id'] . '&amp;user_id=' . $assignment['user_id'] . '" ',
+							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
 							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
 							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
 							"</a>\n",
@@ -1500,7 +1500,7 @@ class Blog
         );
 
 		// form
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&amp;blog_id=' . $blog_id . '">';
+		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
 
 		// form title
 		echo '<legend>'.get_lang('AddTask').'</legend>';
@@ -1598,7 +1598,7 @@ class Blog
 		$task = Database::fetch_array($result);
 
 		// Display
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&amp;blog_id=' . $blog_id . '">
+		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
 					<legend>' . get_lang('EditTask') . '</legend>
 					<table width="100%" border="0" cellspacing="2">
 						<tr>
@@ -1922,7 +1922,7 @@ class Blog
 		if (Database::num_rows($result) > 0) {
 			while($blog_post = Database::fetch_array($result)) {
 			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
-				echo '<a href="blog.php?action=execute_task&amp;blog_id=' . $blog_id . '&amp;task_id=' . $task_id . '&amp;post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
+				echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
 			}
         } else {
             echo get_lang('NoArticles');
@@ -2072,7 +2072,7 @@ class Blog
 
 				//Link to register users
 				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&amp;blog_id=$blog_id&amp;register=yes&amp;user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
+					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
 				} else {
 					$row[] = '';
 				}
@@ -2083,11 +2083,11 @@ class Blog
 		// Display
 		$query_vars['action'] = 'manage_members';
 		$query_vars['blog_id'] = $blog_id;
-		echo '<form method="post" action="blog.php?action=manage_members&amp;blog_id=' . $blog_id . '">';
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
 			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
 			$link = '';
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&amp;' : '';
-			$link .= "blog_id=$blog_id&amp;";
+			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
+			$link .= "blog_id=$blog_id&";
 
 			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
 			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
@@ -2181,7 +2181,7 @@ class Blog
 			//Link to register users
 
 			if ($myrow["user_id"] != $_user['user_id']) {
-				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&amp;blog_id=$blog_id&amp;unregister=yes&amp;user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
+				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
 			} else {
 				$row[] = '';
 			}
@@ -2191,11 +2191,11 @@ class Blog
 
 		$query_vars['action'] = 'manage_members';
 		$query_vars['blog_id'] = $blog_id;
-		echo '<form method="post" action="blog.php?action=manage_members&amp;blog_id=' . $blog_id . '">';
+		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
 		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
 		$link = '';
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&amp;' : '';
-		$link .= "blog_id=$blog_id&amp;";
+		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
+		$link .= "blog_id=$blog_id&";
 
 		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
 		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
@@ -2318,8 +2318,8 @@ class Blog
 		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
 		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
 		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&amp;filter=" . $filter."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&amp;filter=" . $filter."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
+		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
+		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
 
 		// Get posts for this month
 		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
@@ -2405,7 +2405,7 @@ class Blog
 
 					// If there are posts on this day, create a filter link.
 					if(in_array($curday, $posts))
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&amp;filter=' . $year . '-' . $month . '-' . $curday . '&amp;month=' . $month . '&amp;year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
+						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
 					else
 						echo $dayheader;
 
@@ -2413,7 +2413,7 @@ class Blog
 						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
 							// Add tasks to calendar
 							foreach ($tasks[$curday] as $task) {
-								echo '<a href="blog.php?action=execute_task&amp;blog_id=' . $task['blog_id'] . '&amp;task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
+								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
 								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
 							}
 						}
@@ -2523,7 +2523,7 @@ class Blog
 				// Validation when belongs to a session
 				$session_img = api_get_session_image($info_log[4], $_user['status']);
 
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&amp;".api_get_cidreq();
+				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
 				$title = $info_log[0];
     			$image = '<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">';
     			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
@@ -2533,14 +2533,14 @@ class Blog
 
 				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
 				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&amp;blog_id=' . $info_log[3] . '">';
+			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
 				$my_image.= '<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />';
 				$my_image.= "</a>\n";
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&amp;blog_id=' . $info_log[3] . '" ';
+				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
 				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
 				$my_image.= '<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />';
 				$my_image.= "</a>\n";
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&amp;blog_id=' . $info_log[3] . '">';
+				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
 				$my_image.= '<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />';
 				$my_image.= "</a>\n";
 

+ 27 - 16
main/inc/lib/course.lib.php

@@ -1699,6 +1699,7 @@ class CourseManager
      * @param string $date_from
      * @param string $date_to
      * @param boolean $includeInvitedUsers Whether include the invited users
+     * @param int $groupId
      * @return array with user id
      */
     public static function get_student_list_from_course_code(
@@ -1707,7 +1708,8 @@ class CourseManager
         $session_id = 0,
         $date_from = null,
         $date_to = null,
-        $includeInvitedUsers = true
+        $includeInvitedUsers = true,
+        $groupId = 0
     ) {
 
         $userTable = Database::get_main_table(TABLE_MAIN_USER);
@@ -1715,28 +1717,37 @@ class CourseManager
         $course_code = Database::escape_string($course_code);
         $courseInfo = api_get_course_info($course_code);
         $courseId = $courseInfo['real_id'];
-
         $students = array();
 
         if ($session_id == 0) {
-            // students directly subscribed to the course
-            $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " cu
-                    INNER JOIN $userTable u
-                    ON cu.user_id = u.user_id
-                    WHERE c_id = '$courseId' AND cu.status = " . STUDENT;
-
-            if (!$includeInvitedUsers) {
-                $sql .= " AND u.status != " . INVITEE;
-            }
-
-            $rs = Database::query($sql);
-            while ($student = Database::fetch_array($rs)) {
-                $students[$student['user_id']] = $student;
+            if (empty($groupId)) {
+                // students directly subscribed to the course
+                $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu
+                        INNER JOIN $userTable u
+                        ON cu.user_id = u.user_id
+                        WHERE c_id = '$courseId' AND cu.status = ".STUDENT;
+
+                if (!$includeInvitedUsers) {
+                    $sql .= " AND u.status != ".INVITEE;
+                }
+                $rs = Database::query($sql);
+                while ($student = Database::fetch_array($rs)) {
+                    $students[$student['user_id']] = $student;
+                }
+            } else {
+                $students = GroupManager::get_users(
+                    $groupId,
+                    false,
+                    null,
+                    null,
+                    false,
+                    $courseInfo['real_id']
+                );
+                $students = array_flip($students);
             }
         }
 
         // students subscribed to the course through a session
-
         if ($with_session) {
 
             $joinSession = "";

+ 19 - 11
main/inc/lib/groupmanager.lib.php

@@ -1001,6 +1001,7 @@ class GroupManager
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
 
         $group_id = intval($group_id);
+
         if (empty($courseId)) {
             $courseId = api_get_course_int_id();
         } else {
@@ -1028,7 +1029,6 @@ class GroupManager
             $limit = intval($limit);
             $sql .= " LIMIT $start, $limit";
         }
-
         $res = Database::query($sql);
         $users = array();
         while ($obj = Database::fetch_object($res)) {
@@ -2234,7 +2234,7 @@ class GroupManager
                     $groupNameClass = 'muted';
                 }
 
-                $group_name = '<a class="'.$groupNameClass.'" href="group_space.php?cidReq='.api_get_course_id().'&amp;origin='.$orig.'&amp;gidReq='.$this_group['id'].'">'.
+                $group_name = '<a class="'.$groupNameClass.'" href="group_space.php?cidReq='.api_get_course_id().'&origin='.$orig.'&gidReq='.$this_group['id'].'">'.
                     Security::remove_XSS($this_group['name']).'</a> ';
                 if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) {
                     $group_name .= Display::label(get_lang('OneMyGroups'), 'success');
@@ -2289,9 +2289,9 @@ class GroupManager
             // Self-registration / unregistration
             if (!api_is_allowed_to_edit(false, true)) {
                 if (self :: is_self_registration_allowed($user_id, $this_group['id'])) {
-                    $row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
+                    $row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_reg&group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfRegInf').'</a>';
                 } elseif (self :: is_self_unregistration_allowed($user_id, $this_group['id'])) {
-                    $row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
+                    $row[] = '<a class = "btn btn-default" href="group.php?'.api_get_cidreq().'&category='.$category_id.'&action=self_unreg&group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."'".')) return false;">'.get_lang('GroupSelfUnRegInf').'</a>';
                 } else {
                     $row[] = '-';
                 }
@@ -2306,10 +2306,10 @@ class GroupManager
                     Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
 
                 if ($this_group['status'] == 1) {
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&amp;action=set_invisible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
+                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true,false) . '&category=' . $category_id . '&action=set_invisible&id=' . $this_group['id'] . '" title="' . get_lang('Hide') . '">' .
                         Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
                 } else {
-                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&amp;action=set_visible&amp;id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
+                    $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=set_visible&id=' . $this_group['id'] . '" title="' . get_lang('Show') . '">' .
                         Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>&nbsp;';
                 }
 
@@ -2319,13 +2319,13 @@ class GroupManager
                 $edit_actions .= '<a href="'.$url.'group_overview.php?action=export&type=xls&'.api_get_cidreq(true, false).'&id='.$this_group['id'].'"  title="'.get_lang('ExportUsers').'">'.
                     Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL).'</a>&nbsp;';
 
-                /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=empty_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
+                /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'.
                     Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';*/
 
-                $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=fill_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
+                $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=fill_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('FillGroup').'">'.
                     Display::return_icon('fill.png',get_lang('FillGroup'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
 
-                $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&amp;action=delete_one&amp;id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
+                $edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=delete_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.
                     Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
 
                 $row[] = $edit_actions;
@@ -2752,6 +2752,10 @@ class GroupManager
                     $groups = GroupManager::get_group_list($category['id']);
                 }
 
+                if (empty($groups)) {
+                    $groups = GroupManager::get_group_list();
+                }
+
                 $content .= '<ul>';
                 if (!empty($groups)) {
                     foreach ($groups as $group) {
@@ -2764,7 +2768,9 @@ class GroupManager
                             $content .= "<li>".Display::tag('h4', get_lang('Tutors'))."</li><ul>";
                             foreach ($users as $user) {
                                 $user_info = api_get_user_info($user['user_id']);
-                                $content .= '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
+                                $content .= '<li title="'.$user_info['username'].'">'.
+                                    $user_info['complete_name_with_username'].
+                                '</li>';
                             }
                             $content .= '</ul>';
                             $content .= '</ul>';
@@ -2776,7 +2782,9 @@ class GroupManager
                             $content .= "<li>".Display::tag('h4', get_lang('Students'))."</li><ul>";
                             foreach ($users as $user) {
                                 $user_info = api_get_user_info($user['user_id']);
-                                $content .= '<li title="'.$user_info['username'].'">'.$user_info['complete_name_with_username'].'</li>';
+                                $content .= '<li title="'.$user_info['username'].'">'.
+                                    $user_info['complete_name_with_username'].
+                                    '</li>';
                             }
                             $content .= '</ul>';
                             $content .= '</ul>';

+ 157 - 25
main/inc/lib/tracking.lib.php

@@ -14,6 +14,74 @@ use CpChart\Classes\pImage as pImage;
  */
 class Tracking
 {
+    public static function get_group_reporting(
+        $course_id,
+        $group_id = null,
+        $type = 'all',
+        $start = 0,
+        $limit = 1000,
+        $sidx = 1,
+        $sord = 'desc',
+        $where_condition = array()
+    ) {
+        if (empty($course_id)) {
+            return null;
+        }
+        $course_info = api_get_course_info_by_id($course_id);
+        $table_group = Database :: get_course_table(TABLE_GROUP);
+        $course_id = intval($course_id);
+
+        $select = ' * ';
+        if ($type == 'count') {
+            $select = ' count(id) as count ';
+        }
+
+        $default_where = array('c_id = ? ' => array($course_id));
+
+        $result = Database::select($select, $table_group, array(
+                'limit' => " $start, $limit",
+                'where' => $default_where,
+                'order' => "$sidx $sord")
+        );
+
+        if ($type == 'count') {
+            return $result[0]['count'];
+        }
+
+        $parsed_result = array();
+        if (!empty($result)) {
+            foreach ($result as $group) {
+                $users = GroupManager::get_users($group['id'], true);
+
+                $time = 0;
+                $avg_student_score = 0;
+                $avg_student_progress = 0;
+                $work = 0;
+                $messages = 0;
+
+                foreach ($users as $user_data) {
+                    $time += Tracking::get_time_spent_on_the_course($user_data['user_id'], $course_info['code'], 0);
+                    $avg_student_score += Tracking::get_avg_student_score($user_data['user_id'], $course_info['code'], array(), 0);
+                    $avg_student_progress += Tracking::get_avg_student_progress($user_data['user_id'], $course_info['code'], array(), 0);
+                    $work += Tracking::count_student_assignments($user_data['user_id'], $course_info['code'], 0);
+                    $messages += Tracking::count_student_messages($user_data['user_id'], $course_info['code'], 0);
+                }
+
+                $group_item = array(
+                    'id' => $group['id'],
+                    'name' => $group['name'],
+                    'time' => api_time_to_hms($time),
+                    'progress' => $avg_student_progress,
+                    'score' => $avg_student_score,
+                    'works' => $work,
+                    'messages' => $messages,
+                );
+                $parsed_result[] = $group_item;
+            }
+        }
+        return $parsed_result;
+    }
+
     /**
      * @param int $user_id
      * @param array $courseInfo
@@ -3245,6 +3313,7 @@ class Tracking
         $rs = Database::query($sql);
         $row = Database::fetch_array($rs, 'ASSOC');
         $count = $row['count'];
+
         return $count;
     }
 
@@ -3254,32 +3323,46 @@ class Tracking
      * @param    int        Session id (optional), if param $session_id is
      * null(default) it'll return results including sessions,
      * 0 = session is not filtered
+     * @param int $groupId
      * @return    int     The number of post by course
      */
-    public static function count_number_of_posts_by_course($course_code, $session_id = null)
+    public static function count_number_of_posts_by_course($course_code, $session_id = null, $groupId = 0)
     {
-        $a_course = CourseManager :: get_course_information($course_code);
-        if (!empty($a_course)) {
-            $tbl_posts 		= Database :: get_course_table(TABLE_FORUM_POST);
-            $tbl_forums 	= Database :: get_course_table(TABLE_FORUM);
+        $courseInfo = api_get_course_info($course_code);
+        if (!empty($courseInfo)) {
+            $tbl_posts = Database :: get_course_table(TABLE_FORUM_POST);
+            $tbl_forums = Database :: get_course_table(TABLE_FORUM);
 
             $condition_session = '';
             if (isset($session_id)) {
                 $session_id = intval($session_id);
-                $condition_session = ' AND f.session_id = '. $session_id;
+                $condition_session = api_get_session_condition($session_id, true,  false, 'f.session_id');
             }
 
-            $course_id	 = $a_course['real_id'];
+            $course_id = $courseInfo['real_id'];
+            $groupId = intval($groupId);
+            if (!empty($groupId)) {
+                $groupCondition = " i.to_group_id = $groupId  ";
+            } else {
+                $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) ";
+            }
 
-            $sql = "SELECT count(*) FROM $tbl_posts p INNER JOIN $tbl_forums f
-                    ON f.forum_id = p.forum_id
-                    WHERE 	p.c_id = $course_id AND
-                            f.c_id = $course_id
-                            $condition_session
+            $item = Database :: get_course_table(TABLE_ITEM_PROPERTY);
+            $sql = "SELECT count(*) FROM $tbl_posts p
+                    INNER JOIN $tbl_forums f
+                    ON f.forum_id = p.forum_id AND p.c_id = f.c_id
+                    INNER JOIN $item i
+                    ON (tool = '".TOOL_FORUM."' AND f.c_id = i.c_id AND f.iid = i.ref)
+                    WHERE
+                        p.c_id = $course_id AND
+                        f.c_id = $course_id AND
+                        $groupCondition
+                        $condition_session
                     ";
             $result = Database::query($sql);
             $row = Database::fetch_row($result);
             $count = $row[0];
+
             return $count;
         } else {
             return null;
@@ -3292,31 +3375,60 @@ class Tracking
      * @param    int        Session id (optional),
      * if param $session_id is null(default) it'll return results including
      * sessions, 0 = session is not filtered
+     * @param int $groupId
      * @return    int     The number of threads by course
      */
-    public static function count_number_of_threads_by_course($course_code, $session_id = null)
+    public static function count_number_of_threads_by_course($course_code, $session_id = null, $groupId = 0)
     {
         $course_info = api_get_course_info($course_code);
         if (empty($course_info)) {
             return null;
         }
+
         $course_id = $course_info['real_id'];
         $tbl_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
-        $tbl_forums  = Database :: get_course_table(TABLE_FORUM);
+        $tbl_forums = Database :: get_course_table(TABLE_FORUM);
+
         $condition_session = '';
         if (isset($session_id)) {
             $session_id = intval($session_id);
-            $condition_session = '  AND f.session_id = '. $session_id;
+            $condition_session = ' AND f.session_id = '. $session_id;
         }
 
-        $sql = "SELECT count(*) FROM $tbl_threads t INNER JOIN $tbl_forums f ON f.forum_id = t.forum_id
-                WHERE t.c_id = $course_id AND f.c_id = $course_id  $condition_session ";
+        $groupId = intval($groupId);
+
+        if (!empty($groupId)) {
+            $groupCondition = " i.to_group_id = $groupId ";
+        } else {
+            $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) ";
+        }
+
+        $item = Database :: get_course_table(TABLE_ITEM_PROPERTY);
+        $sql = "SELECT count(*)
+                FROM $tbl_threads t
+                INNER JOIN $tbl_forums f
+                ON f.iid = t.forum_id AND f.c_id = t.c_id
+                INNER JOIN $item i
+                ON (
+                    tool = '".TOOL_FORUM_THREAD."' AND
+                    f.c_id = i.c_id AND
+                    t.iid = i.ref
+                )
+                WHERE
+                    t.c_id = $course_id AND
+                    f.c_id = $course_id AND
+                    $groupCondition
+                    $condition_session
+                ";
+
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
             $row = Database::fetch_row($result);
             $count = $row[0];
+
             return $count;
         } else {
+
             return null;
         }
     }
@@ -3327,9 +3439,10 @@ class Tracking
      * @param    int        Session id (optional),
      * if param $session_id is null(default) it'll return results
      * including sessions, 0 = session is not filtered
+     * @param int $groupId
      * @return    int     The number of forums by course
      */
-    public static function count_number_of_forums_by_course($course_code, $session_id = null)
+    public static function count_number_of_forums_by_course($course_code, $session_id = null, $groupId = 0)
     {
         $course_info = api_get_course_info($course_code);
         if (empty($course_info)) {
@@ -3340,11 +3453,28 @@ class Tracking
         $condition_session = '';
         if (isset($session_id)) {
              $session_id = intval($session_id);
-             $condition_session = '  session_id = '. $session_id;
+             $condition_session = ' AND f.session_id = '. $session_id;
+        }
+
+        $groupId = intval($groupId);
+        if (!empty($groupId)) {
+            $groupCondition = " i.to_group_id = $groupId ";
+        } else {
+            $groupCondition = " (i.to_group_id = 0 OR i.to_group_id IS NULL) ";
         }
 
         $tbl_forums = Database :: get_course_table(TABLE_FORUM);
-        $sql = "SELECT count(*) FROM $tbl_forums WHERE c_id = $course_id AND $condition_session";
+        $item = Database :: get_course_table(TABLE_ITEM_PROPERTY);
+
+        $sql = "SELECT count(*)
+                FROM $tbl_forums f
+                INNER JOIN $item i
+                    ON f.c_id = i.c_id AND f.iid = i.ref AND tool = '".TOOL_FORUM."'
+                WHERE
+                    f.c_id = $course_id AND
+                    $groupCondition
+                    $condition_session
+                ";
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
             $row = Database::fetch_row($result);
@@ -3372,7 +3502,6 @@ class Tracking
 
         //protect data
         $last_days   = intval($last_days);
-        $course_code = Database::escape_string($course_code);
         $session_id  = intval($session_id);
         $tbl_stats_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
         $now = api_get_utc_datetime();
@@ -3733,7 +3862,7 @@ class Tracking
      */
     public static function get_tools_most_used_by_course($courseId, $session_id = null)
     {
-        $course_code = intval($courseId);
+        $courseId = intval($courseId);
         $data = array();
         $TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
         $condition_session     = '';
@@ -3741,7 +3870,10 @@ class Tracking
             $session_id = intval($session_id);
             $condition_session = ' AND access_session_id = '. $session_id;
         }
-        $sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool
+        $sql = "SELECT
+                    access_tool,
+                    COUNT(DISTINCT access_user_id),
+                    count(access_tool) as count_access_tool
                 FROM $TABLETRACK_ACCESS
                 WHERE
                     access_tool IS NOT NULL AND
@@ -3940,8 +4072,8 @@ class Tracking
 
         $data = array();
 
-        $TABLETRACK_LINKS       = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
-        $TABLECOURSE_LINKS      = Database::get_course_table(TABLE_LINK);
+        $TABLETRACK_LINKS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
+        $TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
 
         $condition_session = '';
         if (isset($session_id)) {

+ 2 - 2
main/template/default/learnpath/view.tpl

@@ -89,9 +89,9 @@
             {# right zone #}
             <div id="learning_path_right_zone" style="height:100%" class="content-scorm">
                 {% if oLP.mode == 'fullscreen' %}
-                    <iframe id="content_id_blank" name="content_name_blank" src="blank.php" border="0" frameborder="0" style="width: 100%; height: 100%" ></iframe>
+                    <iframe id="content_id_blank" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" name="content_name_blank" src="blank.php" border="0" frameborder="0" style="width: 100%; height: 100%" ></iframe>
                 {% else %}
-                    <iframe id="content_id" name="content_name" src="{{ iframe_src }}" border="0" frameborder="0" style="display: block; width: 100%; height: 100%"></iframe>
+                    <iframe id="content_id" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" name="content_name" src="{{ iframe_src }}" border="0" frameborder="0" style="display: block; width: 100%; height: 100%"></iframe>
                 {% endif %}
             </div>
             {# end right Zone #}

+ 4 - 0
main/tracking/courseLog.php

@@ -219,6 +219,10 @@ Display::display_header($nameTools, 'Tracking');
 echo '<div class="actions">';
 
 echo Display::return_icon('user_na.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM);
+echo Display::url(
+    Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
+    'course_log_groups.php?'.api_get_cidreq()
+);
 echo Display::url(
     Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
     'course_log_tools.php?'.api_get_cidreq()

+ 127 - 0
main/tracking/course_log_groups.php

@@ -0,0 +1,127 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+require_once '../inc/global.inc.php';
+
+$from_myspace = false;
+$from = isset($_GET['from']) ? $_GET['from'] : null;
+
+if ($from == 'myspace') {
+    $from_myspace = true;
+    $this_section = "session_my_space";
+} else {
+    $this_section = SECTION_COURSES;
+}
+
+// Access restrictions.
+$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
+
+if (!$is_allowedToTrack) {
+    api_not_allowed(true);
+    exit;
+}
+
+$course_id = api_get_course_int_id();
+$course_code = api_get_course_id();
+
+// jqgrid will use this URL to do the selects
+$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_group_reporting&course_id='.$course_id;
+
+// The order is important you need to check the the $column variable in the model.ajax.php file
+$columns = array(
+    get_lang('Name'),
+    get_lang('Time'),
+    get_lang('Progress'),
+    get_lang('Score'),
+    get_lang('Works'),
+    get_lang('Messages'),
+    get_lang('Actions'),
+);
+
+// Column config
+$column_model = array(
+    array(
+        'name' => 'name',
+        'index' => 'name',
+        'width' => '200',
+        'align' => 'left',
+    ),
+    array(
+        'name' => 'time',
+        'index' => 'time',
+        'width' => '50',
+        'align' => 'left',
+        'sortable' => 'false',
+    ),
+    array(
+        'name' => 'progress',
+        'index' => 'progress',
+        'width' => '50',
+        'align' => 'left',
+        'sortable' => 'false',
+    ),
+    array(
+        'name' => 'score',
+        'index' => 'score',
+        'width' => '50',
+        'align' => 'left',
+        'sortable' => 'false',
+    ),
+    array(
+        'name' => 'works',
+        'index' => 'works',
+        'width' => '50',
+        'align' => 'left',
+        'sortable' => 'false',
+    ),
+    array(
+        'name' => 'messages',
+        'index' => 'messages',
+        'width' => '50',
+        'align' => 'left',
+        'sortable' => 'false',
+    ),
+    array(
+        'name' => 'actions',
+        'index' => 'actions',
+        'width' => '50',
+        'align' => 'left',
+        'formatter' => 'action_formatter',
+        'sortable' => 'false',
+    ),
+);
+
+// Autowidth
+$extra_params['autowidth'] = 'true';
+// height auto
+$extra_params['height'] = 'auto';
+
+$action_links = '
+function action_formatter(cellvalue, options, rowObject) {
+    return \'<a href="course_log_tools.php?id_session=0&cidReq='.$course_code.'&gidReq=\'+options.rowId+\'">'.Display::return_icon('2rightarrow.gif',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
+    '\';
+}';
+
+
+// Add the JS needed to use the jqgrid
+$htmlHeadXtra[] = api_get_jqgrid_js();
+
+$htmlHeadXtra[] = '
+<script>
+$(function() {
+    '.Display::grid_js('group_users',$url, $columns, $column_model, $extra_params, array(), $action_links, true).'
+});
+</script>';
+
+Display::display_header();
+
+echo '<div class="actions">';
+echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM), 'courseLog.php?'.api_get_cidreq(true, false));
+echo Display::url(Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#');
+echo Display::url(Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_tools.php?'.api_get_cidreq(true, false));
+echo Display::url(Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_resources.php?'.api_get_cidreq(true, false));
+echo '</div>';
+
+echo Display::grid_html('group_users');
+
+Display::display_footer();

+ 5 - 0
main/tracking/course_log_resources.php

@@ -65,6 +65,11 @@ echo Display::url(
     api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq()
 );
 
+echo Display::url(
+    Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
+    'course_log_groups.php?'.api_get_cidreq(true, false)
+);
+
 echo Display::url(
     Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
     api_get_path(WEB_CODE_PATH).'tracking/course_log_tools.php?'.api_get_cidreq()

+ 362 - 181
main/tracking/course_log_tools.php

@@ -5,14 +5,12 @@
  *	@package chamilo.tracking
  */
 
-/* INIT SECTION */
-
-$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
-// Including the global initialization file
 require_once '../inc/global.inc.php';
 $current_course_tool = TOOL_TRACKING;
 
 $course_info = api_get_course_info();
+$groupId = isset($_REQUEST['gidReq']) ? intval($_REQUEST['gidReq']) : 0;
+//$groupId = api_get_group_id();
 
 $from_myspace = false;
 $from = isset($_GET['from']) ? $_GET['from'] : null;
@@ -32,10 +30,26 @@ if (!$is_allowedToTrack) {
     exit;
 }
 
+$showChatReporting = true;
+$showTrackingReporting = true;
+$documentReporting = true;
+$linkReporting = true;
+$exerciseReporting = true;
+$lpReporting = true;
+
+if (!empty($groupId)) {
+    $showChatReporting = false;
+    $showTrackingReporting = false;
+    $documentReporting = false;
+    $linkReporting = false;
+    $exerciseReporting = false;
+    $lpReporting = false;
+}
+
 // Including additional libraries.
 require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
 
-$TABLEQUIZ              = Database::get_course_table(TABLE_QUIZ_TEST);
+$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
 
 // Starting the output buffering when we are exporting the information.
 $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
@@ -65,25 +79,62 @@ Display::display_header($nameTools, 'Tracking');
 // getting all the students of the course
 if (empty($session_id)) {
 	// Registered students in a course outside session.
-	$a_students = CourseManager :: get_student_list_from_course_code(api_get_course_id());
+    $a_students = CourseManager:: get_student_list_from_course_code(
+        api_get_course_id(),
+        false,
+        0,
+        null,
+        null,
+        true,
+        api_get_group_id()
+    );
 } else {
 	// Registered students in session.
-	$a_students = CourseManager :: get_student_list_from_course_code(api_get_course_id(), true, api_get_session_id());
+    $a_students = CourseManager:: get_student_list_from_course_code(
+        api_get_course_id(),
+        true,
+        api_get_session_id()
+    );
 }
-
 $nbStudents = count($a_students);
 
+$student_ids = array_keys($a_students);
+$studentCount = count($student_ids);
 
 /* MAIN CODE */
 
 echo '<div class="actions">';
 
-echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32), 'courseLog.php?'.api_get_cidreq());
-echo Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), 32);
-echo Display::url(Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), 32), 'course_log_resources.php?'.api_get_cidreq());
+echo Display::url(
+    Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
+    'courseLog.php?'.api_get_cidreq()
+);
+
+if (empty($groupId)) {
+    echo Display::url(
+        Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
+        'course_log_groups.php?'.api_get_cidreq()
+    );
+    echo Display::url(Display::return_icon('course_na.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), '#');
+} else {
+    echo Display::url(
+        Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM),
+        '#'
+    );
+    echo Display::url(
+        Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
+        'course_log_tools.php?'.api_get_cidreq(true, false).'&gidReq=0'
+    );
+}
+
+echo Display::url(
+    Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
+    'course_log_resources.php?'.api_get_cidreq()
+);
 
 echo '<span style="float:right; padding-top:0px;">';
-echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
+echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
+    Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
 
 echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&id_session='.api_get_session_id().'&export=csv">
 	'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
@@ -94,118 +145,175 @@ echo '</div>';
 $course_code = api_get_course_id();
 $course_id = api_get_course_int_id();
 
-$list = new LearnpathList(null, $course_code, $session_id);
+if ($lpReporting) {
+    $list = new LearnpathList(null, $course_code, $session_id);
+    $flat_list = $list->get_flat_list();
 
-$flat_list = $list->get_flat_list();
+    if (count($flat_list) > 0) {
 
+        // learning path tracking
+        echo '<div class="report_section">
+                '.Display::page_subheader(
+                Display::return_icon(
+                    'scorms.gif',
+                    get_lang('AverageProgressInLearnpath')
+                ).get_lang('AverageProgressInLearnpath')
+            ).'
+                <table class="data_table">';
 
-if (count($flat_list) > 0) {
+        if ($export_csv) {
+            $temp = array(get_lang('AverageProgressInLearnpath', ''), '');
+            $csv_content[] = array('', '');
+            $csv_content[] = $temp;
+        }
 
-    // learning path tracking
+        foreach ($flat_list as $lp_id => $lp) {
+            $lp_avg_progress = 0;
+            foreach ($a_students as $student_id => $student) {
+                // get the progress in learning pathes
+                $lp_avg_progress += Tracking::get_avg_student_progress(
+                    $student_id,
+                    $course_code,
+                    array($lp_id),
+                    $session_id
+                );
+            }
+            if ($studentCount > 0) {
+                $lp_avg_progress = $lp_avg_progress / $studentCount;
+            } else {
+                $lp_avg_progress = null;
+            }
+            // Separated presentation logic.
+            if (is_null($lp_avg_progress)) {
+                $lp_avg_progress = '0%';
+            } else {
+                $lp_avg_progress = round($lp_avg_progress, 1).'%';
+            }
+            echo '<tr><td>'.$lp['lp_name'].'</td><td align="right">'.$lp_avg_progress.'</td></tr>';
+            if ($export_csv) {
+                $temp = array($lp['lp_name'], $lp_avg_progress);
+                $csv_content[] = $temp;
+            }
+        }
+        echo '</table></div>';
+    } else {
+        if ($export_csv) {
+            $temp = array(get_lang('NoLearningPath', ''), '');
+            $csv_content[] = $temp;
+        }
+    }
+}
+
+if ($exerciseReporting) {
+
+    // Exercices tracking.
     echo '<div class="report_section">
-            '.Display::page_subheader(Display::return_icon('scorms.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath')).'
+               '.Display::page_subheader(
+            Display::return_icon(
+                'quiz.gif',
+                get_lang('AverageResultsToTheExercices')
+            ).get_lang('AverageResultsToTheExercices')
+        ).'
             <table class="data_table">';
 
+    $course_id = api_get_course_int_id();
+
+    $sql = "SELECT id, title FROM $TABLEQUIZ
+            WHERE c_id = $course_id AND active <> -1 AND session_id = $session_id";
+    $rs = Database::query($sql);
+
     if ($export_csv) {
-        $temp = array(get_lang('AverageProgressInLearnpath', ''), '');
+        $temp = array(get_lang('AverageProgressInLearnpath'), '');
         $csv_content[] = array('', '');
         $csv_content[] = $temp;
     }
 
-    foreach ($flat_list as $lp_id => $lp) {
-        $lp_avg_progress = 0;
-        foreach ($a_students as $student_id => $student) {
-            // get the progress in learning pathes
-            $lp_avg_progress += Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
-        }
-        if ($nbStudents > 0) {
-            $lp_avg_progress = $lp_avg_progress / $nbStudents;
-        } else {
-            $lp_avg_progress = null;
-        }
-        // Separated presentation logic.
-        if (is_null($lp_avg_progress)) {
-            $lp_avg_progress = '0%';
-        } else {
-            $lp_avg_progress = round($lp_avg_progress, 1).'%';
+    $course_path_params = '&cidReq='.$course_code.'&id_session='.$session_id;
+
+    if (Database::num_rows($rs) > 0) {
+        while ($quiz = Database::fetch_array($rs)) {
+            $quiz_avg_score = 0;
+            if ($studentCount > 0) {
+                foreach ($student_ids as $student_id) {
+                    $avg_student_score = Tracking::get_avg_student_exercise_score(
+                        $student_id,
+                        $course_code,
+                        $quiz['id'],
+                        $session_id
+                    );
+                    $quiz_avg_score += $avg_student_score;
+                }
+            }
+            $studentCount = ($studentCount == 0 || is_null(
+                    $studentCount
+                ) || $studentCount == '') ? 1 : $studentCount;
+            $quiz_avg_score = round(($quiz_avg_score / $studentCount), 2).'%';
+            $url = api_get_path(
+                    WEB_CODE_PATH
+                ).'exercice/overview.php?exerciseId='.$quiz['id'].$course_path_params;
+
+            echo '<tr><td>'.Display::url(
+                    $quiz['title'],
+                    $url
+                ).'</td><td align="right">'.$quiz_avg_score.'</td></tr>';
+            if ($export_csv) {
+                $temp = array($quiz['title'], $quiz_avg_score);
+                $csv_content[] = $temp;
+            }
         }
-        echo '<tr><td>'.$lp['lp_name'].'</td><td align="right">'.$lp_avg_progress.'</td></tr>';
+    } else {
+        echo '<tr><td>'.get_lang('NoExercises').'</td></tr>';
         if ($export_csv) {
-            $temp = array($lp['lp_name'], $lp_avg_progress);
+            $temp = array(get_lang('NoExercises', ''), '');
             $csv_content[] = $temp;
         }
     }
+
     echo '</table></div>';
-} else {
-    if ($export_csv) {
-        $temp = array(get_lang('NoLearningPath', ''), '');
-        $csv_content[] = $temp;
-    }
+    echo '<div class="clear"></div>';
 }
 
-// Exercices tracking.
-echo '<div class="report_section">
-           '.Display::page_subheader(Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices')).'
-        <table class="data_table">';
+$filterByUsers = array();
 
-$course_id = api_get_course_int_id();
+if (!empty($groupId)) {
+    $filterByUsers = $student_ids;
+}
 
-$sql = "SELECT id, title FROM $TABLEQUIZ
-        WHERE c_id = $course_id AND active <> -1 AND session_id = $session_id";
-$rs = Database::query($sql);
+$count_number_of_forums_by_course = Tracking:: count_number_of_forums_by_course(
+    $course_code,
+    $session_id,
+    $groupId
+);
 
-if ($export_csv) {
-    $temp = array(get_lang('AverageProgressInLearnpath'), '');
-    $csv_content[] = array('', '');
-    $csv_content[] = $temp;
-}
+$count_number_of_threads_by_course = Tracking:: count_number_of_threads_by_course(
+    $course_code,
+    $session_id,
+    $groupId
+);
 
-$course_path_params = '&cidReq='.$course_code.'&id_session='.$session_id;
-
-if (Database::num_rows($rs) > 0) {
-    $student_ids = array_keys($a_students);
-    $count_students = count($student_ids);
-    while ($quiz = Database::fetch_array($rs)) {
-        $quiz_avg_score = 0;
-        if ($count_students > 0) {
-            foreach ($student_ids as $student_id) {
-                $avg_student_score = Tracking::get_avg_student_exercise_score($student_id, $course_code, $quiz['id'], $session_id);
-                $quiz_avg_score += $avg_student_score;
-            }
-        }
-        $count_students = ($count_students == 0 || is_null($count_students) || $count_students == '') ? 1 : $count_students;
-        $quiz_avg_score = round(($quiz_avg_score / $count_students), 2).'%';
-        $url = api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$quiz['id'].$course_path_params;
+$count_number_of_posts_by_course = Tracking:: count_number_of_posts_by_course(
+    $course_code,
+    $session_id,
+    $groupId
+);
 
-        echo '<tr><td>'.Display::url($quiz['title'], $url).'</td><td align="right">'.$quiz_avg_score.'</td></tr>';
-        if ($export_csv) {
-            $temp = array($quiz['title'], $quiz_avg_score);
-            $csv_content[] = $temp;
-        }
-    }
-} else {
-    echo '<tr><td>'.get_lang('NoExercises').'</td></tr>';
-    if ($export_csv) {
-        $temp = array(get_lang('NoExercises', ''), '');
-        $csv_content[] = $temp;
-    }
+if ($export_csv) {
+    $csv_content[] = array(get_lang('Forum'));
+    $csv_content[] = array(get_lang('ForumForumsNumber'), $count_number_of_forums_by_course);
+    $csv_content[] = array(get_lang('ForumThreadsNumber'), $count_number_of_threads_by_course);
+    $csv_content[] = array(get_lang('ForumPostsNumber'), $count_number_of_posts_by_course);
 }
-echo '</table></div>';
-echo '<div class="clear"></div>';
 
 // Forums tracking.
 echo '<div class="report_section">
-        '.Display::page_subheader(Display::return_icon('forum.gif', get_lang('Forum')).get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a>').
-        '<table class="data_table">';
-$count_number_of_posts_by_course    = Tracking :: count_number_of_posts_by_course($course_code, $session_id);
-$count_number_of_forums_by_course   = Tracking :: count_number_of_forums_by_course($course_code, $session_id);
-$count_number_of_threads_by_course  = Tracking :: count_number_of_threads_by_course($course_code, $session_id);
-if ($export_csv) {
-    $csv_content[] = array(get_lang('Forum'), '');
-    $csv_content[] = array(get_lang('ForumForumsNumber', ''), $count_number_of_forums_by_course);
-    $csv_content[] = array(get_lang('ForumThreadsNumber', ''), $count_number_of_threads_by_course);
-    $csv_content[] = array(get_lang('ForumPostsNumber', ''), $count_number_of_posts_by_course);
-}
+        '.Display::page_subheader(
+        Display::return_icon('forum.gif', get_lang('Forum')).
+        get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?'.api_get_cidreq().'">'.
+        get_lang('SeeDetail').'</a>'
+    ).
+    '<table class="data_table">';
+
+
 echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
 echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
 echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';
@@ -213,124 +321,197 @@ echo '</table></div>';
 echo '<div class="clear"></div>';
 
 // Chat tracking.
+if ($showChatReporting) {
+    echo '<div class="report_section">
+            '.Display::page_subheader(
+            Display::return_icon('chat.gif', get_lang('Chat')).get_lang('Chat')
+        ).'
+            <table class="data_table">';
+    $chat_connections_during_last_x_days_by_course = Tracking::chat_connections_during_last_x_days_by_course(
+        $course_code,
+        7,
+        $session_id
+    );
+    if ($export_csv) {
+        $csv_content[] = array(get_lang('Chat', ''), '');
+        $csv_content[] = array(
+            sprintf(
+                get_lang('ChatConnectionsDuringLastXDays', ''),
+                '7'
+            ),
+            $chat_connections_during_last_x_days_by_course
+        );
+    }
+    echo '<tr><td>'.sprintf(
+            get_lang('ChatConnectionsDuringLastXDays'),
+            '7'
+        ).'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
 
-echo '<div class="report_section">
-        '.Display::page_subheader(Display::return_icon('chat.gif',get_lang('Chat')).get_lang('Chat')).'
-        <table class="data_table">';
-$chat_connections_during_last_x_days_by_course = Tracking::chat_connections_during_last_x_days_by_course($course_code, 7, $session_id);
-if ($export_csv) {
-    $csv_content[] = array(get_lang('Chat', ''), '');
-    $csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays', ''), '7'), $chat_connections_during_last_x_days_by_course);
+    echo '</table></div>';
+    echo '<div class="clear"></div>';
 }
-echo '<tr><td>'.sprintf(get_lang('ChatConnectionsDuringLastXDays'), '7').'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
-
-echo '</table></div>';
-echo '<div class="clear"></div>';
 
 // Tools tracking.
-echo '<div class="report_section">
-            '.Display::page_subheader(Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed')).'
+if ($showTrackingReporting) {
+    echo '<div class="report_section">
+            '.Display::page_subheader(
+            Display::return_icon(
+                'acces_tool.gif',
+                get_lang('ToolsMostUsed')
+            ).get_lang('ToolsMostUsed')
+        ).'
         <table class="data_table">';
 
-$tools_most_used = Tracking::get_tools_most_used_by_course($course_id, $session_id);
+    $tools_most_used = Tracking::get_tools_most_used_by_course(
+        $course_id,
+        $session_id
+    );
 
-if ($export_csv) {
-    $temp = array(get_lang('ToolsMostUsed'), '');
-    $csv_content[] = $temp;
-}
+    if ($export_csv) {
+        $temp = array(get_lang('ToolsMostUsed'), '');
+        $csv_content[] = $temp;
+    }
 
-if (!empty($tools_most_used)) {
-    foreach ($tools_most_used as $row) {
-        echo '	<tr>
+    if (!empty($tools_most_used)) {
+        foreach ($tools_most_used as $row) {
+            echo '	<tr>
                     <td>'.get_lang(ucfirst($row['access_tool'])).'</td>
-                    <td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td>
+                    <td align="right">'.$row['count_access_tool'].' '.get_lang(
+                    'Clicks'
+                ).'</td>
                 </tr>';
-        if ($export_csv) {
-            $temp = array(get_lang(ucfirst($row['access_tool']), ''), $row['count_access_tool'].' '.get_lang('Clicks', ''));
-            $csv_content[] = $temp;
+            if ($export_csv) {
+                $temp = array(
+                    get_lang(ucfirst($row['access_tool']), ''),
+                    $row['count_access_tool'].' '.get_lang('Clicks', '')
+                );
+                $csv_content[] = $temp;
+            }
         }
     }
-}
 
-echo '</table></div>';
-echo '<div class="clear"></div>';
-
-// Documents tracking.
-if (!isset($_GET['num']) || empty($_GET['num'])) {
-    $num = 3;
-    $link = '&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&num=1#documents_tracking">'.get_lang('SeeDetail').'</a>';
-} else {
-    $num = 1000;
-    $link = '&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&num=0#documents_tracking">'.get_lang('ViewMinus').'</a>';
+    echo '</table></div>';
+    echo '<div class="clear"></div>';
 }
 
- echo '<a name="documents_tracking" id="a"></a><div class="report_section">
-            '.Display::page_subheader(Display::return_icon('documents.gif',get_lang('DocumentsMostDownloaded')).'&nbsp;'.get_lang('DocumentsMostDownloaded').$link).'
-        <table class="data_table">';
+if ($documentReporting) {
+    // Documents tracking.
+    if (!isset($_GET['num']) || empty($_GET['num'])) {
+        $num = 3;
+        $link = '&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq(
+            ).'&num=1#documents_tracking">'.get_lang('SeeDetail').'</a>';
+    } else {
+        $num = 1000;
+        $link = '&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq(
+            ).'&num=0#documents_tracking">'.get_lang('ViewMinus').'</a>';
+    }
 
-$documents_most_downloaded = Tracking::get_documents_most_downloaded_by_course($course_code, $session_id, $num);
+    echo '<a name="documents_tracking" id="a"></a><div class="report_section">
+                '.Display::page_subheader(
+            Display::return_icon(
+                'documents.gif',
+                get_lang('DocumentsMostDownloaded')
+            ).'&nbsp;'.get_lang('DocumentsMostDownloaded').$link
+        ).'
+            <table class="data_table">';
 
-if ($export_csv) {
-    $temp = array(get_lang('DocumentsMostDownloaded', ''), '');
-    $csv_content[] = array('', '');
-    $csv_content[] = $temp;
-}
+    $documents_most_downloaded = Tracking::get_documents_most_downloaded_by_course(
+        $course_code,
+        $session_id,
+        $num
+    );
+
+    if ($export_csv) {
+        $temp = array(get_lang('DocumentsMostDownloaded', ''), '');
+        $csv_content[] = array('', '');
+        $csv_content[] = $temp;
+    }
 
-if (!empty($documents_most_downloaded)) {
-    foreach ($documents_most_downloaded as $row) {
-        echo '<tr>
-                <td>'.Display::url($row['down_doc_path'], api_get_path(WEB_CODE_PATH).'document/show_content.php?file='.$row['down_doc_path'].$course_path_params).'</td>
-                <td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td>
-              </tr>';
+    if (!empty($documents_most_downloaded)) {
+        foreach ($documents_most_downloaded as $row) {
+            echo '<tr>
+                    <td>'.Display::url(
+                    $row['down_doc_path'],
+                    api_get_path(
+                        WEB_CODE_PATH
+                    ).'document/show_content.php?file='.$row['down_doc_path'].$course_path_params
+                ).'</td>
+                    <td align="right">'.$row['count_down'].' '.get_lang(
+                    'Clicks'
+                ).'</td>
+                  </tr>';
+            if ($export_csv) {
+                $temp = array(
+                    $row['down_doc_path'],
+                    $row['count_down'].' '.get_lang('Clicks', '')
+                );
+                $csv_content[] = $temp;
+            }
+        }
+    } else {
+        echo '<tr><td>'.get_lang('NoDocumentDownloaded').'</td></tr>';
         if ($export_csv) {
-            $temp = array($row['down_doc_path'], $row['count_down'].' '.get_lang('Clicks', ''));
+            $temp = array(get_lang('NoDocumentDownloaded', ''), '');
             $csv_content[] = $temp;
         }
     }
-} else {
-    echo '<tr><td>'.get_lang('NoDocumentDownloaded').'</td></tr>';
-    if ($export_csv) {
-        $temp = array(get_lang('NoDocumentDownloaded', ''), '');
-        $csv_content[] = $temp;
-    }
+    echo '</table></div>';
+
+    echo '<div class="clear"></div>';
 }
-echo '</table></div>';
 
-echo '<div class="clear"></div>';
+if ($linkReporting) {
 
-// links tracking
- echo '<div class="report_section">
-            '.Display::page_subheader(Display::return_icon('link.gif',get_lang('LinksMostClicked')).'&nbsp;'.get_lang('LinksMostClicked')).'
-        <table class="data_table">';
+    // links tracking
+    echo '<div class="report_section">
+                '.Display::page_subheader(
+            Display::return_icon(
+                'link.gif',
+                get_lang('LinksMostClicked')
+            ).'&nbsp;'.get_lang('LinksMostClicked')
+        ).'
+            <table class="data_table">';
 
-$links_most_visited = Tracking::get_links_most_visited_by_course($course_code, $session_id);
+    $links_most_visited = Tracking::get_links_most_visited_by_course(
+        $course_code,
+        $session_id
+    );
 
-if ($export_csv) {
-    $temp = array(get_lang('LinksMostClicked'), '');
-    $csv_content[] = array('', '');
-    $csv_content[] = $temp;
-}
+    if ($export_csv) {
+        $temp = array(get_lang('LinksMostClicked'), '');
+        $csv_content[] = array('', '');
+        $csv_content[] = $temp;
+    }
 
-if (!empty($links_most_visited)) {
-    foreach ($links_most_visited as $row) {
-        echo '	<tr>
-                    <td>'.Display::url($row['title'].' ('.$row['url'].')', $row['url']).'</td>
-                    <td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td>
-                </tr>';
-        if ($export_csv){
-            $temp = array($row['title'], $row['count_visits'].' '.get_lang('Clicks', ''));
+    if (!empty($links_most_visited)) {
+        foreach ($links_most_visited as $row) {
+            echo '	<tr>
+                        <td>'.Display::url(
+                    $row['title'].' ('.$row['url'].')',
+                    $row['url']
+                ).'</td>
+                        <td align="right">'.$row['count_visits'].' '.get_lang(
+                    'Clicks'
+                ).'</td>
+                    </tr>';
+            if ($export_csv) {
+                $temp = array(
+                    $row['title'],
+                    $row['count_visits'].' '.get_lang('Clicks', '')
+                );
+                $csv_content[] = $temp;
+            }
+        }
+    } else {
+        echo '<tr><td>'.get_lang('NoLinkVisited').'</td></tr>';
+        if ($export_csv) {
+            $temp = array(get_lang('NoLinkVisited'), '');
             $csv_content[] = $temp;
         }
     }
-} else {
-    echo '<tr><td>'.get_lang('NoLinkVisited').'</td></tr>';
-    if ($export_csv) {
-        $temp = array(get_lang('NoLinkVisited'), '');
-        $csv_content[] = $temp;
-    }
+    echo '</table></div>';
+    echo '<div class="clear"></div>';
 }
-echo '</table></div>';
-echo '<div class="clear"></div>';
 
 // send the csv file if asked
 if ($export_csv) {