本文整理汇总了PHP中CourseManager::updateTeachers方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::updateTeachers方法的具体用法?PHP CourseManager::updateTeachers怎么用?PHP CourseManager::updateTeachers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::updateTeachers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importCourses
/**
* @param string $file
* @param bool $moveFile
* @param array $teacherBackup
* @param array $groupBackup
*/
private function importCourses($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array())
{
$data = Import::csv_to_array($file);
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$row = $this->cleanCourseRow($row);
$courseCode = CourseManager::get_course_id_from_original_id($row['extra_' . $this->extraFieldIdNameList['course']], $this->extraFieldIdNameList['course']);
$courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
// Create
$params = array();
$params['title'] = $row['title'];
$params['exemplary_content'] = false;
$params['wanted_code'] = $row['course_code'];
$params['course_category'] = $row['course_category'];
$params['course_language'] = $row['language'];
$params['teachers'] = $row['teachers'];
$courseInfo = CourseManager::create_course($params);
if (!empty($courseInfo)) {
CourseManager::update_course_extra_field_value($courseInfo['code'], 'external_course_id', $row['extra_' . $this->extraFieldIdNameList['course']]);
$this->logger->addInfo("Courses - Course created " . $courseInfo['code']);
} else {
$this->logger->addError("Courses - Can't create course:" . $row['title']);
}
} else {
// Update
$params = array('title' => $row['title'], 'category_code' => $row['course_category']);
$result = CourseManager::update_attributes($courseInfo['real_id'], $params);
$addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
$teachers = $row['teachers'];
if (!is_array($teachers)) {
$teachers = array($teachers);
}
if ($addTeacherToSession) {
CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, true, false, $teacherBackup);
} else {
CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, false, false, $teacherBackup);
}
foreach ($teachers as $teacherId) {
if (isset($groupBackup['tutor'][$teacherId]) && isset($groupBackup['tutor'][$teacherId][$courseInfo['code']])) {
foreach ($groupBackup['tutor'][$teacherId][$courseInfo['code']] as $data) {
GroupManager::subscribe_tutors(array($teacherId), $data['group_id'], $data['c_id']);
}
}
if (isset($groupBackup['user'][$teacherId]) && isset($groupBackup['user'][$teacherId][$courseInfo['code']]) && !empty($groupBackup['user'][$teacherId][$courseInfo['code']])) {
foreach ($groupBackup['user'][$teacherId][$courseInfo['code']] as $data) {
GroupManager::subscribe_users(array($teacherId), $data['group_id'], $data['c_id']);
}
}
}
if ($result) {
$this->logger->addInfo("Courses - Course updated " . $courseInfo['code']);
} else {
$this->logger->addError("Courses - Course NOT updated " . $courseInfo['code']);
}
}
}
}
if ($moveFile) {
$this->moveFile($file);
}
}
示例2: copyCoachesFromSessionToCourse
/**
* Assign coaches of a session(s) as teachers to a given course (or courses)
* @param array A list of session IDs
* @param array A list of course IDs
* @return string
*/
public static function copyCoachesFromSessionToCourse($sessions, $courses)
{
$coachesPerSession = array();
foreach ($sessions as $sessionId) {
$coaches = self::getCoachesBySession($sessionId);
$coachesPerSession[$sessionId] = $coaches;
}
$result = array();
if (!empty($courses)) {
foreach ($courses as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId);
foreach ($coachesPerSession as $sessionId => $coachList) {
CourseManager::updateTeachers($courseInfo['real_id'], $coachList, false, false, false);
$result[$courseInfo['code']][$sessionId] = $coachList;
}
}
}
$sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=';
$htmlResult = null;
if (!empty($result)) {
foreach ($result as $courseCode => $data) {
$url = api_get_course_url($courseCode);
$htmlResult .= sprintf(get_lang('CoachesSubscribedAsATeacherInCourseX'), Display::url($courseCode, $url, array('target' => '_blank')));
foreach ($data as $sessionId => $coachList) {
$sessionInfo = self::fetch($sessionId);
$htmlResult .= '<br />';
$htmlResult .= Display::url(get_lang('Session') . ': ' . $sessionInfo['name'] . ' <br />', $sessionUrl . $sessionId, array('target' => '_blank'));
$teacherList = array();
foreach ($coachList as $coachId) {
$userInfo = api_get_user_info($coachId);
$teacherList[] = $userInfo['complete_name'];
}
if (!empty($teacherList)) {
$htmlResult .= implode(', ', $teacherList);
} else {
$htmlResult .= get_lang('NothingToAdd');
}
}
$htmlResult .= '<br />';
}
$htmlResult = Display::return_message($htmlResult, 'normal', false);
}
return $htmlResult;
}
示例3: ExtraFieldValue
$courseFieldValue = new ExtraFieldValue('course');
$courseFieldValue->saveFieldValues($course);
$addTeacherToSessionCourses = isset($course['add_teachers_to_sessions_courses']) && !empty($course['add_teachers_to_sessions_courses']) ? 1 : 0;
$sessionCoaches = isset($course['session_coaches']) ? $course['session_coaches'] : '';
// Updating teachers
if ($addTeacherToSessionCourses) {
if (!empty($sessionCoaches)) {
foreach ($sessionCoaches as $sessionId => $teacherInfo) {
$coachesToSubscribe = $teacherInfo['coaches_by_session'];
SessionManager::updateCoaches($sessionId, $courseId, $coachesToSubscribe, true);
}
}
CourseManager::updateTeachers($courseId, $teachers, true, true, false);
} else {
// Normal behaviour
CourseManager::updateTeachers($courseId, $teachers, true, false);
// Updating session coaches
$sessionCoaches = $course['session_coaches'];
if (!empty($sessionCoaches)) {
foreach ($sessionCoaches as $sessionId => $coachesToSubscribe) {
if (!empty($coachesToSubscribe)) {
SessionManager::updateCoaches($sessionId, $courseId, $coachesToSubscribe, true);
}
}
}
}
if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
$sql = "UPDATE {$course_table} SET\n add_teachers_to_sessions_courses = '{$addTeacherToSessionCourses}'\n WHERE id = " . $courseInfo['real_id'];
Database::query($sql);
}
$course_id = $courseInfo['real_id'];
示例4: importCourses
/**
* @param string $file
* @param bool $moveFile
*/
private function importCourses($file, $moveFile = true)
{
$data = Import::csvToArray($file);
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$row = $this->cleanCourseRow($row);
$courseId = CourseManager::getCourseInfoFromOriginalId($row['extra_' . $this->extraFieldIdNameList['course']], $this->extraFieldIdNameList['course']);
$courseInfo = api_get_course_info_by_id($courseId);
if (empty($courseInfo)) {
// Create
$params = array();
$params['title'] = $row['title'];
$params['exemplary_content'] = false;
$params['wanted_code'] = $row['course_code'];
$params['course_category'] = $row['course_category'];
$params['course_language'] = $row['language'];
$params['teachers'] = $row['teachers'];
$courseInfo = CourseManager::create_course($params);
if (!empty($courseInfo)) {
CourseManager::update_course_extra_field_value($courseInfo['code'], 'external_course_id', $row['extra_' . $this->extraFieldIdNameList['course']]);
$this->logger->addInfo("Courses - Course created " . $courseInfo['code']);
} else {
$this->logger->addError("Courses - Can't create course:" . $row['title']);
}
} else {
// Update
$params = array('title' => $row['title']);
$result = CourseManager::update_attributes($courseInfo['real_id'], $params);
$addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
if ($addTeacherToSession) {
CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, true, false);
} else {
CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, false);
}
if ($result) {
$this->logger->addInfo("Courses - Course updated " . $courseInfo['code']);
} else {
$this->logger->addError("Courses - Course NOT updated " . $courseInfo['code']);
}
}
}
}
if ($moveFile) {
$this->moveFile($file);
}
}