本文整理汇总了PHP中api_get_course_int_id函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_course_int_id函数的具体用法?PHP api_get_course_int_id怎么用?PHP api_get_course_int_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_course_int_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
/**
* @Route("/edit/{tool}")
* @Method({"GET"})
*
* @param string $tool
* @return Response
*/
public function editAction($tool)
{
$message = null;
// @todo use proper functions not api functions.
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$tool = \Database::escape_string($tool);
$TBL_INTRODUCTION = \Database::get_course_table(TABLE_TOOL_INTRO);
$url = $this->generateUrl('introduction.controller:editAction', array('tool' => $tool, 'course' => api_get_course_id()));
$form = $this->getForm($url, $tool);
if ($form->validate()) {
$values = $form->exportValues();
$content = $values['content'];
$sql = "REPLACE {$TBL_INTRODUCTION}\n SET c_id = {$courseId},\n id = '{$tool}',\n intro_text='" . \Database::escape_string($content) . "',\n session_id='" . intval($sessionId) . "'";
\Database::query($sql);
$message = \Display::return_message(get_lang('IntroductionTextUpdated'), 'confirmation', false);
} else {
$sql = "SELECT intro_text FROM {$TBL_INTRODUCTION}\n WHERE c_id = {$courseId} AND id='" . $tool . "' AND session_id = '" . intval($sessionId) . "'";
$result = \Database::query($sql);
$content = null;
if (\Database::num_rows($result) > 0) {
$row = \Database::fetch_array($result);
$content = $row['intro_text'];
}
$form->setDefaults(array('content' => $content));
}
$this->getTemplate()->assign('content', $form->return_form());
$this->getTemplate()->assign('message', $message);
$response = $this->getTemplate()->renderLayout('layout_1_col.tpl');
return new Response($response, 200, array());
}
示例2: __construct
/**
* Sets the surveylist and the plainsurveylist
*/
public function __construct()
{
// Database table definitions
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
// searching
$search_restriction = SurveyUtil::survey_search_restriction();
if ($search_restriction) {
$search_restriction = ' AND ' . $search_restriction;
}
$course_id = api_get_course_int_id();
$sql = "SELECT\n survey.survey_id,\n survey.parent_id,\n survey_version,\n survey.code as name\n\t\t\t\tFROM {$table_survey} survey\n\t\t\t\tLEFT JOIN {$table_survey_question} survey_question\n\t\t\t\tON survey.survey_id = survey_question.survey_id , {$table_user} user\n\t\t\t\tWHERE\n\t\t\t\t\tsurvey.c_id \t\t\t= {$course_id} AND\n\t\t\t\t\tsurvey_question.c_id \t= {$course_id} AND\n\t\t\t\t\tsurvey.author \t\t\t= user.user_id\n\t\t\t\tGROUP BY survey.survey_id";
$res = Database::query($sql);
$surveys_parents = array();
$refs = array();
$list = array();
$plain_array = array();
while ($survey = Database::fetch_array($res, 'ASSOC')) {
$plain_array[$survey['survey_id']] = $survey;
$surveys_parents[] = $survey['survey_version'];
$thisref =& $refs[$survey['survey_id']];
$thisref['parent_id'] = $survey['parent_id'];
$thisref['name'] = $survey['name'];
$thisref['id'] = $survey['survey_id'];
$thisref['survey_version'] = $survey['survey_version'];
if ($survey['parent_id'] == 0) {
$list[$survey['survey_id']] =& $thisref;
} else {
$refs[$survey['parent_id']]['children'][$survey['survey_id']] =& $thisref;
}
}
$this->surveylist = $list;
$this->plainsurveylist = $plain_array;
}
示例3: update_db_info
/**
* Update the file or directory path in the document db document table
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @param - action (string) - action type require : 'delete' or 'update'
* @param - old_path (string) - old path info stored to change
* @param - new_path (string) - new path info to substitute
* @desc Update the file or directory path in the document db document table
*
*/
function update_db_info($action, $old_path, $new_path = '')
{
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
switch ($action) {
case 'delete':
$old_path = Database::escape_string($old_path);
$to_delete = "WHERE c_id = {$course_id} AND (path LIKE BINARY '" . $old_path . "' OR path LIKE BINARY '" . $old_path . "/%')";
$query = "DELETE FROM {$dbTable} " . $to_delete;
$result = Database::query("SELECT id FROM {$dbTable} " . $to_delete);
if (Database::num_rows($result)) {
require_once api_get_path(INCLUDE_PATH) . '../metadata/md_funcs.php';
$mdStore = new mdstore(TRUE);
// create if needed
$md_type = substr($dbTable, -13) == 'scormdocument' ? 'Scorm' : 'Document';
while ($row = Database::fetch_array($result)) {
$eid = $md_type . '.' . $row['id'];
$mdStore->mds_delete($eid);
$mdStore->mds_delete_offspring($eid);
}
}
Database::query($query);
break;
case 'update':
if ($new_path[0] == '.') {
$new_path = substr($new_path, 1);
}
$new_path = str_replace('//', '/', $new_path);
// Attempt to update - tested & working for root dir
$new_path = Database::escape_string($new_path);
$query = "UPDATE {$dbTable} SET\n path = CONCAT('" . $new_path . "', SUBSTRING(path, LENGTH('" . $old_path . "')+1) )\n WHERE c_id = {$course_id} AND (path LIKE BINARY '" . $old_path . "' OR path LIKE BINARY '" . $old_path . "/%')";
Database::query($query);
break;
}
}
示例4: save_scores
/**
* Save the score for a HP quiz. Can be used by the learnpath tool as well
* for HotPotatoes quizzes. When coming from the learning path, we
* use the session variables telling us which item of the learning path has to
* be updated (score-wise)
* @param string File is the exercise name (the file name for a HP)
* @param integer Score to save inside the tracking tables (HP and learnpath)
* @return void
*/
function save_scores($file, $score)
{
global $origin;
$TABLETRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$_user = api_get_user_info();
// if tracking is disabled record nothing
$weighting = 100;
// 100%
$date = api_get_utc_datetime();
$c_id = api_get_course_int_id();
if ($_user['user_id']) {
$user_id = $_user['user_id'];
} else {
// anonymous
$user_id = "NULL";
}
$params = ['exe_name' => $file, 'exe_user_id' => $user_id, 'exe_date' => $date, 'c_id' => $c_id, 'exe_result' => $score, 'exe_weighting' => $weighting];
Database::insert($TABLETRACK_HOTPOTATOES, $params);
if ($origin == 'learnpath') {
//if we are in a learning path, save the score in the corresponding
//table to get tracking in there as well
global $jscript2run;
//record the results in the learning path, using the SCORM interface (API)
$jscript2run .= "<script>\n \$(document).ready(function() {\n //API_obj = window.frames.window.content.API;\n //API_obj = \$('content_id').context.defaultView.content.API; //works only in FF\n //API_obj = window.parent.frames.window.top.API;\n API_obj = window.top.API;\n API_obj.void_save_asset('{$score}', '{$weighting}', 0, 'completed');\n });\n </script>";
}
}
示例5: get_class_data
/**
* Get the classes to display on the current page.
*/
function get_class_data($from, $number_of_items, $column, $direction)
{
$class_table = Database::get_main_table(TABLE_MAIN_CLASS);
$class_user_table = Database::get_main_table(TABLE_MAIN_CLASS_USER);
$courseId = api_get_course_int_id();
$em = Database::getManager();
$res = $em->getRepository('ChamiloCoreBundle:CourseRelClass')->findBy(['courseId' => $courseId]);
$subscribed_classes = array();
foreach ($res as $obj) {
$subscribed_classes[] = $obj->getClassId();
}
$sql = "SELECT\n c.id AS col0,\n c.name AS col1,\n COUNT(cu.user_id) AS col2,\n c.id AS col3\n FROM {$class_table} c ";
$sql .= " LEFT JOIN {$class_user_table} cu ON cu.class_id = c.id";
$sql .= " WHERE 1 = 1";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (c.name LIKE '%" . $keyword . "%')";
}
if (count($subscribed_classes) > 0) {
$sql .= " AND c.id NOT IN ('" . implode("','", $subscribed_classes) . "')";
}
$sql .= " GROUP BY c.id, c.name ";
$sql .= " ORDER BY col{$column} {$direction} ";
$sql .= " LIMIT {$from},{$number_of_items}";
$res = Database::query($sql);
$classes = array();
while ($class = Database::fetch_row($res)) {
$classes[] = $class;
}
return $classes;
}
示例6: get_next_by_row_id
/**
* @param int $entity_id
* @param int $row_entity_id
* @param int $course_id
* @return array|bool
*/
public static function get_next_by_row_id($entity_id, $row_entity_id, $course_id = null)
{
if (self::_debug) {
error_log('Entering ' . __FUNCTION__ . ' in ' . __FILE__);
}
$row_entity_id = Database::escape_string($row_entity_id);
$entity_id = Database::escape_string($entity_id);
$course_id = Database::escape_string($course_id);
if (is_numeric($row_entity_id) && is_numeric($entity_id)) {
$row_entity_id = intval($row_entity_id);
$entity_id = intval($entity_id);
$course_id = is_numeric($course_id) ? intval($course_id) : api_get_course_int_id();
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
$row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
$sql = "SELECT row.id FROM {$row_table} row\n WHERE\n row.sequence_type_entity_id = {$entity_id} AND\n row.row_id = {$row_entity_id} AND\n row.c_id = {$course_id} LIMIT 0, 1";
$sql = "SELECT main.sequence_row_entity_id_next\n FROM {$seq_table} main WHERE main.sequence_row_entity_id_next IN ({$sql})";
$sql = "SELECT * FROM {$row_table} res\n WHERE res.id IN ({$sql})";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($temp_next = Database::fetch_array($result, 'ASSOC')) {
$next[] = $temp_next;
}
return $next;
}
}
return false;
}
示例7: get_data
/**
* Get actual array data
* @return array 2-dimensional array - each array contains the elements:
* 0: cat/eval/link object
* 1: item name
* 2: description
* 3: weight
* 4: date
* 5: student's score (if student logged in)
*/
public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
{
//$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
// do some checks on count, redefine if invalid value
if (!isset($count)) {
$count = count($this->items) - $start;
}
if ($count < 0) {
$count = 0;
}
$allitems = $this->items;
// sort array
if ($sorting & self::GDG_SORT_TYPE) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_type'));
} elseif ($sorting & self::GDG_SORT_ID) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_id'));
} elseif ($sorting & self::GDG_SORT_NAME) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_name'));
} elseif ($sorting & self::GDG_SORT_DESCRIPTION) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_description'));
} elseif ($sorting & self::GDG_SORT_WEIGHT) {
usort($allitems, array('GradebookDataGenerator', 'sort_by_weight'));
} elseif ($sorting & self::GDG_SORT_DATE) {
//usort($allitems, array('GradebookDataGenerator', 'sort_by_date'));
}
if ($sorting & self::GDG_SORT_DESC) {
$allitems = array_reverse($allitems);
}
// get selected items
$visibleitems = array_slice($allitems, $start, $count);
//status de user in course
$user_id = api_get_user_id();
$status_user = api_get_status_of_user_in_course($user_id, api_get_course_int_id());
// generate the data to display
$data = array();
foreach ($visibleitems as $item) {
$row = array();
$row[] = $item;
$row[] = $item->get_name();
// display the 2 first line of description, and all description on mouseover (https://support.chamilo.org/issues/6588)
$row[] = '<span title="' . api_remove_tags_with_space($item->get_description()) . '">' . api_get_short_text_from_html($item->get_description(), 160) . '</span>';
$row[] = $item->get_weight();
/*if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_date_column($item);
}*/
if (count($this->evals_links) > 0) {
if (!api_is_allowed_to_edit() || $status_user != 1) {
$row[] = $this->build_result_column($item, $ignore_score_color);
$row[] = $item;
}
}
$data[] = $row;
}
return $data;
}
示例8: current_course
/**
*
* @return \Entity\Course
*/
public static function current_course()
{
static $result = false;
if ($result === false) {
$repo = \Entity\Course::repository();
$course_id = api_get_course_int_id();
if ($course_id) {
$result = $repo->find($course_id);
}
}
return $result;
}
示例9: set_parameters
/**
* Setting parameters: course id, session id, etc
* @param array
*/
public function set_parameters($params = array())
{
//Setting course id
if (isset($params['course_id'])) {
$this->course_id = intval($params['course_id']);
} else {
$this->course_id = $params['course_id'] = api_get_course_int_id();
}
//Setting course info
if (isset($this->course_id)) {
$this->course_info = api_get_course_info_by_id($this->course_id);
}
//Setting session id
if (isset($params['session_id'])) {
$this->session_id = intval($params['session_id']);
} else {
$this->session_id = $params['session_id'] = api_get_session_id();
}
//Setting user ids
if (isset($params['user_id'])) {
$this->user_id = intval($params['user_id']);
} else {
$this->user_id = $params['user_id'] = api_get_user_id();
}
//Setting user ids
if (isset($params['exercise_id'])) {
$this->exercise_id = intval($params['exercise_id']);
} else {
$this->exercise_id = 0;
}
//Setting user ids
if (isset($params['question_id'])) {
$this->question_id = intval($params['question_id']);
} else {
$this->question_id = 0;
}
$this->can_edit = false;
if (api_is_allowed_to_edit()) {
$this->can_edit = true;
} else {
if ($this->user_id == api_get_user_id()) {
$this->can_edit = true;
}
}
//Settings the params array
$this->params = $params;
$this->store_path = api_get_path(SYS_COURSE_PATH) . $this->course_info['path'] . '/exercises/';
$this->create_user_folder();
$this->store_path = $this->store_path . implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)) . '/';
$this->filename = $this->generate_filename();
$this->store_filename = $this->store_path . $this->filename;
}
示例10: get_all_links
/**
* Generates an array of all surveys available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_all_links()
{
if (empty($this->course_code)) {
die('Error in get_all_links() : course code not set');
}
$tbl_survey = $this->get_survey_table();
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$sql = 'SELECT survey_id, title, code FROM ' . $tbl_survey . ' WHERE c_id = ' . $course_id . ' AND session_id = ' . intval($session_id) . '';
$result = Database::query($sql);
while ($data = Database::fetch_array($result)) {
$links[] = array($data['survey_id'], Text::api_trunc_str($data['code'] . ': ' . self::html_to_text($data['title']), 80));
}
return isset($links) ? $links : null;
}
示例11: __construct
/**
* @param int $course
* @param int $announcement
*/
public function __construct($course, $announcement)
{
if (empty($course)) {
$course = api_get_course_int_id();
$course = api_get_course_info_by_id($course);
} else {
if (is_numeric($course)) {
$course = api_get_course_info_by_id($course);
}
}
$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;
}
示例12: is_active
/**
* Returns true if the gradebook is active and visible in a course, false
* otherwise.
*
* @param int $c_id Course integer id, defaults to the current course
* @return boolean
*/
public static function is_active($c_id = null)
{
$name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from {$table} WHERE variable='course_hide_tools' AND subkey='{$name}'";
$setting = ResultSet::create($sql)->first();
$setting = $setting ? $setting : array();
$inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true';
if ($inactive) {
return false;
}
$c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from {$table} WHERE c_id = {$c_id} and name='{$name}'";
$item = ResultSet::create($sql)->first();
if (empty($item)) {
return true;
}
return $item['visibility'] == '1';
}
示例13: updateLink
/**
* Update a link in the database
* @param int $linkId The ID of the link to update
* @param string $linkUrl The new URL to be saved
* @param int Course ID
* @param int Session ID
* @return bool
*/
public function updateLink($linkId, $linkUrl, $courseId = null, $sessionId = null)
{
$tblLink = Database::get_course_table(TABLE_LINK);
$linkUrl = Database::escape_string($linkUrl);
$linkId = intval($linkId);
if (is_null($courseId)) {
$courseId = api_get_course_int_id();
}
$courseId = intval($courseId);
if (is_null($sessionId)) {
$sessionId = api_get_session_id();
}
$sessionId = intval($sessionId);
if ($linkUrl != '') {
$sql = "UPDATE {$tblLink} SET url = '{$linkUrl}'\n WHERE id = {$linkId} AND c_id = {$courseId} AND session_id = {$sessionId}";
$resLink = Database::query($sql);
return $resLink;
}
return false;
}
示例14: update_db_info
/**
* Update the file or directory path in the document db document table
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @param - action (string) - action type require : 'delete' or 'update'
* @param - old_path (string) - old path info stored to change
* @param - new_path (string) - new path info to substitute
* @desc Update the file or directory path in the document db document table
*
*/
function update_db_info($action, $old_path, $new_path = '')
{
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
switch ($action) {
case 'delete':
$old_path = Database::escape_string($old_path);
$query = "DELETE FROM {$dbTable}\n WHERE\n c_id = {$course_id} AND\n (\n path LIKE BINARY '" . $old_path . "' OR\n path LIKE BINARY '" . $old_path . "/%'\n )";
Database::query($query);
break;
case 'update':
if ($new_path[0] == '.') {
$new_path = substr($new_path, 1);
}
$new_path = str_replace('//', '/', $new_path);
// Attempt to update - tested & working for root dir
$new_path = Database::escape_string($new_path);
$query = "UPDATE {$dbTable} SET\n path = CONCAT('" . $new_path . "', SUBSTRING(path, LENGTH('" . $old_path . "')+1) )\n WHERE c_id = {$course_id} AND (path LIKE BINARY '" . $old_path . "' OR path LIKE BINARY '" . $old_path . "/%')";
Database::query($query);
break;
}
}
示例15: save_scores
/**
* Save the score for a HP quiz. Can be used by the learnpath tool as well
* for HotPotatoes quizzes. When coming from the learning path, we
* use the session variables telling us which item of the learning path has to
* be updated (score-wise)
* @param string File is the exercise name (the file name for a HP)
* @param integer Score to save inside the tracking tables (HP and learnpath)
* @return void
*/
function save_scores($file, $score)
{
global $origin, $_user, $TABLETRACK_HOTPOTATOES;
$weighting = 100;
// 100%
$date = api_get_utc_datetime();
if ($_user['user_id']) {
$user_id = $_user['user_id'];
} else {
// anonymous
$user_id = "NULL";
}
$sql = "INSERT INTO {$TABLETRACK_HOTPOTATOES} (exe_name, exe_user_id, exe_date, c_id, exe_result, exe_weighting) VALUES (\n\t\t\t'" . Database::escape_string($file) . "',\n\t\t\t'" . Database::escape_string($user_id) . "',\n\t\t\t'" . Database::escape_string($date) . "',\n\t\t\t'" . api_get_course_int_id() . "',\n\t\t\t'" . Database::escape_string($score) . "',\n\t\t\t'" . Database::escape_string($weighting) . "')";
Database::query($sql);
if ($origin == 'learnpath') {
//if we are in a learning path, save the score in the corresponding
//table to get tracking in there as well
global $jscript2run;
//record the results in the learning path, using the SCORM interface (API)
$jscript2run .= "<script>\n \$(document).ready(function() {\n //API_obj = window.frames.window.content.API;\n //API_obj = \$('content_id').context.defaultView.content.API; //works only in FF\n //API_obj = window.parent.frames.window.top.API;\n API_obj = window.top.API;\n API_obj.void_save_asset('{$score}', '{$weighting}', 0, 'completed');\n });\n </script>";
}
}