<commit_before><?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Utils.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Users.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Courses.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Completion.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/certificates/classes/Certificate.php';

/**
 * Description of Reports
 *
 * @author moyo
 */
class Reports extends Utils {

    function __construct() {
        parent::__construct();
    }

    function get_reports_page($userid) {
        $list = "";
        $data = $this->get_report_initial_data($userid);
        $list.=$this->get_report_dashboard($data);
        return $list;
    }

    function get_report_initial_data($userid) {

        $users = array();
        $courses = array();
        $scourses = array();
        //echo "User id: " . $userid . "<br>";

        if ($userid == 2) {
            $courses = $this->get_all_courses();
            $scourses = $this->get_scorm_courses($courses);
            $users = $this->get_all_users();
            $stat = $this->get_courses_stat($users);
            $left = $stat->progress;
            $complete = $stat->compelete;
            $overdue = $stat->overdue;
            $left_pers = round($left / count($scourses));
            $complete_pers = round($complete / count($scourses));
            $overdue_pers = round($overdue / count($scourses));
        } // end if
        else {
            $groups = $this->get_practice_groups($userid);

            /*
              echo "Groups: <pre>";
              print_r($groups);
              echo "</pre><br>------------------------<br>";
             */

            $courses = $this->get_practice_courses_by_groups($groups);
            /*
              echo "Courses: <pre>";
              print_r($courses);
              echo "</pre><br>------------------------<br>";
             */

            $scourses = $this->get_scorm_courses($courses);
            $users = $this->get_practice_users($userid);
            /*
              echo "Users: <pre>";
              print_r($users);
              echo "</pre><br>------------------------<br>";
            */ 

            $stat = $this->get_courses_stat($users);
            $left = $stat->progress;
            $complete = $stat->compelete;
            $overdue = $stat->overdue;
            $left_pers = round($left / count($scourses));
            $complete_pers = round($complete / count($scourses));
            $overdue_pers = round($overdue / count($scourses));
        } // end else

        $data = new stdClass();
        $data->userid = $userid;
        $data->courses = $courses;
        $data->scourses = $scourses;
        $data->users = $users;
        $data->left = $left;
        $data->complete = $complete;
        $data->overdue = $overdue;
        $data->left_pers = $left_pers;
        $data->complete_pers = $complete_pers;
        $data->overdue_pers = $overdue_pers;

        return $data;
    }

