本文整理汇总了PHP中api_get_course_info函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_course_info函数的具体用法?PHP api_get_course_info怎么用?PHP api_get_course_info使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_course_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_information
/**
* Get document information
*/
private function get_information($course_id, $link_id)
{
$course_information = api_get_course_info($course_id);
$course_id = $course_information['real_id'];
$course_id_alpha = $course_information['id'];
if (!empty($course_information)) {
$item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$link_id = Database::escape_string($link_id);
$sql = "SELECT insert_user_id FROM {$item_property_table}\n \t\tWHERE ref = {$link_id} AND tool = '" . TOOL_LINK . "' AND c_id = {$course_id}\n \t\tLIMIT 1";
$name = get_lang('Links');
$url = api_get_path(WEB_PATH) . 'main/link/link.php?cidReq=%s';
$url = sprintf($url, $course_id_alpha);
// Get the image path
$thumbnail = api_get_path(WEB_IMG_PATH) . 'link.gif';
$image = $thumbnail;
//FIXME: use big images
// get author
$author = '';
$item_result = Database::query($sql);
if ($row = Database::fetch_array($item_result)) {
$user_data = api_get_user_info($row['insert_user_id']);
$author = api_get_person_name($user_data['firstName'], $user_data['lastName']);
}
return array($thumbnail, $image, $name, $author, $url);
} else {
return array();
}
}
示例2: __construct
/**
* constructor of the class
*
* @author Olivier Brouckaert
* @param int $questionId that answers belong to
* @param int $course_id
*/
public function __construct($questionId, $course_id = null)
{
$this->questionId = intval($questionId);
$this->answer = array();
$this->correct = array();
$this->comment = array();
$this->weighting = array();
$this->position = array();
$this->hotspot_coordinates = array();
$this->hotspot_type = array();
$this->destination = array();
// clears $new_* arrays
$this->cancel();
if (!empty($course_id)) {
$courseInfo = api_get_course_info_by_id($course_id);
} else {
$courseInfo = api_get_course_info();
}
$this->course = $courseInfo;
$this->course_id = $courseInfo['real_id'];
// fills arrays
$objExercise = new Exercise($this->course_id);
$exerciseId = isset($_REQUEST['exerciseId']) ? $_REQUEST['exerciseId'] : null;
$objExercise->read($exerciseId);
if ($objExercise->random_answers == '1') {
$this->readOrderedBy('rand()', '');
// randomize answers
} else {
$this->read();
// natural order
}
}
示例3: loginCheck
/**
* Checking user in DB
* @param int $uid
*/
public static function loginCheck($uid)
{
$_course = api_get_course_info();
$uid = (int) $uid;
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
if (!empty($uid)) {
$login_ip = '';
if (!empty($_SERVER['REMOTE_ADDR'])) {
$login_ip = Database::escape_string($_SERVER['REMOTE_ADDR']);
}
$login_date = api_get_utc_datetime();
$access_url_id = 1;
if (api_get_multiple_access_url() && api_get_current_access_url_id() != -1) {
$access_url_id = api_get_current_access_url_id();
}
$session_id = api_get_session_id();
// if the $_course array exists this means we are in a course and we have to store this in the who's online table also
// to have the x users in this course feature working
if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) {
$query = "REPLACE INTO " . $online_table . " (login_id, login_user_id, login_date, login_ip, course, session_id, access_url_id)\n VALUES ({$uid}, {$uid}, '{$login_date}', '{$login_ip}', '" . $_course['id'] . "', '{$session_id}', '{$access_url_id}' )";
} else {
$query = "REPLACE INTO " . $online_table . " (login_id,login_user_id,login_date,login_ip, session_id, access_url_id)\n VALUES ({$uid},{$uid},'{$login_date}','{$login_ip}', '{$session_id}', '{$access_url_id}')";
}
Database::query($query);
}
}
示例4: Answer
/**
* Constructor of the class
*
* @author Olivier Brouckaert
* @param integer Question ID that answers belong to
* @param int course id
* @param \Exercise obj
*/
public function Answer($questionId, $course_id = null, \Exercise $exercise = null)
{
$this->questionId = intval($questionId);
$this->answer = array();
$this->correct = array();
$this->comment = array();
$this->weighting = array();
$this->position = array();
$this->hotspot_coordinates = array();
$this->hotspot_type = array();
$this->destination = array();
// clears $new_* arrays
$this->cancel();
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
} else {
$course_info = api_get_course_info();
}
$this->course = $course_info;
$this->course_id = $course_info['real_id'];
if (isset($exercise)) {
if ($exercise->random_answers == '1') {
// Randomize answers.
$this->readOrderedBy('rand()', '');
} else {
// Normal order
$this->read();
}
} else {
$this->read();
}
}
示例5: copyQuestionAction
/**
* @param Application $app
* @param int $exerciseId
* @param int $questionId
* @return Response
*/
public function copyQuestionAction(Application $app, $exerciseId, $questionId)
{
$question = \Question::read($questionId);
if ($question) {
$newQuestionTitle = $question->selectTitle() . ' - ' . get_lang('Copy');
$question->updateTitle($newQuestionTitle);
//Duplicating the source question, in the current course
$courseInfo = api_get_course_info();
$newId = $question->duplicate($courseInfo);
// Reading new question
$newQuestion = \Question::read($newId);
$newQuestion->addToList($exerciseId);
// Reading Answers obj of the current course
$newAnswer = new \Answer($questionId);
$newAnswer->read();
//Duplicating the Answers in the current course
$newAnswer->duplicate($newId);
/*$params = array(
'cidReq' => api_get_course_id(),
'id_session' => api_get_session_id(),
'id' => $newId,
'exerciseId' => $exerciseId
);
$url = $app['url_generator']->generate('exercise_question_pool', $params);
return $app->redirect($url);*/
$response = \Display::return_message(get_lang('QuestionCopied') . ": " . $newQuestionTitle);
return new Response($response, 200, array());
}
}
示例6: validate_data
/**
* Validates imported data.
*/
function validate_data($courses)
{
$errors = array();
$coursecodes = array();
foreach ($courses as $index => $course) {
$course['line'] = $index + 1;
// 1. Check whether mandatory fields are set.
$mandatory_fields = array('Code', 'Title', 'CourseCategory');
foreach ($mandatory_fields as $field) {
if (!isset($course[$field]) || strlen($course[$field]) == 0) {
$course['error'] = get_lang($field . 'Mandatory');
$errors[] = $course;
}
}
// 2. Check current course code.
if (isset($course['Code']) && strlen($course['Code']) != 0) {
// 2.1 Check whether code has been already used by this CVS-file.
if (isset($coursecodes[$course['Code']])) {
$course['error'] = get_lang('CodeTwiceInFile');
$errors[] = $course;
} else {
// 2.2 Check whether course code has been occupied.
$courseInfo = api_get_course_info($course['Code']);
if (!empty($courseInfo)) {
$course['error'] = get_lang('CodeExists');
$errors[] = $course;
}
}
$coursecodes[$course['Code']] = 1;
}
// 3. Check whether teacher exists.
$teacherList = getTeacherListInArray($course['Teacher']);
if (!empty($teacherList)) {
foreach ($teacherList as $teacher) {
$teacherInfo = api_get_user_info_from_username($teacher);
if (empty($teacherInfo)) {
$course['error'] = get_lang('UnknownTeacher') . ' (' . $teacher . ')';
$errors[] = $course;
} else {
/*if ($teacherInfo['status'] != COURSEMANAGER) {
$course['error'] = get_lang('UserIsNotATeacher').' ('.$teacher.')';
$errors[] = $course;
}*/
}
}
}
// 4. Check whether course category exists.
if (isset($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) {
require_once api_get_path(LIBRARY_PATH) . 'course_category.lib.php';
$categoryInfo = getCategory($course['CourseCategory']);
if (empty($categoryInfo)) {
//@todo this is so bad even all lang variables are wrong ...
$course['error'] = get_lang('UnkownCategoryCourseCode') . ' (' . $course['CourseCategory'] . ')';
$errors[] = $course;
}
}
}
return $errors;
}
示例7: data
public function data()
{
$_course = api_get_course_info();
if ($_course == '-1') {
$_course = array();
}
return $_course;
}
示例8: classicAction
/**
* @param string $name
* @param Request $request
* @return Response
*/
public function classicAction($name, Request $request)
{
// get.
$_GET = $request->query->all();
// post.
$_POST = $request->request->all();
$rootDir = $this->get('kernel')->getRealRootDir();
//$_REQUEST = $request->request->all();
$mainPath = $rootDir . 'main/';
$fileToLoad = $mainPath . $name;
// Setting legacy values inside the container
/** @var Connection $dbConnection */
$dbConnection = $this->container->get('database_connection');
$em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager');
$database = new \Database($dbConnection, array());
$database->setConnection($dbConnection);
$database->setManager($em);
Container::$container = $this->container;
Container::$dataDir = $this->container->get('kernel')->getDataDir();
Container::$courseDir = $this->container->get('kernel')->getDataDir();
//Container::$configDir = $this->container->get('kernel')->getConfigDir();
$this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq());
//$breadcrumb = $this->container->get('chamilo_core.block.breadcrumb');
if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) {
// Files inside /main need this variables to be set
$is_allowed_in_course = api_is_allowed_in_course();
$is_courseAdmin = api_is_course_admin();
$is_platformAdmin = api_is_platform_admin();
$toolNameFromFile = basename(dirname($fileToLoad));
$charset = 'UTF-8';
// Default values
$_course = api_get_course_info();
$_user = api_get_user_info();
$debug = $this->container->get('kernel')->getEnvironment() == 'dev' ? true : false;
// Loading file
ob_start();
require_once $fileToLoad;
$out = ob_get_contents();
ob_end_clean();
// No browser cache when executing an exercise.
if ($name == 'exercice/exercise_submit.php') {
$responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate');
}
$js = isset($htmlHeadXtra) ? $htmlHeadXtra : array();
// $interbreadcrumb is loaded in the require_once file.
$interbreadcrumb = isset($interbreadcrumb) ? $interbreadcrumb : null;
$template = Container::$legacyTemplate;
$defaultLayout = 'layout_one_col.html.twig';
if (!empty($template)) {
$defaultLayout = $template;
}
return $this->render('ChamiloCoreBundle::' . $defaultLayout, array('legacy_breadcrumb' => $interbreadcrumb, 'content' => $out, 'js' => $js));
} else {
// Found does not exist
throw new NotFoundHttpException();
}
}
示例9: initializeReport
/**
* @param $course_code
* @return array|bool
*/
function initializeReport($course_code)
{
$course_info = api_get_course_info($course_code);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
$table_semanas_curso = Database::get_main_table('rp_semanas_curso');
$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
$course_code = Database::escape_string($course_code);
$res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '" . $course_code . "'");
$sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
$resWeeks = Database::query($sqlWeeks);
$weeks = Database::fetch_object($resWeeks);
$obj = Database::fetch_object($res);
$weeksCount = (!isset($_POST['weeksNumber'])) ? (($weeks->semanas == 0) ? 7 : $weeks->semanas) : $_POST['weeksNumber'];
$weeksCount = Database::escape_string($weeksCount);
Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
if (intval($obj->cant) != $weeksCount) {
if (intval($obj->cant) > $weeksCount) {
$sql = "DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'";
Database::query("DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'");
} else {
for ($i = $obj->cant + 1; $i <= $weeksCount; $i++) {
if (!Database::query("INSERT INTO $table_reporte_semanas (week_id, course_code, forum_id, work_id, quiz_id, pc_id)
VALUES ($i, '$course_code', '0', '0', '0', '0' )")) {
return false;
}
}
}
}
$sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
SELECT cu.user_id, rs.id, 0, 0, 0, 0
FROM $table_course_rel_user cu
LEFT JOIN $table_reporte_semanas rs ON cu.course_code = rs.course_code
WHERE cu.status = 5 AND rs.course_code = '$course_code'
ORDER BY cu.user_id, rs.id";
if (!Database::query($sql)) {
return false;
} else {
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)
FROM $table_work w JOIN $table_reporte_semanas rs ON w.parent_id = rs.work_id)");
Database::query("UPDATE $table_students_report sr SET sr.thread_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)
FROM $table_post f JOIN $table_reporte_semanas rs ON f.thread_id = rs.forum_id)");
return showResults($course_info, $weeksCount, $page);
}
}
示例10: displayForm
/**
* Show the form to copy courses
* @global string $returnLink
* @global string $courseCode
*/
function displayForm()
{
global $returnLink, $courseCode;
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$userId = api_get_user_id();
$sessions = SessionManager::getSessionsCoachedByUser($userId);
$html = '';
// Actions
$html .= '<div class="actions">';
// Link back to the documents overview
$html .= '<a href="' . $returnLink . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM) . '</a>';
$html .= '</div>';
$html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation'));
$html .= '<form name="formulaire" method="post" action="' . api_get_self() . '?' . api_get_cidreq() . '" >';
$html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
// Source
$html .= '<tr><td width="15%"><b>' . get_lang('OriginCoursesFromSession') . ':</b></td>';
$html .= '<td width="10%" align="left">' . api_get_session_name($sessionId) . '</td>';
$html .= '<td width="50%">';
$html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>';
// Destination
$html .= '<tr><td width="15%"><b>' . get_lang('DestinationCoursesFromSession') . ':</b></td>';
$html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">';
$html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">';
if (empty($sessions)) {
$html .= '<option value = "0">' . get_lang('ThereIsNotStillASession') . '</option>';
} else {
$html .= '<option value = "0">' . get_lang('SelectASession') . '</option>';
foreach ($sessions as $session) {
if ($session['id'] == $sessionId) {
continue;
}
if (!SessionManager::sessionHasCourse($session['id'], $courseCode)) {
continue;
}
$html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>';
}
}
$html .= '</select ></div></td>';
$html .= '<td width="50%">';
$html .= '<div id="ajax_list_courses_destination">';
$html .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" ></select></div></td>';
$html .= '</tr></table>';
$html .= "<fieldset>";
$html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>';
$html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= get_lang('FullCopy') . '</label>';
$html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>';
$html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>';
$html .= "</fieldset>";
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>';
$html .= '</form>';
echo $html;
}
示例11: save
/**
* Organize the saving of a link, using the parent's save method and
* updating the item_property table
* @param array $params
* @param boolean $show_query Whether to show the query in logs when
* calling parent's save method
*
* @return bool True if link could be saved, false otherwise
*/
public function save($params, $show_query = null)
{
$course_info = api_get_course_info();
$params['session_id'] = api_get_session_id();
$params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0;
$id = parent::save($params, $show_query);
if (!empty($id)) {
api_item_property_update($course_info, TOOL_LINK, $id, 'LinkAdded', api_get_user_id());
}
return $id;
}
示例12: __construct
public function __construct()
{
$this->paths = array('root_sys' => api_get_path(SYS_PATH), 'sys_root' => api_get_path(SYS_PATH), 'sys_course_path' => api_get_path(SYS_COURSE_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH));
/*$this->entityManager = $entityManager;
$this->paths = $paths;
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
$this->security = $security;*/
$this->user = api_get_user_info();
$this->course = api_get_course_info();
$this->driverList = $this->getDefaultDriverList();
}
示例13: __construct
public function __construct(EntityManager $entityManager, array $paths, Router $urlGenerator, Translator $translator, SecurityContext $security, $user, $course = null)
{
$this->paths = array('root_sys' => api_get_path(SYS_PATH), 'sys_root' => api_get_path(SYS_PATH), 'sys_course_path' => api_get_path(SYS_COURSE_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH));
$this->entityManager = $entityManager;
//$this->paths = $paths;
$this->urlGenerator = $urlGenerator;
$this->translator = $translator;
$this->security = $security;
$this->user = empty($user) ? api_get_user_info() : $user;
$this->course = empty($course) ? api_get_course_info() : $course;
$this->driverList = $this->getDefaultDriverList();
}
示例14: classicAction
/**
* Handles default Chamilo scripts handled by Display::display_header() and display_footer()
*
* @param \Silex\Application $app
* @param string $file
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response|void
*/
public function classicAction(Application $app, $file)
{
$responseHeaders = array();
/** @var Request $request */
$request = $app['request'];
// get.
$_GET = $request->query->all();
// post.
$_POST = $request->request->all();
// echo $request->getMethod();
//$_REQUEST = $request->request->all();
$mainPath = $app['paths']['sys_root'] . 'main/';
$fileToLoad = $mainPath . $file;
if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) {
// Default values
$_course = api_get_course_info();
$_user = api_get_user_info();
$charset = 'UTF-8';
$debug = $app['debug'];
$text_dir = api_get_text_direction();
$is_platformAdmin = api_is_platform_admin();
$_cid = api_get_course_id();
// Loading file
ob_start();
require_once $mainPath . $file;
$out = ob_get_contents();
ob_end_clean();
// No browser cache when executing an exercise.
if ($file == 'exercice/exercise_submit.php') {
$responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate');
}
// Setting page header/footer conditions (important for LPs)
$app['template']->setFooter($app['template.show_footer']);
$app['template']->setHeader($app['template.show_header']);
if (isset($htmlHeadXtra)) {
$app['template']->addJsFiles($htmlHeadXtra);
}
if (isset($interbreadcrumb)) {
$app['template']->setBreadcrumb($interbreadcrumb);
$app['template']->loadBreadcrumbToTemplate();
}
if (isset($tpl)) {
$response = $app['twig']->render($app['default_layout']);
} else {
$app['template']->assign('content', $out);
$response = $app['twig']->render($app['default_layout']);
}
} else {
return $app->abort(404, 'File not found');
}
return new Response($response, 200, $responseHeaders);
}
示例15: __construct
/**
* @param int $courseId
* @param int $announcement
*/
public function __construct($courseId, $announcement)
{
if (!empty($courseId)) {
$course = api_get_course_info_by_id($courseId);
} else {
$course = api_get_course_info();
}
$this->course = $course;
$this->session_id = api_get_session_id();
if (is_numeric($announcement)) {
$announcement = AnnouncementManager::get_by_id($course['real_id'], $announcement);
}
$this->announcement = $announcement;
}