本文整理汇总了PHP中learnpath类的典型用法代码示例。如果您正苦于以下问题:PHP learnpath类的具体用法?PHP learnpath怎么用?PHP learnpath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了learnpath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aicc
/**
* Class constructor. Based on the parent constructor.
* @param string Course code
* @param integer Learnpath ID in DB
* @param integer User ID
*/
function aicc($course_code = null, $resource_id = null, $user_id = null)
{
if ($this->debug > 0) {
error_log('In aicc::aicc()', 0);
}
if (!empty($course_code) and !empty($resource_id) and !empty($user_id)) {
parent::learnpath($course_code, $resource_id, $user_id);
} else {
//do nothing but still build the aicc object
}
}
示例2: save_objectives
/**
* Writes an item's new values into the database and returns the operation result
* @param integer Learnpath ID
* @param integer User ID
* @param integer View ID
* @param integer Item ID
* @param array Objectives array
*/
function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = array())
{
$debug = 0;
$return = '';
if ($debug > 0) {
error_log('In xajax_save_objectives(' . $lp_id . ',' . $user_id . ',' . $view_id . ',' . $item_id . ',"' . (count($objectives) > 0 ? count($objectives) : '') . '")', 0);
}
$mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
$mylpi =& $mylp->items[$item_id];
if (is_array($objectives) && count($objectives) > 0) {
foreach ($objectives as $index => $objective) {
$mylpi->add_objective($index, $objectives[$index]);
}
$mylpi->write_objectives_to_db();
}
return $return;
}
示例3: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
public function write_to_db()
{
if (self::debug > 0) {
error_log('learnpathItem::write_to_db()', 0);
}
// Check the session visibility.
if (!api_is_allowed_to_session_edit()) {
if (self::debug > 0) {
error_log('return false api_is_allowed_to_session_edit');
}
return false;
}
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = 'SELECT status FROM ' . $item_view_table . '
WHERE
c_id = ' . $course_id . ' AND
lp_item_id="' . $this->db_id . '" AND
lp_view_id="' . $this->view_id . '" AND
view_count="' . $this->get_attempt_id() . '" ';
$rs_verified = Database::query($sql);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
$save = true;
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if (($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' || $mode == 'review' || $mode == 'browse')) && ($this->seriousgame_mode != 1 && $this->type == 'sco')) {
if (self::debug > 1) {
error_log("This info shouldn't be saved as the credit or lesson mode info prevent it");
error_log('learnpathItem::write_to_db() - credit(' . $credit . ') or' . ' lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
// Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises.
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// We force the item to be restarted.
$this->restart();
$params = array("c_id" => $course_id, "total_time" => $this->get_total_time(), "start_time" => $this->current_start_time, "score" => $this->get_score(), "status" => $this->get_status(false), "max_score" => $this->get_max(), "lp_item_id" => $this->db_id, "lp_view_id" => $this->view_id, "view_count" => $this->get_attempt_id(), "suspend_data" => $this->current_data, "lesson_location" => $this->lesson_location);
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1), 0);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if ($this->db_item_view_id) {
$sql = "UPDATE {$item_view_table} SET id = iid\n WHERE iid = " . $this->db_item_view_id;
Database::query($sql);
$inserted = true;
}
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT * FROM {$item_view_table}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = " . $this->db_id . " AND\n lp_view_id = " . $this->view_id . " AND\n view_count = " . intval($this->get_attempt_id());
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Querying item_view: ' . $sql, 0);
}
$check_res = Database::query($sql);
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
if (!$inserted && Database::num_rows($check_res) < 1) {
$params = array("c_id" => $course_id, "total_time" => $this->get_total_time(), "start_time" => $this->current_start_time, "score" => $this->get_score(), "status" => $this->get_status(false), "max_score" => $this->get_max(), "lp_item_id" => $this->db_id, "lp_view_id" => $this->view_id, "view_count" => $this->get_attempt_id(), "suspend_data" => $this->current_data, "lesson_location" => $this->lesson_location);
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1), 0);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if ($this->db_item_view_id) {
$sql = "UPDATE {$item_view_table} SET id = iid\n WHERE iid = " . $this->db_item_view_id;
Database::query($sql);
}
} else {
if ($this->type == 'hotpotatoes') {
$params = array('total_time' => $this->get_total_time(), 'start_time' => $this->get_current_start_time(), 'score' => $this->get_score(), 'status' => $this->get_status(false), 'max_score' => $this->get_max(), 'suspend_data' => $this->current_data, 'lesson_location' => $this->lesson_location);
$where = array('c_id = ? AND lp_item_id = ? AND lp_view_id = ? AND view_count = ?' => array($course_id, $this->db_id, $this->view_id, $this->get_attempt_id()));
Database::update($item_view_table, $params, $where);
} else {
// For all other content types...
$my_status = ' ';
$total_time = ' ';
if ($this->type == 'quiz') {
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$safe_exe_id = intval($_REQUEST['exeId']);
$sql = "SELECT start_date,exe_date\n FROM {$TBL_TRACK_EXERCICES}\n WHERE exe_id = {$safe_exe_id}";
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = convert_sql_date($row_dates['start_date']);
$time_exe_date = convert_sql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// This is a array containing values finished
//.........这里部分代码省略.........
示例4: get_flat_ordered_items_list
/**
* Gets a flat list of item IDs ordered for display (level by level ordered by order_display)
* This method can be used as abstract and is recursive
* @param integer Learnpath ID
* @param integer Parent ID of the items to look for
* @return mixed Ordered list of item IDs or false on error
*/
public static function get_flat_ordered_items_list($lp, $parent = 0, $course_id = null)
{
if (empty($course_id)) {
$course_id = api_get_course_int_id();
} else {
$course_id = intval($course_id);
}
$list = array();
if (empty($lp)) {
return false;
}
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql = "SELECT id FROM {$tbl_lp_item} WHERE c_id = {$course_id} AND lp_id = {$lp} AND parent_item_id = {$parent} ORDER BY display_order";
$res = Database::query($sql);
while ($row = Database::fetch_array($res)) {
$sublist = learnpath::get_flat_ordered_items_list($lp, $row['id'], $course_id);
$list[] = $row['id'];
foreach ($sublist as $item) {
$list[] = $item;
}
}
return $list;
}
示例5: get_document_preview
/**
* @param array $course_info
* @param bool $lp_id
* @param string $target
* @param int $session_id
* @param bool $add_move_button
* @param string $filter_by_folder
* @param string $overwrite_url
* @param bool $showInvisibleFiles
* @param bool $showOnlyFolders
* @param int $folderId
* @return string
*/
public static function get_document_preview($course_info, $lp_id = false, $target = '', $session_id = 0, $add_move_button = false, $filter_by_folder = null, $overwrite_url = null, $showInvisibleFiles = false, $showOnlyFolders = false, $folderId = false)
{
if (empty($course_info['real_id']) || empty($course_info['code']) || !is_array($course_info)) {
return '';
}
$overwrite_url = Security::remove_XSS($overwrite_url);
$user_id = api_get_user_id();
$user_in_course = false;
if (api_is_platform_admin()) {
$user_in_course = true;
}
if (!$user_in_course) {
if (CourseManager::is_course_teacher($user_id, $course_info['code'])) {
$user_in_course = true;
}
}
// Condition for the session
$session_id = intval($session_id);
if (!$user_in_course) {
if (empty($session_id)) {
if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) {
$user_in_course = true;
}
// Check if course is open then we can consider that the student is registered to the course
if (isset($course_info) && in_array($course_info['visibility'], array(2, 3))) {
$user_in_course = true;
}
} else {
$user_status = SessionManager::get_user_status_in_course_session($user_id, $course_info['real_id'], $session_id);
//is true if is an student, course session teacher or coach
if (in_array($user_status, array('0', '2', '6'))) {
$user_in_course = true;
}
}
}
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$tbl_item_prop = Database::get_course_table(TABLE_ITEM_PROPERTY);
$condition_session = " AND (last.session_id = '{$session_id}' OR last.session_id = '0' OR last.session_id IS NULL)";
$add_folder_filter = null;
if (!empty($filter_by_folder)) {
$add_folder_filter = " AND docs.path LIKE '" . Database::escape_string($filter_by_folder) . "%'";
}
// If we are in LP display hidden folder https://support.chamilo.org/issues/6679
$lp_visibility_condition = null;
if ($lp_id) {
// $lp_visibility_condition = " OR filetype='folder'";
if ($showInvisibleFiles) {
$lp_visibility_condition .= ' OR last.visibility = 0';
}
}
$showOnlyFoldersCondition = null;
if ($showOnlyFolders) {
//$showOnlyFoldersCondition = " AND docs.filetype = 'folder' ";
}
$folderCondition = " AND docs.path LIKE '/%' ";
if (!api_is_allowed_to_edit()) {
$protectedFolders = self::getProtectedFolderFromStudent();
foreach ($protectedFolders as $folder) {
$folderCondition .= " AND docs.path NOT LIKE '{$folder}' ";
}
}
$parentData = [];
if ($folderId !== false) {
$parentData = self::get_document_data_by_id($folderId, $course_info['code']);
if (!empty($parentData)) {
$cleanedPath = $parentData['path'];
$num = substr_count($cleanedPath, '/');
$notLikeCondition = null;
for ($i = 1; $i <= $num; $i++) {
$repeat = str_repeat('/%', $i + 1);
$notLikeCondition .= " AND docs.path NOT LIKE '" . Database::escape_string($cleanedPath . $repeat) . "' ";
}
$folderCondition = " AND\n docs.id <> {$folderId} AND\n docs.path LIKE '" . $cleanedPath . "/%'\n {$notLikeCondition}\n ";
} else {
$folderCondition = " AND\n docs.filetype = 'file' ";
}
}
$levelCondition = null;
if ($folderId === false) {
$levelCondition = " AND docs.path NOT LIKE'/%/%'";
}
$sql = "SELECT last.visibility, docs.*\n FROM {$tbl_item_prop} AS last INNER JOIN {$tbl_doc} AS docs\n ON (docs.id = last.ref AND docs.c_id = last.c_id)\n WHERE\n docs.path NOT LIKE '%_DELETED_%' AND\n last.tool = '" . TOOL_DOCUMENT . "' {$condition_session} AND\n (last.visibility = '1' {$lp_visibility_condition}) AND\n last.visibility <> 2 AND\n docs.c_id = {$course_info['real_id']} AND\n last.c_id = {$course_info['real_id']}\n {$showOnlyFoldersCondition}\n {$folderCondition}\n {$levelCondition}\n {$add_folder_filter}\n ORDER BY docs.filetype DESC, docs.title ASC";
$res_doc = Database::query($sql);
$resources = Database::store_result($res_doc, 'ASSOC');
$return = '';
if ($lp_id) {
$learnPath = learnpath::getCurrentLpFromSession();
//.........这里部分代码省略.........
示例6: api_get_course_int_id
$form->addElement('hidden', 'action', 'add_lp_category');
$form->addElement('hidden', 'c_id', api_get_course_int_id());
$form->addElement('hidden', 'id', 0);
$form->addButtonSave(get_lang('Save'));
if ($form->validate()) {
$values = $form->getSubmitValues();
if (!empty($values['id'])) {
learnpath::updateCategory($values);
$url = api_get_self() . '?action=list&' . api_get_cidreq();
header('Location: ' . $url);
exit;
} else {
learnpath::createCategory($values);
$url = api_get_self() . '?action=list&' . api_get_cidreq();
header('Location: ' . $url);
exit;
}
} else {
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
if ($id) {
$item = learnpath::getCategory($id);
$defaults = array('id' => $item->getId(), 'name' => $item->getName());
$form->setDefaults($defaults);
}
}
Display::display_header(get_lang('LearnpathAddLearnpath'), 'Path');
echo '<div class="actions">';
echo '<a href="lp_controller.php?' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
$form->display();
Display::display_footer();
示例7: str_replace
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url);
//echo $doc_url;
if (strpos($doc_url, '../') or strpos($doc_url, '/..')) {
$doc_url = '';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/scorm';
$user_id = api_get_user_id();
/** @var learnpath $learnPath */
$learnPath = Session::read('oLP');
if ($learnPath) {
$lp_id = $learnPath->get_id();
$lp_item_id = $learnPath->current;
$lp_item_info = new learnpathItem($lp_item_id);
if (!empty($lp_item_info)) {
//if (basename($lp_item_info->path) == basename($doc_url)) {
$visible = learnpath::is_lp_visible_for_student($lp_id, $user_id);
if ($visible) {
Event::event_download($doc_url);
if (Security::check_abs_path($sys_course_path . $doc_url, $sys_course_path . '/')) {
$full_file_name = $sys_course_path . $doc_url;
DocumentManager::file_send_for_download($full_file_name);
exit;
}
}
//}
}
}
Display::display_error_message(get_lang('ProtectedDocument'));
//api_not_allowed backbutton won't work.
exit;
示例8: dealPerPage
/**
* Manages page splitting
* @param string Page header
* @param string Page body
* @return void
*/
function dealPerPage($header, $body)
{
$_course = api_get_course_info();
// Split document to pages.
$pages = explode('||page_break||', $body);
$first_item = 0;
foreach ($pages as $key => $page_content) {
// For every pages, we create a new file.
$key += 1;
$page_content = $this->format_page_content($header, $page_content, $this->base_work_dir . $this->created_dir);
$html_file = $this->created_dir . '-' . $key . '.html';
$handle = fopen($this->base_work_dir . $this->created_dir . '/' . $html_file, 'w+');
fwrite($handle, $page_content);
fclose($handle);
$document_id = add_document($_course, $this->created_dir . $html_file, 'file', filesize($this->base_work_dir . $this->created_dir . $html_file), $html_file);
$slide_name = '';
if ($document_id) {
// Put the document in item_property update.
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_SESSION['_uid'], 0, 0, null, null, api_get_session_id());
$infos = pathinfo($this->filepath);
$slide_name = 'Page ' . str_repeat('0', 2 - strlen($key)) . $key;
$previous = learnpath::add_item(0, $previous, 'document', $document_id, $slide_name, '');
if ($this->first_item == 0) {
$this->first_item = $previous;
}
// Code for text indexing.
if (isset($_POST['index_document']) && $_POST['index_document']) {
//Display::display_normal_message(print_r($_POST));
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
$di->connectDb(NULL, NULL, $lang);
$ic_slide = new IndexableChunk();
$ic_slide->addValue('title', $slide_name);
$specific_fields = get_specific_field_list();
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
if (isset($_REQUEST[$specific_field['code']])) {
$sterms = trim($_REQUEST[$specific_field['code']]);
$all_specific_terms .= ' ' . $sterms;
if (!empty($sterms)) {
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$ic_slide->addTerm(trim($sterm), $specific_field['code']);
}
}
}
}
$page_content = $all_specific_terms . ' ' . $page_content;
$ic_slide->addValue('content', $page_content);
// Add a comment to say terms separated by commas.
$courseid = api_get_course_id();
$ic_slide->addCourseId($courseid);
$ic_slide->addToolId(TOOL_LEARNPATH);
$lp_id = $this->lp_id;
$xapian_data = array(SE_COURSE_ID => $courseid, SE_TOOL_ID => TOOL_LEARNPATH, SE_DATA => array('lp_id' => $lp_id, 'lp_item' => $previous, 'document_id' => $document_id), SE_USER => (int) api_get_user_id());
$ic_slide->xapian_data = serialize($xapian_data);
$di->addChunk($ic_slide);
// Index and return search engine document id.
$did = $di->index();
if ($did) {
// Save it to db.
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, ref_id_second_level, search_did)
VALUES (NULL , \'%s\', \'%s\', %s, %s, %s)';
$sql = sprintf($sql, $tbl_se_ref, api_get_course_id(), TOOL_LEARNPATH, $lp_id, $previous, $did);
Database::query($sql);
}
}
}
}
}
示例9: api_protect_course_script
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.learnpath
*/
require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'lp/impress';
$this_section = SECTION_COURSES;
//To prevent the template class
$show_learnpath = true;
api_protect_course_script();
$lp_id = intval($_GET['lp_id']);
// Check if the learning path is visible for student - (LP requisites)
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
api_not_allowed();
}
//Checking visibility (eye icon)
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_LEARNPATH, $lp_id, $action, api_get_user_id(), api_get_session_id());
if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0) {
api_not_allowed();
}
if (empty($_SESSION['oLP'])) {
api_not_allowed(true);
}
$debug = 0;
if ($debug) {
error_log('------ Entering lp_impress.php -------');
}
$course_code = api_get_course_id();
示例10: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
public function write_to_db()
{
if (self::debug > 0) {
error_log('learnpathItem::write_to_db()', 0);
}
// Check the session visibility.
if (!api_is_allowed_to_session_edit()) {
if (self::debug > 0) {
error_log('return false api_is_allowed_to_session_edit');
}
return false;
}
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql_verified = 'SELECT status FROM ' . $item_view_table . '
WHERE c_id = ' . $course_id . ' AND lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->get_attempt_id() . '" ;';
$rs_verified = Database::query($sql_verified);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
$save = true;
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if (($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' or $mode == 'review' or $mode == 'browse')) && ($this->seriousgame_mode != 1 && $this->type == 'sco')) {
if (self::debug > 1) {
error_log("This info shouldn't be saved as the credit or lesson mode info prevent it");
error_log('learnpathItem::write_to_db() - credit(' . $credit . ') or lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
// Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises.
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// We force the item to be restarted.
$this->restart();
$sql = "INSERT INTO {$item_view_table} " . "(c_id, total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "({$course_id}, " . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . $sql, 0);
}
$res = Database::query($sql);
$this->db_item_view_id = Database::insert_id();
$inserted = true;
}
$check_attempts = self::check_attempts($this->get_attempt_id());
if (!$check_attempts) {
return false;
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$check = "SELECT * FROM {$item_view_table}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = " . $this->db_id . " AND\n lp_view_id = " . $this->view_id . " AND\n view_count = " . $this->get_attempt_id();
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Querying item_view: ' . $check, 0);
}
$check_res = Database::query($check);
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
$res = 0;
if (!$inserted && Database::num_rows($check_res) < 1) {
$sql = "INSERT INTO {$item_view_table} " . "(c_id, total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "({$course_id}, " . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view: ' . $sql, 0);
}
$res = Database::query($sql);
$this->db_item_view_id = Database::insert_id();
} else {
$sql = '';
if ($this->type == 'hotpotatoes') {
$sql = "UPDATE {$item_view_table} " . "SET total_time = " . $this->get_total_time() . ", " . " start_time = " . $this->get_current_start_time() . ", " . " score = " . $this->get_score() . ", " . " status = '" . $this->get_status(false) . "'," . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE c_id = {$course_id} AND lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id . " " . "AND view_count = " . $this->get_attempt_id();
} else {
// For all other content types...
if ($this->type == 'quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
$sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . (int) $safe_exe_id;
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = api_convert_sql_date($row_dates['start_date']);
$time_exe_date = api_convert_sql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// This is a array containing values finished
$case_completed = array('completed', 'passed', 'browsed', 'failed');
//is not multiple attempts
if ($this->seriousgame_mode == 1 && $this->type == 'sco') {
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
$my_status = " status = '" . $this->get_status(false) . "' ,";
} elseif ($this->get_prevent_reinit() == 1) {
//.........这里部分代码省略.........
示例11: isset
* @author Yannick Warnier <ywarnier@beeznest.org> (extended and maintained - 2005-2014)
* @version v 1.2
* @access public
* @package chamilo.learnpath.scorm
*/
// If you open the imsmanifest.xml via local machine (f.ex.: file://c:/...), then the Apiwrapper.js
// of Maritime Navigation when trying to execute this row
// var result = api.LMSInitialize("");
// get the error response : you are not authorized to call this function
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
//require_once '../inc/global.inc.php';
\Chamilo\CoreBundle\Framework\Container::$legacyTemplate = 'layout_empty.html.twig';
$file = Session::read('file');
/** @var learnpath $oLP */
$oLP = learnpath::getCurrentLpFromSession();
/** @var learnpathItem $oItem */
$oItem = isset($oLP->items[$oLP->current]) ? $oLP->items[$oLP->current] : null;
if (!is_object($oItem)) {
error_log('New LP - scorm_api - Could not load oItem item', 0);
exit;
}
$autocomplete_when_80pct = 0;
$user = api_get_user_info();
$userId = api_get_user_id();
header('Content-type: text/javascript');
?>
var scorm_logs=<?php
echo (empty($oLP->scorm_debug) or !api_is_course_admin() && !api_is_platform_admin()) ? '0' : '3';
?>
; //debug log level for SCORM. 0 = none, 1=light, 2=a lot, 3=all - displays logs in log frame
示例12: session_cache_limiter
session_cache_limiter('none');
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Protection
api_protect_course_script();
if (!isset($_course)) {
api_not_allowed(true);
}
// If LP obj exists
if (isset($_SESSION['oLP'])) {
$obj = $_SESSION['oLP'];
} else {
api_not_allowed();
}
//If is visible for the current user
if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id())) {
api_not_allowed();
}
$doc_url = isset($_GET['doc_url']) ? $_GET['doc_url'] : null;
// Change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $doc_url);
// Still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url);
//echo $doc_url;
if (strpos($doc_url, '../') or strpos($doc_url, '/..')) {
$doc_url = '';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/scorm';
//var_dump($sys_course_path);
if (is_dir($sys_course_path . $doc_url)) {
示例13: api_get_path
if (!isset($_POST['file_name'])) {
return false;
}
// Escape path with basename so it can only be directly into the archive/ directory.
$s = api_get_path(SYS_ARCHIVE_PATH) . basename($_POST['file_name']);
// Get name of the zip file without the extension
$info = pathinfo($s);
$filename = $info['basename'];
$extension = $info['extension'];
$file_base_name = str_replace('.' . $extension, '', $filename);
$new_dir = api_replace_dangerous_char(trim($file_base_name));
$result = learnpath::verify_document_size($s);
if ($result == true) {
throw new \Exception(get_lang('UplFileTooBig'));
}
$type = learnpath::get_package_type($s, basename($s));
switch ($type) {
case 'scorm':
require_once 'scorm.class.php';
$oScorm = new scorm();
$manifest = $oScorm->import_local_package($s, $current_dir);
if ($manifest === false) {
throw new \Exception('Error import local package');
}
if (!empty($manifest)) {
$oScorm->parse_manifest($manifest);
$oScorm->import_manifest(api_get_course_id(), $_REQUEST['use_max_score']);
}
$proximity = '';
if (!empty($_REQUEST['content_proximity'])) {
$proximity = Database::escape_string($_REQUEST['content_proximity']);
示例14: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
function write_to_db()
{
if ($this->debug > 0) {
error_log('New LP - In learnpathItem::write_to_db()', 0);
}
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$my_verified_status = $this->get_status(false);
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql_verified = 'SELECT status FROM ' . $item_view_table . ' WHERE lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->attempt_id . '" ;';
$rs_verified = Database::query($sql_verified, __FILE__, __LINE__);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
//added by isaac flores
if (in_array($sql_verified['status'], $my_case_completed)) {
$save = false;
} else {
$save = true;
}
if ($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' or $mode == 'review' or $mode == 'browse')) {
//this info shouldn't be saved as the credit or lesson mode info prevent it
if ($this->debug > 1) {
error_log('New LP - In learnpathItem::write_to_db() - credit(' . $credit . ') or lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
//check the row exists
$inserted = false;
// this a special case for multiple attempts and Dokeos exercises
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// we force the item to be restarted
$this->restart();
$sql = "INSERT INTO {$item_view_table} " . "(total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "(" . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view forced: ' . $sql, 0);
}
$res = Database::query($sql, __FILE__, __LINE__);
$this->db_item_view_id = Database::insert_id();
$inserted = true;
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$check = "SELECT * FROM {$item_view_table} " . "WHERE lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id;
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Querying item_view: ' . $check, 0);
}
$check_res = Database::query($check);
//depending on what we want (really), we'll update or insert a new row
//now save into DB
$res = 0;
if ($inserted == false && Database::num_rows($check_res) < 1) {
/*$my_status = '';
if ($this->type!=TOOL_QUIZ) {
$my_status = $this->get_status(false);
}*/
$sql = "INSERT INTO {$item_view_table} " . "(total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "(" . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view: ' . $sql, 0);
}
$res = Database::query($sql, __FILE__, __LINE__);
$this->db_item_view_id = Database::insert_id();
} else {
$sql = '';
if ($this->type == 'hotpotatoes') {
//make an exception for HotPotatoes, don't update the score
//because it has been saved outside of this tool
$sql = "UPDATE {$item_view_table} " . "SET total_time = " . $this->get_total_time() . ", " . " start_time = " . $this->get_current_start_time() . ", " . " score = " . $this->get_score() . ", " . " status = '" . $this->get_status(false) . "'," . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id;
} else {
//for all other content types...
if ($this->type == 'quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
$sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . (int) $safe_exe_id;
$res = Database::query($sql, __FILE__, __LINE__);
$row_dates = Database::fetch_array($res);
$time_start_date = convert_mysql_date($row_dates['start_date']);
$time_exe_date = convert_mysql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// this is a array containing values finished
$case_completed = array('completed', 'passed', 'browsed');
//is not multiple attempts
if ($this->get_prevent_reinit() == 1) {
// process of status verified into data base
$sql_verified = 'SELECT status FROM ' . $item_view_table . ' WHERE lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->attempt_id . '" ;';
$rs_verified = Database::query($sql_verified, __FILE__, __LINE__);
$row_verified = Database::fetch_array($rs_verified);
//get type lp: 1=lp dokeos and 2=scorm
// if not is completed or passed or browsed and learning path is scorm
if (!in_array($this->get_status(false), $case_completed) && $my_type_lp == 2) {
//&& $this->type!='dir'
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
//.........这里部分代码省略.........
示例15: is_visible
/**
* Checks if the exercise is visible due a lot of conditions
* visibility, time limits, student attempts
* Return associative array
* value : true if execise visible
* message : HTML formated message
* rawMessage : text message
* @param int $lpId
* @param int $lpItemId
* @param int $lpItemViewId
* @param bool $filterByAdmin
* @return array
*/
public function is_visible($lpId = 0, $lpItemId = 0, $lpItemViewId = 0, $filterByAdmin = true)
{
// 1. By default the exercise is visible
$is_visible = true;
$message = null;
// 1.1 Admins and teachers can access to the exercise
if ($filterByAdmin) {
if (api_is_platform_admin() || api_is_course_admin()) {
return array('value' => true, 'message' => '');
}
}
// Deleted exercise.
if ($this->active == -1) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
// Checking visibility in the item_property table.
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
if ($visibility == 0 || $visibility == 2) {
$this->active = 0;
}
// 2. If the exercise is not active.
if (empty($lpId)) {
// 2.1 LP is OFF
if ($this->active == 0) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
} else {
// 2.1 LP is loaded
if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lpId, api_get_user_id())) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
}
//3. We check if the time limits are on
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00' || !empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') {
$limitTimeExists = true;
} else {
$limitTimeExists = false;
}
if ($limitTimeExists) {
$timeNow = time();
$existsStartDate = false;
$nowIsAfterStartDate = true;
$existsEndDate = false;
$nowIsBeforeEndDate = true;
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$existsStartDate = true;
}
if (!empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') {
$existsEndDate = true;
}
// check if we are before-or-after end-or-start date
if ($existsStartDate && $timeNow < api_strtotime($this->start_time, 'UTC')) {
$nowIsAfterStartDate = false;
}
if ($existsEndDate & $timeNow >= api_strtotime($this->end_time, 'UTC')) {
$nowIsBeforeEndDate = false;
}
// lets check all cases
if ($existsStartDate && !$existsEndDate) {
// exists start date and dont exists end date
if ($nowIsAfterStartDate) {
// after start date, no end date
$isVisible = true;
$message = sprintf(get_lang('ExerciseAvailableSinceX'), api_convert_and_format_date($this->start_time));
} else {
// before start date, no end date
$isVisible = false;
$message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
}
} else {
if (!$existsStartDate && $existsEndDate) {
// doesnt exist start date, exists end date
if ($nowIsBeforeEndDate) {
// before end date, no start date
$isVisible = true;
$message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
} else {
// after end date, no start date
$isVisible = false;
$message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
}
} elseif ($existsStartDate && $existsEndDate) {
// exists start date and end date
if ($nowIsAfterStartDate) {
if ($nowIsBeforeEndDate) {
// after start date and before end date
$isVisible = true;
//.........这里部分代码省略.........