    function get_category_name($categoryid) {
        $query = "select * from uk_course_categories where id=$categoryid";
        $result = $this->db->query($query);
        while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
            $name = $row['name'];
        }
        return $name;
    }

    function get_gp_courses_box($courses) {
        $list = "";
        $list.="<select id='r_courses_g' style='width:width:125px'>";
        $list.="<option value='All Courses' selected>All Courses</option>";
        foreach ($courses as $courseid) {
            $categoryid = $this->get_course_categoryid($courseid);
            $categoryname = $this->get_category_name($categoryid);
            $coursename = $this->get_course_name($courseid);
            $name = $categoryname . "-" . $coursename;
            $list.="<option value='$name'>$name</option>";
        } // end foreach
        $list.="</select>";
        return $list;
    }

    function get_gp_users_box($users) {
        $list = "";
        $list.="<select id='r_users_g' style='width:width:125px'>";
        $list.="<option value='All Users' selected>All Users</option>";
        foreach ($users as $userid) {
            $userdata = $this->get_user_data_by_id($userid);
            $name = $userdata->firstname . " " . $userdata->lastname;
            $list.="<option value='$name'>$name</option>";
        }
        $list.="</select>";
        return $list;
    }

    function get_report_dashboard($data, $toolbar = true) {
        $list = "";

        $left = $data->left;
        $complete = $data->complete;
        $overdue = $data->overdue;

        $left_side = $this->get_left_summary_block($data);

        if ($toolbar) {
            if ($data->userid == 2) {
                $list.="<br/><div class='row-fluid'>";
                $list.="<span class='span2'><input type='text' id='r_cohort' style='width:125px' placeholder='All Cohorts'></span>";
                $list.="<span class='span2'><input type='text' id='r_practice' style='width:125px' placeholder='All Practices'></span>";
                $list.="<span class='span2'><input type='text' id='r_courses' style='width:125px' placeholder='All Courses'></span>";
                $list.="<span class='span2'><input type='text' id='r_users' style='width:125px;padding-right:5px;' placeholder='All Users'></span>";
                $list.="<span class='span1'><input type='text' id='date1' style='width:75px;' placeholder='From'></span>";
                $list.="<span class='span1'><input type='text' id='date2' style='width:75px;' placeholder='To'></span>";
                $list.="<span class='span1' style='padding-left:15px;'><button id='report_search_ad'>Search</button></span>";
                $list.="</div>";
            } // end if $data->userid==2
            else {
                $coursesbox = $this->get_gp_courses_box($data->scourses);
                $usersbox = $this->get_gp_users_box($data->users);
                $list.="<br/><div class='row-fluid' style='text-align:center;'>";
                $list.="<span class='span4'>$coursesbox</span>";
                $list.="<span class='span2'>$usersbox</span>";
                $list.="<span class='span1'><input type='text' id='date1' style='width:75px;' placeholder='From'></span>";
                $list.="<span class='span1'><input type='text' id='date2' style='width:75px;' placeholder='To'></span>";
                $list.="<span class='span1' style='padding-left:15px;'><button id='report_search_gp'>Search</button></span>";
                $list.="</div>";
            } // end else 
<commit_msg>Report fix placeholder name<commit_after><?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Utils.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Users.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Courses.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/classes/Completion.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lms/custom/common/certificates/classes/Certificate.php';

/**
 * Description of Reports
 *
 * @author moyo
 */
class Reports extends Utils {

    function __construct() {
        parent::__construct();
    }

    function get_reports_page($userid) {
        $list = "";
        $data = $this->get_report_initial_data($userid);
        $list.=$this->get_report_dashboard($data);
        return $list;
    }

    function get_report_initial_data($userid) {

        $users = array();
        $courses = array();
        $scourses = array();
        //echo "User id: " . $userid . "<br>";

        if ($userid == 2) {
            $courses = $this->get_all_courses();
            $scourses = $this->get_scorm_courses($courses);
            $users = $this->get_all_users();
            $stat = $this->get_courses_stat($users);
            $left = $stat->progress;
            $complete = $stat->compelete;
            $overdue = $stat->overdue;
            $left_pers = round($left / count($scourses));
            $complete_pers = round($complete / count($scourses));
            $overdue_pers = round($overdue / count($scourses));
        } // end if
        else {
            $groups = $this->get_practice_groups($userid);

            /*
              echo "Groups: <pre>";
              print_r($groups);
              echo "</pre><br>------------------------<br>";
             */

            $courses = $this->get_practice_courses_by_groups($groups);
            /*
              echo "Courses: <pre>";
              print_r($courses);
              echo "</pre><br>------------------------<br>";
             */

            $scourses = $this->get_scorm_courses($courses);
            $users = $this->get_practice_users($userid);
            /*
              echo "Users: <pre>";
              print_r($users);
              echo "</pre><br>------------------------<br>";
            */ 

            $stat = $this->get_courses_stat($users);
            $left = $stat->progress;
            $complete = $stat->compelete;
            $overdue = $stat->overdue;
            $left_pers = round($left / count($scourses));
            $complete_pers = round($complete / count($scourses));
            $overdue_pers = round($overdue / count($scourses));
        } // end else

        $data = new stdClass();
        $data->userid = $userid;
        $data->courses = $courses;
        $data->scourses = $scourses;
        $data->users = $users;
        $data->left = $left;
        $data->complete = $complete;
        $data->overdue = $overdue;
        $data->left_pers = $left_pers;
        $data->complete_pers = $complete_pers;
        $data->overdue_pers = $overdue_pers;

        return $data;
    }

    function get_category_name($categoryid) {
        $query = "select * from uk_course_categories where id=$categoryid";
        $result = $this->db->query($query);
        while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
            $name = $row['name'];
        }
        return $name;
    }

    function get_gp_courses_box($courses) {
        $list = "";
        $list.="<select id='r_courses_g' style='width:width:125px'>";
        $list.="<option value='All Courses' selected>All Courses</option>";
        foreach ($courses as $courseid) {
            $categoryid = $this->get_course_categoryid($courseid);
            $categoryname = $this->get_category_name($categoryid);
            $coursename = $this->get_course_name($courseid);
            $name = $categoryname . "-" . $coursename;
            $list.="<option value='$name'>$name</option>";
        } // end foreach
        $list.="</select>";
        return $list;
    }

    function get_gp_users_box($users) {
        $list = "";
        $list.="<select id='r_users_g' style='width:width:125px'>";
        $list.="<option value='All Users' selected>All Users</option>";
        foreach ($users as $userid) {
            $userdata = $this->get_user_data_by_id($userid);
            $name = $userdata->firstname . " " . $userdata->lastname;
            $list.="<option value='$name'>$name</option>";
        }
        $list.="</select>";
        return $list;
    }

    function get_report_dashboard($data, $toolbar = true) {
        $list = "";

        $left = $data->left;
        $complete = $data->complete;
        $overdue = $data->overdue;

        $left_side = $this->get_left_summary_block($data);

        if ($toolbar) {
            if ($data->userid == 2) {
                $list.="<br/><div class='row-fluid'>";
                $list.="<span class='span2'><input type='text' id='r_cohort' style='width:125px' placeholder='All Clinical Groups'></span>";
                $list.="<span class='span2'><input type='text' id='r_practice' style='width:125px' placeholder='All Practices'></span>";
                $list.="<span class='span2'><input type='text' id='r_courses' style='width:125px' placeholder='All Courses'></span>";
                $list.="<span class='span2'><input type='text' id='r_users' style='width:125px;padding-right:5px;' placeholder='All Users'></span>";
                $list.="<span class='span1'><input type='text' id='date1' style='width:75px;' placeholder='From'></span>";
                $list.="<span class='span1'><input type='text' id='date2' style='width:75px;' placeholder='To'></span>";
                $list.="<span class='span1' style='padding-left:15px;'><button id='report_search_ad'>Search</button></span>";
                $list.="</div>";
            } // end if $data->userid==2
            else {
                $coursesbox = $this->get_gp_courses_box($data->scourses);
                $usersbox = $this->get_gp_users_box($data->users);
                $list.="<br/><div class='row-fluid' style='text-align:center;'>";
                $list.="<span class='span4'>$coursesbox</span>";
                $list.="<span class='span2'>$usersbox</span>";
                $list.="<span class='span1'><input type='text' id='date1' style='width:75px;' placeholder='From'></span>";
                $list.="<span class='span1'><input type='text' id='date2' style='width:75px;' placeholder='To'></span>";
                $list.="<span class='span1' style='padding-left:15px;'><button id='report_search_gp'>Search</button></span>";
                $list.="</div>";
            } // end else 

{'fraction_non_alphanumeric': 0.19085901444097067, 'fraction_numerical': 0.007443799315170463, 'mean_word_length': 2.2428192131305815, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 229, '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': '1542921', 'n_tokens_mistral': 4223, 'n_tokens_neox': 4064, 'n_words': 644}