Example #1
0
     $returnStr = $enumLib->findStudentsForForm($_REQUEST['formid'], isset($_REQUEST['searchstr']) ? $_REQUEST['searchstr'] : '', isset($_REQUEST['site']) ? $_REQUEST['site'] : -1);
     break;
 case 'listunusedstudentsforformAsExcel':
     include 'lib/EnumLib.php';
     $reportsLib = new ReportsLib();
     $phpexcelObj = $reportsLib->findUnusedStudentsForFormAsExcel($_REQUEST['formid']);
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="OSCE_Missing_students_report.xlsx"');
     header('Cache-Control: max-age=0');
     $objWriter = new PHPExcel_Writer_Excel2007($phpexcelObj);
     $objWriter->save('php://output');
     break;
 case 'getstudentbyid':
     include 'lib/EnumLib.php';
     $enumLib = new EnumLib();
     $returnStr = $enumLib->getStudentByID($_REQUEST['id']);
     break;
 case 'lockstudent':
     $returnStr = $authlib->lock_student($_REQUEST['id']);
     break;
 case 'unlockstudent':
     $returnStr = $authlib->unlock_student($_REQUEST['id']);
     break;
 case 'checklockstudent':
     include 'lib/EnumLib.php';
     $enumLib = new EnumLib();
     $returnStr = $enumLib->check_lock_student($_REQUEST['id']);
     break;
     /////////////////////////////////////////////////////////////////////////////////////////
     //form management
     /////////////////////////////////////////////////////////////////////////////////////////
Example #2
0
 /**
  * Associates multiple students with an exam instance ID and a location
  * @global type $CFG
  * @param type $id
  * @param type $studentIDs The IDs of the student to associate, as a comma separated list
  * @return XML-formatted string containing details of the student, or an error if the insert query fails
  */
 public function associateStudentsWithInstance($id, $studentIDs, $siteID)
 {
     // a little cleanup
     $ids = explode(',', $studentIDs);
     $ids_sql = implode(",", array_map("intval", $ids));
     global $CFG;
     $success = true;
     $studentsStr = "";
     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>');
     }
     // check that this student isn't apready assigned:
     $query = "SELECT COUNT(*) FROM student_exam_instance_link WHERE exam_instances_ID = :id AND students_ID IN ({$ids_sql})";
     //$result = mysqli_query($conn, $query) or die('<data><error>associateStudentsWithInstance insert query failed</error><detail>' . $stmt->errorCode() . '</detail></data>');
     $stmt = $conn->prepare($query);
     $stmt->bindValue(':id', $id, PDO::PARAM_INT);
     $stmt->bindValue(':studentIDs', $studentIDs, PDO::PARAM_INT);
     //$result = mysqli_query($conn, $query) or die('<data><error>delete query failed</error><detail>' . mysqli_error($conn) . $query . '</detail></data>');
     //$result = $stmt->execute() or die('<data><error>check associateStudentsWithInstance query failed</error><detail>' . $stmt->errorCode() . '</detail></data>');
     $rows = $stmt->fetch(PDO::FETCH_NUM);
     // or die('<data><error>check associateStudentsWithInstance query failed</error><detail>' . var_dump($stmt->errorInfo()) . '</detail></data>');
     if ($rows[0] == 0) {
         for ($i = 0; $i < count($ids); $i++) {
             $stmt->closeCursor();
             $query = "INSERT INTO student_exam_instance_link (exam_instances_ID, students_ID, site_ID) VALUES(:id, :studentID, :site);";
             //$result = mysqli_query($conn, $query) or die('<data><error>associateStudentsWithInstance insert query failed</error><detail>' . $stmt->errorCode() . '</detail></data>');
             $stmt = $conn->prepare($query);
             $stmt->bindValue(':id', $id, PDO::PARAM_INT);
             $stmt->bindValue(':studentID', $ids[$i], PDO::PARAM_INT);
             $stmt->bindValue(':site', $siteID, PDO::PARAM_INT);
             //$result = mysqli_query($conn, $query) or die('<data><error>delete query failed</error><detail>' . mysqli_error($conn) . $query . '</detail></data>');
             $result = $stmt->execute() or die('<data><error>associateStudentsWithInstance query failed</error><detail>' . var_dump($stmt->errorInfo()) . '</detail></data>');
             if ($stmt->rowCount() < 1) {
                 $success = false;
             } else {
                 $enumlib = new EnumLib();
                 $info = simplexml_load_string($enumlib->getStudentByID($ids[$i]));
                 //$siteinfo = simplexml_load_string($enumlib->getSiteByID($id));
                 $studentsStr .= $info->student[0]->asXML();
             }
         }
     }
     if ($success) {
         return "<data>{$studentsStr}</data>";
     } else {
         return '<data><error>operation failed</error><detail></detail></data>';
     }
 }