function gbUserPDF($id, $option, &$rows, &$lists) { global $Itemid, $JLMS_CONFIG, $JLMS_DB; $juser = JLMSFactory::getUser(); $JLMS_ACL =& JLMSFactory::getACL(); chdir(JPATH_SITE); if (file_exists(JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'pdf' . DS . 'lms.pdf.php')) { include JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'pdf' . DS . 'lms.pdf.php'; } else { die('Unable to print PDF'); } $pdf = new JLMSPDF('P', 'mm', 'A4', true, 'UTF-8', false); //A4 Portrait $pdf->SetMargins(10, 10, 10, true); $pdf->SetDrawColor(0, 0, 0); $header = "<br /><div align=\"center\">" . $JLMS_CONFIG->get('course_name') . "</div>"; $footer = "\n\t\t\t<hr />\n\t\t\t<table>\n\t\t\t <tr>\n\t\t\t <td align=\"left\">" . $JLMS_CONFIG->get('sitename') . ' - ' . $JLMS_CONFIG->get('live_site') . "</td>\n\t\t"; if ($JLMS_CONFIG->get('is_trial')) { $footer .= "<td align=\"center\">Powered by JoomlaLMS (www.joomlalms.com)</td>"; } $footer .= "\n\t\t\t <td align=\"right\">" . date('j F, Y, H:i', time() + $JLMS_CONFIG->get('offset') * 60 * 60) . "</td>\n\t\t\t </tr>\t\t \n\t\t\t</table>\n\t\t"; $pdf->setHeaderFont(array('freesans', '', 6)); $pdf->setHeaderHTML($header); $pdf->setFooterMargin(5); $pdf->setFooterFont(array('freesans', '', 6)); $pdf->setFooterHTML($footer); $pdf->addPage(); $pdf->setFont('freesans'); //choose font $pdf->SetFontSize(8); ob_clean(); ob_start(); ?> <table width="100%"> <tr> <td align="right"> <font size="10"><?php if ($rows[0]->user_certificate) { echo $JLMS_ACL->CheckPermissions('gradebook', 'manage') ? _JLMS_COURSE_COMPLETED_ADMIN : ($juser->get('id') == $rows[0]->user_id ? _JLMS_COURSE_COMPLETED_USER : _JLMS_COURSE_COMPLETED_ADMIN); echo str_repeat(' ', 15); } ?> </font> </td> </tr> </table> <br /> <?php $params_cs = array(); if ($JLMS_ACL->CheckPermissions('gradebook', 'manage') && !empty($lists['enrollment_answers'])) { ?> <table width="100%"> <tr> <td width="50%" valign="top"> <div><strong><font size="10"><?php echo _JLMS_GB_USER_INFORMATION; ?> </font></strong></div> <table width="100%" cellpadding="0" cellspacing="0" border="0" > <tr> <td width="20%" align="left"><strong><?php echo _JLMS_UI_USERNAME; ?> </strong></td> <td align="left"><?php echo $rows[0]->username; ?> </td> </tr> <tr> <td align="left"><strong><?php echo _JLMS_UI_NAME; ?> </strong></td> <td align="left"><?php echo $rows[0]->name; ?> </td> </tr> <tr> <td align="left"><strong><?php echo _JLMS_UI_EMAIL; ?> </strong></td> <td align="left"><?php echo $rows[0]->email; ?> </td> </tr> <tr> <td align="left"><strong><?php echo _JLMS_UI_GROUP; ?> </strong></td> <td align="left"><?php echo $rows[0]->ug_name ? $rows[0]->ug_name : ' '; ?> </td> </tr> </table> </td> <td width="50%" valign="top"> <div><strong><font size="10"><?php echo _JLMS_GB_REG_INFORMATION; ?> </font></strong></div> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php foreach ($lists['enrollment_answers'] as $ea) { echo '<tr><td width: "30%"><strong>' . $ea->course_question . '</strong></td><td>' . ($ea->user_answer ? $ea->user_answer : ' ') . '</td></tr>'; } ?> </table> </td> </tr> </table> <?php } else { ?> <table width="100%" cellpadding="0" cellspacing = "0"> <tr><td width="20%" align="left"><strong><?php echo _JLMS_UI_USERNAME; ?> </strong></td><td align="left"><?php echo $rows[0]->username; ?> </td></tr> <tr><td align="left"><strong><?php echo _JLMS_UI_NAME; ?> </strong></td><td align="left"><?php echo $rows[0]->name; ?> </td></tr> <tr><td align="left"><strong><?php echo _JLMS_UI_EMAIL; ?> </strong></td><td align="left"><?php echo $rows[0]->email; ?> </td></tr> <tr><td align="left"><strong><?php echo _JLMS_UI_GROUP; ?> </strong></td><td align="left"><?php echo $rows[0]->ug_name ? $rows[0]->ug_name : ' '; ?> </td></tr> </table> <?php } $html = ob_get_contents(); ob_end_flush(); ob_clean(); $pdf->writeHTML($html, true, false, false, false, ''); $pdf->setY($pdf->GetY() + 20); /** * Certificates MOD - 04.10.2007 (DEN) * We will show the list of all achieved certificates in the User Gradebook */ $query = "SELECT count(*) FROM #__lms_certificates WHERE course_id = '" . $id . "' AND published = 1 AND crtf_type = 1 AND parent_id = 0"; $JLMS_DB->SetQuery($query); $is_course_certificate = $JLMS_DB->loadResult(); if (!empty($lists['user_quiz_certificates']) || isset($rows[0]->user_certificate) && $rows[0]->user_certificate && $is_course_certificate) { $pdf->setFontSize(10); $pdf->setFont('freesansb'); //choose font $pdf->Cell(0, 10, _JLMS_GB_CERTIFICATES, '', 1, 'L'); $pdf->setFont('freesans'); //choose font $pdf->setFontSize(8); ob_clean(); ob_start(); $old_format = $JLMS_CONFIG->get('date_format', 'Y-m-d'); $new_format = $JLMS_CONFIG->get('gradebook_certificate_date', ''); if ($new_format) { $JLMS_CONFIG->set('date_format', $new_format); } echo '<table width="100%" cellpadding="0" cellspacing="0" border="1">'; foreach ($lists['user_quiz_certificates'] as $crtf_row) { ?> <tr> <td width="50%" align="left"> <strong><?php echo $crtf_row->quiz_name; ?> </strong></td> <td align="center"><?php echo JLMS_dateToDisplay($crtf_row->crtf_date); ?> </td> </tr> <?php } if (isset($rows[0]->user_certificate) && $rows[0]->user_certificate && $is_course_certificate) { $cert_user_id = 0; if (isset($lists['user_id']) && $lists['user_id']) { global $my; if ($my->id == $lists['user_id']) { } else { $cert_user_id = $lists['user_id']; } } ?> <tr> <td width="50%" align="left"> <strong><?php echo _JLMS_GB_COURSE_CERTIFICATE; ?> </strong></td> <td align="center"><?php echo JLMS_dateToDisplay($rows[0]->user_certificate_date); ?> </td> </tr> <?php } $JLMS_CONFIG->set('date_format', $old_format); echo '</table>'; $html = ob_get_contents(); ob_end_flush(); ob_clean(); $pdf->writeHTML($html, true, false, false, false, ''); } /* END of Certificates MOD */ if (count($lists['sc_rows'])) { $is_shown = 0; foreach ($lists['sc_rows'] as $sc_row) { if ($sc_row->show_in_gradebook) { $is_shown++; if ($is_shown == 1) { $pdf->setFontSize(10); $pdf->setFont('freesansb'); //choose font $pdf->cell(0, 10, _JLMS_GB_SCORM_RESULTS, '', 1, 'L'); $pdf->setFont('freesans'); //choose font $pdf->setFontSize(8); ob_clean(); ob_start(); echo '<table width="100%" cellpadding="0" cellspacing="0" border="1">'; } $j = 0; while ($j < count($rows[0]->scorm_info)) { if ($rows[0]->scorm_info[$j]->gbi_id == $sc_row->item_id) { if ($rows[0]->scorm_info[$j]->user_status == -1) { ?> <tr> <td width="50%" align="left"> <strong><?php echo $sc_row->lpath_name; ?> </strong></td> <td width="20%" align="center"> - </td> <td width="30%" align="center"> </td> </tr> <?php } else { $status = $rows[0]->scorm_info[$j]->user_status ? _JLMS_GB_SCORM_COMPLETED : _JLMS_GB_SCORM_INCOMPLETED; ?> <tr> <td width="50%" align="left"> <strong><?php echo $sc_row->lpath_name; ?> </strong></td> <td width="20%" align="center"><strong><?php echo $status; ?> </strong></td> <td width="30%" align="center"><b><?php echo $rows[0]->scorm_info[$j]->user_grade . "</b> (" . $rows[0]->scorm_info[$j]->user_pts . _JLMS_GB_POINTS . ")"; ?> </td> </tr> <?php } } $j++; } } } if ($is_shown) { echo '</table>'; $html = ob_get_contents(); ob_end_flush(); ob_clean(); $pdf->writeHTML($html, true, false, false, false, ''); } } if (count($lists['quiz_rows'])) { $pdf->setFontSize(10); $pdf->setFont('freesansb'); //choose font $pdf->cell(0, 10, _JLMS_GB_QUIZ_RESULTS, '', 1, 'L'); $pdf->setFont('freesans'); //choose font $pdf->setFontSize(8); ob_clean(); ob_start(); /*Integration Plugin Percentiles*/ echo '<table width="100%" cellpadding="0" cellspacing="0" border="1">'; foreach ($lists['quiz_rows'] as $quiz_row) { $j = 0; while ($j < count($rows[0]->quiz_info)) { if ($rows[0]->quiz_info[$j]->gbi_id == $quiz_row->c_id) { if ($rows[0]->quiz_info[$j]->user_status == -1) { ?> <tr> <td width="50%" align="left"> <strong><?php echo $quiz_row->c_title; ?> </strong></td> <td width="20%" align="center"> - </td> <td width="30%" align="center"> </td> </tr> <?php } else { $status = $rows[0]->quiz_info[$j]->user_status ? _JLMS_GB_SCORM_COMPLETED : _JLMS_RESULT_FAIL; ?> <tr> <td width="50%" align="left"> <strong><?php echo $quiz_row->c_title; ?> </strong></td> <td width="20%" align="center"><strong><?php echo $status; ?> </strong></td> <td width="30%" align="center"> <?php if ($rows[0]->quiz_info[$j]->user_grade != '-') { echo "<b>" . $rows[0]->quiz_info[$j]->user_grade . "</b> (" . $rows[0]->quiz_info[$j]->user_pts_full . ")"; } else { echo $rows[0]->quiz_info[$j]->user_pts_full; } if (isset($rows[0]->quiz_info[$j]->user_percentile)) { echo ' - ' . $rows[0]->quiz_info[$j]->user_percentile; } ?> </td> </tr> <?php } } $j++; } } echo '</table>'; $html = ob_get_contents(); ob_end_flush(); ob_clean(); $pdf->writeHTML($html, true, false, false, false, ''); } if (count($lists['gb_rows'])) { $pdf->setFontSize(10); $pdf->setFont('freesansb'); //choose font $pdf->cell(0, 10, _JLMS_GB_GBI_RESULTS, '', 1, 'L'); $pdf->setFont('freesans'); //choose font $pdf->setFontSize(8); ob_clean(); ob_start(); echo '<table width="100%" cellpadding="0" cellspacing="0" border="1">'; foreach ($lists['gb_rows'] as $gb_row) { $j = 0; while ($j < count($rows[0]->grade_info)) { if ($rows[0]->grade_info[$j]->gbi_id == $gb_row->id) { ?> <tr> <td width="50%" align="left"> <strong><?php echo $gb_row->gbi_name; ?> </strong></td> <td width="50%" align="center"> <?php echo $rows[0]->grade_info[$j]->user_grade != '-' ? $rows[0]->grade_info[$j]->user_grade : ''; ?> </td> </tr> <?php } $j++; } } echo '</table>'; $html = ob_get_contents(); ob_end_flush(); ob_clean(); $pdf->writeHTML($html, true, false, false, false, ''); } $pdf->Output('gradebook_' . $rows[0]->username . '_course' . $id . '.pdf', 'I'); die; }