관리-도구
편집 파일: CFCourse_course_control.php
<?php //This controller will deal with the front end working of the client / or students if (!class_exists('CFCourse_course_control')) { class CFCourse_course_control { public $loader; function __construct($arr) { $this->loader = $arr['loader']; } public function getCourseSetting($theme) { global $mysqli; global $dbpref; $table = $dbpref . 'course_setting'; $run = $mysqli->query("SELECT * FROM `$table` WHERE `theme`='$theme'"); $r = false; if ($run->num_rows > 0 && $r = $run->fetch_object()) { return $r; } return $r; } public function getCourseCategory($c = "") { $ca = ""; if (empty($c)) { $c = "Not Selected"; } switch ($c) { case "bus": $ca = "Business"; break; case "des": $ca = "Design"; break; case "dev": $ca = "Development"; break; case "ent": $ca = "Entertainment and Music"; break; case "edu": $ca = "Education"; break; case "fin": $ca = "Finance and Accounting"; break; case "hea": $ca = "Health and Fitness"; break; case "its": $ca = "IT and Software"; break; case "lan": $ca = "Language Learning"; break; case "lif": $ca = "Lifestyle"; break; case "mar": $ca = "Marketing"; break; case "off": $ca = "Office Productivity"; break; case "per": $ca = "Personal Development"; break; case "pav": $ca = "Photography and Video"; break; case "sam": $ca = "Science and Mathematics"; break; default: $ca = $c; } return $ca; } //shortcode function to view single courses by id function get_course_by_id($course_id, $get_only = false) { global $mysqli; global $dbpref; $table = $dbpref . 'all_products'; $course_id = trim($mysqli->real_escape_string($course_id)); if ($get_only) { $r = $mysqli->query("SELECT `" . $get_only . "` FROM `" . $table . "` WHERE `id`=" . $course_id); } else { $r = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `id`=" . $course_id); } if ($r->num_rows > 0) { $data = $r->fetch_assoc(); return $data; } return false; } /** * This function will return individual field value * * @param * $table_name * $field_name1 * $field_name2 * $id */ function getFieldValue(String $table_name, String $field_name1, String $field_name2, Int $id) { global $mysqli; global $dbpref; $table = $dbpref . $table_name; //table Name $sql = "SELECT `$field_name1` FROM `$table` WHERE `$field_name2`=$id"; $run = $mysqli->query($sql); $field_value = ''; if ($run->num_rows > 0 && $r = $run->fetch_object()) { $field_value .= $r->$field_name1; } return $field_value; } /** * This function will return first course id * @param $course_id */ function getFirstLesson($course_id) { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; //table Name $sql = "SELECT `id` FROM `$table` WHERE `course_id`=$course_id AND `display_order`=1"; $run = $mysqli->query($sql); $field_value = ''; if ($run->num_rows > 0 && $r = $run->fetch_object()) { $field_value .= $r->id; } return $field_value; } //shortcode function to view all courses together. function get_all_courses($get = false, $course_id = false) { global $mysqli; global $dbpref; $table = $dbpref . 'all_products'; if ($get) { $qry = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `id`=" . $course_id); } else { $qry = $mysqli->query("SELECT * FROM `" . $table . "`"); } if (isset($qry->num_rows)) { if ($qry->num_rows) { return $qry; } return 0; } } //function to view single quiz by id function get_quiz_by_id($quiz_id) { global $mysqli; global $dbpref; $table = $dbpref . 'content_options'; $quiz_id = trim($mysqli->real_escape_string($quiz_id)); $r = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `id`=" . $quiz_id); if ($r->num_rows > 0) { $data = $r->fetch_assoc(); return $data; } } //function to view quiz questions.. function get_quiz_questions_by_id($quiz_id) { global $mysqli; global $dbpref; $table = $dbpref . 'quiz_questions'; $quiz_id = trim($mysqli->real_escape_string($quiz_id)); $qry = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `quiz_id`=" . $quiz_id); if (isset($qry->num_rows)) { return $qry; } } //function to view quiz questions.. function checkAlreadyplayedQuizAssign($qu_or_ass_id, $mem_id, $action = false) { global $mysqli; global $dbpref; $mem_id = trim($mysqli->real_escape_string($mem_id)); $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($mem_id); $mid = $mem_data['mid']; if ($action == "a") { $table = $dbpref . 'stud_assignment'; $qu_or_ass_id = trim($mysqli->real_escape_string($qu_or_ass_id)); $qry = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `assign_id`=$qu_or_ass_id AND `member_id`=$mid ORDER BY `submitted_on` DESC LIMIT 1"); } else if ($action == "q") { $table = $dbpref . 'stud_quiz'; $qu_or_ass_id = trim($mysqli->real_escape_string($qu_or_ass_id)); $qry = $mysqli->query("SELECT * FROM `" . $table . "` WHERE `quiz_id`=$qu_or_ass_id AND `member_id`=$mid ORDER BY `submitted_on` DESC LIMIT 1"); } if ($qry->num_rows > 0) { return $qry; } return 0; } function getquizUI($id = null) { $quiz_data = self::get_quiz_by_id($id); $quiz_questions = self::get_quiz_questions_by_id($id); require plugin_dir_path(dirname(__FILE__, 1)) . "/views/view_stud_quiz_shortcode.php"; } function getTime($duration = 60) { $hour = floor(($duration / 60) / 60); $minutes = floor(($duration / 60) % 60); $seconds = $duration % 60; if ($hour < 10) { $hour = "0" . $hour; } if ($minutes < 10) { $minutes = "0" . $minutes; } if ($seconds < 10) { $seconds = "0" . $seconds; } if ($hour > 0) { $times = $hour . ":" . $minutes . ":" . $seconds; } else if ($minutes > 0) { $times = "00:" . $minutes . ":" . $seconds; } else { $times = "00:00:" . $seconds; } return $times; } function getcourseUI($id = null) { $course_data = self::get_all_courses(true, $id); require plugin_dir_path(dirname(__FILE__, 1)) . "/views/view_course_shortcode.php"; } function getallcourseUI($id = null) { $allcourse_data = self::get_all_courses(false, false); require plugin_dir_path(dirname(__FILE__, 1)) . "/views/view_allcourse_shortcode.php"; } // this function show main screen and all course related content function getMainScreeUI($course_id, $mdata, $questions_ob, $quiz_stud_ob, $lecture_ob, $assign_stud_ob, $assignment_ob, $person) { global $mysqli; global $dbpref; if (!empty($course_id) && isset($course_id)) { $table = $dbpref . "all_products"; $table1 = $dbpref . "section"; $table2 = $dbpref . "content_options"; $course_id = $mysqli->real_escape_string($course_id); $qr1 = "SELECT * FROM `" . $table . "` WHERE `id`=" . $course_id; $cresult = $mysqli->query($qr1); if ($cresult->num_rows > 0) { $cr = $cresult->fetch_assoc(); if (isset($mdata['email'])) { $email = $mdata['email']; $name = $mdata['name']; } else { header("Location:" . $cr['membership_url'] . ""); } $c_id = $cr['id']; $qr5 = $mysqli->query("SELECT COUNT(*) as 't_l' FROM `" . $table2 . "` WHERE `option_type`='lecture' AND `course_id`=$c_id"); $t_l = $qr5->fetch_assoc(); $qr6 = $mysqli->query("SELECT COUNT(*) as 't_q' FROM `" . $table2 . "` WHERE `option_type`='quiz' AND `course_id`=$c_id"); $t_q = $qr6->fetch_assoc(); $qr7 = $mysqli->query("SELECT COUNT(*) as 't_a' FROM `" . $table2 . "` WHERE `option_type`='assign' AND `course_id`=$c_id"); $t_a = $qr7->fetch_assoc(); $qr8 = $mysqli->query("SELECT COUNT(*) as 't_t' FROM `" . $table2 . "` WHERE `option_type`='test' AND `course_id`=$c_id"); $t_t = $qr8->fetch_assoc(); if ($qr5->num_rows > 0) { $course_name = $cr['title']; $brand_image = $cr['brand_img_url']; $theme = $cr['theme']; $brand_image = $cr['brand_img_url']; if (!$brand_image && !empty($brand_image)) { list($bimg_width, $bimg_height, $type, $attr) = getimagesize($brand_image); } else { $bimg_height = 0; $bimg_width = 0; } $theme = (!empty($theme) && in_array($theme, array("a", "b", "c", "d"))) ? $theme : "a"; $p_dir_url = plugin_dir_url(dirname(__FILE__, 1)); $default_header = $cr['default_header']; $new_theme = $theme; if ($theme == 'd') $theme = 'c'; if (isset($_COOKIE['cfCourseUserChooseTheme'])) { $theme = $_COOKIE['cfCourseUserChooseTheme']; } else { setcookie("cfCourseTheme", $theme, (time() + (86400 * 365)), "/"); if (isset($_COOKIE['cfCourseTheme'])) { $theme = $_COOKIE['cfCourseTheme']; } } $drip_texts = !empty($cr['drip_text']) ? $cr['drip_text'] : "Sorry! The next section will be available after {days}"; $drip_texts = $mysqli->real_escape_string($drip_texts); $drip_texts = str_ireplace("{days}", ' <span id="cf-course--d-ys" class="font-weight-bold">2 days</span>', $drip_texts); $drip_texts = explode("\\r\\n", rtrim($drip_texts, "\\r\\n")); $drip_textss = '<p>'; foreach ($drip_texts as $drip_text) { $drip_textss .= $drip_text; } $drip_textss .= '</p>'; $membership_url = $cr['membership_url']; $course_show_url = $cr['show_url']; if (!empty($course_show_url) && $course_show_url != "") { $current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $current_url = parse_url($current_url); $course_show_url = $current_url['scheme'] . "://" . $current_url['host'] . "" . $current_url['path']; } $c_des = stripcslashes(trim(stripcslashes($cr['description']), "\r\n")); $course_video = $cr['demo_video']; $course_image = $cr['image']; $course_url = $cr['url']; $st_texts = self::getCourseThemeStyle($new_theme); if ($st_texts) { $cstyle = json_decode($st_texts->style); $ctext = json_decode($st_texts->text); } else { $st_texts = self::getDefaultText(); $cstyle = $st_texts['styles']; $ctext = $st_texts['texts']; } $show_end_cirtificate = $cr['end_cirtificate']; require plugin_dir_path(dirname(__FILE__, 1)) . "/views/course_screen_" . $theme . ".php"; } } else { echo "please add course in course page setting or go back in membership page"; } } } function getCourseThemeStyle($theme) { global $mysqli; global $dbpref; $table = $dbpref . "course_setting"; $sql = "SELECT * FROM `$table` WHERE `theme`='$theme'"; $run = $mysqli->query($sql); $r = false; if ($run->num_rows > 0 && $r = $run->fetch_object()) { return $r; } return $r; } function getallSectionDataMo($sresult, $c_id, $mem_id, $oo_id, $ss_id, $theme, $person, $drip_on_off, $courses) { $htmCon = ''; global $mysqli; global $dbpref; if ($person == "s") { self::addDripFeedData($mem_id, $c_id); } $drip_count = 0; $add_times_ser = date("Y-m-d", time()); //to pick date from Server.. $result_drip = self::showDripLocks($mem_id, $c_id); if ($result_drip->num_rows > 0) { if ($row = $result_drip->fetch_assoc()) { $drip_days = $row['drip_days']; $created_at = $row['created_at']; } } else { $drip_days = 0; $created_at = date("Y-m-d", time()); } $add_days = 0; while ($sr = $sresult->fetch_assoc()) { $drip_count++; $s_title = htmlspecialchars(stripslashes($sr['title'])); $s_id = $sr['id']; $table = $dbpref . "content_options"; $qr = "SELECT * FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$s_id ORDER BY `display_order` ASC "; $oresult = $mysqli->query($qr); $total_row = self::getTotalContent($c_id, $s_id); $counts = self::getWatched($mem_id, $c_id, $s_id); $style = ($ss_id == $s_id) ? 'style="background-color: #d9e5fa61 !important"' : ''; $fas_down = ($ss_id == $s_id) ? 'fa-angle-up' : 'fa-angle-down'; $showc = ($ss_id == $s_id) ? 'show' : ''; $drip_collapse = "collapse"; $open_modal = ""; $lcount = 0; if (isset($drip_on_off)) { if ($drip_on_off == 1 || $drip_on_off == "1") //showing locks system only if drip is on via admin. { if ($drip_count == 1) { $htmCon_lock = '<i class="fa fa-unlock d--cf--lock "></i>'; $drip_collapse = "collapse"; } else { $created_at = date('Y-m-d', strtotime($created_at . ' + ' . $drip_days . ' days')); if ($created_at <= $add_times_ser) { $htmCon_lock = '<i class="fa fa-unlock d--cf--lock"></i>'; $drip_collapse = "collapse"; } else { $htmCon_lock = '<i class="fa fa-lock d--cf--lock"></i>'; $drip_collapse = ""; $open_modal = "cf-course-open-model"; $add_days = $add_days + $drip_days; } } } //drip on off ends if condition } $htmCon .= '<div class="cf-course-msr-s"> <div class="cf-course-msr-sec custom-b-secbackgroundColor "> <div class="cf-course-sec-o b--cf--sec-o c--cf--sec-o d--cf--sec-o e--cf--sec-o cf-course-open-s ' . $open_modal . ' p-3" data-days="' . $add_days . '" ' . $style . ' data-bs-toggle="' . $drip_collapse . '" data-bs-target="#cf-course-sec-' . $s_id . '" >'; if (isset($htmCon_lock)) { $htmCon .= $htmCon_lock; } $htmCon .= '<div class="d-flex justify-content-between cf-course-sec-o-' . $s_id . '"> <div class="cf-course-sec-o-' . $s_id . '"> <span class="cf-course-sec-o-' . $s_id . '" >' . $courses->text25 . ' <span class="cf-course-main-scount" ></span>: </span> <span class="cfcourse-s-t-t cf-course-sec-o-' . $s_id . '" > ' . $s_title . ' <span> </div> <div class="ms-1 cf-course-sec-o-' . $s_id . '"><i class="cf-course-msr-s-arr fas ' . $fas_down . ' cf-course-sec-o-' . $s_id . '"></i></div> </div> <div class="cf-course-msrs-cl"> <div> <span class="cf-course-slec-count" id="cf-course-slec-count-' . $s_id . '" > ' . $counts . ' </span> | <span> ' . $total_row . ' </span></div> </div> </div> <div id="cf-course-sec-' . $s_id . '" class=" d--cf--crse-in collapse ' . $showc . '">'; if ($oresult->num_rows > 0) { while ($o_data = $oresult->fetch_assoc()) { $lcount++; $op_id = $o_data['id']; $s_id = $o_data['section_id']; $c_id = $o_data['course_id']; $o_title = htmlspecialchars(stripslashes($o_data['title'])); $o_type = $o_data['content_type']; if (!empty($o_data['content'])) { $o_cont = json_decode(base64_decode($o_data['content']), true); } else { $o_cont = ''; } $progress = self::getUserProgress($mem_id, $c_id, $s_id, $op_id); $watched = (($progress == true) ? "checked" : ""); $style = ($oo_id == $op_id) ? 'style="background-color: #f0f5f9 !important"' : ''; $tabindex = ($oo_id == $op_id) ? 'tabindex="-1"' : ''; $type = $o_data['option_type']; if ($type == "lecture") { $htmCon .= ' <div class="cf-course-msrslc px-1 px-md-4 pt-2"> <div class="cf-course-msrs-lc p-2" ' . $style . ' ' . $tabindex . '> <div class="cf-course-msrs-lct"> <input class="cf-course-msrs-lch d--cf--sl-check cf-course-sl-check" name="cf-course-opcom-' . $op_id . '" ' . $watched . ' data-c_id="' . $c_id . '" data-m_id="' . $mem_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" id="cf-course-sl-checkbox-' . $op_id . '" type="checkbox" > <label class="mb-0" for="cf-course-sl-checkbox-' . $op_id . '" title="' . $courses->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $courses->text42 . '"></label> <span class="cf-course-getlen-id custom-b-color" id="cf-course-main-ccount-' . $op_id . '" data-type="lecture" data-course="' . $c_id . '" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '"><span>' . $courses->text21 . ' <span class="cf-course-main-lcount cf-course-main-ocount" >' . $lcount . '</span> </span>: <span class="cf-course-msr-slt" > ' . $o_title . ' </span></span> </div> <div class="cf-course-msrs-lcty mt-2">'; if ($o_type == 'vu') : $htmCon .= '<i class="fas fa-play-circle cf-courseI"></i> <span class="cf-course-msrs-lcount"> ' . $courses->text43 . ' <span>' . (isset($o_cont['v_h']) && !empty($o_cont['v_h']) ? $o_cont["v_h"] . "H" : "") . ' </span> <span>' . (isset($o_cont['v_m']) && !empty($o_cont['v_m']) ? $o_cont["v_m"] . "Mn" : "") . ' </span><span>' . (isset($o_cont['v_s']) && !empty($o_cont['v_s']) ? $o_cont["v_s"] . "S" : "") . ' </span> </span>'; elseif ($o_type == 'au') : $htmCon .= '<i class="fas fa-headphones cf-courseI"></i><span class="cf-course-msrs-lcount"> ' . $courses->text44 . ' </span>'; elseif ($o_type == 'y') : $htmCon .= '<i class="fas fa-play-circle cf-courseI"></i> <span class="cf-course-msrs-lcount"> ' . $courses->text43 . ' <span>' . (isset($o_cont['y_h']) && !empty($o_cont['y_h']) ? $o_cont["y_h"] . "H" : "") . ' </span> <span>' . (isset($o_cont['y_m']) && !empty($o_cont['y_m']) ? $o_cont["y_m"] . "Mn" : "") . ' </span> <span>' . (isset($o_cont['y_s']) && !empty($o_cont['y_s']) ? $o_cont["y_s"] . "S" : "") . ' </span> </span>'; elseif ($o_type == 'vm') : $htmCon .= ' <i class="fas fa-play-circle cf-courseI"></i> <span class="cf-course-msrs-lcount"> ' . $courses->text43 . ' <span>' . (isset($o_cont['vm_h']) && !empty($o_cont['vm_h']) ? $o_cont["vm_h"] . "H" : "") . ' </span> <span>' . (isset($o_cont['vm_m']) && !empty($o_cont['vm_m']) ? $o_cont["vm_m"] . "Mn" : "") . ' </span><span>' . (isset($o_cont['vm_s']) && !empty($o_cont['vm_s']) ? $o_cont["vm_s"] . "S" : "") . ' </span> </span>'; elseif ($o_type == 'i') : $htmCon .= '<i class="fas fa-image cf-courseI" ></i><span class="cf-course-msrs-lcount"> ' . $courses->text45 . ' </span>'; elseif ($o_type == 'd') : $htmCon .= '<i class="fas fa-file cf-courseI"></i><span class="cf-course-msrs-lcount"> ' . $courses->text46 . ' </span>'; elseif ($o_type == 'cfcourselat') : $htmCon .= '<i class="fas fa-newspaper cf-courseI"></i> <span class="cf-course-msrs-lcount"> ' . $courses->text47 . ' </span>'; elseif ($o_type == 'if') : $htmCon .= '<i class="fas fa-play-circle cf-courseI"></i> <span class="cf-course-msrs-lcount"> ' . $courses->text43 . ' </span>'; endif; $htmCon .= $this->getHelpContent($op_id); $htmCon .= '</div> </div> </div>'; } else if ($type == "quiz") { $htmCon .= ' <div class="cf-course-msrslc px-1 px-md-4 pt-2"> <div class="cf-course-msrs-lc p-2" ' . $style . ' ' . $tabindex . '> <div class="cf-course-msrs-lct"> <input class="cf-course-msrs-lch d--cf--sl-check cf-course-sl-check" ' . $watched . ' name="cf-course-opcom-' . $op_id . '" data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" id="cf-course-sl-checkbox-' . $op_id . '" type="checkbox" > <label class="mb-0" for="cf-course-sl-checkbox-' . $op_id . '" title="' . $courses->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $courses->text42 . '"></label> <span class="cf-course-getlen-id custom-b-color" id="cf-course-main-ccount-' . $op_id . '" data-type="quiz" data-course="' . $c_id . '" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '"><span>' . $courses->text22 . ' <span class="cf-course-main-qcount cf-course-main-ocount" >' . $lcount . '</span> </span>: <span class="cf-course-msr-slt" >' . $o_title . ' </span></span> </div> <div class="cf-course-msrs-lcty mt-2"><i class="fas fa-puzzle-piece cf-courseI"></i> <span > ' . $courses->text22 . ' </span></div> </div> </div>'; } else if ($type == "assign") { $htmCon .= ' <div class="cf-course-msrslc px-1 px-md-4 pt-2"> <div class="cf-course-msrs-lc p-2" ' . $style . ' ' . $tabindex . '> <div class="cf-course-msrs-lct"> <input class="cf-course-msrs-lch d--cf--sl-check cf-course-sl-check" ' . $watched . ' name="cf-course-opcom-' . $op_id . '" data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" id="cf-course-sl-checkbox-' . $op_id . '" type="checkbox" > <label class="mb-0" for="cf-course-sl-checkbox-' . $op_id . '" title="' . $courses->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $courses->text42 . '"></label> <span class="cf-course-getlen-id custom-b-color" id="cf-course-main-ccount-' . $op_id . '" data-course="' . $c_id . '" data-type="assignment" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '"> <span>' . $courses->text23 . ' <span class="cf-course-main-acount cf-course-main-ocount" >' . $lcount . '</span> </span>: <span class="cf-course-msr-slt" >' . $o_title . '</span></span> </div> <div class="cf-course-msrs-lcty mt-2"><i class="fas fa-tasks cf-courseI"></i> <span > ' . $courses->text23 . ' </span></div> </div> </div>'; } else if ($type == "test") { $htmCon .= ' <div class="cf-course-msrslc px-1 px-md-4 pt-2"> <div class="cf-course-msrs-lc p-2" ' . $style . ' ' . $tabindex . '> <div class="cf-course-msrs-lct"> <input class="cf-course-msrs-lch d--cf--sl-check cf-course-sl-check" ' . $watched . ' name="cf-course-opcom-' . $op_id . '" data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" id="cf-course-sl-checkbox-' . $op_id . '" type="checkbox" > <label class="mb-0" for="cf-course-sl-checkbox-' . $op_id . '" title="' . $courses->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $courses->text42 . '"></label> <span class="cf-course-getlen-id custom-b-color" id="cf-course-main-ccount-' . $op_id . '" data-course="' . $c_id . '" data-type="test" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '"><span>' . $courses->text29 . ' <span class="cf-course-main-tcount cf-course-main-ocount" >' . $lcount . '</span> </span>: <span class="cf-course-msr-slt" >' . $o_title . '</span></span> </div> <div class="cf-course-msrs-lcty mt-2"><i class="fas fa-pen-fancy cf-courseI"></i> <span > ' . $courses->text29 . ' </span></div> </div> </div>'; } } } $htmCon .= '</div> </div> </div>'; } return $htmCon; } function getallSectionDataA($sresult, $c_id, $mem_id, $oo_id, $ss_id, $person, $drip_on_off, $texts, $theme) { $htmCon = ''; global $mysqli; global $dbpref; if ($person == "s") { self::addDripFeedData($mem_id, $c_id); } $drip_count = 0; $add_times_ser = date("Y-m-d", time()); //to pick date from Server.. $result_drip = self::showDripLocks($mem_id, $c_id); if ($result_drip->num_rows > 0) { if ($row = $result_drip->fetch_assoc()) { $drip_days = $row['drip_days']; $created_at = $row['created_at']; } } else { $drip_days = 0; $created_at = date("Y-m-d", time()); } $add_days = 0; $sc = 0; $lcount = 0; while ($sr = $sresult->fetch_assoc()) { $drip_count++; $s_title = htmlentities(stripcslashes($sr['title'])); $s_id = $sr['id']; $table = $dbpref . "content_options"; $qr = "SELECT * FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$s_id ORDER BY `display_order` ASC "; $oresult = $mysqli->query($qr); $sc++; $sc0 = self::getNumberWithZero($sc); $fas_down = ($ss_id == $s_id) ? 'fa-angle-up' : 'fa-angle-down'; $showc = ($ss_id == $s_id) ? 'show' : ''; $drip_collapse = "collapse"; $open_modal = ""; if (isset($drip_on_off)) { if ($drip_on_off == 1 || $drip_on_off == "1") //showing locks system only if drip is on via admin. { if ($drip_count == 1) { $htmCon_lock = '<i class="fa fa-unlock "></i>'; $drip_collapse = "collapse"; } else { $created_at = date('Y-m-d', strtotime($created_at . ' + ' . $drip_days . ' days')); if ($created_at <= $add_times_ser) { $htmCon_lock = '<i class="fa fa-unlock"></i>'; $drip_collapse = "collapse"; } else { $htmCon_lock = '<i class="fa fa-lock"></i>'; $drip_collapse = ""; $open_modal = "cf-course-open-model"; $add_days = $add_days + $drip_days; } } } //drip on off ends if condition } $htmCon .= '<li class="cf-course-course-title-a custom-b-secbackgroundColor cf-course-open-s cf-course-sec-o ' . $open_modal . '" data-days="' . $add_days . '" data-bs-toggle="' . $drip_collapse . '" data-bs-target="#cf-course-sec-' . $s_id . '" > <div class="d-flex justify-content-between"> <div> <h4 class="custom-b-color">' . (isset($htmCon_lock) ? $htmCon_lock : '') . '<span>' . $texts->text25 . ' ' . $sc0 . ' :</span> ' . $s_title . ' </h4></div> <span><i class="cf-course-msr-s-arr fas ' . $fas_down . ' "></i></span> </div> </li>'; $htmCon .= '<li id="cf-course-sec-' . $s_id . '" class="cf-course-course-details-a collapse ' . $showc . '"><ul>'; if ($oresult->num_rows > 0) { while ($o_data = $oresult->fetch_assoc()) { $lcount++; $op_id = $o_data['id']; $le_count0 = self::getNumberWithZero($lcount); $s_id = $o_data['section_id']; $c_id = $o_data['course_id']; $o_title = htmlspecialchars(stripslashes($o_data['title'])); $progress = self::getUserProgress($mem_id, $c_id, $s_id, $op_id); $watched = (($progress == true) ? "checked" : ""); $style = ($oo_id == $op_id) ? 'style="background-color: #2ACF97 !important"' : ''; $tabindex = ($oo_id == $op_id) ? 'tabindex="-1"' : ''; $type = $o_data['option_type']; if ($type == "lecture") { $htmCon .= '<li ' . $tabindex . ' ' . $style . ' > <p class="d-flex align-items-center"> <span class="cf-course-a-checkboxes"> <input data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" class="cf-course-msrs-lch" type="checkbox" id="cf-course-sl-checkbox-' . $op_id . '" name="cf-course-opcom-' . $op_id . '" ' . $watched . ' > <label for="cf-course-sl-checkbox-' . $op_id . '" title="' . $texts->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $texts->text42 . '"></label> </span> <span class="cf-course-getlen-id custom-' . $theme . '-color" id="cf-course-main-ccount-' . $op_id . '" data-type="lecture" data-course="' . $c_id . '" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '">' . $texts->text48 . ' ' . $le_count0 . ' : ' . $o_title . '</span> </p> </li>'; } else if ($type == "quiz") { $htmCon .= '<li ' . $tabindex . ' ' . $style . '> <p class="d-flex align-items-center"> <span class="cf-course-a-checkboxes"> <input data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" class="cf-course-msrs-lch" type="checkbox" id="cf-course-sl-checkbox-' . $op_id . '" name="cf-course-opcom-' . $op_id . '" ' . $watched . ' > <label for="cf-course-sl-checkbox-' . $op_id . '" title="' . $texts->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $texts->text42 . '"></label> </span> <span class="cf-course-getlen-id custom-' . $theme . '-color" id="cf-course-main-ccount-' . $op_id . '" data-type="quiz" data-course="' . $c_id . '" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '">' . $texts->text22 . ' ' . $le_count0 . ' : ' . $o_title . '</span> </p></li>'; } else if ($type == "assign") { $htmCon .= '<li ' . $tabindex . ' ' . $style . '> <p class="d-flex align-items-center"> <span class="cf-course-a-checkboxes"> <input data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" class="cf-course-msrs-lch" type="checkbox" id="cf-course-sl-checkbox-' . $op_id . '" name="cf-course-opcom-' . $op_id . '" ' . $watched . ' > <label for="cf-course-sl-checkbox-' . $op_id . '" title="' . $texts->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $texts->text42 . '"></label> </span> <span id="cf-course-main-ccount-' . $op_id . '" class="cf-course-getlen-id custom-' . $theme . '-color" data-course="' . $c_id . '" data-type="assignment" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '">' . $texts->text23 . ' ' . $le_count0 . ' : ' . $o_title . '</span> </p></li>'; } else if ($type == "test") { $htmCon .= '<li ' . $tabindex . ' ' . $style . '> <p class="d-flex align-items-center"> <span class="cf-course-a-checkboxes"> <input data-m_id="' . $mem_id . '" data-c_id="' . $c_id . '" data-s_id="' . $s_id . '" data-op_id="' . $op_id . '" class="cf-course-msrs-lch" type="checkbox" id="cf-course-sl-checkbox-' . $op_id . '" name="cf-course-opcom-' . $op_id . '" ' . $watched . ' > <label for="cf-course-sl-checkbox-' . $op_id . '" title="' . $texts->text42 . '" data-bs-toggle="tooltip" data-original-title="' . $texts->text42 . '"></label> </span> <span id="cf-course-main-ccount-' . $op_id . '" class="cf-course-getlen-id custom-' . $theme . '-color" data-course="' . $c_id . '" data-type="test" data-m_id="' . $mem_id . '" data-opt="' . $op_id . '" data-sec="' . $s_id . '" data-count="' . $lcount . '">' . $texts->text29 . ' ' . $le_count0 . ' : ' . $o_title . '</span> </p> </li>'; } } } $htmCon .= '</ul></li>'; } return $htmCon; } function getNumberWithZero($num = 1) { if ($num < 10) { return "0" . $num; } else { return $num; } } function getTotalContent($c_id, $s_id) { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; $qr1 = "SELECT COUNT(*) AS 'total_row' FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$s_id AND `option_type`!='NULL' OR `option_type`!=NULL"; $oresult2 = $mysqli->query($qr1); $ofetch = $oresult2->fetch_assoc(); return $ofetch['total_row']; } function getWatched($m_id, $c_id, $s_id = 0) { global $mysqli; global $dbpref; $table = $dbpref . "member_progress"; $progress = 1; $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($m_id); $mid = $mem_data['mid']; if ($s_id == 0) { $qr1 = "SELECT COUNT(*) as total_watched FROM `" . $table . "` WHERE `course_id`=$c_id AND `member_id`=$mid AND `progress`=" . $progress; $cou_result = $mysqli->query($qr1); } else { $qr1 = "SELECT COUNT(*) as total_watched FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$s_id AND `member_id`=$mid AND `progress`=" . $progress; $cou_result = $mysqli->query($qr1); } if ($cou_result->num_rows > 0) { $counts = $cou_result->fetch_assoc(); return $counts['total_watched']; } else { return "0"; } } function getUserProgress($m_id, $c_id, $s_id, $oid) { global $mysqli; global $dbpref; $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($m_id); $mid = $mem_data['mid']; $table = $dbpref . "member_progress"; $watched = 1; $qr1 = "SELECT * FROM `" . $table . "` WHERE `member_id`=$mid AND `option_id`=$oid AND `progress`=" . $watched; $cou_result = $mysqli->query($qr1); // print_r($qr1); if ($cou_result->num_rows > 0) { $counts = $cou_result->fetch_assoc(); return $counts['progress']; } else { return "0"; } } // this function fetch all related help content for a lecture. function getHelpContent($op_id) { global $mysqli; global $dbpref; $table = $dbpref . "content_resource"; $sql = "SELECT * FROM `" . $table . "` WHERE `content_id`=" . $op_id; $h_r = $mysqli->query($sql); $help_cont = ""; if ($h_r->num_rows > 0) { $count = 1; $help_cont .= '<span class="btn p-0 ms-2 btn-unstyled px-2 cf-course-msrs-lctexob" data-bs-toggle="collapse" data-bs-target="#cf-course-msrs-lctexb-' . $op_id . '"> <i class="fas fa-caret-down"></i> Extras</span> <div id="cf-course-msrs-lctexb-' . $op_id . '" class="collapse" > <div class="cf-course-msrs-lctexd "> '; while ($h_ds = $h_r->fetch_assoc()) { $link = htmlentities($h_ds["link"]); $text = htmlentities($h_ds["text"]); $help_cont .= '<div class="cf-course-lex p-1">'; if ($h_ds['resource_type'] == "d") : $help_cont .= '<a href="' . $link . '" download class="text-primary"> <i class="fas fa-download"></i> ' . $text . ' </a>'; elseif ($h_ds['resource_type'] == "v") : $help_cont .= '<a href="' . $link . '" target="_blank" class="text-success"> <i class="fas fa-eye"></i> ' . $text . ' </a>'; elseif ($h_ds['resource_type'] == "l") : $help_cont .= '<a href="' . $link . '" target="_blank" class="text-info"> <i class="fas fa-link"> </i> ' . $text . ' </a>'; endif; $help_cont .= '</div>'; } $help_cont .= '</div></div>'; } return $help_cont; } function getHelpContentData($op_id) { global $mysqli; global $dbpref; $table = $dbpref . "content_resource"; $sql = "SELECT * FROM `" . $table . "` WHERE `content_id`=" . $op_id; $h_r = $mysqli->query($sql); return $h_r; } function getOptionsContent($oid, $sid, $c_id, $count, $assign_stud_ob, $type = "", $mem_id = 0, $text = '') { global $mysqli; global $dbpref; $c = $mysqli->real_escape_string($count); $table = $dbpref . "content_options"; $qr = "SELECT * FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$sid AND `id`=" . $oid; $oresult = $mysqli->query($qr); $htmCon = ''; if ($oresult->num_rows > 0) { $o_data = $oresult->fetch_assoc(); $op_id = $o_data['id']; $s_id = $o_data['section_id']; $c_id = $o_data['course_id']; $o_title = htmlspecialchars(stripslashes($o_data['title'])); $o_des = stripslashes($o_data['description']); $o_type = $o_data['option_type']; $progress = self::getUserProgress($mem_id, $c_id, $s_id, $op_id); $watched = (($progress == true) ? "1" : "0"); if ($o_type == "quiz") { $title = '<span class="cf-course-sltcou"> Quiz <span class="cf-cc-mcon-cont">' . $c . '</span>: </span>'; $about = '<h5 class="font-weight-bold">About This Quiz </h5>'; } else if ($o_type == "assign" || $o_type == "test") { $astst = $o_type == "assign" ? "Assignment" : "Test"; $title = '<span class="cf-course-sltcou"> ' . $astst . ' <span class="cf-cc-mcon-cont">' . $c . '</span>: </span>'; $about = '<h5 class="font-weight-bold">About This ' . $astst . ' </h5>'; $assingment_details = $assign_stud_ob->get_assign_details_by_id($op_id); $inst_video_url = $assingment_details['inst_video_url']; $inst_instructions = $assingment_details['inst_instructions']; $inst_resourses_url = $assingment_details['inst_resourses_url']; $solu_video_url = $assingment_details['solu_video_url']; $solu_down_resource = $assingment_details['solu_down_resource']; $training_ob = $this->loader->load("training_control"); if (stristr($inst_video_url, "youtu")) { $vid = $training_ob->getYoutubeVimeoId($inst_video_url, "y"); $ivu = '<iframe style="width:80%;height:200px" src="https://www.youtube.com/embed/' . $vid . '" title="YouTube video player" frameborder="0" allowfullscreen></iframe>'; } else if (stristr($inst_video_url, "vimeo")) { $vid = $training_ob->getYoutubeVimeoId($inst_video_url, "vm"); $ivu = '<iframe style="width:80%;height:200px" src="https://player.vimeo.com/video/' . $vid . '" width="100%" frameborder="0" allow="fullscreen; picture-in-picture" allowfullscreen></iframe>'; } else { $ivu = '<video style="width:80%;height:200px" controls> <source src="' . $inst_video_url . '" type="video/mp4"> <source src="' . $inst_video_url . '" type="video/ogg"> Your browser does not support the video tag. </video>'; } $ivu = (!empty($inst_video_url)) ? '<h4 class="py-2">Instruction Video</h4>' . $ivu : ""; if (stristr($solu_video_url, "youtu")) { $vid = $training_ob->getYoutubeVimeoId($solu_video_url, "y"); $svu = '<iframe style="width:80%;height:200px" src="https://www.youtube.com/embed/' . $vid . '" title="YouTube video player" frameborder="0" allowfullscreen></iframe>'; } else if (stristr($solu_video_url, "vimeo")) { $vid = $training_ob->getYoutubeVimeoId($solu_video_url, "vm"); $svu = '<iframe style="width:80%;height:200px" src="https://player.vimeo.com/video/' . $vid . '" width="100%" frameborder="0" allow="fullscreen; picture-in-picture" allowfullscreen></iframe>'; } else { $svu = ' <video style="width:80%;height:200px" controls> <source src="' . $solu_video_url . '" type="video/mp4"> <source src="' . $solu_video_url . '" type="video/ogg"> Your browser does not support the video tag. </video>'; } $svu = (!empty($solu_video_url)) ? '<h4 class="py-2">Solution Video</h4>' . $svu : ""; $i_res_u = ' <h5 class="py-1 mt-1">Instruction Resource Download</h5><a class="btn btn-primary" href="' . $inst_resourses_url . '" download>Download</a>'; $i_res_u = (!empty($inst_resourses_url)) ? $i_res_u : ""; $s_res_u = ' <h3>Solution Resource Download</h3><a class="btn btn-primary" href="' . $solu_down_resource . '" download>Download</a>'; $s_res_u = (!empty($solu_down_resource)) ? $s_res_u : ""; $assign_dataa = '<div class=" mx-auto mb-3"> <div class="row"> <div class="col-md-12"> <h5>Instructions to Solve ' . $astst . '</h5></div> </div> <div class="row cf-couse-slcon">'; if (!empty($inst_instructions)) { $assign_dataa .= '<div class="col-md-12">' . $inst_instructions . '</div>'; } if (!empty($ivu)) { $assign_dataa .= '<div class="col-md-6">' . $ivu . '</div>'; } if (!empty($svu)) { $assign_dataa .= '<div class="col-md-6">' . $svu . '</div>'; } $assign_dataa .= '</div>'; $assign_dataa .= '<div class="row cf-couse-slcon">'; if (!empty($i_res_u)) { $assign_dataa .= '<div class="col-md-6">' . $i_res_u . '</div>'; } if (!empty($s_res_u)) { $assign_dataa .= '<div class="col-md-6">' . $s_res_u . '</div>'; } $assign_dataa .= '</div>'; $assign_dataa .= '</div>'; if (!empty($i_res_u) || !empty($ivu) || !empty($svu) || !empty($s_res_u) || !empty($inst_instructions)) { $o_des .= $assign_dataa; } } else if ($o_type == "lecture") { $title = '<span class="cf-course-sltcou"> Lecture <span class="cf-cc-mcon-cont">' . $c . '</span>: </span>'; $about = '<h5 class="font-weight-bold">About This Lecture </h5>'; } if ($type == "title") { $htmCon .= ' <div class="cf-course-slti px-1 py-2 pb-2 px-sm-0"> ' . $title . '<span class="cf-course-clttext"> ' . $o_title . ' <span> </div>'; } else if ($type == "desc") { $des_len = strip_tags($o_des); if (strlen($des_len) > 500) { $class = "cf-course-assign-ada-ans-h"; $button = '<a href="javascript:void(0)" class="d-inline-block cf-course-assign-ada-btn">Read More</a>'; } else { $class = ''; $button = ''; } $htmCon .= '<div class="cf-course-content px-3 pt-5">' . $about . '</div><hr />'; $htmCon .= '<div class="cf-course-sltdec cf-course-read-more-des position-relative c--cf-l-des py-2 px-3"> <div class="cf-couse-slcon py-2 ' . $class . ' c--cf-l-des "> ' . $o_des . ' </div> ' . $button . ' </div><hr />'; } } return $htmCon; } //end of function // this function will return all details of content function getContentDetails($oid, $cid, $get_only = false) { global $mysqli; global $dbpref; $op_id = $mysqli->real_escape_string($oid); $c_id = $mysqli->real_escape_string($cid); $table = $dbpref . "content_options"; if ($get_only) { $qr = "SELECT `" . $get_only . "` FROM `" . $table . "` WHERE `course_id`=$c_id AND `id`=" . $op_id; } else { $qr = "SELECT * FROM `" . $table . "` WHERE `course_id`=$c_id AND `id`=" . $op_id; } $cresult = $mysqli->query($qr); if ($cresult->num_rows > 0) { $o_data = $cresult->fetch_assoc(); return $o_data; } } // this function will return description of content function getContentTitle($oid, $cid) { global $mysqli; global $dbpref; $opid = $mysqli->real_escape_string($oid); $c_id = $mysqli->real_escape_string($cid); $table = $dbpref . "content_options"; $qr = "SELECT `title` FROM `" . $table . "` WHERE `course_id`=$c_id AND `id`=" . $opid; $cresult = $mysqli->query($qr); if ($cresult->num_rows > 0) { $c_data = $cresult->fetch_assoc(); $c_title = htmlspecialchars(stripslashes($c_data['title'])); return $c_title; } } // this function will return title of content function getContentDescription($oid, $cid) { global $mysqli; global $dbpref; $opid = $mysqli->real_escape_string($oid); $c_id = $mysqli->real_escape_string($cid); $table = $dbpref . "content_options"; $qr = "SELECT `description` FROM `" . $table . "` WHERE `course_id`=$c_id AND `id`=" . $opid; $cresult = $mysqli->query($qr); if ($cresult->num_rows > 0) { $c_data = $cresult->fetch_assoc(); $c_desc = stripslashes($c_data['description']); return $c_desc; } } function getLectureHeader($oid, $count, $take, $type = "") { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; $qr = "SELECT * FROM `" . $table . "` WHERE `id`=" . $oid; $oresult = $mysqli->query($qr); $htmCon = ''; if ($oresult->num_rows > 0) { $o_data = $oresult->fetch_assoc(); $o_tit = htmlspecialchars(stripslashes($o_data['title'])); $o_title = ((strlen($o_tit) > 80) ? substr($o_tit, 0, 80) . '...' : $o_tit); $o_type = $o_data['option_type']; if ($take == "all") { if ($o_type == "quiz") { $title = '<span class="cf-course-sltcou b--cf-sltcou c--cf-sltcou d--cf-sltcou e--cf-sltcou"> Quiz <span class="cf-cc-mcon-cont"></span>: </span>'; } else if ($o_type == "assign") { $title = '<span class="cf-course-sltcou b--cf-sltcou c--cf-sltcou d--cf-sltcou e--cf-sltcou"> Assignment <span class="cf-cc-mcon-cont"></span>: </span>'; } else if ($o_type == "lecture") { $title = '<span class="cf-course-sltcou b--cf--sltcou c--cf-sltcou d--cf-sltcou e--cf-sltcou"> Lecture <span class="cf-cc-mcon-cont"</span>: </span>'; } else if ($o_type == "test") { $title = '<span class="cf-course-sltcou b--cf-sltcou c--cf-sltcou d--cf-sltcou e--cf-sltcou"> Test <span class="cf-cc-mcon-cont"></span>: </span>'; } $htmCon .= ' <div class="cf-course-slti px-1 px-sm-0"> ' . $title . '<span class="cf-course-clttext b--cf--clttext c--cf--clttext d--cf--clttext e--cf--clttext"> ' . $o_title . ' <span> </div>'; } elseif ($take == "one") { if ($o_type == "quiz") { $title = '<span class="font-weight-bold text-primary" >Quiz: </span>'; } else if ($o_type == "assign") { $title = '<span class="font-weight-bold text-primary" > Assignment: </span>'; } else if ($o_type == "test") { $title = '<span class="font-weight-bold text-primary" > Test: </span>'; } else if ($o_type == "lecture") { $title = '<span class="font-weight-bold text-primary" > Lecture: </span>'; } $htmCon .= ' <div class=""> ' . $title . '<span > ' . $o_title . ' <span> </div>'; } } return $htmCon; } //end of function //this function is just to collect important data from 1st row function showDripLocks($member_id, $c_id, $sid = false) { global $mysqli; global $dbpref; $table_drip = $dbpref . "member_drip"; if ($sid) { $sql_drip = "SELECT `drip_days`,`created_at` FROM `$table_drip` WHERE `course_id`= " . $c_id . " and `member_id`= " . $member_id . " and `section_id`=" . $sid . " limit 1"; } else { $sql_drip = "SELECT `drip_days`,`created_at` FROM `$table_drip` WHERE `course_id`= " . $c_id . " and `member_id`= " . $member_id . " limit 1"; } $result_drip = $mysqli->query($sql_drip); return $result_drip; } public function getCourseData($sresult, $c_id) { global $mysqli; global $dbpref; $course_content = []; while ($sr = $sresult->fetch_assoc()) { $s_id = $sr['id']; $table = $dbpref . "content_options"; $qr = "SELECT * FROM `" . $table . "` WHERE `course_id`=$c_id AND `section_id`=$s_id ORDER BY `display_order` ASC "; $oresult = $mysqli->query($qr); if ($oresult->num_rows > 0) { while ($o_data = $oresult->fetch_assoc()) { $op_id = $o_data['id']; $s_id = $o_data['section_id']; $c_id = $o_data['course_id']; $type = $o_data['option_type']; if ($type == "lecture") { $course_content[] = ['course_id' => $c_id, "section_id" => $s_id, "option_id" => $op_id, "option_type" => "lecture"]; } else if ($type == "quiz") { $course_content[] = ['course_id' => $c_id, "section_id" => $s_id, "option_id" => $op_id, "option_type" => "quiz"]; } else if ($type == "assign") { $course_content[] = ['course_id' => $c_id, "section_id" => $s_id, "option_id" => $op_id, "option_type" => "assignment"]; } else if ($type == "test") { $course_content[] = ['course_id' => $c_id, "section_id" => $s_id, "option_id" => $op_id, "option_type" => "test"]; } } } } return $course_content; } public function getAdjascentKey($key, $hash = array(), $increment = 0) { $keys = array_keys($hash); // print_r( $hash ); $found_index = array_search($key, $keys); if ($found_index === false) { // echo $found_index; return false; } $newindex = $found_index + $increment; // echo $newindex; $re = ($newindex >= 0 && $newindex < count($hash)) ? $hash[$newindex] : false; return $re; } //this function will add drip feed data into the table function addDripFeedData($member_id, $c_id) { global $mysqli; global $dbpref; $table_all_products = $dbpref . "all_products"; $table_drip = $dbpref . "member_drip"; $table_section = $dbpref . "section"; $sql_drip = "SELECT * FROM `" . $table_drip . "` WHERE course_id= " . $c_id . " and member_id= " . $member_id; $result_drip = $mysqli->query($sql_drip); if ($result_drip->num_rows === 0) { $sql_product = "SELECT * FROM `" . $table_all_products . "` WHERE id= " . $c_id . ""; $result_product = $mysqli->query($sql_product); if ($result_product->num_rows > 0) { if ($row = $result_product->fetch_assoc()) { $drip_on_off = $row['drip_on_off']; $drip_days = $row['drip_days']; } } if ($drip_on_off != NULL && $drip_on_off != 0) { $sql_sec = "SELECT * FROM `" . $table_section . "` WHERE course_id= " . $c_id . " ORDER BY `display_order` ASC"; $result = $mysqli->query($sql_sec); $arr = []; if ($result->num_rows > 0) { $add_times = date("Y-m-d", time()); while ($row = $result->fetch_assoc()) { $section_id = $row['id']; $locked = 1; $total_count = getTotalCount($table_drip); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { break; } $sql = "INSERT INTO `" . $table_drip . "`(`course_id`, `section_id`, `member_id`,`locked`,`drip_on_off`,`drip_days`, `created_at`) VALUES (" . $c_id . "," . $section_id . "," . $member_id . "," . $locked . "," . $drip_on_off . "," . $drip_days . ",'" . $add_times . "')"; $mysqli->query($sql); $add_times = date('Y-m-d', strtotime($add_times . ' + ' . $drip_days . ' days')); } } } } else { //It is already entered } } //end of function. public function addRating($data) { global $mysqli; global $dbpref; $rating_table = $dbpref . "course_review"; $cid = (int) cf_enc($mysqli->real_escape_string(trim($data['cid'])), "decrypt"); $mid = (int)cf_enc($mysqli->real_escape_string(trim($data['mid'])), "decrypt"); $rating = isset($data['rating']) ? $data['rating'] : "4.5"; $rating = $mysqli->real_escape_string($rating); $summery = $mysqli->real_escape_string(trim($data['summery'])); $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($mid); $mid = $mem_data['mid']; $email = $mem_data['email']; $name = $mem_data['name']; $is_ad = $mem_data['is_ad']; $r_appr = 1; $time = date("Y-m-d H:i:s"); $sql = "SELECT * FROM `" . $rating_table . "` WHERE `member_id`=$mid AND `course_id`=$cid"; $fetch_row = $mysqli->query($sql); if ($fetch_row->num_rows > 0) { $sql2 = "UPDATE `" . $rating_table . "` SET `rating`=$rating WHERE `member_id`= $mid AND `course_id`= $cid"; } else { $sql2 = "INSERT INTO `" . $rating_table . "`(`course_id`, `member_id`, `name`, `email`, `rating`, `summary`, `is_admin`, `approved`, `added_on`) VALUES ($cid,$mid,'" . $name . "','" . $email . "',$rating,'" . $summery . "',$is_ad,$r_appr,'" . $time . "')"; } $total_count = getTotalCount($rating_table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 5) { $true = 0; } else { $true = $mysqli->query($sql2) ? 1 : -1; } if ($true) { echo json_encode(array("status" => 1, "data" => "added successfull")); if (get_option('reply_review_email') && get_option('reply_review_email') == 1) { self::sendReviewEmail($name, $cid); } } else { echo json_encode(array("status" => 1, "data" => "not added successfull")); } die(); } function sendReviewEmail($name, $course_id) { $t = self::get_course_by_id($course_id, 'title'); $email_body = "<p>Hello,</p>"; $bottom_line = "<p>Thanks </p><p>CourseFunnels</p>"; $com_email = get_option("communication_email"); $subject = "(CourseFunnels) Rating Notification"; $email_body = ""; $newurl = get_option("install_url") . "?page=cfcourse_manage_review&cfcourse_id=" . $course_id; $email_body .= "<p>I hope you’re having a great week. <strong>" . $name . "</strong> has given a rating on the <strong>" . $t['title'] . "</strong> course.</p>"; $email_body .= "<p><a target='_blank' href='" . $newurl . "'>See rating</a> </p>"; $email_body .= "<p>Thanks </p><p>CourseFunnels</p>"; $email_data = [ "", "name" => "", "email" => $com_email, "subject" => $subject, "body" => $email_body ]; $sends_email = cf_mail($email_data); } public function getRatingStatus($cid, $mid) { global $mysqli; global $dbpref; $rating_table = $dbpref . "course_review"; $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($mid); $mid = $mem_data['mid']; $sql = "SELECT * FROM `" . $rating_table . "` WHERE `member_id`=$mid AND `course_id`=$cid"; $row = $mysqli->query($sql); if ($row->num_rows > 0) { return "yes"; } else { return "no"; } } function getProgress($mid, $cid) { global $mysqli; global $dbpref; $m_id = $mysqli->real_escape_string($mid); $c_id = $mysqli->real_escape_string($cid); $table = $dbpref . "content_options"; $qr1 = "SELECT COUNT(*) AS 'total_content' FROM `" . $table . "` WHERE `course_id`=" . $c_id; $row = $mysqli->query($qr1); if ($row->num_rows > 0) { $data = $row->fetch_assoc(); $alllecture_count = $data['total_content']; $totol_progress = self::getWatched($m_id, $c_id); $cfCoursePrgrs = floor(($totol_progress / $alllecture_count) * 100); return $cfCoursePrgrs; } return 0; } public function getExamStatus($type, $mem_id, $content_id) { global $mysqli; global $dbpref; $mem_id = $mysqli->real_escape_string($mem_id); $type = $mysqli->real_escape_string($type); $content_id = $mysqli->real_escape_string($content_id); if ($type == "assign" || $type == "test") { $table = $dbpref . "stud_assignment"; $sql = "SELECT * FROM `" . $table . "` WHERE `assign_id`=$content_id AND `member_id`=" . $mem_id; } else if ($type == "quiz") { $table = $dbpref . "stud_quiz"; $sql = "SELECT * FROM `" . $table . "` WHERE `quiz_id`=$content_id AND `member_id`=" . $mem_id; } $qry = $mysqli->query($sql); $r = []; if ($qry->num_rows > 0) { while ($data = $qry->fetch_assoc()) { $r = $data; } } return $r; } function isResultPublished($id, $mid, $type) { global $mysqli; global $dbpref; $id = $mysqli->real_escape_string($id); $mid = $mysqli->real_escape_string($mid); $type = $mysqli->real_escape_string($type); $content_table = $dbpref . "content_options"; $member_id = 0; $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($mid); $member_id = $mem_data['mid']; if ($type == "assign") { $table = $dbpref . "stud_assignment"; $sql = "SELECT `result_out_date`,`checked` FROM `" . $table . "` WHERE `assign_id`=$id AND `type`='assign' AND `member_id`=" . $member_id . " order by `id` desc limit 1"; } elseif ($type == "test") { $table = $dbpref . "stud_assignment"; $sql = "SELECT `result_out_date`,`checked` FROM `" . $table . "` WHERE `assign_id`=$id AND `type`='test' AND `member_id`=" . $member_id . " order by `id` desc limit 1"; } elseif ($type == "quiz") { $table = $dbpref . "stud_quiz"; $sql = "SELECT `result_out_date`,`checked` FROM `" . $table . "` WHERE `quiz_id`=$id AND `member_id`=" . $member_id . " order by `id` desc limit 1"; } $delay_days = 0; $admin_check = 0; $no_of_days = 0; $checked = 0; $sql1 = $mysqli->query("SELECT `delay_result`,`admin_check` FROM `" . $content_table . "` WHERE `id`=$id"); if ($sql1->num_rows > 0) { $data = $sql1->fetch_assoc(); $delay_days = $data['delay_result']; $admin_check = $data['admin_check']; } $qry = $mysqli->query($sql); if ($qry->num_rows > 0) { $add_times_ser = date("d-M-Y", time()); //GET TODAY DATE $r = $qry->fetch_object(); $result_out_date = $r->result_out_date; $diff = strtotime($add_times_ser) - strtotime($result_out_date); $diff = round($diff / 86400); $no_of_days = $diff * (-1); //to change the sign $checked = $r->checked; } if ($admin_check) { if ($qry->num_rows > 0) { if ($checked) { if ($delay_days == 0) { return true; } else { if ($no_of_days <= 0) // this one is correct .. if($no_of_days>0) { return true; } } } } return false; } else { if ($qry->num_rows > 0) { if ($type == "assign" || $type == "test") { if ($checked) { if ($delay_days == 0) { return true; } else { if ($no_of_days <= 0) // this one is correct .. if($no_of_days>0) { return true; } } } } else { if ($delay_days == 0) { return true; } else { if ($no_of_days <= 0) // this one is correct .. if($no_of_days>0) { return true; } } } } } return false; } function saveCourseSetting($data) { global $mysqli; global $dbpref; $table = $dbpref . "course_setting"; $edit = json_decode($data['data']); $theme = $edit->theme; $text = $edit->text; $style = $edit->style; $texts = []; $styles = []; foreach ($text as $key => $txt) { $texts[$key] = $mysqli->real_escape_string($txt); } foreach ($style as $key1 => $styl) { $styles[$key1] = $mysqli->real_escape_string($styl); } $txts = $mysqli->real_escape_string(json_encode($texts)); $stys = $mysqli->real_escape_string(json_encode($styles)); $run = $mysqli->query("SELECT `id` FROM `$table` WHERE `theme`='$theme'"); if ($run->num_rows > 0) { $sql = "UPDATE `$table` SET `text`='$txts', `style`='$stys', `theme`='$theme' WHERE `theme`='$theme'"; } else { $sql = "INSERT INTO `$table`(`text`,`style`,`theme`) VALUES ('$txts','$stys','$theme')"; } $total_count = getTotalCount($table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { $run1 = 0; } else { $run1 = $mysqli->query($sql) ? 1 : 0; } if ($run1) { echo json_encode(array("status" => 1, "msg" => "Saved successfuly")); } else { echo json_encode(array("status" => 0, "msg" => "Error! Not saved successfuly")); } die(); } function resetCourseSetting($data) { global $mysqli; global $dbpref; $table = $dbpref . "course_setting"; $edit = json_decode($data['data']); $theme = $edit->theme; $sql = "DELETE FROM `$table` WHERE `theme`='$theme'"; $run1 = $mysqli->query($sql) ? 1 : 0; if ($run1) { echo json_encode(array("status" => 1, "msg" => "Saved successfuly")); } else { echo json_encode(array("status" => 0, "msg" => "Error! Not saved successfuly")); } die(); } function getDefaultText() { $texts = [ "text1" => 'Lecture', "text2" => 'Overview', "text3" => 'Discuss', "text4" => 'Notes', "text5" => 'Create A Note', "text6" => 'Currently There Are No Notes Available', "text7" => 'Create A Note', "text8" => 'Create Note At', "text9" => 'Cancel', "text10" => 'Add Note', "text11" => 'Comments', "text12" => 'Currently There Are No Comments Available', "text13" => 'Post', "text14" => 'Discussion', "text15" => 'Add Comment', "text16" => 'Quiz', "text17" => 'About This Lecture', "text18" => 'About This Course', "text19" => 'Skill level', "text20" => 'Category', "text21" => 'Lecture', "text22" => 'Quiz', "text23" => 'Assignment', "text24" => 'Description', "text25" => 'Section', "text26" => 'Please start the course for notes', "text27" => 'Sorry! Comments are disabled for this content', "text28" => 'Course Content', "text29" => 'Test', "text30" => 'Are You Sure You Want To Submit This Assignment', "text31" => 'Submit', "text32" => 'Please Confirm', "text33" => 'Choose Theme', "text34" => 'Dashboard', "text35" => 'Logout', "text36" => 'Your Progress', "text37" => 'Content', "text38" => 'Course Content', "text39" => 'Read More', "text40" => 'Edit', "text41" => 'Remove', "text42" => 'Mark as completed', "text43" => 'Video', "text44" => 'Audio', "text45" => 'Image', "text46" => 'Document', "text47" => 'Article', "text48" => 'Lesson', "text49" => 'Prev', "text50" => 'Next', "text51" => 'Theater mode', "text52" => 'Full screen', "text53" => 'Leave a rating', "text54" => 'About This Test', "text55" => 'About This Quiz', "text56" => 'About This Assignment', "text57" => 'Intermediate', "text58" => 'Beginner', "text59" => 'Expert', "text60" => 'Instruction Resource Download', "text61" => 'Solution Resource Download', "text62" => 'Solution Video', "text63" => 'Download', "text64" => 'Instructions to Solve', "text65" => 'Links', "text66" => 'Number of questions', "text67" => 'Time', "text68" => 'This Assignment has already been submitted', "text69" => 'View Result', "text70" => 'Download Certificate', "text71" => 'Start Assignment', "text72" => 'Time Left', "text73" => 'No Questions Available', "text74" => 'Question', "text75" => 'Enter Answer', "text76" => 'Unlimited ', "text77" => 'File', "text78" => 'Assignment Details', "text79" => 'Read This', "text80" => 'Add Summery', "text81" => 'Summary', "text82" => 'Please Rate Us', "text83" => 'Thanks For Watching', "text84" => 'Thanks For Rating Us', "text85" => 'Next Tutorial', "text86" => 'Start Quiz', "text87" => 'Play Again', "text88" => 'Quiz Details', "text90" => 'of', "text91" => 'Start Test', "text92" => 'This Test has already been submitted', "text93" => 'Test Details', "text94" => 'Complete', "text95" => 'Previous Lecture', "text96" => 'Complete and Continue', "text97" => 'Content', "text98" => 'Next Lecture', "text99" => 'Previous Lecture', "text100" => 'Instruction Video', "text101" => 'Mark As Complete', ]; $stlyes = [ "color" => false, "backgroundColor" => false, "btnbackgroundColor" => false, "btnColor" => false, "secbackgroundColor" => false, "fulsecbackgroundColor" => false, "headerbackgroundColor" => false, ]; return ['texts' => (object)$texts, 'styles' => (object)$stlyes]; } // This function will return section related to couurse function getSections($course_id) { global $mysqli; global $dbpref; $table = $dbpref . "section"; $qr2 = "SELECT * FROM `$table` WHERE `course_id`=$course_id ORDER BY `display_order`"; $sresult = $mysqli->query($qr2); if ($sresult->num_rows > 0) { return $sresult; } return false; } // This function will return section related to 1 couurse function getCourseContent($course_id, $section_id) { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; $qr2 = "SELECT * FROM `$table` WHERE `course_id`=$course_id AND `section_id`=$section_id ORDER BY `display_order`"; $sresult = $mysqli->query($qr2); if ($sresult->num_rows > 0) { return $sresult; } return false; } /** * @param $content html content for product * @return This function check the attribute and return the product based on condition and limit */ function renderOnAnyPage($content, $funnel_id, $get_course = false) { $install_url = get_option("install_url"); if (strpos($content, "{install_url}") !== false) { $content = str_ireplace("{install_url}", $install_url, $content); } //For Product $init_reg = "/(\{mini_collection)(.(?!\{mini_collection))*(\})+/"; $limit = 4; $title_length = 200; $end = "{/mini_collection}"; preg_match_all($init_reg, $content, $arr5, PREG_OFFSET_CAPTURE); $arr5 = !empty($arr5[0]) ? $arr5[0] : "-1"; if ($arr5 != -1) { for ($k = 0; $k < count($arr5); $k++) { preg_match_all($init_reg, $content, $narr1, PREG_OFFSET_CAPTURE); if (isset($narr1[0][0])) { $arr1 = $narr1[0][0]; $new = substr($content, $arr1[1]); $new_pos = stripos($new, $end); $strl = intval(strlen($arr1[0])); $start = $strl + intval($arr1[1]); $new_pos = intval($new_pos) - $strl; $new_string = substr($content, $start, $new_pos); if (preg_match($init_reg, $new_string) === 0) { $arrs = preg_replace('/{mini_collection\s/i', "", $arr1[0]); $arrs = trim(str_ireplace("}", "", $arrs)); if (stristr("mini_collection", $arrs) === false) { $reg = "/([a-zA-Z0-9_\-])+(=)+((\"(.(?!\"))*.\")|(\'(.(?!\'))*.\')|(\S+))/"; $params = array(); preg_match_all($reg, $arrs, $parr); foreach ($parr[0] as $param) { $param = preg_replace_callback("/=/", function ($matches) { return "@-cf-scode-brk-@"; }, $param, 1); $param = explode("@-cf-scode-brk-@", $param); $params[$param[0]] = trim($param[1], "\"\'"); } $limit = isset($params['limit']) ? $params['limit'] : 6; } else { $limit = 6; } $products = $this->getCourse($limit, $funnel_id, $get_course); $find = $arr1[0] . $new_string . "{/mini_collection}"; if ($products['products']) { $str = ""; foreach ($products['products'] as $product) { $str .= $this->tempProducthipReplacerCb($new_string, $product, $title_length); } $content = str_replace($find, $str, $content); } else { $image = $install_url . "/assets/img/norecord.png"; $text = (get_option('product_not_available')) ? get_option('product_not_available') : "Opps! There are not product available"; $image = (get_option('product_not_image')) ? get_option('product_not_image') : get_option('install_url') . "/assets/img/norecord.png"; $str = "<div><div class='card' style='min-width:150px; max-width:250px; width:95%'> <img class='card-img-top' src='$image' alt='No Record Found'> <div class='card-body'> <div class='alert alert-info'> " . stripslashes($text) . " </div> </div> </div> </div>"; $content = str_replace($find, $str, $content); } } } } } return $content; } /** *@param: $get_only array *@param: $data shortcode parameter array *This function will return minimum collection of product */ function getCourse($limits, $funnel_id, $search = false) { global $mysqli; global $dbpref; $limit = $mysqli->real_escape_string(abs((int)$limits)); $search = $mysqli->real_escape_string($search); $get = ''; if ($search) { $get = " WHERE `title` LIKE '%$search%' OR `mini_description` LIKE '%$search%' OR `description` LIKE '%$search%'"; } $start = (int)$mysqli->real_escape_string(isset($_GET['cfpage']) ? $_GET['cfpage'] : 0); if ($start > 0) { $start = ($start - 1) * $limit; } $table = $dbpref . "all_products"; $sql = "SELECT * FROM `$table` $get ORDER BY `id` DESC LIMIT $start,$limit"; $row = $mysqli->query($sql); if ($row->num_rows > 0) { $products = []; while ($data = $row->fetch_assoc()) { $products[] = $data; } return array('products' => $products); } return array('products' => false); } function custom_echo($x, $length) { if (strlen($x) <= $length) { return $x; } else { $y = rtrim(substr($x, 0, $length)) . '...'; return $y; } } function tempProducthipReplacerCb($str, $datas, $title_length) { $currency = json_decode(file_get_contents(get_option("install_url") . "/assets/js/currency.json"), true); $current_crncy = isset($currency[$datas['currency']]['symbol']) ? $currency[$datas['currency']]['symbol'] : "$"; foreach ($datas as $index => $data) { // if($index=="id"){continue;} // if( $index=="productid" ){ $index="id"; } ; if (!is_array($data)) { if ($index == "media") { $data = str_ireplace("@@install_url@@", get_option("install_url"), $data); $str = str_ireplace("{product.$index}", stripslashes($data), $str); } if ($index == "download_url") { $data = str_ireplace("@@install_url@@", get_option("install_url"), $data); $str = str_ireplace("{product.$index}", stripslashes($data), $str); } if ($index == "average_rating") { $str = str_ireplace("{course.$index}", $data, $str); } if ($index == "title") { $str = str_replace("{course." . $index . "}", self::custom_echo($data, $title_length), $str); } if ($index == "price") { $str = str_replace("{course." . $index . "}", $current_crncy . $data, $str); } if ($index == "old_price_cross") { $str = str_replace("{course.c_price}", $current_crncy . $data, $str); } if ($index == "old_price_cross") { $str = str_replace("{course.c_price}", $current_crncy . $data, $str); } $str = str_replace("{course." . $index . "}", $data, $str); } } if (stristr($str, "{course.lesson}")) { $lessons = $this->getTotalLesson($datas['id']); $str = str_ireplace("{course.lesson}", $lessons, $str); } return $str; } function getTotalLesson($id) { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; $id = $mysqli->real_escape_string($id); $sql = "SELECT COUNT(*) AS 'total' FROM `$table` WHERE `course_id`=$id"; $row = $mysqli->query($sql); $run = $row->fetch_assoc(); return $run['total']; } function geCoursePagination($v) { global $mysqli; global $dbpref; $table = $dbpref . "all_products"; $sql = "SELECT COUNT(*) AS 'total' FROM `$table`"; $run = $mysqli->query($sql); $r = $run->fetch_assoc(); $current = isset($_GET['cfpage']) ? $_GET['cfpage'] : 1; $row = $r['total']; $total = $row / 6; $total = ceil($total); $page = 8; if ($total < $page) { $page = $total; } if ($row < 7) return; echo '<div id="myDiv">'; if ($current > 8) { echo '<a href="?cfpage=' . ($current - 8) . '" class="btn1" title="Previous"><i class="fa fa-angle-left" aria-hidden="true"></i></a>'; } if ($current > 8) { $j = $current - 7; } else { $j = 1; } for ($i = $j; $i <= ($j + ($page - 1)); $i++) { if ($current == $i) { echo '<a href="?cfpage=' . $i . '" class="btn1 active">' . $i . '</a>'; } else { echo '<a href="?cfpage=' . $i . '" class="btn1">' . $i . '</a>'; } } if ($total > 8 && $current < $total) { echo '<a href="?cfpage=' . ($j + 8) . '" class="btn1" title="Next"><i class="fa fa-angle-right" aria-hidden="true"></i></a>'; } echo '</div>'; } } }