|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/parasoffline.edukrypt.in/application/models/ |
Upload File : |
<?php
class Lecture_model extends MY_Model
{
public function get_sort($admin_id)
{
$result = $this->db->where('admin_id', $admin_id)->get('lectures')->{$this->_return_type(1)}();
foreach ($result as $key => &$row) {
$row = $this->trigger('after_get', $row, ($key == count($result) - 1));
}
$this->_with = array();
return $result;
}
/*********************************************************************************/
public function lecture_posts($limit, $start, $col, $dir, $course_id, $subject_id, $chapter_id, $admin_id = NULL)
{
$this->db->select('lectures.*, chapters.chapter, subjects.subject, courses.course, au.username as admin');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = lectures.admin_id');
if (!empty($admin_id)) {
$this->db->where('lectures.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('lectures');
if ($query->num_rows() > 0) {
return $query->result();
}
return [];
}
public function lecture_posts_count($course_id, $subject_id, $chapter_id, $admin_id = NULL)
{
$this->db->select('lectures.id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = lectures.admin_id');
if (!empty($admin_id)) {
$this->db->where('lectures.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
$query = $this->db->get('lectures');
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
function lecture_posts_search($limit, $start, $search, $col, $dir, $course_id, $subject_id, $chapter_id, $admin_id = NULL)
{
$this->db->select('lectures.*, chapters.chapter, subjects.subject, courses.course, au.username as admin');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = lectures.admin_id');
if (!empty($admin_id)) {
$this->db->where('lectures.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
$this->db->like('lectures.file_name', $search);
$this->db->or_like('lectures.name', $search);
$this->db->or_like('chapters.chapter', $search);
$this->db->or_like('subjects.subject', $search);
$this->db->or_like('courses.course', $search);
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('lectures');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return [];
}
}
public function lecture_posts_search_count($search, $course_id, $subject_id, $chapter_id, $admin_id = NULL)
{
$this->db->select('lectures.id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = lectures.admin_id');
if (!empty($admin_id)) {
$this->db->where('lectures.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
$this->db->like('lectures.file_name', $search);
$this->db->or_like('lectures.name', $search);
$this->db->or_like('chapters.chapter', $search);
$this->db->or_like('subjects.subject', $search);
$this->db->or_like('courses.course', $search);
$query = $this->db->get('lectures');
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
/*********************************************************************************/
public function check_permission_posts($limit, $start, $col, $dir, $course_id, $subject_id, $chapter_id, $user_id, $admin_id = NULL, $e_type)
{
$this->db->select('regfiles.*,lectures.e_type, chapters.chapter, subjects.subject, courses.course, au.username as admin, lectures.file_name as lecture');
$this->db->join('lectures', 'lectures.id = regfiles.lecture_id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = regfiles.admin_id');
if (!empty($admin_id)) {
$this->db->where('regfiles.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
if (!empty($e_type)) {
$this->db->where('lectures.e_type', $e_type);
}
if (!empty($user_id)) {
$this->db->where('regfiles.user_id', $user_id);
}
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('regfiles');
if ($query->num_rows() > 0) {
return $query->result();
}
return [];
}
public function check_permission_posts_count($course_id, $subject_id, $chapter_id, $user_id, $admin_id = NULL, $e_type)
{
$this->db->select('regfiles.id');
$this->db->join('lectures', 'lectures.id = regfiles.lecture_id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = regfiles.admin_id');
if (!empty($admin_id)) {
$this->db->where('regfiles.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
if (!empty($e_type)) {
$this->db->where('lectures.e_type', $e_type);
}
if (!empty($user_id)) {
$this->db->where('regfiles.user_id', $user_id);
}
$query = $this->db->get('regfiles');
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
function check_permission_posts_search($limit, $start, $search, $col, $dir, $course_id, $subject_id, $chapter_id, $user_id, $admin_id = NULL, $e_type)
{
$this->db->select('regfiles.*,lectures.e_type, chapters.chapter, subjects.subject, courses.course, au.username as admin, lectures.file_name as lecture');
$this->db->join('lectures', 'lectures.id = regfiles.lecture_id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = regfiles.admin_id');
if (!empty($admin_id)) {
$this->db->where('regfiles.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
if (!empty($e_type)) {
$this->db->where('lectures.e_type', $e_type);
}
if (!empty($user_id)) {
$this->db->where('regfiles.user_id', $user_id);
}
$this->db->like('lectures.file_name', $search);
$this->db->or_like('chapters.chapter', $search);
$this->db->or_like('subjects.subject', $search);
$this->db->or_like('courses.course', $search);
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('regfiles');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return [];
}
}
public function check_permission_posts_search_count($search, $course_id, $subject_id, $chapter_id, $user_id, $admin_id = NULL, $e_type)
{
$this->db->select('regfiles.id');
$this->db->join('lectures', 'lectures.id = regfiles.lecture_id');
$this->db->join('chapters', 'chapters.id = lectures.chapter_id');
$this->db->join('subjects', 'subjects.id = chapters.subject_id');
$this->db->join('courses', 'courses.id = subjects.course_id');
$this->db->join('admin_users as au', 'au.id = regfiles.admin_id');
if (!empty($admin_id)) {
$this->db->where('regfiles.admin_id', $admin_id);
}
if (!empty($course_id)) {
if (!empty($course_id) && !empty($subject_id)) {
if (!empty($course_id) && !empty($subject_id) && !empty($chapter_id)) {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
$this->db->where('chapters.id', $chapter_id);
} else {
$this->db->where('courses.id', $course_id);
$this->db->where('subjects.id', $subject_id);
}
} else {
$this->db->where('courses.id', $course_id);
}
}
if (!empty($e_type)) {
$this->db->where('lectures.e_type', $e_type);
}
if (!empty($user_id)) {
$this->db->where('regfiles.user_id', $user_id);
}
$this->db->like('lectures.file_name', $search);
$this->db->or_like('chapters.chapter', $search);
$this->db->or_like('subjects.subject', $search);
$this->db->or_like('courses.course', $search);
$query = $this->db->get('regfiles');
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
public function check_result_posts_count($search, $admin_id = NULL)
{
$this->db->select('mcq_results.*,users.username,mcq.title');
$this->db->join('users', 'users.id = mcq_results.user_id');
$this->db->join('mcq', 'mcq.id = mcq_results.mcq_id');
if (!empty($admin_id)) {
$this->db->where('mcq_results.admin_id', $admin_id);
}
if (!empty($search)) {
if (!empty($search['user_id'])) {
$this->db->where('mcq_results.user_id', $search['user_id']);
}
if (!empty($search['mcq_id'])) {
$this->db->where('mcq_results.mcq_id', $search['mcq_id']);
}
if (!empty($search['tag_id'])) {
$this->db->like('users.tag_id', $search['tag_id']);
}
}
$query = $this->db->get('mcq_results');
// return $this->db->last_query();
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
public function check_result_posts($limit, $start, $col, $dir, $search, $admin_id = NULL)
{
$this->db->select('mcq_results.*,users.username,mcq.title');
$this->db->join('users', 'users.id = mcq_results.user_id');
$this->db->join('mcq', 'mcq.id = mcq_results.mcq_id');
if (!empty($admin_id)) {
$this->db->where('mcq_results.admin_id', $admin_id);
}
if (!empty($search)) {
if (!empty($search['user_id'])) {
$this->db->where('mcq_results.user_id', $search['user_id']);
}
if (!empty($search['mcq_id'])) {
$this->db->where('mcq_results.mcq_id', $search['mcq_id']);
}
if (!empty($search['tag_id'])) {
$this->db->like('users.tag_id', $search['tag_id']);
}
}
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('mcq_results');
if ($query->num_rows() > 0) {
return $query->result();
}
return [];
}
function check_result_posts_search($limit, $start, $search, $col, $dir, $_search, $admin_id = NULL)
{
$this->db->select('mcq_results.*,users.username,mcq.title');
$this->db->join('users', 'users.id = mcq_results.user_id');
$this->db->join('mcq', 'mcq.id = mcq_results.mcq_id');
if (!empty($admin_id)) {
$this->db->where('mcq_results.admin_id', $admin_id);
}
if (!empty($_search)) {
if (!empty($_search['user_id'])) {
$this->db->where('mcq_results.user_id', $_search['user_id']);
}
if (!empty($_search['mcq_id'])) {
$this->db->where('mcq_results.mcq_id', $_search['mcq_id']);
}
if (!empty($_search['tag_id'])) {
$this->db->like('users.tag_id', $_search['tag_id']);
}
}
$this->db->like('users.username', $search);
$this->db->or_like('mcq.title', $search);
$this->db->limit($limit, $start);
$this->db->order_by($col, $dir);
$query = $this->db->get('mcq_results');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return [];
}
}
public function check_result_posts_search_count($search, $course_id, $subject_id, $chapter_id, $_search, $admin_id = NULL, $e_type)
{
$this->db->select('mcq_results.*,users.username,mcq.title');
$this->db->join('users', 'users.id = mcq_results.user_id');
$this->db->join('mcq', 'mcq.id = mcq_results.mcq_id');
if (!empty($admin_id)) {
$this->db->where('mcq_results.admin_id', $admin_id);
}
if (!empty($_search)) {
if (!empty($_search['user_id'])) {
$this->db->where('mcq_results.user_id', $_search['user_id']);
}
if (!empty($_search['mcq_id'])) {
$this->db->where('mcq_results.mcq_id', $_search['mcq_id']);
}
if (!empty($_search['tag_id'])) {
$this->db->like('users.tag_id', $_search['tag_id']);
}
}
$this->db->like('users.username', $search);
$this->db->or_like('mcq.title', $search);
$query = $this->db->get('mcq_results');
if ($query->num_rows() > 0) {
return $query->num_rows();
}
return 0;
}
}