当前位置: 首页>>代码示例>>PHP>>正文


PHP SessionManager::get_course_list_by_session_id方法代码示例

本文整理汇总了PHP中SessionManager::get_course_list_by_session_id方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::get_course_list_by_session_id方法的具体用法?PHP SessionManager::get_course_list_by_session_id怎么用?PHP SessionManager::get_course_list_by_session_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionManager的用法示例。


在下文中一共展示了SessionManager::get_course_list_by_session_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: api_get_session_visibility

        $nb_assignments = null;
        $nb_posts = null;
    }
} else {
    // Sessions.
    $visibility = api_get_session_visibility($session_id);
    if ($visibility == SESSION_INVISIBLE) {
        Display::display_warning_message(get_lang('NotAvailable'));
        Display::display_footer();
    }
    $courses = Tracking::get_courses_followed_by_coach($user_id, $session_id);
    //If is drh
    if ($is_drh) {
        $courses_of_the_platform = CourseManager::get_courses_followed_by_drh($user_id);
        $courses = array();
        $courses_from_session = SessionManager::get_course_list_by_session_id($session_id);
        foreach ($courses_from_session as $course_item) {
            if (isset($courses_of_the_platform[$course_item['code']])) {
                $courses[$course_item['code']] = $course_item['code'];
            }
        }
        if (empty($courses)) {
            Display::display_warning_message(get_lang('NoResults'));
        }
    }
    //Courses for the user
    $count_courses = count($courses);
    //Sessions for the user
    $count_sessions = count($sessions);
}
if ($count_courses || $count_sessions) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:index.php

