本文整理汇总了PHP中CourseManager::get_courses_list方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::get_courses_list方法的具体用法?PHP CourseManager::get_courses_list怎么用?PHP CourseManager::get_courses_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::get_courses_list方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: courses_list
/**
* Get a list of courses (code, url, title, teacher, language) and return to caller
* Function registered as service. Returns strings in UTF-8.
* @param string Security key (the Dokeos install's API key)
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function courses_list($security_key, $visibilities = 'public')
{
global $_configuration;
// Check if this script is launch by server and if security key is ok.
if ($security_key != $_configuration['security_key']) {
return array('error_msg' => 'Security check failed');
}
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
$courses_list = array();
if (!is_array($visibilities)) {
$tmp = $visibilities;
$visibilities = array($tmp);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
return $courses_list;
}
示例2: WSCourseList
/**
* Get a list of courses (code, url, title, teacher, language) and return to caller
* Function registered as service. Returns strings in UTF-8.
* @param string User name in Chamilo
* @param string Signature (composed of the sha1(username+apikey)
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function WSCourseList($username, $signature, $visibilities = 'public')
{
if (empty($username) or empty($signature)) {
return -1;
}
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
if (!UserManager::is_admin($user_id)) {
return -1;
}
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
foreach ($list as $key) {
break;
}
$local_key = $username . $key;
if (!api_is_valid_secret_key($signature, $local_key) && !api_is_valid_secret_key($signature, $username . $_configuration['security_key'])) {
return -1;
// The secret key is incorrect.
}
//public-registered = open
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
$courses_list = array();
if (!is_array($visibilities)) {
$visibilities = split(',', $visibilities);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
return $courses_list;
}
示例3: WSListCourses
function WSListCourses($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$course_field_name = isset($params['original_course_id_name']) ? $params['original_course_id_name'] : '';
$courses_result = array();
$category_names = array();
$courses = CourseManager::get_courses_list();
foreach ($courses as $course) {
$course_tmp = array();
$course_tmp['id'] = $course['id'];
$course_tmp['code'] = $course['code'];
$course_tmp['title'] = $course['title'];
$course_tmp['language'] = $course['course_language'];
$course_tmp['visibility'] = $course['visibility'];
// Determining category name
if (!empty($course['category_code']) && $category_names[$course['category_code']]) {
$course_tmp['category_name'] = $category_names[$course['category_code']];
} else {
$category = CourseManager::get_course_category($course['category_code']);
$category_names[$course['category_code']] = $category['name'];
$course_tmp['category_name'] = $category['name'];
}
// Determining number of students registered in course
$course_tmp['number_students'] = CourseManager::get_users_count_in_course($course['code']);
// Determining external course id
$externalCourseId = '';
if ($course_field_name) {
$externalCourseId = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
}
$course_tmp['external_course_id'] = $externalCourseId;
$courses_result[] = $course_tmp;
}
return $courses_result;
}
示例4: array
$global = true;
} else {
$global = false;
}
$global = true;
$course_list = $course_select_list = array();
$course_select_list[0] = get_lang('None');
$htmlHeadXtra[] = '
<script type="text/javascript">
function load_courses() {
document.search_simple.submit();
}
</script> ';
$session_id = intval($_REQUEST['session_id']);
if (empty($session_id)) {
$temp_course_list = CourseManager::get_courses_list();
} else {
$temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
}
foreach ($temp_course_list as $temp_course_item) {
$course_item = CourseManager::get_course_information($temp_course_item['code']);
$course_list[] = array('db_name' => $course_item['db_name'], 'code' => $course_item['code'], 'title' => $course_item['title'], 'visual_code' => $course_item['visual_code']);
$course_select_list[$temp_course_item['code']] = $course_item['title'];
}
//Get session list
$session_list = SessionManager::get_sessions_list(array(), array('name'));
$my_session_list = array();
$my_session_list[0] = get_lang('None');
foreach ($session_list as $sesion_item) {
$my_session_list[$sesion_item['id']] = $sesion_item['name'];
}
示例5: search
function search($needle, $type)
{
global $elements_in;
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
if ($type == 'single') {
} else {
$list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
}
if ($type == 'single') {
} else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($list as $row) {
if (!in_array($row['id'], array_keys($elements_in))) {
$return .= '<option value="' . $row['id'] . '">' . $row['title'] . ' (' . $row['visual_code'] . ')</option>';
}
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_multiple', 'innerHTML', api_utf8_encode($return));
}
}
return $xajax_response;
}
示例6: search
function search($needle, $type)
{
global $tbl_user, $elements_in;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = Database::escape_string($needle);
$needle = api_convert_encoding($needle, $charset, 'utf-8');
if ($type == 'single') {
// search users where username or firstname or lastname begins likes $needle
/* $sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.user_id<>"'.$user_anonymous.'" AND user.status<>'.DRH.''.
$order_clause.
' LIMIT 11';*/
} else {
$list = CourseManager::get_courses_list(0, 0, 2, 'ASC', -1, $needle);
}
$i = 0;
if ($type == 'single') {
/*
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/
} else {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($list as $row) {
if (!in_array($row['id'], array_keys($elements_in))) {
$return .= '<option value="' . $row['id'] . '">' . $row['title'] . ' (' . $row['visual_code'] . ')</option>';
}
}
$return .= '</select>';
$xajax_response->addAssign('ajax_list_multiple', 'innerHTML', api_utf8_encode($return));
}
}
return $xajax_response;
}
示例7: json_encode
}
echo json_encode($results);
} else {
echo json_encode(array());
}
}
break;
case 'search_course':
if (api_is_platform_admin()) {
if (!empty($_GET['session_id']) && intval($_GET['session_id'])) {
//if session is defined, lets find only courses of this session
$courseList = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']);
} else {
//if session is not defined lets search all courses STARTING with $_GET['q']
//TODO change this function to search not only courses STARTING with $_GET['q']
$courseList = CourseManager::get_courses_list(0, 0, 1, 'ASC', -1, $_GET['q'], null, true);
}
$results = array();
require_once api_get_path(LIBRARY_PATH) . 'course_category.lib.php';
if (!empty($courseList)) {
foreach ($courseList as $courseInfo) {
$title = $courseInfo['title'];
if (!empty($courseInfo['category_code'])) {
$parents = getParentsToString($courseInfo['category_code']);
$title = $parents . $courseInfo['title'];
}
$results[] = array('id' => $courseInfo['id'], 'text' => $title);
}
echo json_encode($results);
} else {
echo json_encode(array());
示例8: isset
$tplPath = 'skill/student_boss_report.html.twig';
$tpl->addGlobal('followedStudents', $followedStudents);
$tpl->addGlobal('selectedStudent', $selectedStudent);
} else {
if ($isDRH) {
$selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null;
$selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0;
$action = null;
if (!empty($selectedCourse)) {
$action = 'filterByCourse';
} else {
if (!empty($selectedSkill)) {
$action = 'filterBySkill';
}
}
$courses = CourseManager::get_courses_list();
$tableRows = array();
$reportTitle = null;
$objSkill = new Skill();
$skills = $objSkill->get_all();
switch ($action) {
case 'filterByCourse':
$course = api_get_course_info_by_id($selectedCourse);
$reportTitle = sprintf(get_lang('AchievedSkillInCourseX'), $course['name']);
$tableRows = $objSkill->listAchievedByCourse($selectedCourse);
break;
case 'filterBySkill':
$skill = $objSkill->get($selectedSkill);
$reportTitle = sprintf(get_lang('StudentsWhoAchievedTheSkillX'), $skill['name']);
$students = UserManager::getUsersFollowedByUser($userId, STUDENT, false, false, false, null, null, null, null, null, null, DRH);
$coursesFilter = array();
示例9: array
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// Language files that need to be included.
$language_file = array('admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php';
Display::display_header(null);
$form = new FormValidator('export_certificate');
$courses = CourseManager::get_courses_list(0, 0, 'title');
$options = array();
foreach ($courses as $course) {
$options[$course['id']] = $course['title'];
}
$form->addElement('select', 'course', get_lang('Course'), $options);
$form->addElement('file', 'file', get_lang('File'));
$form->add_button('submit', get_lang('Submit'));
$form->display();
if ($form->validate()) {
$values = $form->getSubmitValues();
if (isset($_FILES['file']['tmp_name']) && !empty($_FILES['file']['tmp_name'])) {
$users = Import::csv_reader($_FILES['file']['tmp_name']);
$courseId = $values['course'];
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo['code'];
$cats = Category::load(null, null, $courseCode, null, null, 0, false);
示例10: ListCourses
/**
* List courses
*
* @param string API secret key
* @param string A list of visibility filter we want to apply
* @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
* 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id')
*/
public function ListCourses($secret_key, $visibility = 'public,public-registered,private,closed') {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$visibilities = split(',',$visibility);
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
foreach ($visibilities as $p => $visibility) {
$visibilities[$p] = $vis[$visibility];
}
$courses_result = array();
$category_names = array();
$courses = CourseManager::get_courses_list();
foreach($courses as $course) {
//skip elements that do not match required visibility
if (!in_array($course['visibility'],$visibilities)) { continue; }
$course_tmp = array();
$course_tmp['id'] = $course['id'];
$course_tmp['code'] = $course['code'];
$course_tmp['title'] = $course['title'];
$course_tmp['language'] = $course['course_language'];
$course_tmp['visibility'] = $course['visibility'];
// Determining category name
if($category_names[$course['category_code']]) {
$course_tmp['category_name'] = $category_names[$course['category_code']];
} else {
$category = CourseManager::get_course_category($course['category_code']);
$category_names[$course['category_code']] = $category['name'];
$course_tmp['category_name'] = $category['name'];
}
// Determining number of students registered in course
$user_list = CourseManager::get_user_list_from_course_code($course['code'], 0);
$course_tmp['number_students'] = count($user_list);
// Determining external course id - this code misses the external course id field name
// $course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_field_name, $course['code']);
$courses_result[] = $course_tmp;
}
return $courses_result;
}
}
示例11: ListCourses
/**
* List courses
*
* @param string API secret key
* @param string Course id field name. Use "chamilo_course_id" to use internal id
* @return array An array with elements of the form ('id' => 'Course internal id', 'code' => 'Course code', 'title' => 'Course title', 'language' => 'Course language', 'visibility' => 'Course visibility',
* 'category_name' => 'Name of the category of the course', 'number_students' => 'Number of students in the course', 'external_course_id' => 'External course id')
*/
public function ListCourses($secret_key, $course_id_field_name) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$courses_result = array();
$category_names = array();
$courses = CourseManager::get_courses_list();
foreach($courses as $course) {
$course_tmp = array();
$course_tmp['id'] = $course['id'];
$course_tmp['code'] = $course['code'];
$course_tmp['title'] = $course['title'];
$course_tmp['language'] = $course['course_language'];
$course_tmp['visibility'] = $course['visibility'];
// Determining category name
if($category_names[$course['category_code']]) {
$course_tmp['category_name'] = $category_names[$course['category_code']];
} else {
$category = CourseManager::get_course_category($course['category_code']);
$category_names[$course['category_code']] = $category['name'];
$course_tmp['category_name'] = $category['name'];
}
// Determining number of students registered in course
$user_list = CourseManager::get_user_list_from_course_code($course['code']);
$course_tmp['number_students'] = count($user_list);
// Determining external course id
$course_tmp['external_course_id'] = CourseManager::get_course_extra_field_value($course_id_field_name, $course['code']);
$courses_result[] = $course_tmp;
}
return $courses_result;
}
}
示例12: reports_template_CourseArticulate_getSQL
function reports_template_CourseArticulate_getSQL()
{
// settings
// Nom, prenom
$query = 'select u.lastname as "Last name", u.firstname as "First name" ';
$query .= 'from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
$query .= ' where u.user_id in (' . reports_getVisibilitySQL() . ') ';
$query .= ' order by u.user_id ';
$queries[0] = $query;
$extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE;
// Custom Field
foreach (array("tags" => "tags") as $k => $v) {
// FIXME
$query = 'select ufv.value as "' . $v . '" ';
$query .= 'from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
$query .= 'left join' . Database::get_main_table(TABLE_EXTRA_FIELD) . ' uf ';
$query .= ' on uf.variable ="' . $k . '" ';
$query .= 'left outer join ' . Database::get_main_table(TABLE_EXTRA_FIELD_VALUES) . ' ufv ';
$query .= ' on ufv.item_id = u.user_id and ufv.field_id = uf.id ';
$query .= 'where ufv.extra_field_type = ' . $extraFieldType . ' AND u.user_id in (' . reports_getVisibilitySQL() . ') ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// Stored Value
$sv = array();
foreach ($sv as $k => $v) {
if (!isset($v['sql'])) {
$v['sql'] = 'FIELD';
}
$sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']);
$query = 'select ' . $sqlField . ' as "' . $v['title'] . '" ';
// $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
$query .= 'from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
$query .= ' left outer join ' . Database::get_main_table(TABLE_TRACK_STORED_VALUES) . ' sv ';
$query .= 'on sv.user_id = u.user_id and sv_key = "' . $k . '" ';
$query .= ' where u.user_id in (' . reports_getVisibilitySQL() . ') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
// first and last connection
$query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" ';
$query .= 'from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
$query .= 'left outer join ' . Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN) . ' tel ';
$query .= ' on tel.login_user_id = u.user_id ';
$query .= ' where u.user_id in (' . reports_getVisibilitySQL() . ') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
// SCORM Data
$scormData = array();
$course_list = CourseManager::get_courses_list();
foreach ($course_list as $code => $details) {
$courseId = $details['id'];
$list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle ' . ' FROM ' . Database::get_course_table(TABLE_LP_MAIN) . ' l, ' . Database::get_course_table(TABLE_LP_ITEM) . ' li ' . ' WHERE l.c_id = ' . $courseId . ' AND li.c_id = ' . $courseId . ' AND l.id = li.lp_id');
while ($lpItem = Database::fetch_assoc($list)) {
$scormData[] = array('lid' => $lpItem['lid'], 'liid' => $lpItem['liid'], 'target_view_count' => 1, 'target_indicator' => 'score', 'title' => $details['title'] . '/' . $lpItem['lname'] . '/' . $lpItem['lititle'] . '/1/score', 'sql' => 'FIELD');
$scormData[] = array('lid' => $lpItem['lid'], 'liid' => $lpItem['liid'], 'target_view_count' => 2, 'target_indicator' => 'score', 'title' => $details['title'] . '/' . $lpItem['lname'] . '/' . $lpItem['lititle'] . '/2/score', 'sql' => 'FIELD');
$scormData[] = array('lid' => $lpItem['lid'], 'liid' => $lpItem['liid'], 'target_view_count' => null, 'target_indicator' => 'score', 'title' => $details['title'] . '/' . $lpItem['lname'] . '/' . $lpItem['lititle'] . '/all/score', 'sql' => 'avg(FIELD)');
}
}
foreach ($scormData as $v) {
if (!isset($v['sql'])) {
$v['sql'] = 'FIELD';
}
$sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']);
$query = 'select ' . $sqlField . ' as "' . $v['title'] . '" ';
$query .= 'from ' . Database::get_main_table(TABLE_MAIN_USER) . ' u ';
$query .= 'left outer join ' . Database::get_course_table(TABLE_LP_VIEW) . ' lv ';
$query .= ' on u.user_id = lv.user_id and lv.lp_id = ' . $v['lid'];
$query .= ' left outer join ' . Database::get_course_table(TABLE_LP_ITEM_VIEW) . ' liv ';
$query .= ' on lv.id = liv.lp_view_id ';
if ($v['target_view_count']) {
$query .= ' and liv.view_count = ' . $v['target_view_count'];
}
$query .= ' and liv.lp_item_id = ' . $v['liid'] . ' ';
$query .= ' where u.user_id in (' . reports_getVisibilitySQL() . ') ';
$query .= ' group by u.user_id ';
$query .= ' order by u.user_id ';
$queries[] = $query;
}
return $queries;
}