/** * Checks to see if a student is already being assessed by this user * @param type $studentID * @param type $examID * @param type $userID */ public function checkAssessment($examID, $userID) { // print("$examID, $userID"); global $CFG; 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>'); } //$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>'); // is this examiner already marking someone? $query = "SELECT * FROM {$CFG->schema}.student_exam_sessions WHERE form_ID = :examID AND created_by_ID = :userID AND status <> 'complete'"; $stmt = $conn->prepare($query); // print($query); $stmt->bindValue(':examID', $examID, PDO::PARAM_INT); $stmt->bindValue(':userID', $userID, PDO::PARAM_INT); // $result = mysqli_query($conn, $query) or die('<data><error>checkAssessment query failed</error><detail>' . mysqli_error($conn) . $query . '</detail></data>'); $stmt->execute() or die('<data><error>checkAssessment query failed</error><detail>' . $stmt->errorInfo() . $query . '</detail></data>'); if ($stmt->rowCount() > 0) { // print('Got a result'); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $reportslib = new ReportsLib(); return $reportslib->getReportForStudentSession($row['ID']); } } else { return "<data></data>"; } }
// print('yo'); $enumlib = new EnumLib(); $overview = simplexml_load_string($enumlib->getExamInstanceOverviewByID($_REQUEST['exam_ID'])); $phpexcelObj = $reportslib->getFullReportAsExcel($_REQUEST['exam_ID']); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="OSCE Analysis report for ' . $overview->instance->name . '.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = new PHPExcel_Writer_Excel2007($phpexcelObj); $objWriter->save('php://output'); break; case 'getallreportsforsessionaspdf': include 'lib/EnumLib.php'; include 'lib/mpdf60/mpdf.php'; include 'lib/ReportsLib.php'; include 'lib/StringLib.php'; $reportslib = new ReportsLib(); $reportslib->getAllReportsForStudentsAsPDF($_REQUEST['exam_ID']); break; case "sendtestemail": include 'lib/EnumLib.php'; include 'lib/ReportsLib.php'; include 'lib/FeedbackLib.php'; include 'lib/StringLib.php'; include 'lib/mpdf60/mpdf.php'; require_once './lib/class.phpmailer.php'; $feedbacklib = new FeedbackLib(); // this often times out. We'll give it a large value set_time_limit(300); $returnStr = $feedbacklib->sendTestMail($_REQUEST['id'], $_REQUEST['address'], $_REQUEST['emailtext'], true, true); break; case 'mailfeedbacktoall':
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php include '../../backend/lib/authlib.php'; include '../../backend/lib/StringLib.php'; include '../../backend/lib/EnumLib.php'; include '../../backend/lib/ReportsLib.php'; require_once '../../backend/config.inc.php'; $enumlib = new EnumLib(); $authlib = new authlib(); $stringlib = new StringLib(); $reportlib = new ReportsLib(); if (isset($_REQUEST['logout'])) { setcookie('uneeoscetoken', "", -3600); //do redirect in Java? print "<script>window.location.assign('{$CFG->wwwroot}{$CFG->basedir}login.php');</script>"; exit; } if (isset($_COOKIE['uneeoscetoken'])) { $token = $_COOKIE['uneeoscetoken']; $authresult = ''; $stringlib = new StringLib(); $loggedinuserdata = new SimpleXMLElement($authlib->getDetailsByToken($token)); if (strlen($loggedinuserdata->error) > 1) { setcookie('uneeoscetoken', "", -3600); header("Location: {$CFG->wwwroot}{$CFG->basedir}login.php"); exit;
/** * 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>"; }