function JLMS_sreportScorm($option, &$rows, $start_date, $end_date, &$pageNav, &$lists, $levels, $filt_cat, $filt_group, $is_full) { global $JLMS_CONFIG; $Itemid = $JLMS_CONFIG->get('Itemid'); //FLMS multicat $multicat = array(); if ($JLMS_CONFIG->get('multicat_use', 0)) { $multicat = array(); $i = 0; foreach ($lists as $key => $item) { if (substr($key, 0, 7) == 'filter_') { $multicat[] = $lists['filter_' . $i]; $i++; } } } JLMS_TMPL::OpenMT(); $lists['user_id'] = isset($lists['user_id']) ? $lists['user_id'] : 0; if ($is_full) { $hparams = array('show_menu' => false); } else { $hparams = array('simple_menu' => true); } $toolbar = array(); JLMS_TMPL::ShowHeader('tracking', _JLMS_REPORTS_SCORM . ' ' . date("Y-m-d H:i:s"), $hparams, $toolbar); JLMS_TMPL::OpenTS(); ?> <script language="javascript" type="text/javascript"> <!--//--><![CDATA[//><!-- function pickup_date(){ var form = document.adminForm; form.end_date.value = form.pick_date.value; form.start_date.value = form.pick_to_date.value; var is_cor = 1; if(form.start_date.value.length == 10 && form.end_date.value.length == 10) { if("<?php echo $JLMS_CONFIG->get('date_format', "Y-m-d"); ?> " == "d-m-Y"){ if(form.end_date.value.substring(5)<form.start_date.value.substring(5)){ is_cor = 0; } else if( form.end_date.value.substring(2,5)<form.start_date.value.substring(2,5)){ is_cor = 0; } else if( form.end_date.value.substring(0,2)<form.start_date.value.substring(0,2)){ is_cor = 0; } } else { if(form.end_date.value.substring(0,4)<form.start_date.value.substring(0,4)){ is_cor = 0; } else if ( form.end_date.value.substring(5,7)<form.start_date.value.substring(5,7)){ is_cor = 0; } else if ( form.end_date.value.substring(8,10)<form.start_date.value.substring(8,10)){ is_cor = 0; } } } if(!is_cor){ alert("<?php echo _JLMS_REPORTS_SELECT_DATE; ?> "); } else { form.view.value = ''; form.submit(); } } function pickup_date_reset(){ var form = document.adminForm; form.pick_date.value = '-'; form.pick_to_date.value = '-'; form.end_date.value = form.pick_date.value; form.start_date.value = form.pick_to_date.value; form.view.value = ''; form.submit(); } var old_filters = new Array(); function read_filter(){ var form = document.adminForm; var count_levels = '<?php echo count($levels); ?> '; for(var i=0;i<parseInt(count_levels);i++){ if(form['filter_id_'+i] != null){ old_filters[i] = form['filter_id_'+i].value; } } } function write_filter(){ var form = document.adminForm; var count_levels = '<?php echo count($levels); ?> '; var j; for(var i=0;i<parseInt(count_levels);i++){ if(form['filter_id_'+i+''] != null && form['filter_id_'+i+''].value != old_filters[i]){ j = i; } if(i > j){ if(form['filter_id_'+i] != null){ form['filter_id_'+i].value = 0; } } } } function submitFormView(view){ var form = document.adminForm; form.view.value = view; form.task.value='report_scorm'; form.submit(); } //--><!]]> </script> <?php $action_url = $is_full ? $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}" : sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"); ?> <form action="<?php echo $action_url; ?> " method="post" name="adminForm"> <table cellpadding="0" cellspacing="0" border="0" id="TheTable" <?php echo $is_full ? "" : 'width="100%"'; ?> > <?php if (!$is_full) { ?> <tr> <td align="<?php echo $is_full ? "left" : "right"; ?> " <?php echo !$is_full ? 'colspan="4"' : ''; ?> > <table <?php echo $is_full ? '' : 'width="30%"'; ?> > <tr> <td valign="top" <?php echo $is_full ? 'width="400"' : 'width="40%"'; ?> > <table width="100%" border="0"> <tr> <td <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> Report Type: </td> <td> <?php echo JLMS_switchType($option); ?> </td> </tr> </table> </td> </tr> </table> </td> </tr> <?php } ?> <tr> <td align="left"> <table <?php echo $is_full ? '' : 'width="100%"'; ?> > <tr> <td valign="top" <?php echo $is_full ? 'width="400"' : 'width="40%"'; ?> > <table width="100%" border="0"> <?php if ($is_full) { ?> <tr> <td <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> Report Type: </td> <td> <?php echo JLMS_switchType($option); ?> </td> </tr> <?php } ?> <tr> <td <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> <?php if ($JLMS_CONFIG->get('multicat_use', 0)) { echo isset($levels[0]->cat_name) && $levels[0]->cat_name != '' ? $levels[0]->cat_name : _JLMS_COURSES_COURSES_GROUPS; } else { echo _JLMS_COURSES_COURSES_GROUPS; } ?> </td> <td> <?php if ($JLMS_CONFIG->get('multicat_use', 0)) { echo $lists['filter_0']; } else { echo $lists['jlms_course_cats']; } ?> </td> </tr> <?php if (count($multicat)) { for ($i = 0; $i < count($multicat); $i++) { if ($i > 0) { ?> <tr> <td <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> <?php echo isset($levels[$i]->cat_name) && $levels[$i]->cat_name != '' ? $levels[$i]->cat_name : _JLMS_COURSES_COURSES_GROUPS; ?> </td> <td> <?php echo $lists['filter_' . $i]; ?> </td> </tr> <?php } } } ?> <tr> <td <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> Courses: </td> <td> <?php echo $lists['filt_course']; ?> </td> </tr> </table> </td> <td valign="top" <?php echo $is_full ? 'width="400"' : 'width="40%"'; ?> > <table width="100%" border="0"> <?php if ($is_full) { ?> <tr> <td colspan="2"> </td> </tr> <?php } if ($JLMS_CONFIG->get('use_global_groups', 1)) { ?> <tr> <td style="padding-left: 5px;" <?php echo $is_full ? 'width="100"' : 'width="20%"'; ?> nowrap="nowrap"> <?php echo _JLMS_USER_GROUP_INFO; ?> </td> <td> <?php echo $lists['filt_group']; ?> </td> </tr> <?php } ?> <tr> <td colspan="2"> <table width="100%" border="0"> <tr> <td style="padding:0px 10px;" width="30">From</td> <td valign="middle" align="center"> <?php echo JLMS_HTML::_('calendar.calendar', $start_date, 'pick_to', 'pick_to', null, null, 'statictext'); ?> </td> <td style="padding:0px 10px;" width="30">To</td> <td valign="middle" align="center"> <?php echo JLMS_HTML::_('calendar.calendar', $end_date, 'pick', 'pick', null, null, 'statictext'); ?> </td> <td valign="middle" align="center" width="18" style="vertical-align:middle "> <a href="javascript:pickup_date_reset();" title=""> <img class="JLMS_png" src="<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/toolbar/btn_publish_hidden.png" alt="" title="Disabled filter date" border="0" width="16" height="16" /> </a> </td> <td valign="middle" align="center" width="18" style="vertical-align:middle "> <a href="javascript:pickup_date();" title=""> <img class="JLMS_png" src="<?php echo $JLMS_CONFIG->get('live_site'); ?> /components/com_joomla_lms/lms_images/toolbar/btn_accept.png" alt="" title="Enabled filter date" border="0" width="16" height="16" /> </a> </td> </tr> </table> </td> </tr> </table> </td> <?php if (!$is_full) { ?> <td style="padding-left:15px; white-space: nowrap;" align="right"> <?php $link = $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option=" . $option . "&Itemid={$Itemid}&task=report_scorm&is_full=1"; $link .= $filt_group ? "&filt_group=" . $filt_group : ""; $link .= $start_date != "-" ? "&start_date=" . JLMS_dateToDisplay($start_date) : ""; $link .= $end_date != "-" ? "&end_date=" . JLMS_dateToDisplay($end_date) : ""; ?> <a href="<?php echo $link; ?> " target="_blank" title="<?php echo _JLMS_FULL_VIEW_BUTTON; ?> "><?php echo _JLMS_FULL_VIEW_BUTTON; ?> </a> </td> <?php } ?> </tr> </table> </td> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <td class="sectiontableheader" style="white-space: nowrap;"> Username </td> <td class="sectiontableheader" style="white-space: nowrap;"> Name </td> <td class="sectiontableheader" style="white-space: nowrap;"> Email </td> <td class="sectiontableheader" style="white-space: nowrap;"> Course Name </td> <td class="sectiontableheader" style="white-space: nowrap;"> Course ID </td> <td class="sectiontableheader" style="white-space: nowrap;"> Date </td> <td class="sectiontableheader" style="text-align: center; white-space: nowrap;"> Score </td> <td class="sectiontableheader" style="text-align: center; white-space: nowrap;"> Course Status </td> </tr> </thead> <tbody> <?php $k = 1; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row = $rows[$i]; ?> <tr class="<?php echo "sectiontableentry{$k}"; ?> "> <td> <?php echo $row->username; ?> </td> <td> <?php echo $row->name; ?> </td> <td> <?php echo $row->email; ?> </td> <td> <?php echo $row->course_name; ?> </td> <td> <?php echo $row->lpath_name; ?> </td> <td> <?php if (isset($row->scorm_data) && $row->scorm_data->status) { if ($row->scorm_data->end) { $date_end = date("Y-m-d H:i:s", $row->scorm_data->end); echo JLMS_dateToDisplay($date_end); } } ?> </td> <td align="center"> <?php if (isset($row->scorm_data)) { echo $row->scorm_data->score; } ?> </td> <td align="center"> <?php $image = $row->course_status ? 'btn_accept.png' : 'btn_cancel.png'; $alt = $row->course_status ? 'btn_accept' : 'btn_cancel'; $alt .= '" align="top'; echo JLMS_reports_html::publishIcon(0, 0, 0, '', $alt, $image, $option, false); ?> </td> </tr> <?php $k = 3 - $k; } ?> </tbody> </table> <?php if ($lists['user_id'] && !$is_full && count($rows)) { if ($JLMS_CONFIG->get('new_lms_features', 1)) { $controls = array(); $controls[] = array('href' => "javascript:submitFormView('csv');", 'title' => 'CSV', 'img' => 'csv'); JLMS_TMPL::ShowControlsFooterC($controls, '', false, false, _JLMS_EXPORT_TO . ':'); } } ?> <?php if ($lists['user_id'] && !$is_full) { ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="center"> <?php $link = "index.php?option={$option}&Itemid={$Itemid}&task=report_scorm&filt_group={$filt_group}&filt_cat={$filt_cat}"; $link .= strlen($start_date) ? "&start_date=" . JLMS_dateToDisplay($start_date) : ""; $link .= strlen($end_date) ? "&end_date=" . JLMS_dateToDisplay($end_date) : ""; echo $pageNav->writePagesLinks($link); ?> </td> </tr> <tr> <td align="center"> <?php echo _JLMS_PN_DISPLAY_NUM . $pageNav->getLimitBox($link) . ' ' . $pageNav->getPagesCounter(); ?> </td> </tr> </table> <?php } ?> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?> " /> <input type="hidden" name="task" value="report_scorm" /> <input type="hidden" name="view" value="" /> <input type="hidden" name="start_date" value="<?php echo $start_date; ?> " /> <input type="hidden" name="end_date" value="<?php echo $end_date; ?> " /> <input type="hidden" name="state" value="0" /> <input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="is_full" value="<?php echo $is_full; ?> " /> </form> <?php $action_url = $is_full ? $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}" : sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"); ?> <form action="<?php echo $action_url; ?> " method="post" name="adminFormCsv"> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?> " /> <input type="hidden" name="task" value="report_scorm" /> <input type="hidden" name="is_full" value="1" /> <input type="hidden" name="view" value="" /> </form> <?php JLMS_TMPL::CloseTS(); JLMS_TMPL::CloseMT(); }
function JLMS_sreportGrade($option, $is_full) { global $JLMS_DB, $JLMS_CONFIG, $JLMS_SESSION, $my, $Itemid; $view = mosGetParam($_REQUEST, 'view', ''); if ($view == 'csv' || $view == 'xls') { $is_full = 0; } $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit')))); $JLMS_SESSION->set('list_limit', $limit); $limitstart = intval(mosGetParam($_GET, 'limitstart', 0)); $filt_group = intval(mosGetParam($_REQUEST, 'filt_group', 0)); $filt_cat = intval(mosGetParam($_REQUEST, 'filt_cat', 0)); $user_id = intval(mosGetParam($_REQUEST, 'filt_user', 0)); $lists = array(); $reporting_header = array(); //FLMS multicat $JLMS_ACL =& JLMSFactory::getACL(); $levels = array(); if ($JLMS_CONFIG->get('multicat_use', 0)) { $query = "SELECT * FROM #__lms_course_cats_config ORDER BY id"; $JLMS_DB->setQuery($query); $levels = $JLMS_DB->loadObjectList(); if (count($levels) == 0) { for ($i = 0; $i < 5; $i++) { if ($i > 0) { $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS; } else { $levels[$i]->cat_name = _JLMS_COURSES_COURSES_GROUPS; } } } $level_id = array(); for ($i = 0; $i < count($levels); $i++) { if ($i == 0) { $level_id[$i] = intval(mosGetParam($_REQUEST, 'filter_id_' . $i . '', $JLMS_SESSION->get('FLMS_filter_id_' . $i . '', 0))); $_REQUEST['filter_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]); } else { $level_id[$i] = intval(mosGetParam($_REQUEST, 'filter_id_' . $i . '', $JLMS_SESSION->get('FLMS_filter_id_' . $i . '', 0))); $_REQUEST['filter_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]); } if ($i == 0) { $parent_id[$i] = 0; } else { $parent_id[$i] = $level_id[$i - 1]; } if ($i == 0 || $parent_id[$i]) { //(Max): extra requests $query = "SELECT count(id) FROM `#__lms_course_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category"; $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadResult(); if ($groups == 0) { $level_id[$i] = 0; $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]); } } } for ($i = 0; $i < count($levels); $i++) { if ($i > 0 && $level_id[$i - 1] == 0) { $level_id[$i] = 0; $_REQUEST['filter_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]); $parent_id[$i] = 0; } elseif ($i == 0 && $level_id[$i] == 0) { $level_id[$i] = 0; $_REQUEST['filter_id_' . $i] = $level_id[$i]; $JLMS_SESSION->set('FLMS_filter_id_' . $i . '', $level_id[$i]); $parent_id[$i] = 0; } } $javascript = 'onclick="javascript:read_filter();" onchange="javascript:write_filter();submitFormView();"'; $query1 = "SELECT group_id FROM `#__lms_users_in_global_groups` WHERE user_id = '" . $my->id . "'"; $JLMS_DB->setQuery($query1); $user_group_ids = $JLMS_DB->loadResultArray(); $categories_reporting = array(); $name_categories_reporting = array(); for ($i = 0; $i < count($levels); $i++) { if ($i == 0 || $parent_id[$i]) { //(Max): extra requests if ($parent_id[$i] == 0 && !$JLMS_ACL->CheckPermissions('lms', 'create_course')) { $query = "SELECT * FROM `#__lms_course_cats` WHERE `parent` = '0'"; $query .= "\n AND ("; if (count($user_group_ids)) { $query .= "( `restricted` = 1 AND ( `groups` LIKE '%|{$user_group_ids['0']}|%'"; for ($i1 = 1; $i1 < count($user_group_ids); $i1++) { $query .= "\n OR `groups` like '%|{$user_group_ids[$i1]}|%'"; } $query .= "\n ) ) \n OR "; } $query .= "(`restricted` = 0 )) "; $query .= "\n ORDER BY `c_category`"; } else { $query = "SELECT * FROM `#__lms_course_cats` WHERE parent = '" . $parent_id[$i] . "' ORDER BY c_category"; } $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadObjectList(); if ($parent_id[$i] && $i > 0 && count($groups)) { $type_level[$i][] = mosHTML::makeOption(0, ' '); foreach ($groups as $group) { $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category); if ($group->id == $level_id[$i]) { $name_categories_reporting[] = $levels[$i]->cat_name; $categories_reporting[] = $group->c_category; } } $lists['filter_' . $i . ''] = mosHTML::selectList($type_level[$i], 'filter_id_' . $i . '', 'class="inputbox" size="1" style="width: 100%;" ' . $javascript, 'value', 'text', $level_id[$i]); //onchange="document.location.href=\''. $link_multi .'\';" } elseif ($i == 0) { $type_level[$i][] = mosHTML::makeOption(0, ' '); foreach ($groups as $group) { $type_level[$i][] = mosHTML::makeOption($group->id, $group->c_category); if ($group->id == $level_id[$i]) { $name_categories_reporting[] = $levels[$i]->cat_name; $categories_reporting[] = $group->c_category; } } $lists['filter_' . $i . ''] = mosHTML::selectList($type_level[$i], 'filter_id_' . $i . '', 'class="inputbox" size="1" style="width: 100%;" ' . $javascript, 'value', 'text', $level_id[$i]); //onchange="document.location.href=\''. $link_multi .'\';" } } } $reporting_header['name_categories'] = $name_categories_reporting; $reporting_header['categories'] = $categories_reporting; } //FLMS multicat $teacher_in_courses = $JLMS_CONFIG->get('teacher_in_courses', array()); $parent_in_courses = $JLMS_CONFIG->get('parent_in_courses', array()); $courses = array_merge($teacher_in_courses, $parent_in_courses); //var_dump($courses); if (count($courses)) { $courses_str = implode(',', $courses); $JLMS_DB->setQuery('SELECT id FROM #__lms_courses WHERE id IN(' . $courses_str . ')'); $courses = $JLMS_DB->loadResultArray(); $g_items = array(); $g_items[] = mosHTML::makeOption(0, _JLMS_ATT_FILTER_ALL_GROUPS); if ($JLMS_CONFIG->get('use_global_groups', 1)) { if (!count($courses)) { $courses = array(0); } $query = "SELECT user_id FROM #__lms_users_in_groups WHERE course_id IN (" . implode(',', $courses) . ")"; $JLMS_DB->setQuery($query); $cid = $JLMS_DB->loadResultArray(); if (!$cid) { $cid = array(-1); } $query = "SELECT group_id FROM #__lms_users_in_global_groups WHERE user_id IN (" . implode(',', $cid) . ")"; $JLMS_DB->setQuery($query); $gid = $JLMS_DB->loadResultArray(); if (!$gid) { $gid = array(-1); } $query = "SELECT distinct id AS value, ug_name AS text FROM #__lms_usergroups WHERE id IN (" . implode(',', $gid) . ") AND course_id = 0 ORDER BY text"; //course id check just in case)) $JLMS_DB->setQuery($query); $groups = $JLMS_DB->loadObjectList(); } else { if (!count($courses)) { $courses = array(0); } $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 IN (" . implode(',', $courses) . ") AND b.group_id = a.id ORDER BY a.ug_name"; $JLMS_DB->SetQuery($query); $groups = $JLMS_DB->LoadObjectList(); } $g_items = array_merge($g_items, $groups); $link = "javascript:submitFormView();"; //$link = $link ."&filt_group=' + this.options[selectedIndex].value + '"; $lists['filter'] = mosHTML::selectList($g_items, 'filt_group', 'class="inputbox" size="1" style="width: 100%;" onchange="' . $link . '"', 'value', 'text', $filt_group); $name_groups_reporting = array(); $groups_reporting = array(); foreach ($groups as $grp) { if ($filt_group && $grp->value == $filt_group) { $name_groups_reporting[] = _JLMS_REPORTING_USERGROUP; $groups_reporting[] = $grp->text; } } $reporting_header['name_groups'] = $name_groups_reporting; $reporting_header['groups'] = $groups_reporting; //--- if ($JLMS_CONFIG->get('use_global_groups', 1) && $filt_group) { $query = "SELECT DISTINCT a.id as value, a.name as text" . "\n FROM #__users as a, #__lms_users_in_global_groups as c" . "\n WHERE a.id = c.user_id " . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '') . "\n ORDER BY a.name"; } else { if (!count($courses)) { $courses = array(0); } if ($view == 'xls') { $query = "SELECT DISTINCT a.id as value, a.name as text" . "\n FROM #__users as a, #__lms_users_in_groups as c" . "\n WHERE a.id = c.user_id AND c.course_id IN (" . implode(',', $courses) . ")" . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '') . "\n ORDER BY a.name"; } else { $query = "SELECT DISTINCT a.id as value, CONCAT(a.name,' (',a.username,')') as text" . "\n FROM #__users as a, #__lms_users_in_groups as c" . "\n WHERE a.id = c.user_id AND c.course_id IN (" . implode(',', $courses) . ")" . ($filt_group ? "\n AND c.group_id = '" . $filt_group . "'" : '') . "\n ORDER BY a.name"; } } $JLMS_DB->SetQuery($query); $usr_cats[] = mosHTML::makeOption('0', _JLMS_SB_SELECT_USER); $usr_cats = array_merge($usr_cats, $JLMS_DB->loadObjectList()); $lists['jlms_filt_user'] = mosHTML::selectList($usr_cats, 'filt_user', 'class="text_area" size="1" style="width: 100%;" onchange="javascript:submitFormView();"', 'value', 'text', $user_id); $name_users_reporting = array(); $users_reporting = array(); foreach ($usr_cats as $usr) { if ($user_id && $usr->value == $user_id) { $name_users_reporting[] = _JLMS_USERS_NAME; $users_reporting[] = $usr->text; } } $reporting_header['name_users'] = $name_users_reporting; $reporting_header['users'] = $users_reporting; //--- //--- //$user_id = 64; $where = ''; if ($JLMS_CONFIG->get('multicat_use', 0)) { //NEW MUSLTICATS // $tmp_level = array(); $last_catid = 0; $tmp_cats_filter = JLMS_getFilterMulticategories($last_catid); /* $i=0; foreach($_REQUEST as $key=>$item){ if(preg_match('#filter_id_(\d+)#', $key, $result)){ if($item){ $tmp_level[$i] = $result; $last_catid = $item; $i++; } } } $query = "SELECT * FROM #__lms_course_cats ORDER BY id"; $JLMS_DB->setQuery($query); $all_cats = $JLMS_DB->loadObjectList(); $tmp_cats_filter = array(); $children = array(); foreach($all_cats as $cat){ $pt = $cat->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $cat->id); $children[$pt] = $list; } $tmp_cats_filter[0] = $last_catid; $i=1; foreach($children as $key=>$childs){ if($last_catid == $key){ foreach($children[$key] as $v){ if(!in_array($v, $tmp_cats_filter)){ $tmp_cats_filter[$i] = $v; $i++; } } } } foreach($children as $key=>$childs){ if(in_array($key, $tmp_cats_filter)){ foreach($children[$key] as $v){ if(!in_array($v, $tmp_cats_filter)){ $tmp_cats_filter[$i] = $v; $i++; } } } } $tmp_cats_filter = array_unique($tmp_cats_filter); */ $catids = implode(",", $tmp_cats_filter); if ($last_catid && count($tmp_cats_filter)) { $where .= "\n AND ( cat_id IN (" . $catids . ")"; if ($JLMS_CONFIG->get('sec_cat_use', 0)) { foreach ($tmp_cats_filter as $tmp_cats_filter_one) { $where .= "\n OR sec_cat LIKE '%|" . $tmp_cats_filter_one . "|%'"; } } $where .= "\n )"; } //NEW MUSLTICATS /* if($level_id[0]){ $where .= " AND cat_id = '".$level_id[0]."' "; } $other_cat_ids = array(); for($i=1;$i<count($level_id);$i++){ if($level_id[$i]){ $other_cat_ids[] = $level_id[$i]; } } $other_cat_id = ''; if(count($other_cat_ids) > 0){ $other_cat_id = implode(",", $other_cat_ids); $query = "SELECT course_id, cat_id, level FROM #__lms_course_level WHERE cat_id IN (".$other_cat_id.")"; $JLMS_DB->setQuery($query); $c_list = $JLMS_DB->loadObjectList(); $c_result = array(); foreach($c_list as $data){ if($data->level == count($other_cat_ids)){ $c_result[] = $data->course_id; } } $course_subs = implode(",", $c_result); $where .= " AND id IN (".$course_subs.") "; } */ } $query = "SELECT id FROM #__lms_courses WHERE id IN(" . $courses_str . ")" . $where . " ORDER BY id"; $JLMS_DB->setQuery($query); $courses2 = $JLMS_DB->loadResultArray(); //Test Course Only (FLMS) (Max - 18.04.2011) if ($JLMS_CONFIG->get('flms_integration')) { $test_lesson = JRequest::getVar('test_lesson', 0); $checked = $test_lesson ? 'checked="checked"' : ''; $lists['test_lesson'] = '<input type="checkbox" name="test_lesson" value="1" class="inputbox" ' . $checked . ' onclick="javascript:submitFormView();" />'; $lists['test_lesson_value'] = $test_lesson; if ($test_lesson) { $query = "SELECT b.course_id" . "\n FROM" . "\n #__lms_courses as a" . "\n, #__lmsf_courses as b" . "\n WHERE 1" . "\n AND a.id = b.course_id" . "\n AND b.test_lesson = 1"; $JLMS_DB->setQuery($query); $test_course_ids = $JLMS_DB->loadResultArray(); $tmp = array(); foreach ($courses2 as $c) { foreach ($test_course_ids as $t) { if ($c == $t) { $tmp[] = $c; } } } if (count($tmp)) { $courses2 = array(); $courses2 = $tmp; } } } //Test Course Only (FLMS) (Max - 18.04.2011) /* OLd Filter $query = "SELECT distinct a.id as value, a.c_category as text FROM #__lms_course_cats as a, #__lms_courses as c WHERE c.cat_id=a.id AND c.id IN (".implode(',',$courses).") order by a.c_category"; $JLMS_DB->setQuery( $query ); $sf_cats = array(); $sf_cats[] = mosHTML::makeOption( '0', '- Select Category -' ); $sf_cats = array_merge( $sf_cats, $JLMS_DB->loadObjectList() ); $lists['jlms_course_cats'] = mosHTML::selectList( $sf_cats, 'filt_cat', 'class="text_area" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $filt_cat ); */ $courses = $courses2; //$JLMS_DB->setQuery('SELECT COUNT(*) FROM #__lms_courses as c, #__lms_user_courses as u WHERE c.id=u.course_id AND c.id IN('.$courses_str.') AND u.user_id = '.$user_id.' '.($filt_cat?" AND cat_id=$filt_cat":"")); require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php"; if (!count($courses)) { $courses = array(0); } $query = "SELECT COUNT(*)" . "\n FROM #__lms_users_in_groups as b" . "\n LEFT JOIN #__lms_usergroups as c ON b.group_id = c.id AND c.course_id IN (" . implode(',', $courses) . ")," . "\n #__users as u, #__lms_courses as lc" . "\n WHERE b.course_id IN (" . implode(',', $courses) . ") AND b.user_id = u.id AND b.course_id = lc.id" . "\n AND b.user_id = '" . $user_id . "'"; $JLMS_DB->SetQuery($query); $pageNav = new JLMSPageNav($JLMS_DB->loadResult(), $limitstart, $limit); $query = "SELECT distinct b.course_id" . "\n FROM #__lms_users_in_groups as b" . "\n LEFT JOIN #__lms_usergroups as c ON b.group_id = c.id AND c.course_id IN (" . implode(',', $courses) . ")," . "\n #__users as u, #__lms_courses as lc" . "\n WHERE b.course_id IN (" . implode(',', $courses) . ") AND b.user_id = u.id AND b.course_id = lc.id" . "\n AND b.user_id = '" . $user_id . "'" . "\n ORDER BY lc.course_name " . (!$is_full ? "LIMIT {$pageNav->limitstart}, {$pageNav->limit}" : ""); $JLMS_DB->SetQuery($query); $courses = $JLMS_DB->loadResultArray(); //$JLMS_DB->setQuery('SELECT id FROM #__lms_courses as c, #__lms_user_courses as u WHERE c.id=u.course_id AND c.id IN('.$courses_str.') AND u.user_id = '.$user_id.' '.($filt_cat?" AND cat_id=$filt_cat":"")." ORDER BY id LIMIT $pageNav->limitstart, $pageNav->limit"); //$courses = $JLMS_DB->loadResultArray(); $hits = array(); $rowz = array(); if ($user_id) { //--start grade $rowz = array(); //$lists = array(); $lists['user_id'] = $user_id; $lists['hits'] = array(); foreach ($courses as $course_id) { //$course_id = 177; $query = "SELECT b.*, u.username, u.name, u.email, c.ug_name, lc.course_name" . "\n FROM #__lms_users_in_groups as b" . "\n LEFT JOIN #__lms_usergroups as c ON b.group_id = c.id AND c.course_id = '" . $course_id . "'," . "\n #__users as u, #__lms_courses as lc" . "\n WHERE b.course_id = '" . $course_id . "' AND b.user_id = u.id AND b.course_id = lc.id" . "\n AND b.user_id = '" . $user_id . "'"; $JLMS_DB->SetQuery($query); $rows = $JLMS_DB->LoadObjectList(); $uids = array(); foreach ($rows as $row) { $uids[] = $row->user_id; } //var_dump($rows);die(); if (count($uids)) { JLMS_GB_getUsersGrades($course_id, $uids, $rows, $lists, 1); if (count($rows)) { $rowz[] = $rows[0]; } } $query = "SELECT COUNT(*) FROM #__lms_track_hits WHERE course_id = " . $course_id . " AND user_id = " . $user_id; $JLMS_DB->SetQuery($query); $lists['hits'][] = $JLMS_DB->LoadResult(); } $hits = $lists['hits']; //JLMS_gradebook_html::showUserGradebook( $course_id, $option, $rows, $lists ); //---end grade //var_dump($users); /*if(count($users)){ $users_str = implode(',',$users); $query = "SELECT h.user_id as usr_id,h.course_id as c_id FROM #__lms_certificate_users as h LEFT JOIN #__users as u ON h.user_id=u.id LEFT JOIN #__lms_courses as c ON h.course_id = c.id WHERE h.course_id IN (".$courses_str.") AND h.user_id IN (".$users_str.") AND h.crt_date > '".$s_date_db."' AND h.crt_date < '".$e_date_db."' ORDER BY h.course_id,h.user_id"; $JLMS_DB->SetQuery( $query ); $hits = $JLMS_DB->LoadObjectLIST(); //var_dump($hits); }*/ } } if ($is_full) { JLMS_reports_html::JLMS_sreportGradeFV($option, $rowz, $pageNav, $lists, $levels, $filt_group, $filt_cat, $user_id, $is_full); } else { $users = array(); $users[] = $user_id; $reporting_header['data_grade']['rowz'] = $rowz; $reporting_header['data_grade']['lists'] = $lists; // if($view == 'csv') { // JLMS_REP_exportCsv($hits, array(), $users, $courses, $pageNav, $lists, $levels, $filt_cat, $filt_group, $option, 1); // } else if ($view == 'xls') { JLMS_REP_exportXLS($hits, array(), $users, $courses, $reporting_header); } else { JLMS_reports_html::JLMS_sreportGrade($option, $rowz, $pageNav, $lists, $levels, $filt_group, $filt_cat, $user_id, $is_full); } } }