$additional_rating = ''; switch ($session->additional_rating) { case '2': $additional_rating = 'Excellent'; break; case '1': $additional_rating = 'Expected Standard'; break; case '0': $additional_rating = 'Marginal Pass'; break; default: $additional_rating = ''; break; } $sitedata = simplexml_load_string($enumlib->getSiteByID($session->siteid)); // work out any modifications feedback $titlestr = ""; if ($session->modifycount > 0 || $session->moderatecount > 0 || $session->lastmodifiedby > 0 || $session->lastmoderatedby > 0) { $titlestr = "title="; //print_r ($enumLib->getUserByID($session->lastmodifiedby)); $moderatedstr = $session->moderatecount > 0 ? "Moderated" : ""; $modifystr = $session->modifycount > 0 ? "Changed" : ""; $titlestr .= "'{$modifystr}" . (strlen($modifystr) > 0 && strlen($moderatedstr) > 0 ? ', ' : '') . $moderatedstr . "'"; } $reportTableStr .= "<tr {$titlestr} class='" . ($session->modifycount > 0 || $session->lastmodifiedby > 0 ? 'modified' : "") . " " . ($session->moderatecount > 0 || $session->lastmoderatedby > 0 ? 'moderated' : "") . "'><td><input type='image' src='{$CFG->wwwroot}{$CFG->basedir}/icons/gtk-print-preview.png' BORDER='0' style='vertical-align: text-bottom;' onclick='openExamDetailForSession({$session->id}); return false;'/></td>"; $reportTableStr .= "<td>{$session->fname} {$session->lname}</td><td>{$session->studentnum}</td>"; $reportTableStr .= "<td>{$session->datetime}</td>"; $reportTableStr .= "<td>{$sitedata->code}</td>"; $reportTableStr .= "<td>{$session->score}/{$session->total}</td>"; $reportTableStr .= "<td>" . ($session->overall_rating == 1 ? 'S' : 'NS') . "</td>";
/** * Get a summary report for an assessment session as Excel * @param type $session_ID * @return PHPExcel an Excel spreadsheet containing a summary report of the results of an assessment session */ public function getSummaryReportAsExcel($session_ID) { $enumlib = new EnumLib(); // get the data $dataXML = simplexml_load_string($this->getSummaryReportForExamInstance($session_ID)); $phpexcelObj = new PHPExcel(); // make a new Excel sheet $summaryWorksheet = new PHPExcel_Worksheet($phpexcelObj, 'Assessment summary'); // $phpexcelObj->createSheet(); $phpexcelObj->addSheet($summaryWorksheet, 0); // put some headings in $summaryWorksheet->setCellValue('A1', "Assessment summary: {$dataXML->summary->description} {$dataXML->summary->examdate}"); $summaryWorksheet->getStyle('A1')->getFont()->setSize(16); $summaryWorksheet->setCellValue('A2', "Student Number"); $summaryWorksheet->getStyle('A2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('B2', "Student Name"); $summaryWorksheet->getStyle('B2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('C2', "Assessment Date/Time"); $summaryWorksheet->getStyle('C2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('D2', "Site"); $summaryWorksheet->getStyle('D2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('E2', "Score"); $summaryWorksheet->getStyle('E2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('F2', "Out of a Possible"); $summaryWorksheet->getStyle('F2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('G2', "Comments"); $summaryWorksheet->getStyle('G2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('H2', "Assessor"); $summaryWorksheet->getStyle('H2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('I2', "Overall Rating"); $summaryWorksheet->getStyle('I2')->getFont()->setBold(true); $summaryWorksheet->setCellValue('J2', "Additional rating if Satisfactory"); $summaryWorksheet->getStyle('J2')->getFont()->setBold(true); // format a bit $summaryWorksheet->getColumnDimension('A')->setWidth(26); $summaryWorksheet->getColumnDimension('B')->setAutoSize(true); $summaryWorksheet->getColumnDimension('C')->setAutoSize(true); $summaryWorksheet->getColumnDimension('D')->setAutoSize(true); $summaryWorksheet->getColumnDimension('E')->setAutoSize(true); $summaryWorksheet->getColumnDimension('F')->setAutoSize(true); $summaryWorksheet->getColumnDimension('G')->setAutoSize(true); $summaryWorksheet->getColumnDimension('H')->setAutoSize(true); $summaryWorksheet->getColumnDimension('I')->setAutoSize(true); $summaryWorksheet->getColumnDimension('J')->setAutoSize(true); $additional_rating = ''; for ($i = 0; $i < count($dataXML->session); $i++) { if ($dataXML->session[$i]->overall_rating == 1) { switch ($dataXML->session[$i]->additional_rating) { case '2': $additional_rating = 'Excellent'; break; case '1': $additional_rating = 'Expected Standard'; break; case '0': $additional_rating = 'Marginal Pass'; break; default: $additional_rating = ''; break; } } else { $additional_rating = 'n/a'; } $sitedata = simplexml_load_string($enumlib->getSiteByID($dataXML->session[$i]->siteid)); $summaryWorksheet->setCellValue('A' . ($i + 3), $dataXML->session[$i]->studentnum); $summaryWorksheet->setCellValue('B' . ($i + 3), $dataXML->session[$i]->fname . ' ' . $dataXML->session[$i]->lname); $summaryWorksheet->setCellValue('C' . ($i + 3), $dataXML->session[$i]->datetime); $summaryWorksheet->setCellValue('D' . ($i + 3), $sitedata->code); $summaryWorksheet->setCellValue('E' . ($i + 3), $dataXML->session[$i]->score); $summaryWorksheet->setCellValue('F' . ($i + 3), $dataXML->session[$i]->total); $summaryWorksheet->setCellValue('G' . ($i + 3), $dataXML->session[$i]->comments); $summaryWorksheet->setCellValue('H' . ($i + 3), $dataXML->session[$i]->examiner); $summaryWorksheet->setCellValue('I' . ($i + 3), $dataXML->session[$i]->overall_rating == 1 ? 'S' : 'NS'); $summaryWorksheet->getStyle('I' . ($i + 3))->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($dataXML->session[$i]->overall_rating == 1 ? 'C6EFCE' : 'FFC7CE'); //, ($dataXML->session[$i]->overall_rating == 1) ? 'S' : 'NS'); $summaryWorksheet->setCellValue('J' . ($i + 3), $additional_rating); } return $phpexcelObj; }