示例2: getApprovedInductionSessions

 /**
  * Get the count of approved induction sessions by a user
  * @param int $userId The user id
  * @return int The count of approved sessions
  */
 private function getApprovedInductionSessions($userId)
 {
     $tSession = Database::get_main_table(TABLE_MAIN_SESSION);
     $tSessionField = Database::get_main_table(TABLE_EXTRA_FIELD);
     $tSessionFieldValues = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
     $tSessionUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
     $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::SESSION_FIELD_TYPE;
     $sql = "SELECT s.id FROM {$tSession} AS s\n            INNER JOIN {$tSessionFieldValues} AS sfv ON s.id = sfv.item_id\n            INNER JOIN {$tSessionField} AS sf ON sfv.field_id = sf.id\n            INNER JOIN {$tSessionUser} AS su ON s.id = su.session_id\n            WHERE\n                sf.extra_field_type = {$extraFieldType} AND\n                sf.variable = 'is_induction_session' AND\n                su.relation_type = 0 AND\n                su.user_id = " . intval($userId);
     $result = Database::query($sql);
     if ($result === false) {
         return 0;
     }
     $numberOfApproved = 0;
     while ($session = Database::fetch_assoc($result)) {
         $numberOfApprovedCourses = 0;
         $courses = SessionManager::get_course_list_by_session_id($session['id']);
         foreach ($courses as $course) {
             $courseCategories = Category::load(null, null, $course['code'], null, null, $session['id'], false);
             if (count($courseCategories) > 0 && Category::userFinishedCourse($userId, $courseCategories[0])) {
                 $numberOfApprovedCourses++;
             }
         }
         if ($numberOfApprovedCourses === count($courses)) {
             $numberOfApproved++;
         }
     }
     return $numberOfApproved;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:33,代码来源:AdvancedSubscriptionPlugin.php

示例3: isset

$page = isset($_GET['page']) ? intval($_GET['page']) : null;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$default_sort = api_sort_by_first_name() ? 'firstname' : 'lastname';
$sort = isset($_GET['sort']) && in_array($_GET['sort'], array('lastname', 'firstname', 'username')) ? $_GET['sort'] : $default_sort;
$idChecked = isset($_GET['idChecked']) && (is_array($_GET['idChecked']) ? $_GET['idChecked'] : (is_array($_POST['idChecked']) ? $_POST['idChecked'] : null));
$direction = isset($_GET['direction']) && in_array($_GET['direction'], array('desc', 'asc')) ? $_GET['direction'] : 'desc';
if (is_array($idChecked)) {
    $my_temp = array();
    foreach ($idChecked as $id) {
        $my_temp[] = intval($id);
        // forcing the intval
    }
    $idChecked = $my_temp;
}
$session_info = SessionManager::fetch($id_session);
$courses = SessionManager::get_course_list_by_session_id($id_session);
if (!isset($courses[$course_info['real_id']])) {
    header('Location: session_course_list.php?id_session=' . $id_session);
    exit;
}
switch ($action) {
    case 'delete':
        SessionManager::unsubscribe_user_from_course_session($id_session, $idChecked, $courseId);
        header('Location: ' . api_get_self() . '?id_session=' . $id_session . '&course_code=' . urlencode($course_code) . '&sort=' . $sort);
        exit;
        break;
    case 'add':
        SessionManager::subscribe_users_to_session_course($idChecked, $id_session, $courseId);
        header('Location: ' . api_get_self() . '?id_session=' . $id_session . '&course_code=' . urlencode($course_code) . '&sort=' . $sort);
        exit;
        break;
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:session_course_user_list.php

示例4: array

     }
     $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $whereCondition);
     break;
 case 'get_sessions_tracking':
     if (api_is_drh()) {
         $sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), $start, $limit, false, false, false, null, $keyword, $description);
     } else {
         // Sessions for the coach
         $sessions = Tracking::get_sessions_coached_by_user(api_get_user_id(), $start, $limit, false, $keyword, $description);
     }
     $columns = array('name', 'date', 'course_per_session', 'student_per_session', 'details');
     $result = array();
     if (!empty($sessions)) {
         foreach ($sessions as $session) {
             if (api_drh_can_access_all_session_content()) {
                 $count_courses_in_session = count(SessionManager::get_course_list_by_session_id($session['id']));
             } else {
                 $count_courses_in_session = count(Tracking::get_courses_followed_by_coach($user_id, $session['id']));
             }
             $count_users_in_session = count(SessionManager::get_users_by_session($session['id'], 0));
             $session_date = array();
             if (!empty($session['access_start_date']) && $session['access_start_date'] != '0000-00-00') {
                 $session_date[] = get_lang('From') . ' ' . api_format_date($session['access_start_date'], DATE_FORMAT_SHORT);
             }
             if (!empty($session['access_end_date']) && $session['access_end_date'] != '0000-00-00') {
                 $session_date[] = get_lang('Until') . ' ' . api_format_date($session['access_end_date'], DATE_FORMAT_SHORT);
             }
             if (empty($session_date)) {
                 $session_date_string = '-';
             } else {
                 $session_date_string = implode(' ', $session_date);
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:model.ajax.php

示例5: array

    $global = false;
}
$global = true;
$course_list = $course_select_list = array();
$course_select_list[0] = get_lang('None');
$htmlHeadXtra[] = '
<script type="text/javascript">
function load_courses() {
	document.search_simple.submit();
}
</script>	';
$session_id = intval($_REQUEST['session_id']);
if (empty($session_id)) {
    $temp_course_list = CourseManager::get_courses_list();
} else {
    $temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
}
foreach ($temp_course_list as $temp_course_item) {
    $course_item = CourseManager::get_course_information($temp_course_item['code']);
    $course_list[] = array('db_name' => $course_item['db_name'], 'code' => $course_item['code'], 'title' => $course_item['title'], 'visual_code' => $course_item['visual_code']);
    $course_select_list[$temp_course_item['code']] = $course_item['title'];
}
//Get session list
$session_list = SessionManager::get_sessions_list(array(), array('name'));
$my_session_list = array();
$my_session_list[0] = get_lang('None');
foreach ($session_list as $sesion_item) {
    $my_session_list[$sesion_item['id']] = $sesion_item['name'];
}
$form = new FormValidator('search_simple', 'POST', '', '', null, false);
$form->addElement('select', 'session_id', get_lang('Sessions'), $my_session_list, array('id' => 'session_id', 'onchange' => 'load_courses();'));
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:question_course_report.php

示例6: while

            $result = Database::query($sql_query);
            while ($survey = Database::fetch_assoc($result)) {
                $survey['title'] .= $survey['anonymous'] == 1 ? ' (' . get_lang('Anonymous') . ')' : '';
                $data[] = array('id' => $survey['id'], 'text' => strip_tags(html_entity_decode($survey['title'])));
            }
            if (!empty($data)) {
                echo json_encode($data);
            } else {
                echo json_encode(array());
            }
        }
        break;
    case 'display_sessions_courses':
        $sessionId = intval($_GET['session']);
        $userTable = Database::get_main_table(TABLE_MAIN_USER);
        $coursesData = SessionManager::get_course_list_by_session_id($sessionId);
        $courses = array();
        foreach ($coursesData as $courseId => $course) {
            $coachData = SessionManager::getCoachesByCourseSession($sessionId, $course['code']);
            $coachName = '';
            if (!empty($coachData)) {
                $userResult = Database::select('lastname,firstname', $userTable, array('where' => array('user_id = ?' => $coachData[0])), 'first');
                $coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']);
            }
            $courses[] = array('id' => $courseId, 'name' => $course['title'], 'coachName' => $coachName);
        }
        echo json_encode($courses);
        break;
    default:
        echo '';
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:course.ajax.php

示例7: change_user_session

 /**
  * Changes the user from one session to another due a reason
  * @params int user_id
  * @params int old session id
  * @params int new session id
  * @params int see SessionManager::get_session_change_user_reasons()
  */
 static function change_user_session($user_id, $old_session_id, $new_session_id, $reason_id)
 {
     if (!empty($user_id) && !empty($old_session_id) && !empty($new_session_id)) {
         $user_id = intval($user_id);
         $old_session_id = intval($old_session_id);
         $new_session_id = intval($new_session_id);
         $reason_id = intval($reason_id);
         $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
         $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
         // Update number of users
         $update_sql = "UPDATE {$tbl_session} SET nbr_users = nbr_users - 1 WHERE id = '{$old_session_id}' ";
         Database::query($update_sql);
         // Get the list of courses related to this session
         $course_list = SessionManager::get_course_list_by_session_id($old_session_id);
         if (!empty($course_list)) {
             foreach ($course_list as $course) {
                 $courseId = $course['id'];
                 // Delete user from course
                 //Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$session_id' AND course_code='$course_code' AND id_user='$user_id'");
                 //if (Database::affected_rows()) {
                 // Update number of users in this relation
                 $sql = "UPDATE {$tbl_session_rel_course} SET nbr_users = nbr_users - 1 WHERE id_session = '{$old_session_id}' AND c_id='{$courseId}'";
                 Database::query($sql);
                 //}
             }
         }
         //Deal with reasons
         switch ($reason_id) {
             case self::SESSION_CHANGE_USER_REASON_SCHEDULE:
             case self::SESSION_CHANGE_USER_REASON_CLASSROOM:
             case self::SESSION_CHANGE_USER_REASON_LOCATION:
                 //Adding to the new session
                 self::suscribe_users_to_session($new_session_id, array($user_id), null, false);
                 //Setting move_to if session was provided
                 $sql = "UPDATE {$tbl_session_rel_user} SET moved_to = '{$new_session_id}'\n                            WHERE id_session = '{$old_session_id}' AND id_user ='{$user_id}'";
                 Database::query($sql);
                 break;
             case self::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION:
                 UserManager::deactivate_users(array($user_id));
                 break;
         }
         $now = api_get_utc_datetime();
         //Setting the moved_status
         $sql = "UPDATE {$tbl_session_rel_user} SET moved_status = {$reason_id}, moved_at = '{$now}'\n                    WHERE id_session = '{$old_session_id}' AND id_user ='{$user_id}'";
         Database::query($sql);
         return true;
     }
     return;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:57,代码来源:sessionmanager.lib.php

示例8: elseif

                }
                if (count($certificateStudent['certificates']) > 0) {
                    $certificateStudents[] = $certificateStudent;
                }
            }
        }
    }
} elseif ($searchStudentOnly) {
    $selectedStudentInfo = api_get_user_info($selectedStudent);
    if (empty($selectedStudentInfo)) {
        Session::write('reportErrorMessage', get_lang('NoUser'));
        Header::location($selfUrl);
    }
    $sessionList = SessionManager::getSessionsFollowedByUser($selectedStudent);
    foreach ($sessionList as $session) {
        $sessionCourseList = SessionManager::get_course_list_by_session_id($session['id']);
        foreach ($sessionCourseList as $sessionCourse) {
            $gradebookCategories = Category::load(null, null, $sessionCourse['code'], null, false, $session['id']);
            $gradebook = null;
            if (!empty($gradebookCategories)) {
                $gradebook = current($gradebookCategories);
            }
            if (!is_null($gradebook)) {
                $sessionName = $session['name'];
                $courseName = $sessionCourse['title'];
                $certificateStudent = ['fullName' => $selectedStudentInfo['complete_name'], 'sessionName' => $sessionName, 'courseName' => $courseName, 'certificates' => []];
                $studentCertificates = GradebookUtils::get_list_gradebook_certificates_by_user_id($selectedStudent, $gradebook->get_id());
                if (!is_array($studentCertificates) || empty($studentCertificates)) {
                    continue;
                }
                foreach ($studentCertificates as $certificate) {
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:certificate_report.php

示例9: foreach

        $coaches = CourseManager::get_coachs_from_course($session['id'], $course['real_id']);
        if ($coaches) {
            foreach ($coaches as $coach) {
                $totalTime = UserManager::getTimeSpentInCourses($coach['user_id'], $course['real_id'], $session['id'], $selectedFrom, $selectedUntil);
                $formattedTime = api_format_time($totalTime);
                $timeReport->data[] = array('session' => array('id' => $session['id'], 'name' => $session['name']), 'course' => array('id' => $course['real_id'], 'name' => $course['title']), 'coach' => array('userId' => $coach['user_id'], 'lastname' => $coach['lastname'], 'firstname' => $coach['firstname'], 'username' => $coach['username'], 'completeName' => api_get_person_name($coach['firstname'], $coach['lastname'])), 'totalTime' => $formattedTime);
            }
        }
    }
}
if (!empty($selectedSession)) {
    $withFilter = true;
    $session = api_get_session_info($selectedSession);
    $sessionData = array('id' => $session['id'], 'name' => $session['name']);
    $reportTitle = sprintf(get_lang('TimeReportForSessionX'), $session['name']);
    $courses = SessionManager::get_course_list_by_session_id($selectedSession);
    foreach ($courses as $course) {
        $courseData = array('id' => $course['id'], 'name' => $course['title']);
        $coaches = CourseManager::get_coachs_from_course($selectedSession, $course['id']);
        if ($coaches) {
            foreach ($coaches as $coach) {
                $totalTime = UserManager::getTimeSpentInCourses($coach['user_id'], $course['id'], $selectedSession, $selectedFrom, $selectedUntil);
                $formattedTime = api_format_time($totalTime);
                $timeReport->data[] = array('session' => $sessionData, 'course' => $courseData, 'coach' => array('userId' => $coach['user_id'], 'lastname' => $coach['lastname'], 'firstname' => $coach['firstname'], 'username' => $coach['username'], 'completeName' => api_get_person_name($coach['firstname'], $coach['lastname'])), 'totalTime' => $formattedTime);
            }
        }
    }
}
if (!empty($selectedTeacher)) {
    $withFilter = true;
    $teacher = api_get_user_info();
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:teacher_time_report.php

示例10: searchCourses

function searchCourses($idSession, $type)
{
    $xajaxResponse = new xajaxResponse();
    $return = null;
    $courseCode = api_get_course_id();
    if (!empty($type)) {
        $idSession = intval($idSession);
        $courseList = SessionManager::get_course_list_by_session_id($idSession);
        $return .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" >';
        foreach ($courseList as $course) {
            $course_list_destination[] = $course['code'];
            if ($course['code'] != $courseCode) {
                continue;
            }
            $courseTitle = str_replace("'", "\\'", $course['title']);
            $return .= '<option value="' . $course['code'] . '" title="' . @htmlspecialchars($course['title'] . ' (' . $course['visual_code'] . ')', ENT_QUOTES, api_get_system_encoding()) . '">' . $course['title'] . ' (' . $course['visual_code'] . ')</option>';
        }
        $return .= '</select>';
        Session::write('course_list_destination', $course_list_destination);
        // Send response by ajax
        $xajaxResponse->addAssign('ajax_list_courses_destination', 'innerHTML', api_utf8_encode($return));
    }
    return $xajaxResponse;
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:24,代码来源:copy_course_session_selected.php

示例11: getParentsToString

                 $title = $courseInfo['title'];
                 if (!empty($courseInfo['category_code'])) {
                     $parents = getParentsToString($courseInfo['category_code']);
                     $title = $parents . $courseInfo['title'];
                 }
                 $results[] = array('id' => $courseInfo['id'], 'text' => $title);
             }
             echo json_encode($results);
         } else {
             echo json_encode(array());
         }
     }
     break;
 case 'search_course_by_session':
     if (api_is_platform_admin()) {
         $results = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']);
         //$results = SessionManager::get_sessions_list(array('s.name LIKE' => "%".$_REQUEST['q']."%"));
         $results2 = array();
         if (!empty($results)) {
             foreach ($results as $item) {
                 $item2 = array();
                 foreach ($item as $id => $internal) {
                     if ($id == 'id') {
                         $item2[$id] = $internal;
                     }
                     if ($id == 'title') {
                         $item2['text'] = $internal;
                     }
                 }
                 $results2[] = $item2;
             }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:course.ajax.php

示例12: isset

$data['termsRejected'] = isset($_REQUEST['r']) ? intval($_REQUEST['r']) : 0;
// Init template
$tpl = new Template($plugin->get_lang('plugin_title'));
$isAllowToDoRequest = $plugin->isAllowedToDoRequest($data['studentUserId'], $data, true);
if (!$isAllowToDoRequest) {
    $tpl->assign('errorMessages', $plugin->getErrorMessages());
}
if (!empty($data['sessionId']) && !empty($data['studentUserId']) && api_get_plugin_setting('courselegal', 'tool_enable')) {
    $lastMessageId = $plugin->getLastMessageId($data['studentUserId'], $data['sessionId']);
    if ($lastMessageId !== false) {
        // Render mail
        $url = $plugin->getRenderMailUrl(array('queueId' => $lastMessageId));
        header('Location: ' . $url);
        exit;
    }
    $courses = SessionManager::get_course_list_by_session_id($data['sessionId']);
    $course = current($courses);
    $data['courseId'] = $course['id'];
    $legalEnabled = api_get_plugin_setting('courselegal', 'tool_enable');
    if ($legalEnabled) {
        $courseLegal = CourseLegalPlugin::create();
        $termsAndConditions = $courseLegal->getData($data['courseId'], $data['sessionId']);
        $termsAndConditions = $termsAndConditions['content'];
        $termFiles = $courseLegal->getCurrentFile($data['courseId'], $data['sessionId']);
    } else {
        $termsAndConditions = $plugin->get('terms_and_conditions');
        $termFiles = '';
    }
    $data['session'] = api_get_session_info($data['sessionId']);
    $data['student'] = api_get_user_info($data['studentUserId']);
    $data['course'] = api_get_course_info_by_id($data['courseId']);
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:terms_and_conditions.php

示例13: getSessionStars

 /**
  * Get the number of stars achieved for an user in a session
  * @param int $sessionId The session ID
  * @param int $userId The user ID
  *
  * @return int The number of stars
  */
 public static function getSessionStars($sessionId, $userId)
 {
     $totalStars = 0;
     $courses = SessionManager::get_course_list_by_session_id($sessionId);
     if (empty($courses)) {
         return 0;
     }
     foreach ($courses as $course) {
         $learnPathListObject = new LearnpathList($userId, $course['code'], $sessionId);
         $learnPaths = $learnPathListObject->get_flat_list();
         if (empty($learnPaths)) {
             continue;
         }
         $stars = 0;
         foreach ($learnPaths as $learnPathId => $learnPathInfo) {
             if (empty($learnPathInfo['seriousgame_mode'])) {
                 continue;
             }
             $learnPath = new learnpath($course['code'], $learnPathId, $userId);
             $stars += $learnPath->getCalculateStars($sessionId);
         }
         $totalStars += round($stars / count($learnPaths));
     }
     return round($totalStars / count($courses));
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:32,代码来源:GamificationUtils.php

示例14: get_courses_list_by_session

 /**
  * Gives a list of courses for the given user in the given session
  * @param integer $user_id
  * @return array  list of statuses (session_id-course_code => status)
  */
 public static function get_courses_list_by_session($user_id, $session_id)
 {
     // Database Table Definitions
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $user_id = intval($user_id);
     $session_id = intval($session_id);
     //we filter the courses from the URL
     $join_access_url = $where_access_url = '';
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
             $join_access_url = " ,  {$tbl_url_session} url_rel_session ";
             $where_access_url = " AND access_url_id = {$access_url_id} AND url_rel_session.session_id = {$session_id} ";
         }
     }
     $personal_course_list = array();
     $courses = array();
     // this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
     $personal_course_list_sql = "SELECT DISTINCT scu.c_id as id\n                                    FROM {$tbl_session_course_user} as scu {$join_access_url}\n                                    WHERE scu.id_user = {$user_id} AND scu.id_session = {$session_id} {$where_access_url}\n                                    ORDER BY c_id";
     $course_list_sql_result = Database::query($personal_course_list_sql);
     if (Database::num_rows($course_list_sql_result) > 0) {
         while ($result_row = Database::fetch_array($course_list_sql_result)) {
             $result_row['status'] = 5;
             if (!in_array($result_row['id'], $courses)) {
                 $personal_course_list[] = $result_row;
                 $courses[] = $result_row['id'];
             }
         }
     }
     if (api_is_allowed_to_create_course()) {
         $personal_course_list_sql = "SELECT DISTINCT scu.c_id as id\n                                        FROM {$tbl_session_course_user} as scu, {$tbl_session} as s {$join_access_url}\n                                        WHERE s.id = {$session_id} AND scu.id_session = s.id AND ((scu.id_user={$user_id} AND scu.status=2) OR s.id_coach = {$user_id})\n                                        {$where_access_url}\n                                        ORDER BY c_id";
         $course_list_sql_result = Database::query($personal_course_list_sql);
         if (Database::num_rows($course_list_sql_result) > 0) {
             while ($result_row = Database::fetch_array($course_list_sql_result)) {
                 $result_row['status'] = 2;
                 if (!in_array($result_row['id'], $courses)) {
                     $personal_course_list[] = $result_row;
                     $courses[] = $result_row['id'];
                 }
             }
         }
     }
     if (api_is_drh()) {
         $session_list = SessionManager::get_sessions_followed_by_drh($user_id);
         $session_list = array_keys($session_list);
         if (in_array($session_id, $session_list)) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     $personal_course_list[] = $course;
                 }
             }
         }
     } else {
         //check if user is general coach for this session
         $s = api_get_session_info($session_id);
         if ($s['id_coach'] == $user_id) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     if (!in_array($course['id'], $courses)) {
                         $personal_course_list[] = $course;
                     }
                 }
             }
         }
     }
     return $personal_course_list;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:76,代码来源:usermanager.lib.php

