本文整理汇总了PHP中CourseManager::get_course_code_from_course_id方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::get_course_code_from_course_id方法的具体用法?PHP CourseManager::get_course_code_from_course_id怎么用?PHP CourseManager::get_course_code_from_course_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::get_course_code_from_course_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unsubscribe_course_from_session
/**
* Unsubscribe course from a session
*
* @param int Session id
* @param int Course id
* @return bool True in case of success, false otherwise
*/
public static function unsubscribe_course_from_session($session_id, $course_id)
{
$session_id = (int) $session_id;
$course_id = (int) $course_id;
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
// Get course code
$course_code = CourseManager::get_course_code_from_course_id($course_id);
$course_id = intval($course_id);
if (empty($course_code)) {
return false;
}
// Unsubscribe course
$sql = "DELETE FROM {$tbl_session_rel_course}\n WHERE c_id = {$course_id} AND session_id = {$session_id}";
$result = Database::query($sql);
$nb_affected = Database::affected_rows($result);
$sql = "DELETE FROM {$tbl_session_rel_course_rel_user}\n WHERE c_id = {$course_id} AND session_id = {$session_id}";
Database::query($sql);
Event::addEvent(LOG_SESSION_DELETE_COURSE, LOG_COURSE_ID, $course_id, api_get_utc_datetime(), api_get_user_id(), $course_id, $session_id);
if ($nb_affected > 0) {
// Update number of courses in the session
$sql = "UPDATE {$tbl_session} SET nbr_courses= nbr_courses - {$nb_affected}\n WHERE id = {$session_id}";
Database::query($sql);
return true;
} else {
return false;
}
}
示例2: getCourseId
/**
* Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
* in the system database
*
* @param string Course id field name
* @param string Course id value
* @return mixed System course id if the course was found, WSError otherwise
*/
protected function getCourseId($course_id_field_name, $course_id_value)
{
if ($course_id_field_name == "chamilo_course_id") {
if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
return intval($course_id_value);
} else {
return new WSError(200, "Course not found");
}
} else {
$course_code = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
if (!empty($course_code)) {
$course_info = CourseManager::get_course_information($course_code);
return $course_info['id'];
} else {
return new WSError(200, "Course not found");
}
/*
if($course_code == 0) {
return new WSError(200, "Course not found");
} else {
return $course_info['id'];
}
*/
}
}
示例3: EditCourseDescription
/**
* Edit course description
*
* @param string API secret key
* @param string Course id field name
* @param string Course id value
* @param int Category id from course description
* @param string Description title
* @param string Course description content
*/
public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) {
return $course_id;
} else {
// Create the new course description
$cd = new CourseDescription();
$cd->set_description_type($course_desc_id);
$cd->set_title($course_desc_title);
$cd->set_content($course_desc_content);
$cd->set_session_id(0);
// Get course info
$course_info = CourseManager::get_course_information(CourseManager::get_course_code_from_course_id($course_id));
// Check if this course description exists
$descriptions = CourseDescription::get_descriptions($course_id);
$exists = false;
foreach($descriptions as $description) {
if($description->get_description_type() == $course_desc_id) {
$exists = true;
}
}
if (!$exists) {
$cd->set_progress(0);
$cd->insert($course_info['db_name']);
} else {
$cd->update($course_info['db_name']);
}
}
}
}
示例4: unsubscribe_course_from_session
/**
* Unsubscribe course from a session
*
* @param int Session id
* @param int Course id
* @return bool True in case of success, false otherwise
*/
public static function unsubscribe_course_from_session($session_id, $course_id)
{
$session_id = (int) $session_id;
$course_id = (int) $course_id;
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
// Get course code
$course_code = CourseManager::get_course_code_from_course_id($course_id);
if (empty($course_code)) {
return false;
}
// Unsubscribe course
$sql = "DELETE FROM $tbl_session_rel_course
WHERE course_code='$course_code' AND id_session='$session_id'";
Database::query($sql);
$nb_affected = Database::affected_rows();
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE course_code='$course_code' AND id_session='$session_id'";
Database::query($sql);
if ($nb_affected > 0) {
// Update number of courses in the session
$sql = "UPDATE $tbl_session SET nbr_courses= nbr_courses + $nb_affected WHERE id='$session_id' ";
Database::query($sql);
return true;
} else {
return false;
}
}
示例5: intval
// Filltering passed to this page parameters.
$accept_course_request = intval($_GET['accept_course_request']);
$delete_course_request = intval($_GET['delete_course_request']);
$request_info = intval($_GET['request_info']);
$message = trim(Security::remove_XSS(stripslashes(urldecode($_GET['message']))));
$is_error_message = !empty($_GET['is_error_message']);
$keyword = Database::escape_string(trim($_GET['keyword']));
if ($course_validation_feature) {
/**
* Acceptance and creation of the requested course.
*/
if (!empty($accept_course_request)) {
$course_request_code = CourseRequestManager::get_course_request_code($accept_course_request);
$course_id = CourseRequestManager::accept_course_request($accept_course_request);
if ($course_id) {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
$message = sprintf(get_lang('CourseRequestAccepted'), $course_request_code, $course_code);
$is_error_message = false;
} else {
$message = sprintf(get_lang('CourseRequestAcceptanceFailed'), $course_request_code);
$is_error_message = true;
}
} elseif (!empty($request_info)) {
$course_request_code = CourseRequestManager::get_course_request_code($request_info);
$result = CourseRequestManager::ask_for_additional_info($request_info);
if ($result) {
$message = sprintf(get_lang('CourseRequestInfoAsked'), $course_request_code);
$is_error_message = false;
} else {
$message = sprintf(get_lang('CourseRequestInfoFailed'), $course_request_code);
$is_error_message = true;
示例6: 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 ($debug) error_log('WSSubscribeUserToCourse course_id: '.$course_id);
if ($course_id == 0) {
// Course was not found
$result['result'] = 0;
} else {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
if ($debug) error_log('WSSubscribeUserToCourse course_code: '.$course_code);
if (!CourseManager::add_user_to_course($user_id, $course_code, $status)) {
$result['result'] = 0;
}
}
}
$results[] = $result;
}
return $results;
}
示例7: getCourseId
/**
* Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
* in the system database
*
* @param string Course id field name
* @param string Course id value
* @return mixed System course id if the course was found, WSError otherwise
*/
protected function getCourseId($course_id_field_name, $course_id_value)
{
if ($course_id_field_name == "chamilo_course_id") {
if (CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
return intval($course_id_value);
} else {
return new WSCMError(200, "Course not found");
}
} else {
$courseId = CourseManager::get_course_code_from_original_id($course_id_value, $course_id_field_name);
if (empty($courseId)) {
return new WSCMError(200, "Course not found");
} else {
return $courseId;
}
}
}
示例8: GetLearnpathStatusSingleItem
/**
* Gets status obtained in the given learning path by the given user,
* assuming there is only one item (SCO) in the learning path
*
* @param string Secret key
* @param string User id field name (use chamilo_user_id if none)
* @param string User id value
* @param string Course id field name (use chamilo_course_id if none)
* @param string Course id value
* @param int Learnpath ID
* @param int Learnpath *ITEM* ID
* @return string "not attempted", "passed", "completed", "failed", "incomplete"
*/
public function GetLearnpathStatusSingleItem($secret_key, $user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $learnpath_id, $learnpath_item_id)
{
$verifKey = $this->verifyKey($secret_key);
if ($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if ($user_id instanceof WSError) {
return $user_id;
}
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if ($course_id instanceof WSError) {
return $course_id;
} else {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
}
$lp = new learnpath($course_code, $learnpath_id, $user_id);
return $lp->items[$learnpath_item_id]->status;
}
}
示例9: changeCourseSubscription
/**
* Change course subscription
*
* @param string Course id field name
* @param string Course id value
* @param string Session id field name
* @param string Session id value
* @param int State (1 to subscribe, 0 to unsubscribe)
* @return mixed True on success, WSError otherwise
*/
protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
if($session_id instanceof WSError) {
return $session_id;
} else {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) {
return $course_id;
} else {
if($state == 1) {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
SessionManager::add_courses_to_session($session_id, array($course_code));
return true;
} else {
$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
if ($result) {
return true;
} else {
return new WSError(304, 'Error unsubscribing course from session');
}
}
}
}
}