当前位置: 首页>>代码示例>>PHP>>正文


PHP learnpath::getLpFromSession方法代码示例

本文整理汇总了PHP中learnpath::getLpFromSession方法的典型用法代码示例。如果您正苦于以下问题:PHP learnpath::getLpFromSession方法的具体用法?PHP learnpath::getLpFromSession怎么用?PHP learnpath::getLpFromSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在learnpath的用法示例。


在下文中一共展示了learnpath::getLpFromSession方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:25,代码来源:lp_ajax_save_objectives.php

示例2: switch_item_details

/**
 * Get one item's details
 * @param   integer LP ID
 * @param   integer user ID
 * @param   integer View ID
 * @param   integer Current item ID
 * @param   integer New item ID
 */
function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_item)
{
    $debug = 0;
    $return = '';
    if ($debug > 0) {
        error_log('In xajax_switch_item_details(' . $lp_id . ',' . $user_id . ',' . $view_id . ',' . $current_item . ',' . $next_item . ')', 0);
    }
    //$objResponse = new xajaxResponse();
    /*$item_id may be one of:
     * -'next'
     * -'previous'
     * -'first'
     * -'last'
     * - a real item ID
     */
    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
    $new_item_id = 0;
    switch ($next_item) {
        case 'next':
            $mylp->set_current_item($current_item);
            $mylp->next();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) {
                error_log('In {next} - next item is ' . $new_item_id . '(current: ' . $current_item . ')', 0);
            }
            break;
        case 'previous':
            $mylp->set_current_item($current_item);
            $mylp->previous();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) {
                error_log('In {previous} - next item is ' . $new_item_id . '(current: ' . $current_item . ')', 0);
            }
            break;
        case 'first':
            $mylp->set_current_item($current_item);
            $mylp->first();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) {
                error_log('In {first} - next item is ' . $new_item_id . '(current: ' . $current_item . ')', 0);
            }
            break;
        case 'last':
            break;
        default:
            // Should be filtered to check it's not hacked.
            if ($next_item == $current_item) {
                // If we're opening the same item again.
                $mylp->items[$current_item]->restart();
            }
            $new_item_id = $next_item;
            $mylp->set_current_item($new_item_id);
            if ($debug > 1) {
                error_log('In {default} - next item is ' . $new_item_id . '(current: ' . $current_item . ')', 0);
            }
            break;
    }
    $mylp->start_current_item(true);
    if ($mylp->force_commit) {
        $mylp->save_current();
    }
    if (is_object($mylp->items[$new_item_id])) {
        $mylpi = $mylp->items[$new_item_id];
    } else {
        if ($debug > 1) {
            error_log('In switch_item_details - generating new item object', 0);
        }
        $mylpi = new learnpathItem($new_item_id, $user_id);
        $mylpi->set_lp_view($view_id);
    }
    /*
     * now get what's needed by the SCORM API:
     * -score
     * -max
     * -min
     * -lesson_status
     * -session_time
     * -suspend_data
     */
    $myscore = $mylpi->get_score();
    $mymax = $mylpi->get_max();
    if ($mymax === '') {
        $mymax = "''";
    }
    $mymin = $mylpi->get_min();
    $mylesson_status = $mylpi->get_status();
    $mylesson_location = $mylpi->get_lesson_location();
    $mytotal_time = $mylpi->get_scorm_time('js');
    $mymastery_score = $mylpi->get_mastery_score();
    $mymax_time_allowed = $mylpi->get_max_time_allowed();
    $mylaunch_data = $mylpi->get_launch_data();
    /*
//.........这里部分代码省略.........
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:lp_ajax_switch_item.php

示例3: last_update_status

/**
 * 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
 * @return  string  JavaScript operations to execute as soon as returned
 */