示例15: getCoursesFollowedByUser

 /**
  * get courses followed by user
  * @param   int $user_id
  * @param   int $status
  * @param   int $from
  * @param   int $limit
  * @param   string $column
  * @param   string $direction
  * @param   boolean $getCount
  * @param   string $keyword
  * @param   int $sessionId
  * @param   boolean $showAllAssignedCourses
  * @return  array   courses
  */
 public static function getCoursesFollowedByUser($user_id, $status = null, $from = null, $limit = null, $column = null, $direction = null, $getCount = false, $keyword = null, $sessionId = null, $showAllAssignedCourses = false)
 {
     // Database Table Definitions
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     $sessionId = intval($sessionId);
     $user_id = intval($user_id);
     $select = "SELECT DISTINCT *, c.id as real_id ";
     if ($getCount) {
         $select = "SELECT COUNT(DISTINCT c.id) as count";
     }
     $whereConditions = null;
     switch ($status) {
         case COURSEMANAGER:
             $whereConditions .= " AND cru.user_id = '{$user_id}'";
             if (!$showAllAssignedCourses) {
                 $whereConditions .= " AND status = " . COURSEMANAGER;
             } else {
                 $whereConditions .= " AND relation_type = " . COURSE_RELATION_TYPE_COURSE_MANAGER;
             }
             break;
         case DRH:
             $whereConditions .= " AND\n                    cru.user_id = '{$user_id}' AND\n                    status = " . DRH . " AND\n                    relation_type = '" . COURSE_RELATION_TYPE_RRHH . "'\n                ";
             break;
     }
     $keywordCondition = null;
     if (!empty($keyword)) {
         $keyword = Database::escape_string($keyword);
         $keywordCondition = " AND (c.code LIKE '%{$keyword}%' OR c.title LIKE '%{$keyword}%' ) ";
     }
     $orderBy = null;
     $extraInnerJoin = null;
     if (!empty($sessionId)) {
         if (!empty($sessionId)) {
             $courseList = SessionManager::get_course_list_by_session_id($sessionId);
             if (!empty($courseList)) {
                 $courseListToString = implode("','", array_keys($courseList));
                 $whereConditions .= " AND c.id IN ('" . $courseListToString . "')";
             }
             $tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
             $orderBy = ' ORDER BY position';
             $extraInnerJoin = " INNER JOIN {$tableSessionRelCourse} src\n                                    ON (c.id = src.c_id AND session_id = {$sessionId}) ";
         }
     }
     $whereConditions .= $keywordCondition;
     $sql = "{$select}\n                FROM {$tbl_course} c\n                    INNER JOIN {$tbl_course_rel_user} cru ON (cru.c_id = c.id)\n                    INNER JOIN {$tbl_course_rel_access_url} a ON (a.c_id = c.id)\n                    {$extraInnerJoin}\n                WHERE\n                    access_url_id = " . api_get_current_access_url_id() . "\n                    {$whereConditions}\n                {$orderBy}\n                ";
     if (isset($from) && isset($limit)) {
         $from = intval($from);
         $limit = intval($limit);
         $sql .= " LIMIT {$from}, {$limit}";
     }
     $result = Database::query($sql);
     if ($getCount) {
         $row = Database::fetch_array($result);
         return $row['count'];
     }
     $courses = array();
     if (Database::num_rows($result) > 0) {
         while ($row = Database::fetch_array($result)) {
             $courses[$row['code']] = $row;
         }
     }
     return $courses;
 }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:79,代码来源:course.lib.php


注:本文中的SessionManager::get_course_list_by_session_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。