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


PHP CourseManager::create_course_extra_field方法代码示例

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


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

示例1: prepareImport

 /**
  * Prepares extra fields before the import
  */
 private function prepareImport()
 {
     // Create user extra field: extra_external_user_id
     UserManager::create_extra_field($this->extraFieldIdNameList['user'], 1, 'External user id', null);
     // Create course extra field: extra_external_course_id
     CourseManager::create_course_extra_field($this->extraFieldIdNameList['course'], 1, 'External course id');
     // Create session extra field extra_external_session_id
     SessionManager::create_session_extra_field($this->extraFieldIdNameList['session'], 1, 'External session id');
     // Create calendar_event extra field extra_external_session_id
     $extraField = new ExtraField('calendar_event');
     $extraField->save(array('field_type' => ExtraField::FIELD_TYPE_TEXT, 'field_variable' => $this->extraFieldIdNameList['calendar_event'], 'field_display_text' => 'External calendar event id'));
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:15,代码来源:import_csv.php

示例2: WSCreateCourseByTitle

function WSCreateCourseByTitle($params)
{
    global $firstExpirationDelay, $_configuration;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
    $courses_params = $params['courses'];
    $results = array();
    $orig_course_id_value = array();
    foreach ($courses_params as $course_param) {
        $title = $course_param['title'];
        $category_code = 'LANG';
        // TODO: A hard-coded value.
        $wanted_code = '';
        $tutor_firstname = api_get_setting('administratorName');
        $tutor_lastname = api_get_setting('administratorSurname');
        $course_language = 'spanish';
        // TODO: Incorrect default value, it should 'english'.
        if (!empty($course_param['course_language'])) {
            $course_language = $course_param['course_language'];
        }
        $tutor_name = api_get_person_name($tutor_firstname, $tutor_lastname, null, null, $course_language);
        if (!empty($course_param['tutor_name'])) {
            $tutor_name = $course_param['tutor_name'];
        }
        $original_course_id_name = $course_param['original_course_id_name'];
        $original_course_id_value = $course_param['original_course_id_value'];
        $orig_course_id_value[] = $course_param['original_course_id_value'];
        $extra_list = $course_param['extra'];
        // Ensure the database prefix + database name do not get over 40 characters
        $maxlength = 40;
        if (empty($wanted_code)) {
            $wanted_code = CourseManager::generate_course_code(substr($title, 0, $maxlength));
        }
        $courseInfo = CourseManager::getCourseInfoFromOriginalId($original_course_id_value, $original_course_id_name);
        if (!empty($courseInfo)) {
            if ($courseInfo['visibility'] != 0) {
                $sql = "UPDATE {$table_course} 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($wanted_code) . "',\n                            visibility = '3'\n                        WHERE id ='" . $courseInfo['real_id'] . "'";
                Database::query($sql);
                $results[] = $courseInfo['real_id'];
                continue;
            } else {
                $results[] = 0;
                continue;
            }
        }
        // Set default values.
        if (isset($_user['language']) && $_user['language'] != '') {
            $values['course_language'] = $_user['language'];
        } else {
            $values['course_language'] = api_get_setting('platformLanguage');
        }
        $values['tutor_name'] = api_get_person_name($_user['firstName'], $_user['lastName'], null, null, $values['course_language']);
        $keys = AddCourse::define_course_keys($wanted_code, '', $_configuration['db_prefix']);
        $sql_check = sprintf('SELECT * FROM ' . $table_course . ' WHERE visual_code = "%s"', Database::escape_string($wanted_code));
        $result_check = Database::query($sql_check);
        // I don't know why this api function doesn't work...
        if (Database::num_rows($result_check) < 1) {
            $params = array();
            $params['title'] = $title;
            $params['wanted_code'] = $wanted_code;
            $params['category_code'] = $category_code;
            $params['tutor_name'] = $tutor_name;
            $params['course_language'] = $course_language;
            $params['user_id'] = api_get_user_id();
            //$params['visibility'] = $visibility;
            $course_info = CourseManager::create_course($params);
            if (!empty($course_info)) {
                $course_code = $course_info['code'];
                // Save new fieldlabel into course_field table.
                CourseManager::create_course_extra_field($original_course_id_name, 1, $original_course_id_name, '');
                // Save the external system's id into user_field_value table.
                CourseManager::update_course_extra_field_value($course_code, $original_course_id_name, $original_course_id_value);
                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 new fieldlabel into course_field table.
                        CourseManager::create_course_extra_field($extra_field_name, 1, $extra_field_name, '');
                        // Save the external system's id into course_field_value table.
                        CourseManager::update_course_extra_field_value($course_code, $extra_field_name, $extra_field_value);
                    }
                }
            }
            $results[] = $course_code;
            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,代码行数:100,代码来源:registration.soap.php

示例3: prepareImport

 /**
  * Prepares extra fields before the import
  */
 private function prepareImport()
 {
     // Create user extra field: extra_external_user_id
     UserManager::create_extra_field($this->extraFieldIdNameList['user'], 1, 'External user id', null);
     // Create course extra field: extra_external_course_id
     CourseManager::create_course_extra_field($this->extraFieldIdNameList['course'], 1, 'External course id');
     // Create session extra field extra_external_session_id
     SessionManager::create_session_extra_field($this->extraFieldIdNameList['session'], 1, 'External session id');
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:12,代码来源:import_csv.php


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