/** * Singleton Pattern * * Auto Create Object Instance. * */ public static function getInstance() { if (null === self::$_objInstance) { self::$_objInstance = new ExamStore(); } return self::$_objInstance; }
<?php require_once 'Repository/ExamStore.php'; $exam = Exam::getInstance(); $examStore = ExamStore::getInstance(); $questions_for_save = unserialize(base64_decode($_POST['random_questions'])); $questions = $examStore->processExam($questions_for_save); //$data['random_questions'] = base64_decode($_POST['questions_id'] ); $data['user_id'] = $_POST['user_id']; $data['name'] = $_POST['name']; $data['exam_minute'] = $_POST['exam_minute']; $data['created_date'] = date('Y-m-d H:i:s'); $result = $exam->saveRandomHistory($data, unserialize($_POST['questions_id'])); $exam_code = ''; $index = 1; $html = ''; Membership::getInstance()->sms($text); Membership::getInstance()->redirect('list_of_exams.php'); exit; if (isset($result) && $result != null) { //validate null $exam_id = $result['exam_id']; if (isset($questions)) { $exam_code = str_pad($exam_id, 6, "0", STR_PAD_LEFT); } else { exit; } $header = "รหัสข้อสอบ {$exam_code} <br/> <b>ยศ ชื่อ - ชื่อสกุล (ตัวบรรจง)</b>....................................<b>ตำแหน่ง</b>....................................<br/>\r\n\t\t<b>หน่วยสอบ</b>....................................<b>ลายมือชื่อ</b>........................................."; $header .= " <div style=\"margin-left:50px\"><img src=\"http://edupol.org/edu_P/systemedu/examsystem/img/instruction.jpg\" width=\"354\" height=\"99\"/></div><br/>"; $header .= "<b>เลือกคำตอบที่ถูกต้องที่สุดเพียงข้อเดียว</b>"; $footer = "<br/><div style=\"margin-left:255px;\">--------------------------------------</div>";
<?php require_once 'Repository/Exam.php'; require_once 'libs/Membership.php'; require_once 'Repository/ExamStore.php'; $user_id = $_POST['user_id']; $exam_id = $_POST['exam_id']; $exam = Exam::getInstance(); $results = $exam->getExistingExam($exam_id); $index = 1; $html = ''; if (isset($results) && $results != null) { //validate null $all_questions = ExamStore::getInstance()->processExam($results); $exam_code = ''; if (isset($all_questions)) { $exam_code = str_pad($exam_id, 6, "0", STR_PAD_LEFT); } else { exit; } $header = "<div style=\"position:relative;right:0px;\">รหัสข้อสอบ {$exam_code} <br/> <b>ยศ ชื่อ - ชื่อสกุล (ตัวบรรจง)</b>....................................<b>ตำแหน่ง</b>........................................<br/>\r\n\t\t<b>หน่วยสอบ</b>......................................................<b>ลายมือชื่อ</b>......................................."; $header .= " <div style=\"margin-left:50px\"><img src=\"http://192.168.1.99/examsystem/img/instruction.jpg\" width=\"550\" height=\"138\"/></div><br/>"; $header .= "<b>เลือกคำตอบที่ถูกต้องที่สุดเพียงข้อเดียว</b>"; $footer = "<br/><div style=\"margin-left:255px;\">--------------------------------------</div>"; $footer .= "<b><div style=\"margin-left:270px;\">กองอำนวยการออกข้อสอบ</div>"; $footer .= "<div style=\"margin-left:230px;\">พล.ต.ต.</div>"; $footer .= "<div style=\"margin-left:270px;\">( จักรกฤษศณ์ สิงห์ศิลารักษ์ )</div>"; $footer .= "<div style=\"margin-left:220px;\">ประธานอนุกรรมการอำนวยการออกข้อสอบ</div></b>"; header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=ชุดปัญหาข้อสอบ.doc"); header("Pragma: no-cache");