本文整理汇总了PHP中CourseManager::update_attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::update_attributes方法的具体用法?PHP CourseManager::update_attributes怎么用?PHP CourseManager::update_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::update_attributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: restore_course_settings
/**
* Restore only harmless course settings: course_language, visibility, department_name,department_url, subscribe, unsubscribe ,category_code
*
* @return unknown_type
*/
function restore_course_settings($destination_course_code)
{
$origin_course_info = api_get_course_info($destination_course_code);
$course_info = $this->course->info;
$params['course_language'] = $course_info['language'];
$params['visibility'] = $course_info['visibility'];
$params['department_name'] = $course_info['department_name'];
$params['department_url'] = $course_info['department_url'];
$params['category_code'] = $course_info['categoryCode'];
$params['subscribe'] = $course_info['subscribe_allowed'];
$params['unsubscribe'] = $course_info['unsubscribe'];
CourseManager::update_attributes($origin_course_info['real_id'], $params);
}
示例3: importCourses
/**
* @param string $file
*/
private function importCourses($file)
{
$data = Import::csv_to_array($file);
//$language = $this->defaultLanguage;
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($row['course_code']);
$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']);
$result = CourseManager::update_attributes($courseInfo['real_id'], $params);
//CourseManager::updateTeachers($courseInfo['id'], $row['teachers']);
if ($result) {
$this->logger->addInfo("Courses - Course updated " . $courseInfo['code']);
} else {
$this->logger->addError("Courses - Course NOT updated " . $courseInfo['code']);
}
}
}
}
$this->moveFile($file);
}
示例4: editCourseHelper
/**
* Edits a course (helper method)
*
* @param string Course id field name
* @param string Course id value
* @param string Title
* @param string Category code
* @param string Department name
* @param string Department url
* @param string Course language
* @param int Visibility
* @param int Subscribe (0 = denied, 1 = allowed)
* @param int Unsubscribe (0 = denied, 1 = allowed)
* @param string Visual code
* @param array Course extra fields
* @return mixed True in case of success, WSError otherwise
*/
protected function editCourseHelper($course_id_field_name, $course_id_value, $title, $category_code, $department_name, $department_url, $language, $visibility, $subscribe, $unsubscribe, $visual_code, $extras) {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) {
return $course_id;
} else {
$attributes = array();
if(!is_empty($title)) {
$attributes['title'] = $title;
}
if(!is_empty($category_code)) {
$attributes['category_code'] = $category_code;
}
if(!is_empty($department_name)) {
$attributes['department_name'] = $department_name;
}
if(!is_empty($department_url)) {
$attributes['department_url'] = $department_url;
}
if(!is_empty($language)) {
$attributes['course_language'] = $language;
}
if($visibility != '') {
$attributes['visibility'] = (int)$visibility;
}
if($subscribe != '') {
$attributes['subscribe'] = (int)$subscribe;
}
if($unsubscribe != '') {
$attributes['unsubscribe'] = (int)$unsubscribe;
}
if(!is_empty($visual_code)) {
$attributes['visual_code'] = $visual_code;
}
if(!is_empty($attributes)) {
CourseManager::update_attributes($course_id, $attributes);
}
if(!empty($extras)) {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
$extras_associative = array();
foreach($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
foreach($extras_associative as $fname => $fvalue) {
CourseManager::update_extra_field_value($course_code, $fname, $fvalue);
}
}
return true;
}
}
示例5: 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);
}
}