function JQ_view_quizReport($option, $page, $course_id, $is_csv = 0) { global $JLMS_DB, $JLMS_SESSION, $Itemid, $JLMS_CONFIG; $quiz_id = intval(mosGetParam($_REQUEST, 'quiz_id', $JLMS_SESSION->get('report_quiz_id', 0))); $user_id = intval(mosGetParam($_REQUEST, 'user_id', $JLMS_SESSION->get('report_user_id', 0))); $limit = intval(mosGetParam($_REQUEST, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->get('list_limit')))); $limitstart = intval(mosGetParam($_REQUEST, 'limitstart', 0)); $JLMS_SESSION->set('report_quiz_id', $quiz_id); $JLMS_SESSION->set('report_user_id', $user_id); $JLMS_SESSION->set('list_limit', $limit); $view = strval(mosGetParam($_REQUEST, 'view', '')); $user_id2 = $user_id; if ($user_id == -1) { $user_id2 = 0; } $query = "SELECT COUNT(sq.c_id)" . "\n FROM #__lms_quiz_t_quiz as q, #__lms_quiz_r_student_quiz as sq" . "\n WHERE sq.c_quiz_id = q.c_id AND q.course_id = '" . $course_id . "'" . ($quiz_id ? "\n AND sq.c_quiz_id = {$quiz_id}" : '') . ($user_id ? "\n AND sq.c_student_id = {$user_id2}" : ''); $JLMS_DB->setQuery($query); $total = $JLMS_DB->loadResult(); require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php"; $pageNav = new JLMSPageNav($total, $limitstart, $limit); $query = "SELECT sq.c_id, sq.c_passed, sq.c_total_score, sq.c_total_time, sq.c_date_time, sq.c_passed," . "\n q.c_title, q.c_author, q.c_passing_score,sq.c_student_id, u.username, u.name, u.email, q.c_full_score, q.c_id as cur_quiz_id" . "\n FROM #__lms_quiz_t_quiz as q, #__lms_quiz_r_student_quiz as sq" . "\n LEFT JOIN #__users as u ON sq.c_student_id = u.id" . "\n WHERE sq.c_quiz_id = q.c_id AND q.course_id = '" . $course_id . "'" . ($quiz_id ? "\n AND sq.c_quiz_id = {$quiz_id}" : '') . ($user_id ? "\n AND sq.c_student_id = {$user_id2}" : '') . "\n ORDER BY sq.c_date_time DESC"; if ($is_csv == 1) { } else { $query .= "\n LIMIT {$pageNav->limitstart}, {$pageNav->limit}"; } $JLMS_DB->SetQuery($query); $rows = $JLMS_DB->LoadObjectList(); $lists = array(); $query = "SELECT distinct quiz_id FROM #__lms_quiz_t_quiz_pool"; $JLMS_DB->SetQuery($query); $lists['pool_quizzes'] = $JLMS_DB->loadResultArray(); if ($JLMS_CONFIG->get('global_quest_pool')) { $query = "SELECT distinct quiz_id FROM #__lms_quiz_t_quiz_gqp"; $JLMS_DB->SetQuery($query); $lists['pool_quizzes_gqp'] = $JLMS_DB->loadResultArray(); } else { $lists['pool_quizzes_gqp'] = array(); } $javascript = 'onchange="document.adminForm.page.value=\'reports\'; document.adminForm.submit();"'; $query = "SELECT distinct q.c_id AS value, q.c_title AS text" . "\n FROM #__lms_quiz_t_quiz as q, #__lms_quiz_r_student_quiz as sq" . "\n WHERE q.course_id = '" . $course_id . "' AND q.c_id = sq.c_quiz_id" . "\n ORDER BY q.c_title"; $JLMS_DB->setQuery($query); $quizzes = array(); $quizzes[] = mosHTML::makeOption('0', _JLMS_SB_SELECT_QUIZ); $quizzes = array_merge($quizzes, $JLMS_DB->loadObjectList()); $quiz = mosHTML::selectList($quizzes, 'quiz_id', 'class="inputbox" size="1" style="width:180px" ' . $javascript, 'value', 'text', $quiz_id); $lists['quiz'] = $quiz; $query = "SELECT c_id FROM #__lms_quiz_t_quiz WHERE course_id = '" . $course_id . "'"; $JLMS_DB->setQuery($query); $quiz_ids = $JLMS_DB->LoadResultArray(); if (!count($quiz_ids)) { $quiz_ids = array(0); } $quiz_id_str = implode(',', $quiz_ids); $query = "SELECT distinct q.id AS value, q.username AS text" . "\n FROM #__users as q, #__lms_quiz_r_student_quiz as sq" . "\n WHERE q.id = sq.c_student_id AND sq.c_quiz_id IN ({$quiz_id_str})" . "\n ORDER BY q.username"; $JLMS_DB->setQuery($query); $users = array(); $users[] = mosHTML::makeOption('0', _JLMS_SB_SELECT_USER); $users = array_merge($users, $JLMS_DB->loadObjectList()); $link = "index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$course_id}"; $link = $link . "&page=reports&user_id='+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); $javascript = 'onchange="document.location.href=\'' . $link . '\';"'; $lists['user'] = mosHTML::selectList($users, 'user_id', 'class="inputbox" size="1" style="width:180px" ' . $javascript, 'value', 'text', $user_id); if ($is_csv == 1) { $str = '"' . _JLMS_QUIZ_TBL_NUMBER . '","' . _JLMS_QUIZ_TBL_QUIZ . '","' . _JLMS_QUIZ_TBL_TOTAL_SCORE . '","' . _JLMS_QUIZ_TBL_PASS_SCORE . '","' . _JLMS_QUIZ_TBL_STUDENT . '","' . _JLMS_QUIZ_TBL_USER_SCORE . '","' . _JLMS_QUIZ_TBL_DATE_TIME . '","' . _JLMS_QUIZ_TBL_SPEND_TIME . '","' . _JLMS_QUIZ_TBL_PASSED . '"' . "\n"; for ($i = 0, $n = count($rows); $i < $n; $i++) { $str .= '"' . ($i + 1) . '","'; $str .= $rows[$i]->c_title . '","'; if ($JLMS_CONFIG->get('global_quest_pool')) { $str .= $rows[$i]->c_full_score . (in_array($rows[$i]->cur_quiz_id, $lists['pool_quizzes_gqp']) ? '+' : '') . '","'; } else { $str .= $rows[$i]->c_full_score . (in_array($rows[$i]->cur_quiz_id, $lists['pool_quizzes']) ? '+' : '') . '","'; } $str .= $rows[$i]->c_passing_score . '%","'; $str .= $rows[$i]->name . " (" . $rows[$i]->username . ')","' . $rows[$i]->c_total_score . '","' . $rows[$i]->c_date_time; $tot_min = floor($rows[$i]->c_total_time / 60); $tot_sec = $rows[$i]->c_total_time - $tot_min * 60; $str .= '","' . str_pad($tot_min, 2, "0", STR_PAD_LEFT) . ":" . str_pad($tot_sec, 2, "0", STR_PAD_LEFT) . '","'; if ($rows[$i]->c_passed) { $str .= _JLMS_YES_ALT_TITLE; } else { $str .= _JLMS_NO_ALT_TITLE; } $str .= "\"\n"; } $UserBrowser = ''; if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) { $UserBrowser = "IE"; } header("Content-Type:application/vnd.ms-excel"); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); if ($UserBrowser == 'IE') { header("Content-Disposition: inline; filename=quiz_results.csv "); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header("Content-Disposition: inline; filename=quiz_results.csv "); header('Pragma: no-cache'); } echo $str; die; } else { if ($view == 'xls') { JLMS_quiz_reporting::prepare($course_id, $user_id2, $quiz_id); } else { JLMS_quiz_admin_html_class::JQ_view_quizReport($rows, $pageNav, $option, $page, $course_id, $lists); } } }