Example #1
0
function map_gen_lesson($uid, $unit, $sb)
{
    global $course, $now;
    if (frand() < $sb->attr) {
        $action = BOLT_ACTION_NONE;
        $t = $now;
    } else {
        $action = BOLT_ACTION_NEXT;
        $t = $now + urand($sb->time_mean, $sb->time_dev);
    }
    $mode = BOLT_MODE_LESSON;
    BoltView::insert("(user_id, course_id, item_name, action, mode, start_time, end_time) values ({$uid}, {$course->id}, '{$unit->name}', {$action}, {$mode}, {$now}, {$t})");
    return $action == BOLT_ACTION_NEXT;
}
function uget_varid($lc_ip)
{
    // 請傳入 $REMOTE_ADDR 之環境變數值 (本值如果在本函數中取得, 則會取到 [空白], 所以才需要在函數外面傳入)
    $m_return = $lc_ip . "_" . strval(urand(10000000, 99999999));
    return $m_return;
}