예제 #1
0
     header('Content-type: image/jpeg');
     imagejpeg($thumb);
     imagedestroy($thumb);
     break;
 case 'getreportforsession':
     include 'lib/ReportsLib.php';
     include 'lib/EnumLib.php';
     $reportslib = new ReportsLib();
     $returnStr = $reportslib->getReportForStudentSession($_REQUEST['session_ID']);
     break;
 case 'getreportforsessionaspdf':
     include 'lib/EnumLib.php';
     include 'lib/mpdf60/mpdf.php';
     include 'lib/ReportsLib.php';
     $reportslib = new ReportsLib();
     $reportslib->getReportForStudentSessionAsPDF($_REQUEST['session_ID'], isset($_REQUEST['showoverall']) ? $_REQUEST['showoverall'] == 'true' : false);
     break;
 case 'getreportforexamasexcel':
     include 'lib/PHPExcel.php';
     include 'lib/ReportsLib.php';
     include 'lib/EnumLib.php';
     $enumlib = new EnumLib();
     $overview = simplexml_load_string($enumlib->getExamInstanceOverviewByID($_REQUEST['exam_ID']));
     $reportslib = new ReportsLib();
     $phpexcelObj = $reportslib->getSummaryReportAsExcel($_REQUEST['exam_ID']);
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="OSCE Summary for ' . $overview->instance->name . '.xlsx"');
     header('Cache-Control: max-age=0');
     $objWriter = new PHPExcel_Writer_Excel2007($phpexcelObj);
     $objWriter->save('php://output');
     break;
예제 #2
0
 /**
  * Sends an email to all students assessed in a session, containing a PDF of their assessment results (but not global comments or overall assessment)
  * @global type $CFG
  * @param type $sessionID
  * @param type $includeComments
  * @return string an XML-formatted string containing the success and failure count of the operation
  */
 public function sendTestMail($sessionID, $emailaddress, $emailtext, $includeComments, $showOverallResult = false)
 {
     //  getExamEmailStemByID
     global $CFG;
     $reportsLib = new ReportsLib();
     $stringlib = new StringLib();
     $enumlib = new EnumLib();
     $failcount = 0;
     $successcount = 0;
     $errordetail = "";
     //$conn = mysqli_connect($CFG->db, $CFG->dbuser, $CFG->dbuserpass, $CFG->schema) or die('<data><error>failed connecting to database</error><detail>' . mysqli_error($conn) . '</detail></data>');
     try {
         $conn = new PDO("mysql:host={$CFG->db};dbname={$CFG->schema}", $CFG->dbuser, $CFG->dbuserpass);
     } catch (PDOException $e) {
         die('<data><error>failed connecting to database</error><detail>' . $e->getMessage() . '</detail></data>');
     }
     $query = "SELECT a.ID,  a.student_id, (SELECT email from students WHERE ID = a.student_id) as email, (SELECT CONCAT(fname, ' ', lname) as studentname from students WHERE ID = a.student_id) as studentname  FROM student_exam_sessions a WHERE a.form_ID = :sessionID LIMIT 0,1";
     $stmt = $conn->prepare($query);
     $stmt->bindValue(':sessionID', $sessionID, PDO::PARAM_INT);
     //$result = mysqli_query($conn, $query) or die('<data><error>select query failed</error><detail>' . mysqli_error($conn) . $query . '</detail></data>');
     $stmt->execute() or die('<data><error>sendMail query failed</error><detail>' . $stmt->errorCode() . '</detail></data>');
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         //$stemXML = simplexml_load_string($enumlib->getExamEmailStemByID($sessionID));
         $mail = new PHPMailer();
         $mail->SetFrom("*****@*****.**", "eOSCE System");
         $mail->Body = "Dear {$row['studentname']}<br/>" . $emailtext;
         $mail->IsHTML(true);
         $mail->Subject = 'OSCE Feedback';
         $to = $emailaddress;
         ////$row['email'];
         $mail->AddAddress($to);
         ob_start();
         $reportsLib->getReportForStudentSessionAsPDF($row['ID'], $showOverallResult);
         $body = ob_get_contents();
         // the raw jpeg image data.
         ob_end_clean();
         $mail->AddStringAttachment($body, "report.pdf");
         if (!$mail->Send()) {
             //    $this->doLog($sessionID, $row['student_id'], $mail->ErrorInfo);
             $failcount++;
             $errordetail = $mail->ErrorInfo;
         } else {
             //  $this->doLog($sessionID, $row['student_id'], 'true');
             $successcount++;
         }
     }
     // $enumlib = new EnumLib();
     //$logresults = $enumlib->getFeedbackSummary($sessionID);
     return "<data><status>{$failcount}</status>" . ($failcount > 0 ? "<error><detail>{$errordetail}</detail></error>" : "") . "</data>";
 }