function last_update_status($lp_id, $user_id, $view_id, $item_id) {
    error_log(__LINE__);
    global $_configuration;
    $debug = 0;
    $return = '';
    if ($debug > 0) { error_log('In last_update_status('.$lp_id.','.$user_id.','.$view_id.','.$item_id.')', 0); }
    require_once 'learnpath.class.php';
    require_once 'scorm.class.php';
    require_once 'learnpathItem.class.php';
    require_once 'scormItem.class.php';
    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);

    // This function should only be used for SCORM paths.
    if ($mylp->get_type() != 2) {
        return;
    }
    $prereq_check = $mylp->prerequisites_match($item_id);
    $mystatus = '';
    if ($prereq_check === true) {
        error_log(__LINE__);
        // Launch the prerequisites check and set error if needed.
        $mylpi =& $mylp->items[$item_id];

        $mystatus_in_db = $mylpi->get_status(true);
        error_log($mystatus_in_db);
        if ($mystatus_in_db == 'not attempted' or $mystatus_in_db == '') {
        error_log(__LINE__);
            $mystatus = 'completed';
            $mastery_score = $mylpi->get_mastery_score();
            if ($mastery_score != -1) {
        error_log(__LINE__);
                $score = $mylpi->get_score();
                if ($score != 0 && $score >= $mastery_score) {
        error_log(__LINE__);
                    $mystatus = 'passed';
                } else {
        error_log(__LINE__);
                    $mystatus = 'failed';
                }
            }
            error_log(__LINE__);
            $mylpi->set_status($mystatus);
            $mylp->save_item($item_id, false);
        } else {
            error_log(__LINE__);
            return $return;
        }
    } else {
        error_log(__LINE__);
        return $return;
    }
    error_log(__LINE__);
    $mytotal = $mylp->get_total_items_count_without_chapters();
    $mycomplete = $mylp->get_complete_items_count();
    $myprogress_mode = $mylp->get_progress_bar_mode();
    $myprogress_mode = ($myprogress_mode==''?'%':$myprogress_mode);
    $return .= "update_toc('".$mystatus."','".$item_id."','no');";
    error_log('Return is now '.$return);
    $update_list = $mylp->get_update_queue();
    foreach ($update_list as $my_upd_id => $my_upd_status) {
        if ($my_upd_id != $item_id) { // Only update the status from other items (i.e. parents and brothers), do not update current as we just did it already.
            $return .= "update_toc('".$my_upd_status."','".$my_upd_id."','no');";
        }
    }
    $return .= "update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');";
    $return .="update_stats();";
    return $return;
    //return $objResponse;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:77,代码来源:lp_ajax_last_update_status.php

示例4: initialize_item

/**
 * Get one item's details
 * @param   integer LP ID
 * @param   integer user ID
 * @param   integer View ID
 * @param   integer Current item ID
 * @param   integer New item ID
 */
