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


PHP CourseManager::update_course_extra_field_value方法代码示例

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


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

示例1: WSEditCourse

function WSEditCourse($params)
{
    global $_configuration;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
    $courses_params = $params['courses'];
    $results = array();
    $orig_course_id_value = array();
    foreach ($courses_params as $course_param) {
        $tutor_id = $course_param['tutor_id'];
        $title = $course_param['title'];
        $category_code = $course_param['category_code'];
        $department_name = $course_param['department_name'];
        $department_url = $course_param['department_url'];
        $course_language = $course_param['course_language'];
        $visibility = $course_param['visibility'];
        $subscribe = $course_param['subscribe'];
        $unsubscribe = $course_param['unsubscribe'];
        $visual_code = $course_param['visual_code'];
        $original_course_id_name = $course_param['original_course_id_name'];
        $original_course_id_value = $course_param['original_course_id_value'];
        $orig_course_id_value[] = $original_course_id_value;
        $extra_list = $course_param['extra'];
        $courseInfo = CourseManager::getCourseInfoFromOriginalId($original_course_id_value, $original_course_id_name);
        if (empty($courseInfo)) {
            $results[] = 0;
            // Original_course_id_value doesn't exist.
            continue;
        }
        $course_code = $courseInfo['code'];
        $courseId = $courseInfo['real_id'];
        $table_user = Database::get_main_table(TABLE_MAIN_USER);
        $sql = "SELECT concat(lastname,'',firstname) as tutor_name\n                FROM {$table_user} WHERE status='1' AND user_id = '{$tutor_id}'\n                ORDER BY lastname,firstname";
        $res = Database::query($sql);
        $tutor_name = Database::fetch_row($res);
        $dbnamelength = strlen($_configuration['db_prefix']);
        $maxlength = 40 - $dbnamelength;
        if (empty($visual_code)) {
            $visual_code = CourseManager::generate_course_code(substr($title, 0, $maxlength));
        }
        $disk_quota = '50000';
        // TODO: A hard-coded value.
        $tutor_name = $tutor_name[0];
        $sql = "UPDATE {$course_table} SET\n                    course_language='" . Database::escape_string($course_language) . "',\n                    title='" . Database::escape_string($title) . "',\n                    category_code='" . Database::escape_string($category_code) . "',\n                    tutor_name='" . Database::escape_string($tutor_name) . "',\n                    visual_code='" . Database::escape_string($visual_code) . "',\n                    department_name='" . Database::escape_string($department_name) . "',\n                    department_url='" . Database::escape_string($department_url) . "',\n                    disk_quota='" . Database::escape_string($disk_quota) . "',\n                    visibility = '" . Database::escape_string($visibility) . "',\n                    subscribe = '" . Database::escape_string($subscribe) . "',\n                    unsubscribe='" . Database::escape_string($unsubscribe) . "'\n                WHERE id ='" . Database::escape_string($courseId) . "'";
        $res = Database::query($sql);
        if (is_array($extra_list) && count($extra_list) > 0) {
            foreach ($extra_list as $extra) {
                $extra_field_name = $extra['field_name'];
                $extra_field_value = $extra['field_value'];
                // Save the external system's id into course_field_value table.
                $res = CourseManager::update_course_extra_field_value($course_code, $extra_field_name, $extra_field_value);
            }
        }
        if ($res) {
            $results[] = 1;
            continue;
        } else {
            $results[] = 0;
            continue;
        }
    }
    // end principal foreach
    $count_results = count($results);
    $output = array();
    for ($i = 0; $i < $count_results; $i++) {
        $output[] = array('original_course_id_value' => $orig_course_id_value[$i], 'result' => $results[$i]);
    }
    return $output;
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:71,代码来源:registration.soap.php

示例2: 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);
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:69,代码来源:import_csv.php

示例3: createCourseHelper

	/**
	 * Creates a course (helper method)
	 *
	 * @param string Title
	 * @param string Category code
	 * @param string Wanted code. If it's not defined, it will be generated automatically
	 * @param string Tutor name
	 * @param string Course admin user id field name
	 * @param string Course admin user id value
	 * @param string Course language
	 * @param string Course id field name
	 * @param string Course id value
	 * @param array Course extra fields
	 * @return mixed Generated id if creation was successful, WSError otherwise
	 */
	protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
		// Add the original course id field name and value to the extra fields if needed
		$extras_associative = array();
		if($course_id_field_name != "chamilo_course_id") {
			$extras_associative[$course_id_field_name] = $course_id_value;
		}
		foreach($extras as $extra) {
			$extras_associative[$extra['field_name']] = $extra['field_value'];
		}
		$course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value);
		if($course_admin_id instanceof WSError) {
			return $course_admin_id;
		}
		if($wanted_code == '') {
			$wanted_code = generate_course_code($title);
		}
		$result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0);
		if (!$result) {
			return new WSError(202, 'There was an error creating the course');
		} else {
			// Update extra fields
			foreach($extras_associative as $fname => $fvalue) {
				CourseManager::update_course_extra_field_value($result, $fname, $fvalue);
			}
			// Get course id
			$course_info = CourseManager::get_course_information($result);
			return $course_info['id'];
		}
	}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:44,代码来源:webservice_course.php

示例4: foreach

 $department_name = $course['department_name'];
 $department_url = $course['department_url'];
 $course_language = $course['course_language'];
 $course['disk_quota'] = $course['disk_quota'] * 1024 * 1024;
 $disk_quota = $course['disk_quota'];
 $subscribe = $course['subscribe'];
 $unsubscribe = $course['unsubscribe'];
 if (!stristr($department_url, 'http://')) {
     $department_url = 'http://' . $department_url;
 }
 $sql = "UPDATE {$course_table} SET course_language='" . Database::escape_string($course_language) . "',\n                title='" . Database::escape_string($title) . "',\n                category_code='" . Database::escape_string($category_code) . "',\n                tutor_name='" . Database::escape_string($tutor_name) . "',\n                visual_code='" . Database::escape_string($visual_code) . "',\n                department_name='" . Database::escape_string($department_name) . "',\n                department_url='" . Database::escape_string($department_url) . "',\n                disk_quota='" . Database::escape_string($disk_quota) . "',\n                visibility = '" . Database::escape_string($visibility) . "',\n                subscribe = '" . Database::escape_string($subscribe) . "',\n                unsubscribe='" . Database::escape_string($unsubscribe) . "'\n            WHERE code='" . Database::escape_string($course_code) . "'";
 Database::query($sql);
 // update the extra fields
 if (count($extras) > 0) {
     foreach ($extras as $key => $value) {
         CourseManager::update_course_extra_field_value($course_code, $key, $value);
     }
 }
 $addTeacherToSessionCourses = isset($course['add_teachers_to_sessions_courses']) && !empty($course['add_teachers_to_sessions_courses']) ? 1 : 0;
 // Updating teachers
 if ($addTeacherToSessionCourses) {
     // Updating session coaches
     $sessionCoaches = $course['session_coaches'];
     if (!empty($sessionCoaches)) {
         foreach ($sessionCoaches as $sessionId => $teacherInfo) {
             $coachesToSubscribe = $teacherInfo['coaches_by_session'];
             SessionManager::updateCoaches($sessionId, $course['code'], $coachesToSubscribe, true);
         }
     }
     CourseManager::updateTeachers($course_code, $teachers, false, true, false);
 } else {
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:course_edit.php

示例5: 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);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:45,代码来源:import_csv.php

示例6: 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);
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:51,代码来源:import_csv.php


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