| @@ 115-143 (lines=29) @@ | ||
| 112 | * @param array Course extra fields |
|
| 113 | * @return mixed Generated id if creation was successful, WSError otherwise |
|
| 114 | */ |
|
| 115 | protected function createCourseHelper( |
|
| 116 | $title, |
|
| 117 | $category_code, |
|
| 118 | $wanted_code, |
|
| 119 | $tutor_name, |
|
| 120 | $course_admin_user_id_field_name, |
|
| 121 | $course_admin_user_id_value, |
|
| 122 | $language, |
|
| 123 | $course_id_field_name, |
|
| 124 | $course_id_value, |
|
| 125 | $extras |
|
| 126 | ) { |
|
| 127 | // Add the original course id field name and value to the extra fields if needed |
|
| 128 | $extras_associative = array(); |
|
| 129 | if ($course_id_field_name != "chamilo_course_id") { |
|
| 130 | $extras_associative[$course_id_field_name] = $course_id_value; |
|
| 131 | } |
|
| 132 | foreach ($extras as $extra) { |
|
| 133 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 134 | } |
|
| 135 | $course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value); |
|
| 136 | if ($course_admin_id instanceof WSError) { |
|
| 137 | return $course_admin_id; |
|
| 138 | } |
|
| 139 | if ($wanted_code == '') { |
|
| 140 | $wanted_code = CourseManager::generate_course_code($title); |
|
| 141 | } |
|
| 142 | $result = create_course($wanted_code, $title, $tutor_name, $category_code, $language, $course_admin_id, $this->_configuration['db_prefix'], 0); |
|
| 143 | if (!$result) { |
|
| 144 | return new WSError(202, 'There was an error creating the course'); |
|
| 145 | } else { |
|
| 146 | // Update extra fields |
|
| @@ 118-146 (lines=29) @@ | ||
| 115 | * @param array Course extra fields |
|
| 116 | * @return mixed Generated id if creation was successful, WSError otherwise |
|
| 117 | */ |
|
| 118 | protected function createCourseHelper( |
|
| 119 | $title, |
|
| 120 | $category_code, |
|
| 121 | $wanted_code, |
|
| 122 | $tutor_name, |
|
| 123 | $course_admin_user_id_field_name, |
|
| 124 | $course_admin_user_id_value, |
|
| 125 | $language, |
|
| 126 | $course_id_field_name, |
|
| 127 | $course_id_value, |
|
| 128 | $extras |
|
| 129 | ) { |
|
| 130 | // Add the original course id field name and value to the extra fields if needed |
|
| 131 | $extras_associative = array(); |
|
| 132 | if ($course_id_field_name != "chamilo_course_id") { |
|
| 133 | $extras_associative[$course_id_field_name] = $course_id_value; |
|
| 134 | } |
|
| 135 | foreach ($extras as $extra) { |
|
| 136 | $extras_associative[$extra['field_name']] = $extra['field_value']; |
|
| 137 | } |
|
| 138 | $course_admin_id = $this->getUserId( |
|
| 139 | $course_admin_user_id_field_name, |
|
| 140 | $course_admin_user_id_value |
|
| 141 | ); |
|
| 142 | if ($course_admin_id instanceof WSError) { |
|
| 143 | return $course_admin_id; |
|
| 144 | } |
|
| 145 | if ($wanted_code == '') { |
|
| 146 | $wanted_code = CourseManager::generate_course_code($title); |
|
| 147 | } |
|
| 148 | $result = create_course( |
|
| 149 | $wanted_code, |
|