function initialize_item($lp_id, $user_id, $view_id, $next_item) {
    global $debug;
    $return = '';
    if ($debug > 0) { error_log('In initialize_item('.$lp_id.','.$user_id.','.$view_id.','.$next_item.')', 0); }
    /*$item_id may be one of:
     * -'next'
     * -'previous'
     * -'first'
     * -'last'
     * - a real item ID
     */
    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
    $mylp->set_current_item($next_item);
    if ($debug > 1) { error_log('In initialize_item() - new item is '.$next_item, 0); }
    $mylp->start_current_item(true);

    if (is_object($mylp->items[$next_item])) {
        if ($debug > 1) { error_log('In initialize_item - recovering existing item object '.$next_item, 0); }
        $mylpi = $mylp->items[$next_item];
    } else {
        if ($debug > 1) { error_log('In initialize_item - generating new item object '.$next_item, 0); }
        $mylpi = new learnpathItem($next_item, $user_id);
    }

    if ($mylpi) {
        $mylpi->set_lp_view($view_id);
    }

    /*
     * now get what's needed by the SCORM API:
     * -score
     * -max
     * -min
     * -lesson_status
     * -session_time
     * -suspend_data
     */
    $myscore = $mylpi->get_score();
    $mymax = $mylpi->get_max();
    if ($mymax === '') { $mymax = "''"; }
    $mymin = $mylpi->get_min();

    $mylesson_status = $mylpi->get_status();
    $mytotal_time = $mylpi->get_scorm_time('js', null, true);
    $mymastery_score = $mylpi->get_mastery_score();
    $mymax_time_allowed = $mylpi->get_max_time_allowed();
    $mylaunch_data = $mylpi->get_launch_data();
    $mysession_time = $mylpi->get_total_time();
    $mysuspend_data = $mylpi->get_suspend_data();
    $mylesson_location = $mylpi->get_lesson_location();
    $myic = $mylpi->get_interactions_count();
    $myistring = '';
    for ($i = 0; $i < $myic; $i++) {
        $myistring .= ",[".$i.",'','','','','','','']";
    }
    if (!empty($myistring)) {
        $myistring = substr($myistring, 1);
    }
	// Obtention des donnees d'objectifs

	$mycoursedb = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
    $course_id = api_get_course_int_id();
	$mylp_iv_id = $mylpi->db_item_view_id;

    $phpobjectives = array();

    if (!empty($mylp_iv_id)) {
        $sql = "SELECT objective_id, status, score_raw, score_max, score_min
            FROM $mycoursedb
            WHERE lp_iv_id = $mylp_iv_id AND c_id = $course_id
            ORDER BY id ASC;";
        $res = Database::query($sql);
        while ($row = Database::fetch_row($res)) {
            $phpobjectives[] = $row;
        }
    }
	$myobjectives = json_encode($phpobjectives);

    $return .=
            "olms.score=".$myscore.";" .
            "olms.max=".$mymax.";" .
            "olms.min=".$mymin.";" .
            "olms.lesson_status='".$mylesson_status."';" .
            "olms.lesson_location='".$mylesson_location."';" .
            "olms.session_time='".$mysession_time."';" .
            "olms.suspend_data='".$mysuspend_data."';" .
            "olms.total_time = '".$mytotal_time."';" .
            "olms.mastery_score = '".$mymastery_score."';" .
            "olms.max_time_allowed = '".$mymax_time_allowed."';" .
            "olms.launch_data = '".$mylaunch_data."';" .
            "olms.interactions = new Array(".$myistring.");" .
            //"olms.item_objectives = new Array();" .
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:lp_ajax_initialize.php

示例5: save_item

/**
 * Writes an item's new values into the database and returns the operation result
 * @param   int $lp_id Learnpath ID
 * @param   int $user_id User ID
 * @param   int $view_id View ID
 * @param   int $item_id Item ID
 * @param   float  $score Current score
 * @param   float  $max Maximum score
 * @param   float  $min Minimum score
 * @param   string  $status Lesson status
 * @param   int  $time Session time
 * @param   string  $suspend Suspend data
 * @param   string  $location Lesson location
 * @param   array   $interactions Interactions array
 * @param   string  $core_exit Core exit SCORM string
 * @param   int     $sessionId Session ID
 * @param   int     $courseId Course ID
 * @param   int     $lmsFinish Whether the call was issued from SCORM's LMSFinish()
 * @param   int     $userNavigatesAway Whether the user is moving to another item
 * @param   int     $statusSignalReceived Whether the SCO called SetValue(lesson_status)
 * @return bool|null|string The resulting JS string
 */
function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1.0, $max = -1.0, $min = -1.0, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none', $sessionId = null, $courseId = null, $lmsFinish = 0, $userNavigatesAway = 0, $statusSignalReceived = 0)
{
    //global $debug;
    $debug = 0;
    $return = null;
    if ($debug > 0) {
        error_log('lp_ajax_save_item.php : save_item() params: ');
        error_log("item_id: {$item_id}");
        error_log("lp_id: {$lp_id} - user_id: - {$user_id} - view_id: {$view_id} - item_id: {$item_id}");
        error_log("score: {$score} - max:{$max} - min: {$min} - status:{$status}");
        error_log("time:{$time} - suspend: {$suspend} - location: {$location} - core_exit: {$core_exit}");
        error_log("finish: {$lmsFinish} - navigatesAway: {$userNavigatesAway}");
    }
    $myLP = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
    if (!is_a($myLP, 'learnpath')) {
        if ($debug) {
            error_log("mylp variable is not an learnpath object");
        }
        return null;
    }
    $prerequisitesCheck = $myLP->prerequisites_match($item_id);
    /** @var learnpathItem $myLPI */
    $myLPI = isset($myLP->items[$item_id]) ? $myLP->items[$item_id] : '';
    if (empty($myLPI)) {
        if ($debug > 0) {
            error_log("item #{$item_id} not found in the items array: " . print_r($myLP->items, 1));
        }
        return false;
    }
    // This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
    $myLPI->set_lp_view($view_id);
    // Launch the prerequisites check and set error if needed
    if ($prerequisitesCheck !== true) {
        // If prerequisites were not matched, don't update any item info
        if ($debug) {
            error_log("prereq_check: " . intval($prerequisitesCheck));
        }
        return $return;
    } else {
        if ($debug > 1) {
            error_log('Prerequisites are OK');
        }
        if (isset($max) && $max != -1) {
            $myLPI->max_score = $max;
            $myLPI->set_max_score($max);
            if ($debug > 1) {
                error_log("Setting max_score: {$max}");
            }
        }
        if (isset($min) && $min != -1 && $min != 'undefined') {
            $myLPI->min_score = $min;
            if ($debug > 1) {
                error_log("Setting min_score: {$min}");
            }
        }
        // set_score function used to save the status, but this is not the case anymore
        if (isset($score) && $score != -1) {
            if ($debug > 1) {
                error_log('Calling set_score(' . $score . ')', 0);
                error_log('set_score changes the status to failed/passed if mastery score is provided', 0);
            }
            $myLPI->set_score($score);
            if ($debug > 1) {
                error_log('Done calling set_score ' . $myLPI->get_score(), 0);
            }
        } else {
            if ($debug > 1) {
                error_log("Score not updated");
            }
        }
        $statusIsSet = false;
        // Default behaviour.
        if (isset($status) && $status != '' && $status != 'undefined') {
            if ($debug > 1) {
                error_log('Calling set_status(' . $status . ')', 0);
            }
            $myLPI->set_status($status);
            $statusIsSet = true;
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:lp_ajax_save_item.php

示例6: switch_item_toc

/**
 * Get one item's details
 * @param   integer LP ID
 * @param   integer user ID
 * @param   integer View ID
 * @param   integer Current item ID
 * @param   integer New item ID
 */
function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item) {
    $debug = 0;
    $return = '';
    if ($debug > 0) { error_log('In xajax_switch_item_toc('.$lp_id.','.$user_id.','.$view_id.','.$current_item.','.$next_item.')', 0); }
    require_once 'learnpath.class.php';
    require_once 'scorm.class.php';
    require_once 'aicc.class.php';
    require_once 'learnpathItem.class.php';
    require_once 'scormItem.class.php';
    require_once 'aiccItem.class.php';
    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
    $new_item_id = 0;
    switch ($next_item) {
        case 'next':
            $mylp->set_current_item($current_item);
            $mylp->next();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {next} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'previous':
            $mylp->set_current_item($current_item);
            $mylp->previous();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {previous} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'first':
            $mylp->set_current_item($current_item);
            $mylp->first();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {first} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'last':
            break;
        default:
            // Should be filtered to check it's not hacked
            if($next_item == $current_item){
                // If we're opening the same item again.
                $mylp->items[$current_item]->restart();
            }
            $new_item_id = $next_item;
            $mylp->set_current_item($new_item_id);
            if ($debug > 1) { error_log('In {default} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
    }
    $mylp->start_current_item(true);
    if ($mylp->force_commit) {
        $mylp->save_current();
    }
    if (is_object($mylp->items[$new_item_id])) {
        $mylpi = $mylp->items[$new_item_id];
    } else {
        if ($debug > 1) { error_log('In switch_item_details - generating new item object', 0); }
        $mylpi = new learnpathItem($new_item_id, $user_id);
        $mylpi->set_lp_view($view_id);
    }
    /*
     * now get what's needed by the SCORM API:
     * -score
     * -max
     * -min
     * -lesson_status
     * -session_time
     * -suspend_data
     */
    $myscore = $mylpi->get_score();
    $mymax = $mylpi->get_max();
    if ($mymax === '') { $mymax = "''"; }
    $mymin = $mylpi->get_min();
    $mylesson_status = $mylpi->get_status();
    $mylesson_location = $mylpi->get_lesson_location();
    $mytotal_time = $mylpi->get_scorm_time('js');
    $mymastery_score = $mylpi->get_mastery_score();
    $mymax_time_allowed = $mylpi->get_max_time_allowed();
    $mylaunch_data = $mylpi->get_launch_data();
    /*
    if ($mylpi->get_type() == 'asset') {
        // Temporary measure to save completion of an asset. Later on, Chamilo should trigger something on unload, maybe... (even though that would mean the last item cannot be completed)
        $mylesson_status = 'completed';
        $mylpi->set_status('completed');
        $mylpi->save();
    }
    */
    $mysession_time = $mylpi->get_total_time();
    $mysuspend_data = $mylpi->get_suspend_data();
    $mylesson_location = $mylpi->get_lesson_location();
    $myic = $mylpi->get_interactions_count();
    $myistring = '';
    for ($i = 0; $i < $myic; $i++) {
        $myistring .= ",[".$i.",'','','','','','','']";
    }
    if (!empty($myistring)) {
        $myistring = substr($myistring, 1);
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:lp_ajax_switch_item_toc.php

示例7: switch_item_toc

/**
 * Get one item's details
 * @param   integer $lpId LP ID
 * @param   integer $userId user ID
 * @param   integer $viewId View ID
 * @param   integer $currentItem Current item ID
 * @param   integer $nextItem New item ID
 * @return  string  JavaScript commands to be executed in scorm_api.php
 */
function switch_item_toc($lpId, $userId, $viewId, $currentItem, $nextItem)
{
    $debug = 0;
    $return = '';
    if ($debug > 0) {
        error_log('In switch_item_toc(' . $lpId . ',' . $userId . ',' . $viewId . ',' . $currentItem . ',' . $nextItem . ')', 0);
    }
    $myLP = learnpath::getLpFromSession(api_get_course_id(), $lpId, $userId);
    $newItemId = 0;
    $oldItemId = 0;
    switch ($nextItem) {
        case 'next':
            $myLP->set_current_item($currentItem);
            $myLP->next();
            $newItemId = $myLP->get_current_item_id();
            if ($debug > 1) {
                error_log('In {next} - next item is ' . $newItemId . '(current: ' . $currentItem . ')', 0);
            }
            break;
        case 'previous':
            $myLP->set_current_item($currentItem);
            $myLP->previous();
            $newItemId = $myLP->get_current_item_id();
            if ($debug > 1) {
                error_log('In {previous} - next item is ' . $newItemId . '(current: ' . $currentItem . ')', 0);
            }
            break;
        case 'first':
            $myLP->set_current_item($currentItem);
            $myLP->first();
            $newItemId = $myLP->get_current_item_id();
            if ($debug > 1) {
                error_log('In {first} - next item is ' . $newItemId . '(current: ' . $currentItem . ')', 0);
            }
            break;
        case 'last':
            break;
        default:
            // Should be filtered to check it's not hacked
            if ($nextItem == $currentItem) {
                // If we're opening the same item again.
                $myLP->items[$currentItem]->restart();
            } else {
                $oldItemId = $currentItem;
            }
            $newItemId = $nextItem;
            $myLP->set_current_item($newItemId);
            if ($debug > 1) {
                error_log('In {default} - next item is ' . $newItemId . '(current: ' . $currentItem . ')', 0);
            }
            break;
    }
    $myLP->start_current_item(true);
    if ($myLP->force_commit) {
        $myLP->save_current();
    }
    if (is_object($myLP->items[$newItemId])) {
        $myLPI = $myLP->items[$newItemId];
    } else {
        if ($debug > 1) {
            error_log('In switch_item_details - generating new item object', 0);
        }
        $myLPI = new learnpathItem($newItemId, $userId);
        $myLPI->set_lp_view($viewId);
    }
    /*
     * now get what's needed by the SCORM API:
     * -score
     * -max
     * -min
     * -lesson_status
     * -session_time
     * -suspend_data
     */
    $lessonStatus = $myLPI->get_status();
    $interactionsCount = $myLPI->get_interactions_count();
    /**
     * Interactions are not returned by switch_item at the moment, but please
     * leave commented code to allow for the addition of these in the future
     */
    /*
    $interactionsString = '';
    for ($i = 0; $i < $interactionsCount; $i++) {
        $interactionsString .= ",[".$i.",'','','','','','','']";
    }
    if (!empty($interactionsString)) {
        $interactionsString = substr($interactionsString, 1);
    }
    */
    $totalItems = $myLP->get_total_items_count_without_chapters();
    $completedItems = $myLP->get_complete_items_count();
//.........这里部分代码省略.........
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:lp_ajax_switch_item_toc.php

示例8: switch_item_details

/**
 * Get one item's details
 * @param	integer	LP ID
 * @param	integer	user ID
 * @param	integer	View ID
 * @param	integer	Current item ID
 * @param	integer New item ID
 */
function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_item) {
    global $charset;

    $debug = 0;
    if ($debug > 0) { error_log('In xajax_switch_item_details('.$lp_id.','.$user_id.','.$view_id.','.$current_item.','.$next_item.')', 0); }
    $objResponse = new xajaxResponse();
    /*$item_id may be one of:
     * -'next'
     * -'previous'
     * -'first'
     * -'last'
     * - a real item ID
     */
    require_once 'learnpath.class.php';
    require_once 'scorm.class.php';
    require_once 'aicc.class.php';
    require_once 'learnpathItem.class.php';
    require_once 'scormItem.class.php';
    require_once 'aiccItem.class.php';
    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
    $new_item_id = 0;
    switch ($next_item) {
        case 'next':
            $mylp->set_current_item($current_item);
            $mylp->next();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {next} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'previous':
            $mylp->set_current_item($current_item);
            $mylp->previous();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {previous} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'first':
            $mylp->set_current_item($current_item);
            $mylp->first();
            $new_item_id = $mylp->get_current_item_id();
            if ($debug > 1) { error_log('In {first} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
        case 'last':
            break;
        default:
            // Should be filtered to check it's not hacked.
            if($next_item == $current_item){
                // If we're opening the same item again.
                $mylp->items[$current_item]->restart();
            }
            $new_item_id = $next_item;
            $mylp->set_current_item($new_item_id);
            if ($debug > 1) { error_log('In {default} - next item is '.$new_item_id.'(current: '.$current_item.')', 0); }
            break;
    }
    $mylp->start_current_item(true);
    if ($mylp->force_commit){
        $mylp->save_current();
    }
    //$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
    if (is_object($mylp->items[$new_item_id])) {
        $mylpi = $mylp->items[$new_item_id];
    } else {
        if ($debug > 1) { error_log('In switch_item_details - generating new item object', 0); }
        $mylpi = new learnpathItem($new_item_id, $user_id);
        $mylpi->set_lp_view($view_id);
    }
    /*
     * now get what's needed by the SCORM API:
     * -score
     * -max
     * -min
     * -lesson_status
     * -session_time
     * -suspend_data
     */
    $myscore = $mylpi->get_score();
    $mymax = $mylpi->get_max();
    $mymin = $mylpi->get_min();
    $mylesson_status = $mylpi->get_status();
    $mylesson_location = $mylpi->get_lesson_location();
    $mytotal_time = $mylpi->get_scorm_time('js');
    $mymastery_score = $mylpi->get_mastery_score();
    $mymax_time_allowed = $mylpi->get_max_time_allowed();
    $mylaunch_data = $mylpi->get_launch_data();
    /*
    if ($mylpi->get_type() == 'asset') {
        // Temporary measure to save completion of an asset. Later on, Chamilo should trigger something on unload, maybe... (even though that would mean the last item cannot be completed)
        $mylesson_status = 'completed';
        $mylpi->set_status('completed');
        $mylpi->save();
    }
    */
    $mysession_time = $mylpi->get_total_time();
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:lp_comm.server.php


注:本文中的learnpath::getLpFromSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。