本文整理汇总了PHP中CourseManager::get_course_id_from_original_id方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::get_course_id_from_original_id方法的具体用法?PHP CourseManager::get_course_id_from_original_id怎么用?PHP CourseManager::get_course_id_from_original_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::get_course_id_from_original_id方法的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: WSSubscribeUserToCourse
function WSSubscribeUserToCourse($params)
{
global $debug;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
if ($debug) {
error_log('WSSubscribeUserToCourse params: ' . print_r($params, 1));
}
$results = array();
$userscourses = $params['userscourses'];
foreach ($userscourses as $usercourse) {
$original_course_id = $usercourse['course_id'];
$original_user_id = $usercourse['user_id'];
$status = STUDENT;
if ($usercourse['status']) {
$status = $usercourse['status'];
}
$result = array('original_user_id_value' => $original_user_id['original_user_id_value'], 'original_course_id_value' => $original_course_id['original_course_id_value'], 'result' => 1);
// Get user id
$user_id = UserManager::get_user_id_from_original_id($original_user_id['original_user_id_value'], $original_user_id['original_user_id_name']);
if ($debug) {
error_log('WSSubscribeUserToCourse user_id: ' . $user_id);
}
if ($user_id == 0) {
// If user was not found, there was a problem
$result['result'] = 0;
} else {
// User was found
$course_id = CourseManager::get_course_id_from_original_id($original_course_id['original_course_id_value'], $original_course_id['original_course_id_name']);
if ($course_id == 0) {
// Course was not found
$result['result'] = 0;
} else {
if (!CourseManager::add_user_to_course($user_id, $course_id, $status)) {
$result['result'] = 0;
}
}
}
$results[] = $result;
}
return $results;
}
示例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: WSUnSubscribeUserFromCourseSimple
/**
* @param array $params
* @return array|null|soap_fault
*/
function WSUnSubscribeUserFromCourseSimple($params)
{
global $debug;
error_log('WSUnSubscribeUserFromCourseSimple');
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$original_user_id_value = $params['original_user_id_value'];
$original_user_id_name = $params['original_user_id_name'];
$original_course_id_value = $params['original_course_id_value'];
$original_course_id_name = $params['original_course_id_name'];
$result = array();
$result['original_user_id_value'] = $original_user_id_value;
$result['result'] = 0;
$user_id = UserManager::get_user_id_from_original_id($original_user_id_value, $original_user_id_name);
if ($user_id) {
if ($debug) {
error_log("User {$original_user_id_value}, {$original_user_id_name} found");
error_log("Course {$original_course_id_value}, {$original_course_id_name} found");
}
$courseCode = CourseManager::get_course_id_from_original_id($original_course_id_value, $original_course_id_name);
if (empty($courseCode)) {
// Course was not found
if ($debug) {
error_log("course not found");
}
} else {
if ($debug) {
error_log("Course {$courseCode} found");
}
CourseManager::unsubscribe_user($user_id, $courseCode, 0);
$result['result'] = 1;
}
} else {
if ($debug) {
error_log("User not found");
}
}
return $result;
}
示例5: WSCreateLp
/**
* @param array $params
* @return null|soap_fault
*/
function WSCreateLp($params)
{
global $debug;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
if ($debug) {
error_log('WSCreateLp');
}
$courseIdName = $params['course_id_name'];
$courseIdValue = $params['course_id_value'];
$lpName = $params['lp_name'];
$lpItemList = $params['lp_item_list'];
/*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
$sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
$courseCode = CourseManager::get_course_id_from_original_id($courseIdValue, $courseIdName);
$courseInfo = api_get_course_info($courseCode);
$courseId = $courseInfo['real_id'];
if (empty($courseInfo)) {
if ($debug) {
error_log('Course not found');
}
}
/*$sessionId = 0;
if (!empty($sessionIdName) && !empty($sessionIdValue)) {
$sessionId = SessionManager::get_session_id_from_original_id(
$sessionIdValue,
$sessionIdName
);
if (empty($sessionId)) {
if ($debug) {
error_log('Session not found');
}
return 'Session not found';
}
}*/
$lpId = learnpath::add_lp($courseCode, $lpName, '', 'chamilo', 'manual');
if ($lpId) {
if ($debug) {
error_log('LP created');
}
$lp = new learnpath($courseCode, $lpId, null);
$previousId = 0;
foreach ($lpItemList as $lpItem) {
$info = pathinfo($lpItem['filename']);
$extension = $info['extension'];
$data = base64_decode($lpItem['data']);
$documentId = $lp->create_document($courseInfo, $data, $info['filename'], $extension);
if ($documentId) {
if ($debug) {
error_log("Document created {$documentId}");
$itemId = $lp->add_item(null, $previousId, 'document', $documentId, $lpItem['title'], '', '');
$previousId = $itemId;
if ($itemId) {
if ($debug) {
error_log("Item added");
}
} else {
if ($debug) {
error_log("Item not added");
}
}
}
} else {
if ($debug) {
error_log("Document NOT created");
}
}
}
return 1;
} else {
if ($debug) {
error_log('LP not created');
}
}
return 0;
}