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


PHP SessionManager::getCoachesByCourseSession方法代码示例

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


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

示例1: while

            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 '';
}
exit;
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:course.ajax.php

示例2: array

$element = $form->addElement('text', 'real_code', array(get_lang('CourseCode'), get_lang('ThisValueCantBeChanged')));
$element->freeze();
// Visual code
$form->addText('visual_code', array(get_lang('VisualCode'), get_lang('OnlyLettersAndNumbers'), get_lang('ThisValueIsUsedInTheCourseURL')), true, ['maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')]);
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addElement('advmultiselect', 'course_teachers', get_lang('CourseTeachers'), $allTeachers);
$courseInfo['course_teachers'] = $course_teachers;
if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
    $form->addElement('checkbox', 'add_teachers_to_sessions_courses', null, get_lang('TeachersWillBeAddedAsCoachInAllCourseSessions'));
}
$coursesInSession = SessionManager::get_session_by_course($courseInfo['real_id']);
if (!empty($coursesInSession)) {
    foreach ($coursesInSession as $session) {
        $sessionId = $session['id'];
        $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseInfo['real_id']);
        $teachers = $allTeachers;
        $sessionTeachers = array();
        foreach ($coaches as $coachId) {
            $userInfo = api_get_user_info($coachId);
            $sessionTeachers[] = $coachId;
            if (isset($teachers[$coachId])) {
                unset($teachers[$coachId]);
            }
        }
        $groupName = 'session_coaches[' . $sessionId . ']';
        $platformTeacherId = 'platform_teachers_by_session_' . $sessionId;
        $coachId = 'coaches_by_session_' . $sessionId;
        $platformTeacherName = 'platform_teachers_by_session';
        $coachName = 'coaches_by_session';
        $sessionUrl = api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $sessionId;
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:course_edit.php

示例3: importCSV


//.........这里部分代码省略.........
                         }
                         // Custom courses/session coaches
                         $teacherToAdd = null;
                         // Only one coach is added.
                         if ($onlyAddFirstCoachOrTeacher == true) {
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     $teacherToAdd = $coach_id;
                                     break;
                                 }
                             }
                             // Un subscribe everyone that's not in the list.
                             $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
                             if (!empty($teacherList)) {
                                 foreach ($teacherList as $teacher) {
                                     if ($teacherToAdd != $teacher['user_id']) {
                                         CourseManager::unsubscribe_user($teacher['user_id'], $course_code);
                                     }
                                 }
                             }
                             if (!empty($teacherToAdd)) {
                                 SessionManager::updateCoaches($session_id, $courseId, array($teacherToAdd), true);
                                 CourseManager::subscribe_user($teacherToAdd, $course_code, COURSEMANAGER);
                             }
                         }
                         // See BT#6449#note-195
                         // All coaches are added.
                         if ($removeAllTeachersFromCourse) {
                             $teacherToAdd = null;
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     $teacherToAdd[] = $coach_id;
                                 }
                             }
                             if (!empty($teacherToAdd)) {
                                 // Deleting all course teachers and adding the only coach as teacher.
                                 $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
                                 if (!empty($teacherList)) {
                                     foreach ($teacherList as $teacher) {
                                         if (!in_array($teacher['user_id'], $teacherToAdd)) {
                                             CourseManager::unsubscribe_user($teacher['user_id'], $course_code);
                                         }
                                     }
                                 }
                                 foreach ($teacherToAdd as $teacherId) {
                                     CourseManager::subscribe_user($teacherId, $course_code, COURSEMANAGER);
                                 }
                             }
                         }
                         // Continue default behaviour.
                         if ($onlyAddFirstCoachOrTeacher == false) {
                             // Checking one more time see BT#6449#note-149
                             $coaches = SessionManager::getCoachesByCourseSession($session_id, $courseId);
                             // Update coaches if only there's 1 course see BT#6449#note-189
                             if (empty($coaches) || count($courses) == 1) {
                                 foreach ($course_coaches as $course_coach) {
                                     $course_coach = trim($course_coach);
                                     $coach_id = UserManager::get_user_id_from_username($course_coach);
                                     if ($coach_id !== false) {
                                         // Just insert new coaches
                                         SessionManager::updateCoaches($session_id, $courseId, array($coach_id), false);
                                         if ($debug) {
                                             $logger->addInfo("Sessions - Adding course coach: user #{$coach_id} ({$course_coach}) to course: '{$course_code}' and session #{$session_id}");
                                         }
                                         $savedCoaches[] = $coach_id;
                                     } else {
                                         $error_message .= get_lang('UserDoesNotExist') . ' : ' . $course_coach . $eol;
                                     }
                                 }
                             }
                         }
                     }
                     // Adding Students, updating relationship "Session - Course - User".
                     $course_users = array_filter($course_users);
                     if (!empty($course_users)) {
                         foreach ($course_users as $user) {
                             $user_id = UserManager::get_user_id_from_username($user);
                             if ($user_id !== false) {
                                 SessionManager::subscribe_users_to_session_course(array($user_id), $session_id, $course_code);
                                 if ($debug) {
                                     $logger->addInfo("Sessions - Adding student: user #{$user_id} ({$user}) to course: '{$course_code}' and session #{$session_id}");
                                 }
                             } else {
                                 $error_message .= get_lang('UserDoesNotExist') . ': ' . $user . $eol;
                             }
                         }
                     }
                     $inserted_in_course[$course_code] = $courseInfo['title'];
                 }
             }
             $access_url_id = api_get_current_access_url_id();
             UrlManager::add_session_to_url($session_id, $access_url_id);
             $sql = "UPDATE {$tbl_session} SET nbr_users = '{$user_counter}', nbr_courses = '{$course_counter}' WHERE id = '{$session_id}'";
             Database::query($sql);
         }
     }
     return array('error_message' => $error_message, 'session_counter' => $session_counter, 'session_list' => $sessionList);
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:sessionmanager.lib.php

