Ejemplo n.º 1
0
 public static function countAllCourses($constraints = array())
 {
     list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints);
     $tables = "courses c";
     if (isset($constraints['branch_url']) && $_SESSION['s_current_branch']) {
         $tables .= ' LEFT OUTER JOIN module_hcd_course_to_branch cb on cb.courses_ID=c.id';
     }
     //$where[] = "d.id=c.directions_ID";
     $result = eF_countTableData($tables, "c.id", implode(" and ", $where));
     return $result[0]['count'];
 }
Ejemplo n.º 2
0
 public function countUserCoursesAggregatingResults($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints);
     $where[] = "d.id=c.directions_ID";
     if (isset($constraints['active']) && $constraints['active']) {
         $activeSql = 'and c1.active=1';
     } else {
         if (isset($constraints['active']) && !$constraints['active']) {
             $activeSql = 'and c1.active=0';
         } else {
             $activeSql = '';
         }
     }
     $where[] = "(select count(*) > 0 from users_to_courses uc1, courses c1 where uc1.users_login='******'login'] . "' and uc1.archive=0 {$activeSql} and c1.archive = 0 and (c1.instance_source=c.id or c1.id=c.id) and c1.id=uc1.courses_ID)=1";
     $result = eF_countTableData("directions d,courses c left outer join (select id from courses) r on c.id=r.id", "c.id", implode(" and ", $where));
     return $result[0]['count'];
 }
Ejemplo n.º 3
0
 /**
  * Get group courses
  *
  * This function returns the list of courses that are part of this group, including unassigned
  *
  * @param array $constraints The constraints for the query
  * @return array An array of EfrontCourse objects or course arrays
  * @since 3.6.2
  * @access public
  */
 public function getGroupCoursesAggregatingResultsIncludingUnassigned($constraints = array())
 {
     !empty($constraints) or $constraints = array('archive' => false, 'active' => true);
     list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints);
     $select = "c.*, (rr.courses_ID is not null OR r.courses_ID is not null) as has_course,\n    \t(select count( * ) from courses l where instance_source=c.id)\n    \tas has_instances,\n    \t(select count( * ) from lessons_to_courses cl, lessons l where cl.courses_ID=c.id and l.archive=0 and l.id=cl.lessons_ID)\n    \tas num_lessons,\n    \t(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and c.archive=0 and u.active!=0 and u.archive=0 and uc.archive=0 and u.login=uc.users_LOGIN and uc.user_type IN ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "'))\n    \tas num_students";
     if (G_VERSIONTYPE == 'enterprise') {
         #cpp#ifdef ENTERPRISE
         $select .= ",(select count( * ) from module_hcd_course_offers_skill s where courses_ID=c.id)\n    \t\tas num_skills";
     }
     #cpp#endif
     //debug();
     $result = eF_getTableData("courses c left outer join (select courses_ID from courses_to_groups where groups_ID=" . $this->group['id'] . ") r on c.id=r.courses_ID left outer join (select courses_ID,name,instance_source from courses c, courses_to_groups cg where c.id=cg.courses_ID and cg.groups_ID={$this->group['id']}) rr on rr.instance_source=c.id", $select, implode(" and ", $where), $orderby, $groupby, $limit);
     //debug(false);
     return EfrontCourse::convertDatabaseResultToCourseObjects($result);
 }