Ejemplo n.º 1
0
function JLMS_statsHW($id, $option)
{
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    $JLMS_SESSION =& JLMSFactory::getSession();
    $Itemid = $JLMS_CONFIG->get('Itemid');
    $db =& JFactory::getDbo();
    $user = JLMSFactory::getUser();
    $my_id = $user->get('id');
    $JLMS_ACL =& JLMSFactory::getACL();
    $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0));
    $hw_id = intval(mosGetParam($_REQUEST, 'hw_id', 0));
    $id = $hw_id ? $hw_id : $id;
    $usertype = JLMS_GetUserType($my_id, $course_id);
    //	if ( $course_id && ($usertype == 1 || $usertype == 6) && ($id && (JLMS_GetHWCourse($id) == $course_id)) ) {
    if ($course_id && ($JLMS_ACL->CheckPermissions('homework', 'view_stats') && !$JLMS_ACL->isStaff() || $JLMS_ACL->CheckPermissions('homework', 'view_stats') && $JLMS_ACL->isStaff()) && ($id && JLMS_GetHWCourse($id) == $course_id)) {
        $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit'))));
        $JLMS_SESSION->set('list_limit', $limit);
        if ($usertype == 1 || $JLMS_ACL->isStaff()) {
            $filt_hw = intval(mosGetParam($_GET, 'filt_hw', $JLMS_SESSION->get('filt_hw', 2)));
            $filt_group = intval(mosGetParam($_GET, 'filt_group', $JLMS_SESSION->get('filt_group', 0)));
            $filt_subgroup = intval(mosGetParam($_GET, 'filt_subgroup', $JLMS_SESSION->get('filt_subgroup', 0)));
            $filter_stu = intval(mosGetParam($_REQUEST, 'filter_stu', $JLMS_SESSION->get('filter_stu_h', 0)));
            if ($JLMS_ACL->isStaff()) {
                $filt_group = 0;
                $filt_subgroup = 0;
                $filter_stu = 0;
            }
        } else {
            $filt_hw = 0;
            $filt_group = 0;
            $filt_subgroup = 0;
            $filter_stu = 0;
        }
        $JLMS_SESSION->set('filt_hw', $filt_hw);
        if ($filt_group != $JLMS_SESSION->get('filt_group', 0)) {
            $filter_stu = 0;
        }
        if (!$filt_group) {
            $filt_subgroup = 0;
        }
        $JLMS_SESSION->set('filt_group', $filt_group);
        $JLMS_SESSION->set('filt_subgroup', $filt_subgroup);
        $JLMS_SESSION->set('filter_stu_h', $filter_stu);
        $limitstart = intval(mosGetParam($_GET, 'limitstart', $JLMS_SESSION->get('limitstart_hw', 0)));
        $JLMS_SESSION->set('limitstart_hw', $limitstart);
        $query = "SELECT * FROM #__lms_homework WHERE id = '" . $id . "'" . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND published = 1");
        $db->SetQuery($query);
        $hw_info = $db->LoadObjectList();
        $members = "'0'";
        $groups_where_admin_manager = "'0'";
        //TODO: where is _role_type == 5 for assistants ???
        //TODO: where is CEO? they are limited to assigned groups !!!
        //if($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 4 || $JLMS_ACL->_role_type == 5) { // teacher or admin
        if ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only')) {
            // limited stats for organization admins/teachers
            $groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($my_id, $course_id);
            if (count($groups_where_admin_manager)) {
                if (JLMS_ACL_HELPER::GetCountAssignedGroups($my_id, $course_id) == 1) {
                    $filt_group = $groups_where_admin_manager[0];
                    if ($JLMS_ACL->isStaff()) {
                        $filt_group = 0;
                    }
                }
            }
            if (count($groups_where_admin_manager)) {
                $groups_where_admin_manager = implode(',', $groups_where_admin_manager);
                if ($groups_where_admin_manager != '') {
                    $query = "SELECT user_id FROM #__lms_users_in_global_groups WHERE (group_id IN ({$groups_where_admin_manager}) OR subgroup1_id IN ({$groups_where_admin_manager})) AND user_id > 0" . ($filt_group ? "\n AND group_id = '" . $filt_group . "'" : '') . ($filt_subgroup ? "\n AND subgroup1_id = '" . $filt_subgroup . "'" : '');
                    $db->setQuery($query);
                    $members = $db->loadResultArray();
                    //$members = implode(',', $members);
                    //if($members == '') {
                    //	$members = "'0'";
                    //}
                }
                $users_where_ceo_parent = array();
                if ($JLMS_ACL->_role_type == 3) {
                    $query = "SELECT user_id FROM `#__lms_user_parents` WHERE parent_id = '" . $my_id . "'";
                    $db->setQuery($query);
                    $users_where_ceo_parent = $db->loadResultArray();
                    //$members = array_merge($members, $users_where_ceo_parent);
                }
                if ($members != "'0'" && count($users_where_ceo_parent)) {
                    $members = array_merge($members, $users_where_ceo_parent);
                } elseif (count($users_where_ceo_parent)) {
                    $members = $users_where_ceo_parent;
                }
                $members = implode(',', $members);
                if ($members == '') {
                    $members = "'0'";
                }
            } else {
                $groups_where_admin_manager = "'0'";
            }
        }
        //}
        if ($JLMS_ACL->isStaff() && $JLMS_ACL->CheckPermissions('homework', 'view_stats')) {
            //ceo
            $staff_learners = $JLMS_ACL->_role_type == 3 && isset($JLMS_ACL->_staff_learners) ? $JLMS_ACL->_staff_learners : array();
            $str_staff_learners = implode(",", $staff_learners);
            //NOTE: $filt_group is always == 0 for Staffs, also they don't have a filter by group - therefore we can use the same query for both 'global' and 'local' groups modes
            //if($JLMS_CONFIG->get('use_global_groups', 1)){
            $query = "SELECT count(u.id)" . "\n FROM (#__users as u, #__lms_homework as d) LEFT JOIN #__lms_homework_results as c ON c.hw_id = d.id AND c.user_id = u.id, #__lms_users_in_groups as a" . ($filt_group ? "\n, #__lms_users_in_global_groups as uigg, #__lms_usergroups AS b" : '') . "\n WHERE d.id = '" . $id . "' AND a.user_id = u.id AND a.course_id = " . $course_id . "\n AND u.id IN (" . $str_staff_learners . ")" . ($filt_group ? "\n AND uigg.group_id = '" . $filt_group . "' AND a.group_id = uigg.group_id AND b.id = uigg.group_id AND b.course_id = 0" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1");
            /*} else {
            			$query = "SELECT count(u.id)"
            			. "\n FROM #__lms_homework as d, #__users as u, #__lms_user_parents as p, #__lms_homework_results as c, #__lms_users_in_groups as a"											
            			. "\n WHERE d.id = '".$id."' AND c.hw_id = d.id AND c.user_id = u.id AND u.id = p.user_id AND p.parent_id = '".$my_id."' AND a.user_id = u.id AND a.course_id = ".$course_id	
            			. ($filt_group ? ("\n AND a.group_id = '".$filt_group."'") : '')				
            			. ($filter_stu ? ("\n AND u.id = '".$filter_stu."'") : '')
            			. ($filt_hw ? ( ($filt_hw == 2) ? "\n AND c.hw_status = 1" : (($filt_hw == 1)?" AND (c.hw_status IS NULL OR c.hw_status <> 1)":"")) : '')
            			. (($JLMS_ACL->CheckPermissions('homework', 'view_all')) ? '' : "\n AND d.published = 1")				
            			;	
            		}*/
        } elseif ($JLMS_ACL->CheckPermissions('homework', 'view_stats')) {
            //teacher or admin
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT count(u.id)" . "\n FROM (#__users as u, #__lms_homework as d) LEFT JOIN #__lms_homework_results as c ON c.hw_id = d.id AND c.user_id = u.id, #__lms_users_in_groups as a " . ($filt_group ? "\n, #__lms_users_in_global_groups as uigg, #__lms_usergroups AS b" : '') . "\n WHERE d.id = '" . $id . "' AND a.user_id = u.id AND a.course_id = " . $course_id . ($filt_group ? "\n AND uigg.group_id = '" . $filt_group . "' AND a.group_id = uigg.group_id AND b.id = uigg.group_id AND b.course_id = 0" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only') ? "\n AND u.id IN ({$members})" : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1");
            } else {
                //TODO: fix this query !
                $query = "SELECT count(u.id)" . "\n FROM #__lms_homework as d, #__users as u, #__lms_homework_results as c, #__lms_users_in_groups as a" . "\n WHERE d.id = '" . $id . "' AND c.hw_id = d.id AND c.user_id = u.id AND a.user_id = u.id AND a.course_id = " . $course_id . ($filt_group ? "\n AND a.group_id = '" . $filt_group . "'" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1");
            }
        } else {
            $query = '';
        }
        $db->SetQuery($query);
        $total = $db->LoadResult();
        require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
        $pageNav = new JLMSPageNav($total, $limitstart, $limit);
        if ($JLMS_ACL->isStaff() && $JLMS_ACL->CheckPermissions('homework', 'view_stats')) {
            // ceo
            //NOTE: $filt_group is always == 0 for Staffs, also they don't have a filter by group - therefore we can use the same query for both 'global' and 'local' groups modes
            //if($JLMS_CONFIG->get('use_global_groups', 1)){
            $staff_learners = $JLMS_ACL->_role_type == 3 && isset($JLMS_ACL->_staff_learners) ? $JLMS_ACL->_staff_learners : array();
            $str_staff_learners = implode(",", $staff_learners);
            $query = "SELECT u.id AS user_id, u.username, u.name, u.email, c.hw_status, c.hw_date, c.grade, d.graded_activity" . ($filt_group ? ", b.ug_name" : '') . "\n FROM (#__lms_homework as d, #__users as u) LEFT JOIN #__lms_homework_results as c ON c.hw_id = d.id AND c.user_id = u.id, #__lms_users_in_groups as a" . ($filt_group ? "\n, #__lms_users_in_global_groups as uigg, #__lms_usergroups AS b" : '') . "\n WHERE d.id = '" . $id . "' AND a.user_id = u.id AND a.course_id = " . $course_id . "\n AND u.id IN (" . $str_staff_learners . ")" . ($filt_group ? "\n AND uigg.group_id = '" . $filt_group . "' AND a.group_id = uigg.group_id AND b.id = uigg.group_id AND b.course_id = 0" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1") . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
            /*} else {
            			$query = "SELECT u.id AS user_id, u.username, u.name, u.email, c.hw_status, c.hw_date, c.grade, d.graded_activity"
            			. ($filt_group ? (", b.ug_name") : '')
            			. "\n FROM #__lms_homework as d, #__users as u, #__lms_user_parents as p, #__lms_homework_results as c, #__lms_users_in_groups as a, #__lms_usergroups AS b"											
            			. "\n WHERE d.id = '".$id."' AND c.hw_id = d.id AND c.user_id = u.id AND u.id = p.user_id AND p.parent_id = '".$my_id."' AND a.user_id = u.id AND b.id = a.group_id AND a.course_id = ".$course_id	
            			. ($filt_group ? ("\n AND a.group_id = '".$filt_group."'") : '')				
            			. ($filter_stu ? ("\n AND u.id = '".$filter_stu."'") : '')
            			. ($filt_hw ? ( ($filt_hw == 2) ? "\n AND c.hw_status = 1" : (($filt_hw == 1)?" AND (c.hw_status IS NULL OR c.hw_status <> 1)":"")) : '')
            			. (($JLMS_ACL->CheckPermissions('homework', 'view_all')) ? '' : "\n AND d.published = 1")
            			. "\n LIMIT $pageNav->limitstart, $pageNav->limit";
            			;				
            		}*/
        } elseif ($JLMS_ACL->CheckPermissions('homework', 'view_stats')) {
            //teacher or admin or assistant
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT u.id AS user_id, u.username, u.name, u.email, c.hw_status, c.hw_date, c.grade, d.graded_activity" . ($filt_group ? ", b.ug_name" : '') . "\n FROM (#__lms_homework as d, #__users as u) LEFT JOIN #__lms_homework_results as c ON c.hw_id = d.id AND c.user_id = u.id, #__lms_users_in_groups as a" . ($filt_group ? "\n, #__lms_users_in_global_groups as uigg, #__lms_usergroups AS b" : '') . "\n WHERE d.id = '" . $id . "' AND a.user_id = u.id AND a.course_id=" . $course_id . ($filt_group ? "\n AND uigg.group_id = '" . $filt_group . "' AND a.group_id = uigg.group_id AND b.id = uigg.group_id AND b.course_id = 0" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only') ? "\n AND u.id IN ({$members})" : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1") . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
            } else {
                $query = "SELECT u.id AS user_id, u.username, u.name, u.email, c.hw_status, c.hw_date, c.grade, d.graded_activity" . ($filt_group ? ", b.ug_name" : '') . "\n FROM #__lms_homework as d, #__users as u, #__lms_homework_results as c, #__lms_users_in_groups as a" . ($filt_group ? ", " . "\n #__lms_usergroups AS b" : '') . "\n WHERE d.id = '" . $id . "' AND c.hw_id = d.id AND c.user_id = u.id AND a.user_id = u.id " . ($filt_group ? "\n AND b.id = a.group_id " : '') . "\n AND a.course_id = " . $course_id . ($filt_group ? "\n AND a.group_id = '" . $filt_group . "'" : '') . ($filter_stu ? "\n AND u.id = '" . $filter_stu . "'" : '') . ($filt_hw ? $filt_hw == 2 ? "\n AND c.hw_status = 1" : ($filt_hw == 1 ? " AND (c.hw_status IS NULL OR c.hw_status <> 1)" : "") : '') . ($JLMS_ACL->CheckPermissions('homework', 'view_all') ? '' : "\n AND d.published = 1") . "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}";
            }
        } else {
            $query = '';
        }
        $db->SetQuery($query);
        $hw_stats = $db->LoadObjectList();
        if (!$filt_group) {
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT ug.ug_name, uig.user_id \n\t\t\t\t\t\t\t\tFROM #__lms_users_in_global_groups AS uigg, #__lms_users_in_groups AS uig, #__lms_usergroups AS ug \n\t\t\t\t\t\t\t\tWHERE uigg.group_id = ug.id AND uig.group_id = uigg.group_id AND uig.course_id = " . $course_id . ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only') ? "\n AND uig.group_id IN ({$groups_where_admin_manager})" : '');
            } else {
                $query = "SELECT ug.ug_name, uig.user_id \n\t\t\t\t\t\t\t\tFROM #__lms_users_in_groups AS uig, #__lms_usergroups AS ug \n\t\t\t\t\t\t\t\tWHERE uig.group_id = ug.id AND uig.course_id = " . $course_id;
            }
            $db->setQuery($query);
            $ug_names = $db->LoadObjectList();
            for ($i = 0; $i < count($hw_stats); $i++) {
                $hw_stats[$i]->ug_name = '';
                foreach ($ug_names as $ug_name) {
                    if ($ug_name->user_id == $hw_stats[$i]->user_id) {
                        if ($hw_stats[$i]->ug_name) {
                            $hw_stats[$i]->ug_name .= ', ' . $ug_name->ug_name;
                        } else {
                            $hw_stats[$i]->ug_name = $ug_name->ug_name;
                        }
                    }
                }
            }
        }
        $lists = array();
        $f_items = array();
        $f_items[] = mosHTML::makeOption(0, _JLMS_HW_FILTER_ALL_RESULTS);
        $f_items[] = mosHTML::makeOption(2, _JLMS_HW_STATUS_COMPLETED);
        $f_items[] = mosHTML::makeOption(1, _JLMS_HW_STATUS_INCOMPLETE);
        $link = "index.php?option={$option}&amp;Itemid={$Itemid}&task=hw_stats&course_id={$course_id}&amp;id={$id}";
        $link = $link . "&amp;filt_hw='+this.options[selectedIndex].value+'";
        $link = sefRelToAbs($link);
        $link = str_replace('%5C%27', "'", $link);
        $link = str_replace('%5B', "[", $link);
        $link = str_replace('%5D', "]", $link);
        $link = str_replace('%20', "+", $link);
        $link = str_replace("\\\\\\", "", $link);
        $link = str_replace('%27', "'", $link);
        $lists['filter'] = mosHTML::selectList($f_items, 'filt_hw', 'class="inputbox" size="1" onchange="document.location.href=\'' . $link . '\';"', 'value', 'text', $filt_hw);
        $g_items = array();
        $g_items[] = mosHTML::makeOption(0, _JLMS_HW_FILTER_ALL_GROUPS);
        if ($JLMS_CONFIG->get('use_global_groups', 1)) {
            if ($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 4) {
                $query = "SELECT distinct a.id as value, a.ug_name as text" . "\n FROM #__lms_usergroups as a" . "\n WHERE a.course_id = 0" . "\n AND a.parent_id = 0" . ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only') ? "\n AND a.id IN ({$groups_where_admin_manager})" : '') . "\n ORDER BY a.ug_name";
            } else {
                //TODO: bug! CEO cann't see all the groups available in the system
                $query = "SELECT distinct a.id as value, a.ug_name as text" . "\n FROM #__lms_usergroups as a" . "\n WHERE a.course_id = 0" . "\n AND a.parent_id = 0" . "\n ORDER BY a.ug_name";
            }
        } else {
            $query = "SELECT distinct a.id as value, a.ug_name as text FROM #__lms_usergroups as a, #__lms_users_in_groups as b" . "\n WHERE a.course_id = '" . $course_id . "' AND b.group_id = a.id ORDER BY a.ug_name";
        }
        $db->SetQuery($query);
        $groups = $db->LoadObjectList();
        $g_items = array_merge($g_items, $groups);
        $link = "index.php?option={$option}&amp;Itemid={$Itemid}&task=hw_stats&course_id={$course_id}&amp;id={$id}";
        $link = $link . "&amp;filt_group='+this.options[selectedIndex].value+'";
        $link = sefRelToAbs($link);
        $link = str_replace('%5C%27', "'", $link);
        $link = str_replace('%5B', "[", $link);
        $link = str_replace('%5D', "]", $link);
        $link = str_replace('%20', "+", $link);
        $link = str_replace("\\\\\\", "", $link);
        $link = str_replace('%27', "'", $link);
        $lists['filter2'] = mosHTML::selectList($g_items, 'filt_group', 'class="inputbox" style="width:250px;" size="1" onchange="document.location.href=\'' . $link . '\';"', 'value', 'text', $filt_group);
        if ($filt_group) {
            $g_items = array();
            $g_items[] = mosHTML::makeOption(0, _JLMS_FILTER_ALL_SUBGROUPS);
            if (($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 4) && $JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT distinct a.id as value, a.ug_name as text" . "\n FROM #__lms_usergroups as a" . "\n WHERE a.course_id = 0" . "\n AND a.parent_id = {$filt_group}" . ($JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only') ? "\n AND a.parent_id IN ({$groups_where_admin_manager})" : '') . "\n ORDER BY a.ug_name";
                $db->SetQuery($query);
                $sbugroups = $db->LoadObjectList();
                if (count($sbugroups)) {
                    $g_items = array_merge($g_items, $sbugroups);
                    $link = "index.php?option={$option}&amp;Itemid={$Itemid}&task=hw_stats&course_id={$course_id}&amp;id={$id}";
                    $link = $link . "&amp;filt_group=" . $filt_group . "&amp;filt_subgroup='+this.options[selectedIndex].value+'";
                    $link = sefRelToAbs($link);
                    $link = str_replace('%5C%27', "'", $link);
                    $link = str_replace('%5B', "[", $link);
                    $link = str_replace('%5D', "]", $link);
                    $link = str_replace('%20', "+", $link);
                    $link = str_replace("\\\\\\", "", $link);
                    $link = str_replace('%27', "'", $link);
                    $lists['filter3'] = mosHTML::selectList($g_items, 'filt_subgroup', 'class="inputbox" style="width:250px;" size="1" onchange="document.location.href=\'' . $link . '\';"', 'value', 'text', $filt_subgroup);
                }
            }
        }
        $r = new stdClass();
        $r->id = 0;
        $r->username = _JLMS_SB_ALL_USERS;
        $r->name = '';
        $r->email = '';
        $r->ug_name = '';
        $students[] = $r;
        $students = array_merge($students, JLMS_getCourseStudentsList2($course_id, $filt_group));
        //		$students = array_merge($students, JLMS_getCourseStudentsList($course_id, $filt_group));
        $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=hw_stats&amp;course_id={$course_id}&amp;id={$id}";
        $link = $link . "&amp;filter_stu='+this.options[selectedIndex].value+'";
        $link = sefRelToAbs($link);
        $link = str_replace('%5C%27', "'", $link);
        $link = str_replace('%5B', "[", $link);
        $link = str_replace('%5D', "]", $link);
        $link = str_replace('%20', "+", $link);
        $link = str_replace("\\\\\\", "", $link);
        $link = str_replace('%27', "'", $link);
        $lists['filter_stu'] = mosHTML::selectList($students, 'filter_stu', 'class="inputbox" style="width:250px;" size="1" onchange="document.location.href=\'' . $link . '\';"', 'id', 'username', $filter_stu);
        $lms_titles_cache =& JLMSFactory::getTitles();
        $lms_titles_cache->setArray('users', $hw_stats, 'user_id', 'username');
        JLMS_homework_html::statsHW($hw_stats, $hw_info[0], $option, $course_id, $pageNav, $lists, $JLMS_ACL->CheckPermissions('homework', 'view_stats'));
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=homework&id={$course_id}"));
    }
}