示例4: while

            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, $courseId);
            $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 '';
}
exit;
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:31,代码来源:course.ajax.php

示例5: addWorkComment

/**
 * Adds a comments to the work document
 * @param array $courseInfo
 * @param int $userId
 * @param array $work
 * @param array $data
 * @return int
 */
function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
{
    if (ADD_DOCUMENT_TO_WORK == false) {
        return null;
    }

    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);

    $params = array(
        'work_id' => $work['id'],
        'c_id' => $work['c_id'],
        'user_id' => $userId,
        'comment' => $data['comment'],
        'sent_at' => api_get_utc_datetime()
    );

    $commentId = Database::insert($commentTable, $params);

    $userIdListToSend = array();

    if (api_is_allowed_to_edit()) {
        if (isset($data['send_mail']) && $data['send_mail']) {
            // Teacher sends a feedback
            $userIdListToSend = array($work['user_id']);
        }
    } else {
        $sessionId = api_get_session_id();
        if (empty($sessionId)) {
            $teachers = CourseManager::get_teacher_list_from_course_code(
                $courseInfo['code']
            );
            if (!empty($teachers)) {
                $userIdListToSend = array_keys($teachers);
            }
        } else {
            $teachers = SessionManager::getCoachesByCourseSession(
                $sessionId,
                $courseInfo['code']
            );

            if (!empty($teachers)) {
                $userIdListToSend = array_values($teachers);
            }
        }
    }

    $url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$work['id'];
    $subject = sprintf(get_lang('ThereIsANewWorkFeedback'), $parentWork['title']);
    $content = sprintf(get_lang('ThereIsANewWorkFeedbackInWorkXHere'), $work['title'], $url);

    if (!empty($userIdListToSend)) {
        foreach ($userIdListToSend as $userId) {
            MessageManager::send_message_simple(
                $userId,
                $subject,
                $content
            );
        }
    }

    $fileData = isset($data['file']) ? $data['file'] : null;
    if (!empty($commentId) && !empty($fileData)) {
        $workParent = get_work_data_by_id($work['parent_id']);
        if (!empty($workParent)) {
            $uploadDir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work'.$workParent['url'];
            $newFileName = 'comment_'.$commentId.'_'.php2phps(
                replace_dangerous_char($fileData['name'], 'strict')
            );
            $newFilePath = $uploadDir.'/'.$newFileName;
            $result = move_uploaded_file($fileData['tmp_name'], $newFilePath);
            if ($result) {
                $params = array('file' => $newFileName);
                Database::update(
                    $commentTable,
                    $params,
                    array('id = ? AND c_id = ? ' => array($commentId, $work['c_id']))
                );
            }
        }
    }
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:89,代码来源:work.lib.php

示例6: WSUnsubscribeTeacherFromSessionCourse

/**
 * Subscribe teacher to a session course
 *
 *  @param array $params - WSFunction parameters (include VerifyKey)
 *  @return bool|null|soap_fault A simple boolean (true if teacher successful unsubscribed, false otherwise)
 */
function WSUnsubscribeTeacherFromSessionCourse($params)
{
    global $debug;
    if ($debug) {
        error_log('WSSubscribeTeacherToSessionCourse');
    }
    if (!WSHelperVerifyKey($params)) {
        return returnError(WS_ERROR_SECRET_KEY);
    }
    if ($debug) {
        error_log('Params ' . print_r($params, 1));
    }
    $params = parseCourseSessionUserParams($params);
    $userId = $params['user_id'];
    $courseId = $params['course_id'];
    $sessionId = $params['session_id'];
    SessionManager::removeUsersFromCourseSession([$userId], $sessionId, $courseId);
    $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseId);
    $result = 0;
    if (!empty($coaches)) {
        if ($debug) {
            error_log('Coaches:  ' . print_r($coaches, 1));
        }
        if (!in_array($userId, $coaches)) {
            $result = 1;
        }
    } else {
        $result = 1;
    }
    if ($debug) {
        error_log('Final Result: ' . $result);
    }
    return $result;
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:40,代码来源:registration.soap.php


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