<commit_before><?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Capstone_Controller
{

        function __construct()
        {
                parent::__construct();
                $this->load->model(array('User_model', 'Course_model', 'Enrollment_model'));
        }

        /**
         * Function to show index page with count for dashboard
         * 
         * @author <NAME> <<EMAIL>>
         */
        public function index()
        {
                $data[''] = NULL; //just incase all not controllers not has permission in current user_group

                if (in_array('users', permission_controllers()))
                {
                        $data['active_users_count'] = $this->User_model->where(array(
                                    'active' => TRUE
                                ))->count_rows();
                }
                if (in_array('students', permission_controllers()))
                {
                        $data['student_enrolled_count'] = $this->Enrollment_model->where(array(
                                    'enrollment_status' => TRUE
                                ))->count_rows();

                        $courses_detale = array();
                        if ($this->session->userdata('user_is_dean'))
                        {
                                if ($id = $this->session->userdata('user_dean_course_id'))
                                {
                                        $course_row        = $this->Course_model->get($id);
                                        $ecount            = $enrollment_object = $this->Enrollment_model->where(array(
                                                    'course_id'         => $id,
                                                    'enrollment_status' => TRUE
                                                ))->count_rows();

                                        $courses_detale[] = array(
                                            'course_id' => $course_row->course_id,
                                            'counts'    => $ecount,
                                            'icon'      => $course_row->course_icon,
                                            'color'     => $course_row->course_color,
                                            'code'      => $course_row->course_code
                                        );
                                }
                        }
                        else
                        {
                                /*
                                 * get all course
                                 */

                                $course_obj = $this->Course_model->order_by('course_code')->set_cache('course_get_all')->get_all();<commit_msg>fix count enrooled when is dean<commit_after><?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Capstone_Controller
{

        function __construct()
        {
                parent::__construct();
                $this->load->model(array('User_model', 'Course_model', 'Enrollment_model'));
        }

        private function _count_enrolled()
        {
                $obj = $this->Enrollment_model->where(array(
                    'enrollment_status' => TRUE
                ));

                if ($this->session->userdata('user_is_dean'))
                {
                        if ($id = $this->session->userdata('user_dean_course_id'))
                        {
                                $obj->where(array(
                                    'course_id' => $id
                                ));
                        }
                }

                return $obj->count_rows();
        }

        /**
         * Function to show index page with count for dashboard
         * 
         * @author <NAME> <<EMAIL>>
         */
        public function index()
        {
                $data[''] = NULL; //just incase all not controllers not has permission in current user_group

                if (in_array('users', permission_controllers()))
                {
                        $data['active_users_count'] = $this->User_model->where(array(
                                    'active' => TRUE
                                ))->count_rows();
                }
                if (in_array('students', permission_controllers()))
                {
                        $data['student_enrolled_count'] = $this->_count_enrolled();

                        $courses_detale = array();
                        if ($this->session->userdata('user_is_dean'))
                        {
                                if ($id = $this->session->userdata('user_dean_course_id'))
                                {
                                        $course_row        = $this->Course_model->get($id);
                                        $ecount            = $enrollment_object = $this->Enrollment_model->where(array(
                                                    'course_id'         => $id,
                                                    'enrollment_status' => TRUE
                                                ))->count_rows();

                                        $courses_detale[] = array(
                                            'course_id' => $course_row->course_id,
                                            'counts'    => $ecount,
                                            'icon'      => $course_row->course_icon,
                                            'color'     => $course_row->course_color,
                                            'code'      => $course_row->course_code
                                        );
                                }
                        }
                        else
                        {
                                /*
                                 * get all course
                                 */

                                $course_obj = $this->Course_model->order_by('course_code')->set_cache('course_get_all')->get_all();
{'fraction_non_alphanumeric': 0.1014587772496312, 'fraction_numerical': 0.0, 'mean_word_length': 0.8390596745027125, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4646789', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1237, 'n_words': 212}