GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 3.139.239.157
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/models/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

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

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

class OBESManagement extends CI_Model {

    function createNewCriteria($newCriteriaInfo) {
        $this->db->insert("obes_criteria_mst", $newCriteriaInfo);
        return $this->db->insert_id();
    }

    function getAllCriteria() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_criteria_mst TCM");
        $this->db->join('tbl_staff_members TSMA', 'TCM.cr_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'TCM.cr_update_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("cr_order", "ASC");
        return $this->db->get();
    }

    function getCriteriaById($cr_id) {
        $this->db->select("*");
        $this->db->from("obes_criteria_mst");
        $this->db->where("cr_id", $cr_id);
        return $this->db->get();
    }

    function getCriteriaByName($cr_name) {
        $this->db->select("*");
        $this->db->from("obes_criteria_mst");
        $this->db->where("cr_name", $cr_name);
        return $this->db->get();
    }

    function getCriteriaByOrder($cr_order) {
        $this->db->select("*");
        $this->db->from("obes_criteria_mst");
        $this->db->where("cr_order", $cr_order);
        return $this->db->get();
    }

    function getAllNonDeletedCriteria() {
        $this->db->select("*");
        $this->db->from("obes_criteria_mst TCM");
        $this->db->where("TCM.cr_delete_status", "F");
        $this->db->order_by("TCM.cr_order", "ASC");
        return $this->db->get();
    }

