<commit_before><?php

class Cce extends CI_Controller
{
    function show_instruc()
    {
        //common criteria

        $this->load->helper('form');
        $this->load->library('form_validation');

        $this->form_validation->set_rules('criteria', 'Criteria', 'required');

        $this->load->view('include/header');
        $this->load->view('include/nav');

        if($this->form_validation->run() === FALSE)
        {
            $d['error'] = '';
            $this->load->view('page/cce', $d);
        }
        else
        {
            $criteria = $this->input->post('criteria');
            $config['upload_path']          = './assets/uploads/';
            // check if the attachment belongs to image/document/spreadsheet
            $config['allowed_types']        = 'jpg|png|jpeg|doc|docx|pdf|xlsx';
            $config['max_size']             = 2048;
            $config['encrypt_name']         = TRUE;
            $this->load->library('upload', $config);

            if($this->upload->do_upload())
            {
                $data['file']       = $this->upload->data('file_name');
                $data['criteria']   = $criteria;
                $data['instructor'] = $this->session->userdata('id');
                $this->db->insert('attachment', $data);
                redirect('/cce');
            }
            else
            {
                $d['error'] = '<div class="alert alert-danger">'.$this->upload->display_errors().'</div>';
                $this->load->view('page/cce', $d);
            }
        }

        $this->load->view('include/footer');
    }

    // calculate total cce points of instructor
    function cce_instruc($id)
    {
        $r = $this->db->get_where('attachment', array('instructor' => $id))->result_array();
        $sum = 0;
        foreach($r as $cce)
        {
            $c = $this->db->get_where('tbl_cce', array('id' => $cce['criteria']))->row_array();
            $sum += $c['point'];
        }
        return $sum;
    }

    //calculate total evaluation of instructor for student
    function student_eval($id)
    {
        $e = $this->db->get_where('tbl_evaluation', array('to_evaluate' => $id))->result_array();
        $sum = 0;
        foreach ($e as $evaluate) {
            $this->db->where('id', $evaluate['evaluator'])->where('usertype', 2);
            $c = $this->db->count_all_results('tbl_userreg');
            if($c > 0)
                $sum = $sum + ($evaluate['group1'] + $evaluate['group2'] + $evaluate['group3'] + $evaluate['group4']);
        }
        return $sum * STUDENT_SUPERVISOR;
    }
}<commit_msg>function to calculate peer evaluation<commit_after><?php

class Cce extends CI_Controller
{
    function show_instruc()
    {
        //common criteria

        $this->load->helper('form');
        $this->load->library('form_validation');

        $this->form_validation->set_rules('criteria', 'Criteria', 'required');

        $this->load->view('include/header');
        $this->load->view('include/nav');

        if($this->form_validation->run() === FALSE)
        {
            $d['error'] = '';
            $this->load->view('page/cce', $d);
        }
        else
        {
            $criteria = $this->input->post('criteria');
            $config['upload_path']          = './assets/uploads/';
            // check if the attachment belongs to image/document/spreadsheet
            $config['allowed_types']        = 'jpg|png|jpeg|doc|docx|pdf|xlsx';
            $config['max_size']             = 2048;
            $config['encrypt_name']         = TRUE;
            $this->load->library('upload', $config);

            if($this->upload->do_upload())
            {
                $data['file']       = $this->upload->data('file_name');
                $data['criteria']   = $criteria;
                $data['instructor'] = $this->session->userdata('id');
                $this->db->insert('attachment', $data);
                redirect('/cce');
            }
            else
            {
                $d['error'] = '<div class="alert alert-danger">'.$this->upload->display_errors().'</div>';
                $this->load->view('page/cce', $d);
            }
        }

        $this->load->view('include/footer');
    }

    // calculate total cce points of instructor
    function cce_instruc($id)
    {
        $r = $this->db->get_where('attachment', array('instructor' => $id))->result_array();
        $sum = 0;
        foreach($r as $cce)
        {
            $c = $this->db->get_where('tbl_cce', array('id' => $cce['criteria']))->row_array();
            $sum += $c['point'];
        }
        return $sum;
    }

    //calculate total evaluation of instructor for student
    function student_eval($id)
    {
        $e = $this->db->get_where('tbl_evaluation', array('to_evaluate' => $id))->result_array();
        $sum = 0;
        foreach ($e as $evaluate) {
            $this->db->where('id', $evaluate['evaluator'])->where('usertype', 2);
            $c = $this->db->count_all_results('tbl_userreg');
            if($c > 0)
                $sum = $sum + ($evaluate['group1'] + $evaluate['group2'] + $evaluate['group3'] + $evaluate['group4']);
        }
        return $sum * STUDENT_SUPERVISOR;
    }

    function peer_eval($id)
    {
        $e = $this->db->get_where('tbl_evaluation', array('to_evaluate' => $id))->result_array();
        $sum = 0;
        foreach ($e as $evaluate) {
            $this->db->where('id', $evaluate['evaluator'])->where('usertype', 1);
            $c = $this->db->count_all_results('tbl_userreg');
            if($c > 0)
                $sum = $sum + ($evaluate['group1'] + $evaluate['group2'] + $evaluate['group3'] + $evaluate['group4']);
        }
        return $sum * PEER_SELF;
    }
}
{'fraction_non_alphanumeric': 0.19075747046560113, 'fraction_numerical': 0.005385684503127172, 'mean_word_length': 1.9477726574500769, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2990180', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1714, 'n_words': 270}