本文整理汇总了PHP中api_get_course_info_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_course_info_by_id函数的具体用法?PHP api_get_course_info_by_id怎么用?PHP api_get_course_info_by_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_course_info_by_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_descriptions
/**
* Returns an array of objects of type CourseDescription corresponding to
* a specific course, without session ids (session id = 0)
*
* @param int $course_id
*
* @return array Array of CourseDescriptions
*/
public static function get_descriptions($course_id)
{
// Get course code
$course_info = api_get_course_info_by_id($course_id);
if (!empty($course_info)) {
$course_id = $course_info['real_id'];
} else {
return array();
}
$t_course_desc = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$sql = "SELECT * FROM {$t_course_desc}\n WHERE c_id = {$course_id} AND session_id = '0'";
$sql_result = Database::query($sql);
$results = array();
while ($row = Database::fetch_array($sql_result)) {
$desc_tmp = new CourseDescription();
$desc_tmp->set_id($row['id']);
$desc_tmp->set_title($row['title']);
$desc_tmp->set_content($row['content']);
$desc_tmp->set_session_id($row['session_id']);
$desc_tmp->set_description_type($row['description_type']);
$desc_tmp->set_progress($row['progress']);
$results[] = $desc_tmp;
}
return $results;
}
示例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: 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();
}
}
示例4: __construct
/**
* Constructor of the class
*
* @author Olivier Brouckaert
*/
public function __construct($course_id = null)
{
$this->id = 0;
$this->exercise = '';
$this->description = '';
$this->sound = '';
$this->type = ALL_ON_ONE_PAGE;
$this->random = 0;
$this->random_answers = 0;
$this->active = 1;
$this->questionList = array();
$this->timeLimit = 0;
$this->end_time = '0000-00-00 00:00:00';
$this->start_time = '0000-00-00 00:00:00';
$this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->review_answers = false;
$this->randomByCat = 0;
$this->text_when_finished = '';
$this->display_category_name = 0;
$this->pass_percentage = '';
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
} else {
$course_info = api_get_course_info();
}
$this->course_id = $course_info['real_id'];
$this->course = $course_info;
$this->sessionId = api_get_session_id();
}
示例5: get_all
/**
* @param array $options
*
* @return array
*/
public function get_all($options = array())
{
$gradebooks = parent::get_all($options);
foreach ($gradebooks as &$gradebook) {
if (!empty($gradebook['name'])) {
continue;
}
$courseInfo = api_get_course_info_by_id($gradebook['c_id']);
$gradebook['name'] = $courseInfo['code'];
}
return $gradebooks;
}
示例6: 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;
}
示例7: __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;
}
示例8: course
/**
*
* @param int $c_id
* @param string $sub_path
* @return FileStore
*/
static function course($c_id, $sub_path = '')
{
$sys_path = api_get_path(SYS_COURSE_PATH);
$course = api_get_course_info_by_id($c_id);
$course_path = $course['path'];
$path = $sys_path . $course_path . $sub_path;
if (!is_dir($path)) {
$mode = api_get_permissions_for_new_directories();
$success = mkdir($path, $mode, true);
if (!$success) {
return false;
}
}
return new self($path);
}
示例9: read
/**
* Reads question information from the data base
*
* @param int $id - question ID
* @param int $course_id
*
* @return Question
*
* @author Olivier Brouckaert
*/
public static function read($id, $course_id = null)
{
$id = intval($id);
if (!empty($course_id)) {
$course_info = api_get_course_info_by_id($course_id);
} else {
$course_info = api_get_course_info();
}
$course_id = $course_info['real_id'];
if (empty($course_id) || $course_id == -1) {
return false;
}
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$sql = "SELECT question, description, ponderation, position, type, picture, level, extra\n FROM {$TBL_QUESTIONS}\n WHERE c_id = {$course_id} AND id = {$id} ";
$result = Database::query($sql);
// if the question has been found
if ($object = Database::fetch_object($result)) {
$objQuestion = Question::getInstance($object->type);
if (!empty($objQuestion)) {
$objQuestion->id = $id;
$objQuestion->question = $object->question;
$objQuestion->description = $object->description;
$objQuestion->weighting = $object->ponderation;
$objQuestion->position = $object->position;
$objQuestion->type = $object->type;
$objQuestion->picture = $object->picture;
$objQuestion->level = (int) $object->level;
$objQuestion->extra = $object->extra;
$objQuestion->course = $course_info;
$objQuestion->category = TestCategory::getCategoryForQuestion($id);
$tblQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT DISTINCT q.exercice_id\n FROM {$TBL_EXERCISE_QUESTION} q\n INNER JOIN {$tblQuiz} e\n ON e.c_id = q.c_id AND e.id = q.exercice_id\n WHERE\n q.c_id = {$course_id} AND\n q.question_id = {$id} AND\n e.active >= 0";
$result = Database::query($sql);
// fills the array with the exercises which this question is in
if ($result) {
while ($obj = Database::fetch_object($result)) {
$objQuestion->exerciseList[] = $obj->exercice_id;
}
}
return $objQuestion;
}
}
// question not found
return false;
}
示例10: editorConnector
/**
* @Route("/editor/connector", name="editor_connector")
* @Method({"GET|POST"})
*/
public function editorConnector(Request $request)
{
error_reporting(-1);
$courseId = $request->get('course_id');
$sessionId = $request->get('session_id');
$courseInfo = [];
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
}
/** @var Connector $connector */
$connector = new Connector($this->container->get('doctrine')->getManager(), [], $this->container->get('router'), $this->container->get('translator.default'), $this->container->get('security.context'), $this->getUser(), $courseInfo);
$driverList = array('PersonalDriver', 'CourseDriver');
$connector->setDriverList($driverList);
$operations = $connector->getOperations();
// Run elFinder
ob_start();
$finder = new Finder($operations);
$elFinderConnector = new ElFinderConnector($finder);
$elFinderConnector->run();
$content = ob_get_contents();
return $this->render('@ChamiloCore/layout_empty.html.twig', ['content' => $content]);
}
示例11: sync
/**
*
*/
function sync()
{
$tableBuySessionRelCourse = Database::get_main_table(TABLE_BUY_SESSION_COURSE);
$tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$sql = "UPDATE {$tableBuySessionRelCourse} SET sync = 0";
Database::query($sql);
$sql = "SELECT session_id, c_id, nbr_users FROM {$tableSessionRelCourse}";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$sql = "SELECT 1 FROM {$tableBuySessionRelCourse} WHERE session_id=" . $row['session_id'];
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
$sql = "UPDATE {$tableBuySessionRelCourse} SET sync = 1 WHERE session_id=" . $row['session_id'];
Database::query($sql);
} else {
$courseCode = api_get_course_info_by_id($row['c_id'])['code'];
$sql = "INSERT INTO {$tableBuySessionRelCourse} (session_id, course_code, nbr_users, sync)\r\n VALUES (" . $row['session_id'] . ", '" . $courseCode . "', " . $row['nbr_users'] . ", 1);";
Database::query($sql);
}
}
$sql = "DELETE FROM {$tableBuySessionRelCourse} WHERE sync = 0;";
Database::query($sql);
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "UPDATE {$tableBuyCourse} SET sync = 0";
Database::query($sql);
$sql = "SELECT id, code, title FROM {$tableCourse}";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$sql = "SELECT session_id FROM {$tableBuySessionRelCourse}\r\n WHERE course_code = '" . $row['code'] . "' LIMIT 1";
$courseIdSession = Database::fetch_assoc(Database::query($sql))['session_id'];
if (!is_numeric($courseIdSession)) {
$courseIdSession = 0;
}
$sql = "SELECT 1 FROM {$tableBuyCourse} WHERE course_id='" . $row['id'] . "';";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
$sql = "UPDATE {$tableBuyCourse} SET sync = 1, session_id = {$courseIdSession} WHERE course_id='" . $row['id'] . "';";
Database::query($sql);
} else {
$sql = "INSERT INTO {$tableBuyCourse} (session_id, course_id, code, title, visible, sync)\r\n VALUES ('" . $courseIdSession . "', '" . $row['id'] . "', '" . $row['code'] . "', '" . $row['title'] . "', 0, 1);";
Database::query($sql);
}
}
$sql = "DELETE FROM {$tableBuyCourse} WHERE sync = 0;";
Database::query($sql);
$tableBuySession = Database::get_main_table(TABLE_BUY_SESSION);
$tableSession = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = "UPDATE {$tableBuySession} SET sync = 0";
Database::query($sql);
$sql = "SELECT id, name, access_start_date, access_end_date FROM {$tableSession}";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$sql = "SELECT 1 FROM {$tableBuySession} WHERE session_id='" . $row['id'] . "';";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
$sql = "UPDATE {$tableBuySession} SET sync = 1 WHERE session_id='" . $row['id'] . "';";
Database::query($sql);
} else {
$sql = "INSERT INTO {$tableBuySession} (session_id, name, date_start, date_end, visible, sync)\r\n VALUES ('" . $row['id'] . "', '" . $row['name'] . "', '" . $row['access_start_date'] . "', '" . $row['access_end_date'] . "', 0, 1);";
Database::query($sql);
}
}
$sql = "DELETE FROM {$tableBuySession} WHERE sync = 0;";
Database::query($sql);
}
示例12: array
cu.c_id = c.id AND
cu.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' ';
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$header = array(array(get_lang('Code'), true), array(get_lang('Title'), true), array(get_lang('Status'), true), array(get_lang('TimeSpentInTheCourse'), true), array(get_lang('TotalPostsInAllForums'), true), array('', false));
$headerList = array();
foreach ($header as $item) {
$headerList[] = $item[0];
}
$csvContent[] = array();
$csvContent[] = array(get_lang('Courses'));
$csvContent[] = $headerList;
$data = array();
$courseToolInformationTotal = null;
while ($course = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($course->c_id);
$courseCode = $courseInfo['code'];
$courseToolInformation = null;
$tools = '<a href="course_information.php?code=' . $courseCode . '">' . Display::return_icon('synthese_view.gif', get_lang('Overview')) . '</a>' . '<a href="' . $courseInfo['course_public_url'] . '">' . Display::return_icon('course_home.gif', get_lang('CourseHomepage')) . '</a>' . '<a href="course_edit.php?course_code=' . $courseCode . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
if ($course->status == STUDENT) {
$tools .= '<a href="user_information.php?action=unsubscribe&course_code=' . $courseCode . '&user_id=' . $user['user_id'] . '">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>';
}
$timeSpent = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseInfo['real_id'], 0));
$totalForumMessages = CourseManager::getCountPostInForumPerUser($user['user_id'], $course->id, 0);
$row = array(Display::url($courseCode, $courseInfo['course_public_url']), $course->title, $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher'), $timeSpent, $totalForumMessages, $tools);
$csvContent[] = array_map('strip_tags', $row);
$data[] = $row;
$result = TrackingUserLogCSV::getToolInformation($user['user_id'], $courseInfo, 0);
$courseToolInformationTotal .= $result['html'];
$csvContent = array_merge($csvContent, $result['array']);
}
示例13: display_student_publications_tracking_info
/**
* Displays the student publications for a specific user in a specific course.
* @todo remove globals
*/
public function display_student_publications_tracking_info($view, $user_id, $course_id)
{
global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
$_course = api_get_course_info_by_id($course_id);
if (substr($view, 2, 1) == '1') {
$new_view = substr_replace($view, '0', 2, 1);
echo "<tr>\n <td valign='top'>\n <font color='#0000FF'>- </font><b>" . get_lang('WorkUploads') . "</b> [<a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($user_id) . "&view=" . Security::remove_XSS($new_view) . "'>" . get_lang('Close') . "</a>] [<a href='userLogCSV.php?" . api_get_cidreq() . "&uInfo=" . Security::remove_XSS($_GET['uInfo']) . "&view=00100'>" . get_lang('ExportAsCSV') . "</a>]\n </td>\n </tr>";
echo "<tr><td style='padding-left : 40px;' valign='top'>" . get_lang('WorksDetails') . "<br>";
$sql = "SELECT u.upload_date, w.title, w.author,w.url\n FROM {$TABLETRACK_UPLOADS} u , {$TABLECOURSE_WORK} w\n WHERE u.upload_work_id = w.id\n AND u.upload_user_id = '" . intval($user_id) . "'\n AND u.c_id = '" . intval($course_id) . "'\n ORDER BY u.upload_date DESC";
echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
$results = StatsUtils::getManyResultsXCol($sql, 4);
echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
echo "<tr>\n <td class='secLine' width='40%'>\n " . get_lang('WorkTitle') . "\n </td>\n <td class='secLine' width='30%'>\n " . get_lang('WorkAuthors') . "\n </td>\n <td class='secLine' width='30%'>\n " . get_lang('Date') . "\n </td>\n </tr>";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$pathToFile = api_get_path(WEB_COURSE_PATH) . $_course['path'] . "/" . $results[$j][3];
$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
echo "<tr>";
echo "<td class='content'>" . "<a href ='" . $pathToFile . "'>" . $results[$j][1] . "</a>" . "</td>";
echo "<td class='content'>" . $results[$j][2] . "</td>";
echo "<td class='content'>" . $beautifulDate . "</td>";
echo "</tr>";
}
} else {
echo "<tr>";
echo "<td colspan='3'><center>" . get_lang('NoResult') . "</center></td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr>";
} else {
$new_view = substr_replace($view, '1', 2, 1);
echo "\n <tr>\n <td valign='top'>\n +<font color='#0000FF'> </font><a href='" . api_get_self() . "?uInfo=" . Security::remove_XSS($user_id) . "&view=" . Security::remove_XSS($new_view) . "' class='specialLink'>" . get_lang('WorkUploads') . "</a>\n </td>\n </tr>\n ";
}
}
示例14: api_protect_course_script
api_protect_course_script(true);
// Configuration settings
$display_announcement_list = true;
$display_form = false;
$display_title_list = true;
// Maximum title messages to display
$maximum = '12';
// Length of the titles
$length = '36';
// Database Table Definitions
$tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
$_course = api_get_course_info_by_id($course_id);
$group_id = api_get_group_id();
$sessionId = api_get_session_id();
api_protect_course_group(GroupManager::GROUP_TOOL_ANNOUNCEMENT);
/* Tracking */
Event::event_access_tool(TOOL_ANNOUNCEMENT);
$announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'list';
$announcement_number = AnnouncementManager::getNumberAnnouncements();
$homeUrl = api_get_self() . '?action=list&' . api_get_cidreq();
$content = '';
$searchFormToString = '';
switch ($action) {
case 'move':
/* Move announcement up/down */
示例15: modifyCategory
/**
* Modify category name or description of category with id=in_id
*/
public function modifyCategory()
{
$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$v_id = intval($this->id);
$v_name = Database::escape_string($this->name);
$v_description = Database::escape_string($this->description);
$sql = "UPDATE {$table} SET\n title = '{$v_name}',\n description = '{$v_description}'\n WHERE id = {$v_id} AND c_id=" . api_get_course_int_id();
$result = Database::query($sql);
if (Database::affected_rows($result) <= 0) {
return false;
} else {
// item_property update
$course_id = api_get_course_int_id();
$course_info = api_get_course_info_by_id($course_id);
api_item_property_update($course_info, TOOL_TEST_CATEGORY, $this->id, 'TestCategoryModified', api_get_user_id());
return true;
}
}