    function isCriteriaNameSafeUpdate($cr_id, $cr_name) {
        $this->db->select("*");
        $this->db->from('obes_criteria_mst');
        $this->db->where('cr_name', $cr_name);
        $this->db->where('cr_id != ' . $cr_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function isCriteriaOrderSafeUpdate($cr_id, $cr_order) {
        $this->db->select("*");
        $this->db->from('obes_criteria_mst');
        $this->db->where('cr_order', $cr_order);
        $this->db->where('cr_id != ' . $cr_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateCriteriaInfo($criteriaData, $cr_id) {
        $this->db->where("cr_id", $cr_id);
        return $this->db->update("obes_criteria_mst", $criteriaData);
    }

    /* Function For Sub-Criteria And Related Stuff */

    function createNewSubCriteria($newSubCriteriaInfo) {
        $this->db->insert("obes_subcriteria_mst", $newSubCriteriaInfo);
        return $this->db->insert_id();
    }

    function getAllSubCriteria() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_subcriteria_mst TCSM");
        $this->db->join("obes_criteria_mst TCM", "TCSM.cr_id=TCM.cr_id");
        $this->db->join('tbl_staff_members TSMA', 'TCSM.csm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'TCSM.csm_update_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("TCSM.csm_name", "ASC");
        return $this->db->get();
    }

    function getAllSubCriteriaByOrder($order) {
        $this->db->select("*");
        $this->db->from("obes_subcriteria_mst csm");
        $this->db->join("obes_criteria_mst cr", "csm.cr_id=cr.cr_id");
        $this->db->where("cr_order", $order);
        $this->db->order_by("csm_name", "ASC");
        return $this->db->get();
    }

    function getAllSubCriteriaUnderGivenCriteria($cr_id) {
        $this->db->select("*");
        $this->db->from("obes_subcriteria_mst");
        $this->db->where("cr_id", $cr_id);
        $this->db->where("csm_delete_status", 'F');
        $this->db->order_by("csm_name", "ASC");
        return $this->db->get();
    }

    function getSubCriteriaInfoByName($csm_name) {
        $this->db->select("*");
        $this->db->from("obes_subcriteria_mst");
        $this->db->where("csm_name", $csm_name);
        return $this->db->get();
    }

    function isSubCriteriaNameSafeUpdate($csm_id, $csm_name) {
        $this->db->select("*");
        $this->db->from('obes_subcriteria_mst');
        $this->db->where('csm_name', $csm_name);
        $this->db->where('csm_id != ' . $csm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateSubCriteriaInfo($criteriaData, $csm_id) {
        $this->db->where("csm_id", $csm_id);
        return $this->db->update("obes_subcriteria_mst", $criteriaData);
    }

    /* Functions For Guidelines And Related Stuffs */

    function createNewGuideline($newGuidelineInfo) {
        $this->db->insert("obes_guidelines_mst", $newGuidelineInfo);
        return $this->db->insert_id();
    }

    function getAllSubCriteriaGuidelines() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_guidelines_mst CSGM");
        $this->db->join("obes_subcriteria_mst CSM", "CSM.csm_id=CSGM.csm_id");
        $this->db->join("obes_criteria_mst CR", "CR.cr_id=CSM.cr_id");
        $this->db->join('tbl_staff_members TSMA', 'CSGM.csgm_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'CSGM.csgm_update_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("csgm_name", "ASC");
        return $this->db->get();
    }

    function getGuidelineByInfoBy($csgm_id) {
        $this->db->select("*");
        $this->db->from("obes_guidelines_mst CSGM");
        $this->db->join("obes_subcriteria_mst CSM", "CSM.csm_id = CSGM.csm_id");
        $this->db->join("obes_criteria_mst CR", "CR.cr_id=CSM.cr_id");
        $this->db->where("csgm_id", $csgm_id);
        return $this->db->get();
    }

    function getGuidelineByInfoByName($csgm_name) {
        $this->db->select("*");
        $this->db->from("obes_guidelines_mst");
        $this->db->where("csgm_name", $csgm_name);
        return $this->db->get();
    }

    function isGuidelineNameSafeUpdate($csgm_id, $csgm_name) {
        $this->db->select("*");
        $this->db->from('obes_guidelines_mst');
        $this->db->where('csgm_name', $csgm_name);
        $this->db->where('csgm_id != ' . $csgm_id);
        $result = $this->db->get()->result();
        if (sizeof($result)) {
            return FALSE;
        } else {
            return TRUE;
        }
    }

    function updateGuidelineInfo($guidelineUpdateData, $csgm_id) {
        $this->db->where("csgm_id", $csgm_id);
        return $this->db->update("obes_guidelines_mst", $guidelineUpdateData);
    }

    function getSubGuideByCriteriaID($csgm_name, $csgm_id) {
        $this->db->select("*");
        $this->db->from("obes_guidelines_mst");
        $this->db->where("csgm_name", $csgm_name);
        $this->db->where("csgm_id NOT IN ('$csgm_id')");
        return $this->db->get();
    }

    function getSubCriteriaById($csm_id) {
        $this->db->select("*");
        $this->db->from("obes_subcriteria_mst");
        $this->db->where("csm_id", $csm_id);
        return $this->db->get();
    }

    /* Functions For Guideline Files And Related Stuffs */

    function createNewGuidelineFile($newGuidelineFileInfo) {
        $this->db->insert("obes_criteriaguide_file_mst", $newGuidelineFileInfo);
        return $this->db->insert_id();
    }

    function getGuidelineFileByCriteriaOrder($cr_order) {
        $this->db->select("*");
        $this->db->from("obes_criteriaguide_file_mst fm");
        $this->db->join("obes_guidelines_mst g", "fm.csgm_id=g.csgm_id");
        $this->db->join("obes_subcriteria_mst sc", "g.csm_id=sc.csm_id");
        $this->db->join("obes_criteria_mst c", "c.cr_id=sc.cr_id");
        $this->db->where("c.cr_order", $cr_order);
        return $this->db->get();
    }

    function updateGuidelineFile($guidelineFileUpdatedInfo, $cgfm_id) {
        $this->db->where("cgfm_id", $cgfm_id);
        return $this->db->update("obes_criteriaguide_file_mst", $guidelineFileUpdatedInfo);
    }

    /* Functions For Program Outcome And Related Stuffs */

    function createNewProgramOutcome($newPOInfo) {
        $this->db->insert("obes_program_outcome", $newPOInfo);
        return $this->db->insert_id();
    }

    function getAllProgramOutcomes() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_program_outcome PO");
        $this->db->join("tbl_course_master CM", "PO.course_id = CM.course_id");
        $this->db->join('tbl_staff_members TSMA', 'PO.po_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'PO.po_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("po.po_name", "ASC");
        return $this->db->get();
    }

    function getProgramOutcomeById($po_id) {
        $this->db->select("*");
        $this->db->from("obes_program_outcome");
        $this->db->where("po_id", $po_id);
        return $this->db->get();
    }

    function getProgramOutcomeByNameAndCourse($po_name, $course_id) {
        $this->db->select("*");
        $this->db->from("obes_program_outcome");
        $this->db->where("po_name", $po_name);
        $this->db->where("course_id", $course_id);
        return $this->db->get();
    }

    function getActiveNonDeletedProgramOutcomeByCourse($course_id) {
        $this->db->select("*");
        $this->db->from("obes_program_outcome");
        $this->db->where("course_id", $course_id);
        return $this->db->get();
    }

    function isProgramOutcomeSafeUpdate($po_name, $course_id, $po_id) {
        $this->db->select("*");
        $this->db->from("obes_program_outcome");
        $this->db->where("po_name", $po_name);
        $this->db->where("course_id", $course_id);
        $this->db->where("po_id NOT IN ('" . $po_id . "')");
        return $this->db->get();
    }

    function updateProgramOutcome($poUpdatedInfo, $po_id) {
        $this->db->where("po_id", $po_id);
        return $this->db->update("obes_program_outcome", $poUpdatedInfo);
    }

    /* Functions For Course Outcome Moudle & Related Stuffs */

    function createNewCourseOutcome($newCOInfo) {
        $this->db->insert("obes_course_outcome", $newCOInfo);
        return $this->db->insert_id();
    }

    function getAllCourseOutcomes() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome CO");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'CO.co_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'CO.co_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("co.co_name", "ASC");
        return $this->db->get();
    }

    function getCourseOutcomeById($co_id) {
        $this->db->select("*");
        $this->db->from("obes_course_outcome");
        $this->db->where("co_id", $co_id);
        return $this->db->get();
    }

    function getActiveNonDeletedCourseOutcomeBySubject($sm_id) {
        $this->db->select("*");
        $this->db->from("obes_course_outcome");
        $this->db->where("co_active_status", "T");
        $this->db->where("co_delete_status", "F");
        $this->db->where("sm_id", $sm_id);
        return $this->db->get();
    }

    function getCourseOutcomeByNameAndSubject($co_name = '', $sm_id = '') {
        $this->db->select("*");
        $this->db->from("obes_course_outcome");
        if ($co_name != '') {
            $this->db->where("co_name", $co_name);
        }
        if ($sm_id != '') {
            $this->db->where("sm_id", $sm_id);
        }
        return $this->db->get();
    }

    function isCouresOutcomeSafeUpdate($co_name, $sm_id, $co_id) {
        $this->db->select("*");
        $this->db->from("obes_course_outcome");
        $this->db->where("co_name", $co_name);
        $this->db->where("sm_id", $sm_id);
        $this->db->where("co_id NOT IN ('" . $co_id . "')");
        return $this->db->get();
    }

    function updateCourseOutcome($coUpdatedInfo, $co_id) {
        $this->db->where("co_id", $co_id);
        return $this->db->update("obes_course_outcome", $coUpdatedInfo);
    }

    /* Functions For CO-PO Mappings & Related Stuffs */

    function createNewCOPOMapping($newCOPOMappingInfo) {
        $this->db->insert("obes_co_po_mapping", $newCOPOMappingInfo);
        return $this->db->insert_id();
    }

    function getAllCOPOMappings() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_co_po_mapping COPO");
        $this->db->join("obes_program_outcome PO", "COPO.po_id = PO.po_id");
        $this->db->join("obes_course_outcome CO", "COPO.co_id = CO.co_id");
        $this->db->join("tbl_course_master TCM", "PO.course_id = TCM.course_id");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'COPO.co_po_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'COPO.co_po_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("PO.po_name", "ASC");
        return $this->db->get();
    }

    function getCOPOMappingById($co_po_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_co_po_mapping COPO");
        $this->db->join("obes_program_outcome PO", "COPO.po_id = PO.po_id");
        $this->db->join("obes_course_outcome CO", "COPO.co_id = CO.co_id");
        $this->db->join("tbl_course_master TCM", "PO.course_id = TCM.course_id");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'COPO.co_po_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'COPO.co_po_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("COPO.co_po_id", $co_po_id);
        return $this->db->get();
    }

    function getCOPOMappingBy($po_id, $co_id) {
        $this->db->select("*");
        $this->db->from("obes_co_po_mapping COPO");
        $this->db->where("COPO.po_id", $po_id);
        $this->db->where("COPO.co_id", $co_id);
        return $this->db->get();
    }

    function isCOPOMappingSafeUpdate($po_id, $co_id, $co_po_id) {
        $this->db->select("*");
        $this->db->from("obes_co_po_mapping COPO");
        $this->db->where("COPO.po_id", $po_id);
        $this->db->where("COPO.co_id", $co_id);
        $this->db->where("COPO.co_po_id NOT IN ('" . $co_po_id . "')");
        return $this->db->get();
    }

    function updateCOPOMapping($copoUpdatedInfo, $co_po_id) {
        $this->db->where("co_po_id", $co_po_id);
        return $this->db->update("obes_co_po_mapping", $copoUpdatedInfo);
    }

    /* Functions For Test Module & Related Stuffs */

    function createNewTest($newTestInfo) {
        $this->db->insert("obes_test", $newTestInfo);
        return $this->db->insert_id();
    }

    function getAllTests() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_test OT");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'OT.test_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'OT.test_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("OT.test_name", "ASC");
        return $this->db->get();
    }

    function getTestById($test_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_test OT");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'OT.test_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'OT.test_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("test_id", $test_id);
        $this->db->order_by("OT.test_name", "ASC");
        return $this->db->get();
    }

    function getNonDeletedActiveTestsBySubject($sm_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_test OT");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'OT.test_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'OT.test_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("OT.sm_id", $sm_id);
        $this->db->order_by("OT.test_name", "ASC");
        return $this->db->get();
    }

    function getTestByNameAndSubject($test_name, $sm_id) {
        $this->db->select("*");
        $this->db->from("obes_test");
        $this->db->where("sm_id", $sm_id);
        $this->db->where("test_name", $test_name);
        return $this->db->get();
    }

    function isTestNameSafeUpdate($test_name, $sm_id, $test_id) {
        $this->db->select("*");
        $this->db->from("obes_test");
        $this->db->where("test_name", $test_name);
        $this->db->where("sm_id", $sm_id);
        $this->db->where("test_id NOT IN ('" . $test_id . "')");
        return $this->db->get();
    }

    function updateTest($testUpdatedInfo, $test_id) {
        $this->db->where("test_id", $test_id);
        return $this->db->update("obes_test", $testUpdatedInfo);
    }

    /* Functions For Question-Marks Mapping & Related Stuffs */

    function createNewCOQuestionMap($COQuestionMap) {
        $this->db->insert_batch("obes_subject_course_outcome", $COQuestionMap);
        return $this->db->insert_id();
    }

    function getAllCOQuestionMappings() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->join("obes_course_outcome CO", "SCO.co_id = CO.co_id");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'SCO.sco_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'SCO.sco_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->join("obes_levels_keywords OLK", "Ques.qno_level = OLK.olk_id");
        $this->db->order_by("Ques.qno_name", "ASC");
        return $this->db->get();
    }

    function getAllCourseOutcomesInCoPoMapping() {
        $this->db->distinct();
        $this->db->select("CO.co_id,CO.co_name");
        $this->db->from("obes_course_outcome CO");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'CO.co_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'CO.co_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->join("obes_co_po_mapping COPO", "CO.co_id=COPO.co_id");
        $this->db->order_by("co.co_name", "ASC");
        return $this->db->get();
    }

    function getCOQuestionMapBy($sco_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->join("obes_course_outcome CO", "SCO.co_id = CO.co_id");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'SCO.sco_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'SCO.sco_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("SCO.sco_id", $sco_id);
        return $this->db->get();
    }

    function getTestQuestionBy($sm_id, $test_id, $qno_name) {
        $this->db->select("*");
        $this->db->from("obes_test_ques Ques");
        //$this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->where("Ques.test_id", $test_id);
        $this->db->where("Ques.qno_name", $qno_name);
        $this->db->where("OT.sm_id", $sm_id);
        //$this->db->where("SCO.co_id", $co_id);
        return $this->db->get();
    }

    function getCOQuestionMappingBy($co_id = '', $sm_id = '', $test_id = '', $qno_id = '') {
        $this->db->select("*");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        if ($co_id != '')
            $this->db->where("SCO.co_id", $co_id);
        if ($sm_id != '')
            $this->db->where("OT.sm_id", $sm_id);
        if ($test_id != '')
            $this->db->where("Ques.test_id", $test_id);
        if ($qno_id != '')
            $this->db->where("Ques.qno_id", $qno_id);
        return $this->db->get();
    }

    function checkCOQuestionMappingIsSafeToUpdate($co_id = '', $sm_id = '', $test_id = '', $qno_id = '', $qno_no = '') {
        $this->db->select("*");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        if ($co_id != '')
            $this->db->where("SCO.co_id", $co_id);
        if ($sm_id != '')
            $this->db->where("OT.sm_id", $sm_id);
        if ($test_id != '')
            $this->db->where("Ques.test_id", $test_id);
        if ($qno_no != '')
            $this->db->where("Ques.qno_name", $qno_no);
        if ($qno_id != '')
            $this->db->where("Ques.qno_id NOT IN ('$qno_id')");
        return $this->db->get();
    }

    function updateCOQuestionMap($scoUpdatedInfo, $sco_id) {
        $this->db->where("sco_id", $sco_id);
        return $this->db->update("obes_subject_course_outcome", $scoUpdatedInfo);
    }

    function updateQuestionMap($qnoUpdatedInfo, $qno_id) {
        $this->db->where("qno_id", $qno_id);
        return $this->db->update("obes_test_ques", $qnoUpdatedInfo);
    }

    function getNonDeletedActiveTestsBySTA($sta_id) {
        $this->db->select("*");
        $this->db->from("obes_test");
        $this->db->where("sm_id =(SELECT sm_id FROM subject_tech_allot WHERE sta_id= $sta_id)");
        $this->db->order_by("test_name", "ASC");
        return $this->db->get();
    }

    function getTestQuestionbySubject($sta_id, $test_name) {
        $this->db->distinct();
        $this->db->select("qno_name,qno_marks,Ques.qno_id");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "SCO.qno_id = Ques.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->where("OT.sm_id =(SELECT sm_id FROM subject_tech_allot WHERE sta_id= $sta_id)");
        $this->db->where("Ques.test_id", $test_name);
        return $this->db->get();
    }

    function createNewQuestion($newQuestionData) {
        $this->db->insert("obes_test_ques", $newQuestionData);
        return $this->db->insert_id();
    }

    function feedNewStudentObtainMarks($newStudentQuesMarkData) {
        $this->db->insert_batch("obes_student_test_marks", $newStudentQuesMarkData);
        return $this->db->insert_id();
    }

    function getStudentTestMarksBy($sta_id, $test_id) {
        $this->db->select("*");
        $this->db->from("obes_student_test_marks STM");
        $this->db->join("obes_test_ques Ques", "STM.qno_id = Ques.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        // $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->where("OT.sm_id =(SELECT sm_id FROM subject_tech_allot WHERE sta_id= $sta_id)");
        $this->db->where("STM.test_id", $test_id);
        $this->db->where("STM.sta_id", $sta_id);
        $this->db->order_by("STM.tspi_id", "ASC");
        return $this->db->get();
    }

    function updateFeedStudentObtainMarks($newStudentQuesMarkData) {
        return $this->db->update_batch("obes_student_test_marks", $newStudentQuesMarkData, "stm_id");
    }

    /* Functions For CO-Attainment Report */

    function getNonDeletedActiveTestsBy($sm_id) {
        $this->db->select("*");
        $this->db->from("obes_test");
        $this->db->where("sm_id", $sm_id);
        $this->db->order_by("test_name", "ASC");
        return $this->db->get();
    }

    function getAllActiveNonDeletedCourseOutcomesBy($sm_id = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome CO");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'CO.co_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'CO.co_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("CO.co_active_status", "T");
        $this->db->where("CO.co_delete_status", "F");
        if ($sm_id != '') {
            $this->db->where("CO.sm_id", $sm_id);
        }
        $this->db->order_by("co.co_name", "ASC");
        return $this->db->get();
    }

    function getCOQuestionsBy($co_id, $test_id = '') {
        $this->db->select("*");
        $this->db->from("obes_subject_course_outcome SCO");
        $this->db->join("obes_test_ques Ques", "Ques.qno_id = SCO.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->where("SCO.co_id", $co_id);
        if ($test_id != '') {
            $this->db->where("Ques.test_id", $test_id);
        }
        $this->db->order_by("Ques.qno_name", "ASC");
        return $this->db->get();
    }

    function getStudentTestMarksForCOAttainmentReport($tspi_id, $session_id, $test_id, $qno_id = '') {
        $this->db->select("*");
        $this->db->from("obes_student_test_marks STM");
        $this->db->join("obes_test_ques Ques", "STM.qno_id = Ques.qno_id");
        $this->db->where("STM.test_id", $test_id);
        $this->db->where("STM.tspi_id", $tspi_id);
        if ($qno_id != '') {
            $this->db->where("STM.qno_id", $qno_id);
        }
        $this->db->where("STM.session_id", $session_id);
        $this->db->order_by("STM.tspi_id", "ASC");
        return $this->db->get();
    }

    function getStudentAllTestMarksForCOAttainmentReport($tspi_id, $session_id, $co_id) {
        $this->db->select("*");
        $this->db->from("obes_student_test_marks STM");
        $this->db->join("obes_test_ques Ques", "STM.qno_id = Ques.qno_id");
        $this->db->join("obes_subject_course_outcome SCO", "SCO.qno_id=Ques.qno_id");
        $this->db->where("SCO.co_id", $co_id);
        $this->db->where("STM.tspi_id", $tspi_id);
        $this->db->where("STM.session_id", $session_id);
        $this->db->order_by("STM.tspi_id", "ASC");
        return $this->db->get();
    }

    function createCOAttainmentPercentage($data) {
        $this->db->insert("obes_course_outcome_overall_percentage_subjectwise", $data);
        return $this->db->insert_id();
    }

    function getCOAttainmentPercentageSubjectby($ocoops_id = '', $sm_id = '', $session = '', $flag = '') {
        $this->db->select("*");
        $this->db->from(" obes_course_outcome_overall_percentage_subjectwise");
        if ($sm_id != '') {
            $this->db->where("sm_id", $sm_id);
        }
        if ($session != '') {
            $this->db->where("session_id", $session);
        }
        if ($ocoops_id != '') {
            $this->db->where("ocoops_id NOT IN ('$ocoops_id')");
        }
        if ($flag != '') {
            $this->db->where("ocoops_percentage_flag", $flag);
        }
        return $this->db->get();
    }

    function getAllCOAttainmentPercentages() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_overall_percentage_subjectwise  ocoops");
        $this->db->join("subject_mst SM", "ocoops.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocoops.ocoops_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocoops.ocoops_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("SM.sm_name", "ASC");
        return $this->db->get();
    }

    function updateCOAttainmentPercentage($ocoops_id, $array) {
        $this->db->where("ocoops_id", $ocoops_id);
        return $this->db->update("obes_course_outcome_overall_percentage_subjectwise", $array);
    }

    function getCOOverAllAttainmentPercentagesBy($ocoops_id) {
        $this->db->select("*");
        $this->db->from("obes_course_outcome_overall_percentage_subjectwise  ");
        $this->db->where("ocoops_id", $ocoops_id);
        return $this->db->get();
    }

    function createCOTargetPercentage(array $array) {
        $this->db->insert_batch("obes_course_outcome_target_percentage", $array);
        return $this->db->insert_id();
    }

    function getCOTargetPercentageby($ocotp_id = '', $co_id = '', $session = '') {
        $this->db->select("*");
        $this->db->from("obes_course_outcome_target_percentage");
        if ($co_id != '') {
            $this->db->where("co_id", $co_id);
        }
        if ($session != '') {
            $this->db->where("session_id", $session);
        }
        if ($ocotp_id != '') {
            $this->db->where("ocotp_id NOT IN ('$ocotp_id')");
        }
        return $this->db->get();
    }

    function getAllCOTargetPercentages() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_target_percentage  ocotp");
        $this->db->join("obes_course_outcome CO", "ocotp.co_id = CO.co_id");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocotp.ocotp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocotp.ocotp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("SM.sm_name", "ASC");
        return $this->db->get();
    }

    function updateCOTargetPercentage($ocotp_id, $array) {
        $this->db->where("ocotp_id", $ocotp_id);
        return $this->db->update("obes_course_outcome_target_percentage", $array);
    }

    function getCOTargetPercentagesBy($ocotp_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_target_percentage  ocotp");
        $this->db->join("obes_course_outcome CO", "ocotp.co_id = CO.co_id");
        $this->db->join("subject_mst SM", "CO.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocotp.ocotp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocotp.ocotp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("ocotp.ocotp_id", $ocotp_id);
        return $this->db->get();
    }

    function getCOSemesterExamTargetPercentageBy($osetp_id = '', $sm_id = '', $session = '') {
        $this->db->select("*");
        $this->db->from("`obes_semester_exam_target_percentage`     ");
        if ($sm_id != '') {
            $this->db->where("sm_id", $sm_id);
        }
        if ($session != '') {
            $this->db->where("session_id", $session);
        }
        if ($osetp_id != '') {
            $this->db->where("osetp_id NOT IN ('$osetp_id')");
        }
        return $this->db->get();
    }

    function createCOSemesterExamTargetPercentage(array $array) {
        $this->db->insert("obes_semester_exam_target_percentage", $array);
        return $this->db->insert_id();
    }

    function getAllCOSemesterExamTargetPercentages() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_semester_exam_target_percentage  osetp");
        $this->db->join("subject_mst SM", "osetp.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'osetp.osetp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'osetp.osetp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("SM.sm_name", "ASC");
        return $this->db->get();
    }

    function updateCOSemesterExamTargetPercentage($osetp_id, $array) {
        $this->db->where("osetp_id", $osetp_id);
        return $this->db->update("obes_semester_exam_target_percentage", $array);
    }

    function getCOSemesterExamTargetPercentagesBy($osetp_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_semester_exam_target_percentage  osetp");
        $this->db->join("subject_mst SM", "osetp.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'osetp.osetp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'osetp.osetp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("osetp.osetp_id", $osetp_id);
        return $this->db->get();
    }

    function getCOAttainmentLevelPercentageBy($ocoalp_id = '', $sm_id = '', $session = '', $level_name = '', $level_value = '', $flag = '') {
        $this->db->select("*");
        $this->db->from("`obes_course_outcome_attainment_level_percentage`");
        if ($sm_id != '') {
            $this->db->where("sm_id", $sm_id);
        }
        if ($session != '') {
            $this->db->where("session_id", $session);
        }
        if ($level_name != '') {
            $this->db->where("ocoalp_level_name ", $level_name);
        }
        if ($level_value != '') {
            $this->db->where("ocoalp_level_value ", $level_value);
        }
        if ($flag != '') {
            $this->db->where("ocoalp_DI_flag", $flag);
        }
        if ($ocoalp_id != '') {
            $this->db->where("ocoalp_id NOT IN ('$ocoalp_id')");
        }
        return $this->db->get();
    }

    function createCOAttainmentLevelPercentage(array $array) {
        $this->db->insert("obes_course_outcome_attainment_level_percentage", $array);
        return $this->db->insert_id();
    }

    function getAllCOAttainmentLevelPercentages() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_attainment_level_percentage  ocoalp");
        $this->db->join("subject_mst SM", "ocoalp.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocoalp.ocoalp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocoalp.ocoalp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("SM.sm_name", "ASC");
        return $this->db->get();
    }

    function updateCOAttainmentLevelPercentage($ocoalp_id, $array) {
        $this->db->where("ocoalp_id", $ocoalp_id);
        return $this->db->update("obes_course_outcome_attainment_level_percentage", $array);
    }

    function getCOAttainmentLevelPercentagesBy($ocoalp_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_attainment_level_percentage  ocoalp");
        $this->db->join("subject_mst SM", "ocoalp.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocoalp.ocoalp_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocoalp.ocoalp_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("ocoalp.ocoalp_id", $ocoalp_id);
        return $this->db->get();
    }

    function getCOAttainmentLevelPercentageIntExtBy($ocoalpie_id = '', $sm_id = '', $session = '', $flag = '') {
        $this->db->select("*");
        $this->db->from("`obes_course_outcome_attainment_level_percentage_int_ext`");
        if ($sm_id != '') {
            $this->db->where("sm_id", $sm_id);
        }
        if ($session != '') {
            $this->db->where("session_id", $session);
        }
        if ($ocoalpie_id != '') {
            $this->db->where("ocoalpie_id NOT IN ('$ocoalpie_id')");
        }
        if ($flag != '') {
            $this->db->where("ocoalpie_IE_flag", $flag);
        }
        return $this->db->get();
    }

    function createCOAttainmentLevelPercentageIntExt(array $array) {
        $this->db->insert_batch("obes_course_outcome_attainment_level_percentage_int_ext", $array);
        return $this->db->insert_id();
    }

    function getAllCOAttainmentLevelPercentagesIntExt() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_attainment_level_percentage_int_ext  ocoalpie");
        $this->db->join("subject_mst SM", "ocoalpie.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocoalpie.ocoalpie_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocoalpie.ocoalpie_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->order_by("SM.sm_name", "ASC");
        return $this->db->get();
    }

    function updateCOAttainmentLevelPercentageIntExt($ocoalpie_id, $array) {
        $this->db->where("ocoalpie_id", $ocoalpie_id);
        return $this->db->update("obes_course_outcome_attainment_level_percentage_int_ext", $array);
    }

    function getCOAttainmentLevelPercentagesByIntExt($ocoalpie_id) {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_course_outcome_attainment_level_percentage_int_ext  ocoalpie");
        $this->db->join("subject_mst SM", "ocoalpie.sm_id = SM.sm_id");
        $this->db->join('tbl_staff_members TSMA', 'ocoalpie.ocoalpie_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'ocoalpie.ocoalpie_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        $this->db->where("ocoalpie.ocoalpie_id", $ocoalpie_id);
        return $this->db->get();
    }

    function getTestMarksDataBy($sm_id, $co_id, $assessment_id) {
        $this->db->select("*");
        $this->db->from("obes_student_test_marks OSTM");
        $this->db->join("obes_test_ques OTQ", "OTQ.qno_id=OSTM.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = OTQ.test_id");
        $this->db->where("OSTM.sta_id IN (SELECT STA.sta_id FROM subject_tech_allot STA WHERE STA.sm_id = '$sm_id')");
        $this->db->where("OSTM.qno_id IN ("
                . "SELECT q.qno_id "
                . "FROM obes_test_ques q, "
                . "obes_test t, "
                . "obes_subject_course_outcome sco "
                . "WHERE q.test_id = t.test_id "
                . "AND sco.qno_id = q.qno_id "
                . "AND sco.co_id = '$co_id' "
                . "AND t.test_id = '$assessment_id')");
        return $this->db->get();
    }

    function getSumOfTestMarksOfAllStudentInCOForSubject($sm_id, $co_id, $assessment_id, $session_id) {
        $this->db->select("SUM(OSTM.stm_obt_marks) as total_obtained_marks_for_co");
        $this->db->from("obes_student_test_marks OSTM");
        $this->db->join("obes_test_ques OTQ", "OTQ.qno_id=OSTM.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = OTQ.test_id");
        $this->db->where("OSTM.sta_id IN (SELECT STA.sta_id FROM subject_tech_allot STA WHERE STA.sm_id = '$sm_id' AND STA.session_id ='$session_id' )");
        $this->db->where("OSTM.qno_id IN ("
                . "SELECT q.qno_id "
                . "FROM obes_test_ques q, "
                . "obes_test t, "
                . "obes_subject_course_outcome sco "
                . "WHERE q.test_id = t.test_id "
                . "AND sco.qno_id = q.qno_id "
                . "AND sco.co_id = '$co_id' "
                . "AND t.test_id = '$assessment_id')");
        $this->db->where("OSTM.session_id", $session_id);
        return $this->db->get();
    }

    function getSumOfTestMaximumMarksOfAllStudentPresentInCOForSubject($sm_id, $co_id, $assessment_id, $session_id) {
        $this->db->select("SUM(OTQ.qno_marks) as total_maximum_marks_for_co");
        $this->db->from("obes_student_test_marks OSTM");
        $this->db->join("obes_test_ques OTQ", "OTQ.qno_id=OSTM.qno_id");
        $this->db->join("obes_test OT", "OT.test_id = OTQ.test_id");
        $this->db->where("OSTM.sta_id IN (SELECT STA.sta_id FROM subject_tech_allot STA WHERE STA.sm_id = '$sm_id' AND STA.session_id ='$session_id') ");
        $this->db->where("OSTM.qno_id IN ("
                . "SELECT q.qno_id "
                . "FROM obes_test_ques q, "
                . "obes_test t, "
                . "obes_subject_course_outcome sco "
                . "WHERE q.test_id = t.test_id "
                . "AND sco.qno_id = q.qno_id "
                . "AND sco.co_id = '$co_id' "
                . "AND t.test_id = '$assessment_id')");
        $this->db->where("OSTM.stm_flag", "P");
        $this->db->where("OSTM.session_id", $session_id);
        return $this->db->get();
    }

    function getTotalAveragePercentageOfStudentsInASubject($sm_id) {
        $this->db->select("SUM(SSSM.sssm_marks) as obtained_total, SUM(SSSM.sssm_max_marks) as total, (SUM(SSSM.sssm_marks) * 100 / SUM(SSSM.sssm_max_marks)) as percent");
        $this->db->from("student_subject_allot SSA");
        $this->db->join("student_subject_sem_marks SSSM", "SSA.tspi_id = SSSM.tspi_id");
        $this->db->where("SSA.sm_id=SSSM.sm_id");
        $this->db->where("SSA.sm_id", $sm_id);
        $this->db->group_by("SSA.sm_id");
        return $this->db->get();
    }

    function getExternalPercentageForCOAttainment($sm_id, $type) {
        $this->db->select("*");
        $this->db->from("obes_course_outcome_attainment_level_percentage_int_ext");
        $this->db->where("sm_id", $sm_id);
        $this->db->where("ocoalpie_IE_flag", $type);
        return $this->db->get();
    }

    /* 01/06/2021 Developer 1 code */

    function createLevelsAndKeywords(array $array) {
        $this->db->insert("obes_levels_keywords", $array);
        return $this->db->insert_id();
    }

    function getLevelsAndKeywordsBy($olk_id = '', $level_abbre = '', $level_name = '') {
        $this->db->select("*");
        $this->db->from("`obes_levels_keywords`");
        if ($level_abbre != '') {
            $this->db->where("olk_level_abbreviation", $level_abbre);
        }
        if ($olk_id != '') {
            $this->db->where("olk_id NOT IN ('$olk_id')");
        }
        if ($level_name != '') {
            $this->db->where("olk_level_name", $level_name);
        }
        return $this->db->get();
    }

    function getLevelsAndKeywordsByID($olk_id = '') {
        $this->db->select("*");
        $this->db->from("`obes_levels_keywords`");
        $this->db->where("olk_id", $olk_id);
        return $this->db->get();
    }

    function getLevelsAndKeywords() {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_levels_keywords olk");
        $this->db->join('tbl_staff_members TSMA', 'olk.olk_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'olk.olk_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        return $this->db->get();
    }

    function getActiveAndNonDeletedLevelsAndKeywords() {
        $this->db->select("*");
        $this->db->from("obes_levels_keywords olk");
        $this->db->where("olk.olk_active_status", "T");
        $this->db->where("olk.olk_delete_status", "F");
        return $this->db->get();
    }

    function updateLevelsAndKeywordst($olk_id, $array) {
        $this->db->where("olk_id", $olk_id);
        return $this->db->update("obes_levels_keywords", $array);
    }

    function getModelQuestionPaper($course = '', $subject = '', $test = '') {
        $this->db->select("*,"
                . "CONCAT(TPRFLA.tprfl_firstname,' ',TPRFLA.tprfl_lastname) addedByAdmin,"
                . "CONCAT(TPRFLU.tprfl_firstname,' ',TPRFLU.tprfl_lastname) updatedByAdmin");
        $this->db->from("obes_test_ques Ques");
        $this->db->join("obes_test OT", "OT.test_id = Ques.test_id");
        $this->db->join("subject_mst SM", "OT.sm_id = SM.sm_id");
        $this->db->join("obes_levels_keywords olk", "olk.olk_id = ques.qno_level");
        $this->db->join('tbl_staff_members TSMA', 'Ques.qno_added_by = TSMA.smember_id');
        $this->db->join('tbl_profile TPRFLA', 'TSMA.smember_id = TPRFLA.tprfl_id');
        $this->db->join('tbl_staff_members TSMU', 'Ques.qno_updated_by = TSMU.smember_id');
        $this->db->join('tbl_profile TPRFLU', 'TSMU.smember_id = TPRFLU.tprfl_id');
        if ($course != '') {
            $this->db->where('sm.course_id', $course);
        }
        if ($subject != '') {
            $this->db->where('sm.sm_id', $subject);
        }
        if ($test != '') {
            $this->db->where('OT.test_id', $test);
        }
        $this->db->order_by("Ques.qno_name", "ASC");
        return $this->db->get();
    }

    function getModelQuestionPaperAndCOSummaryInJSON($test_id = '') {
        $dataValues = [];
        $dataLabel = [];
        $this->db->select("SUM(Ques.qno_marks) as marks,OSCO.co_id,OCO.co_name as co_name");
        $this->db->from("obes_test_ques Ques");
        $this->db->join("obes_subject_course_outcome OSCO", "Ques.qno_id = OSCO.qno_id");
        $this->db->join("obes_course_outcome OCO", "OSCO.co_id = OCO.co_id");
        $this->db->where("Ques.test_id", $test_id);
        $this->db->group_by("OSCO.co_id,OCO.co_name");
        $coQuestionSummary = $this->db->get()->result();
        for ($i = 0; $i < (sizeof($coQuestionSummary)); $i++) {
            array_push($dataValues, $coQuestionSummary[$i]->marks);
            array_push($dataLabel, $coQuestionSummary[$i]->co_name);
        }
        return json_encode(array(
            'data' => $dataValues,
            'labels' => $dataLabel
        ));
    }

    function getLevelWiseMarksDistributionSummaryInJSON($test_id = '') {
        $dataValues = [];
        $dataLabel = [];
        $this->db->select("SUM(Ques.qno_marks) as marks,olk.olk_id,olk.olk_level_name");
        $this->db->from("obes_test_ques Ques");
        $this->db->join("obes_levels_keywords OLK", "OLK.olk_id = Ques.qno_level");
        $this->db->where("Ques.test_id", $test_id);
        $this->db->group_by("olk.olk_id,olk.olk_level_name");
        $coQuestionSummary = $this->db->get()->result();
        for ($i = 0; $i < (sizeof($coQuestionSummary)); $i++) {
            array_push($dataValues, $coQuestionSummary[$i]->marks);
            array_push($dataLabel, $coQuestionSummary[$i]->olk_level_name);
        }
        return json_encode(array(
            'data' => $dataValues,
            'labels' => $dataLabel
        ));
    }

    function getCOMappedToQuestion($qno_id) {
        $this->db->select("*");
        $this->db->from("obes_subject_course_outcome OSCO");
        $this->db->join("obes_course_outcome OCO", "OCO.co_id = OSCO.co_id");
        $this->db->where("OSCO.qno_id", $qno_id);
        return $this->db->get();
    }

    function getPOMappedToCO($co_id) {
        $this->db->select("*");
        $this->db->from("obes_co_po_mapping OCPM");
        $this->db->join("obes_program_outcome PO", "PO.po_id = OCPM.po_id");
        $this->db->where("OCPM.co_id", $co_id);
        return $this->db->get();
    }
}

KBHT - 2023