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


PHP EventManager::notify方法代码示例

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


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

示例1: get_module_course_tbl

            $previousTotalTimeTab[1] += $spentTime;
            $previousTotalTimeTab[0] += (int) ($previousTotalTimeTab[1] / 60);
            $previousTotalTimeTab[1] %= 60;
            $newTotalTime = '';
            if ($previousTotalTimeTab[0] > 9999) {
                $newTotalTime = '9999:59:59';
            } else {
                if ($previousTotalTimeTab[0] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[0] . ':';
                if ($previousTotalTimeTab[1] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[1] . ':' . $previousTotalTimeTab[2];
            }
            $tblUserModuleProgress = get_module_course_tbl(array('lp_user_module_progress'), $courseCode);
            Claroline::getDatabase()->exec("UPDATE `{$tblUserModuleProgress['lp_user_module_progress']}`\n                    SET total_time = " . Claroline::getDatabase()->quote($newTotalTime) . ",\n                        session_time = " . Claroline::getDatabase()->quote($sessionTime) . "\n                  WHERE user_module_progress_id = " . Claroline::getDatabase()->escape((int) $userModuleProgressId));
            $documentTimeUpdateArgs = array('sessionTime' => $sessionTime, 'date' => $date, 'userId' => $userId, 'courseCode' => $courseCode, 'learnPathId' => $learnPathId, 'moduleId' => $moduleId);
            $documentTimeUpdateEvent = new Event('lp_document_time_update', $documentTimeUpdateArgs);
            EventManager::notify($documentTimeUpdateEvent);
            echo 'Document spent time updated';
        } else {
            echo 'Wrong userId or wrong courseCode';
        }
    } else {
        echo 'There is at least one null param';
    }
} else {
    echo 'User not authenticated';
}
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:updateDocumentTracking.php

示例2: set_learning_path_progression

function set_learning_path_progression($totalResult, $totalGrade, $timeToCompleteExe, $_uid)
{
    $tbl_cdb_names = get_module_course_tbl(array('lp_rel_learnPath_module', 'lp_user_module_progress'), claro_get_current_course_id());
    $tbl_lp_rel_learnPath_module = $tbl_cdb_names['lp_rel_learnPath_module'];
    $tbl_lp_user_module_progress = $tbl_cdb_names['lp_user_module_progress'];
    // update raw in DB to keep the best one, so update only if new raw is better  AND if user NOT anonymous
    if ($_uid) {
        // exercices can have a negative score, but we don't accept that in LP
        // so if totalScore is negative use 0 as result
        $totalResult = max($totalResult, 0);
        if ($totalGrade != 0) {
            $newRaw = @round($totalResult / $totalGrade * 100);
        } else {
            $newRaw = 0;
        }
        $scoreMin = 0;
        $scoreMax = $totalGrade;
        $scormSessionTime = seconds_to_scorm_time($timeToCompleteExe);
        // need learningPath_module_id and raw_to_pass value
        $sql = "SELECT LPM.`raw_to_pass`, LPM.`learnPath_module_id`, UMP.`total_time`, UMP.`raw`\n                  FROM `" . $tbl_lp_rel_learnPath_module . "` AS LPM, `" . $tbl_lp_user_module_progress . "` AS UMP\n                 WHERE LPM.`learnPath_id` = '" . (int) $_SESSION['path_id'] . "'\n                   AND LPM.`module_id` = '" . (int) $_SESSION['module_id'] . "'\n                   AND LPM.`learnPath_module_id` = UMP.`learnPath_module_id`\n                   AND UMP.`user_id` = " . (int) $_uid;
        $lastProgression = claro_sql_query_get_single_row($sql);
        if ($lastProgression) {
            // build sql query
            $sql = "UPDATE `" . $tbl_lp_user_module_progress . "` SET ";
            // if recorded score is more than the new score => update raw, credit and status
            if ($lastProgression['raw'] < $totalResult) {
                // update raw
                $sql .= "`raw` = " . $totalResult . ",";
                // update credit and statut if needed ( score is better than raw_to_pass )
                if ($newRaw >= $lastProgression['raw_to_pass']) {
                    $sql .= "    `credit` = 'CREDIT',\n                                 `lesson_status` = 'PASSED',";
                } else {
                    $sql .= "    `credit` = 'NO-CREDIT',\n                                `lesson_status` = 'FAILED',";
                }
            }
            // else don't change raw, credit and lesson_status
            // default query statements
            $sql .= "    `scoreMin`         = " . (int) $scoreMin . ",\n                        `scoreMax`         = " . (int) $scoreMax . ",\n                        `total_time`    = '" . addScormTime($lastProgression['total_time'], $scormSessionTime) . "',\n                        `session_time`    = '" . $scormSessionTime . "'\n                     WHERE `learnPath_module_id` = " . (int) $lastProgression['learnPath_module_id'] . "\n                       AND `user_id` = " . (int) $_uid . "";
            // Generate an event to notify that the exercise has been completed
            $learnPathEventArgs = array('userId' => (int) $_uid, 'courseCode' => claro_get_current_course_id(), 'scoreRaw' => (int) $totalResult, 'scoreMin' => (int) $scoreMin, 'scoreMax' => (int) $scoreMax, 'sessionTime' => $scormSessionTime, 'learnPathModuleId' => (int) $lastProgression['learnPath_module_id'], 'type' => "update");
            if ($newRaw >= $lastProgression['raw_to_pass']) {
                $learnPathEventArgs['status'] = "PASSED";
            } else {
                $learnPathEventArgs['status'] = "FAILED";
            }
            $learnPathEvent = new Event('lp_user_module_progress_modified', $learnPathEventArgs);
            EventManager::notify($learnPathEvent);
            return claro_sql_query($sql);
        } else {
            return false;
        }
    }
}
开发者ID:rhertzog,项目名称:lcs,代码行数:53,代码来源:exercise.lib.php

示例3: addScormTime

    if ($lesson_status_value == "COMPLETED" || $lesson_status_value == "PASSED") {
        if (strtoupper($_POST['credit']) == "CREDIT") {
            $credit_value = "CREDIT";
        }
    }
    if (isScormTime($_POST['session_time'])) {
        $total_time_value = addScormTime($_POST['total_time'], $_POST['session_time']);
    } else {
        $total_time_value = $_POST['total_time'];
    }
    $sql = "UPDATE `" . $TABLEUSERMODULEPROGRESS . "` \n            SET \n                `lesson_location` = '" . claro_sql_escape($_POST['lesson_location']) . "',\n                `lesson_status` = '" . claro_sql_escape($lesson_status_value) . "',\n                `entry` = '" . claro_sql_escape($entry_value) . "',\n                `raw` = '" . (int) $_POST['raw'] . "',\n                `scoreMin` = '" . (int) $_POST['scoreMin'] . "',\n                `scoreMax` = '" . (int) $_POST['scoreMax'] . "',\n                `total_time` = '" . claro_sql_escape($total_time_value) . "',\n                `session_time` = '" . claro_sql_escape($_POST['session_time']) . "',\n                `suspend_data` = '" . claro_sql_escape($_POST['suspend_data']) . "',\n                `credit` = '" . claro_sql_escape($credit_value) . "'\n          WHERE `user_module_progress_id` = " . (int) $_POST['ump_id'];
    claro_sql_query($sql);
    // Generate an event to notify that the module tracking has been updated
    $learnPathEventArgs = array('userId' => (int) claro_get_current_user_id(), 'courseCode' => claro_get_current_course_id(), 'scoreRaw' => (int) $_POST['raw'], 'scoreMin' => (int) $_POST['scoreMin'], 'scoreMax' => (int) $_POST['scoreMax'], 'sessionTime' => claro_sql_escape($_POST['session_time']), 'userModuleProgressId' => (int) $_POST['ump_id'], 'type' => "update", 'status' => claro_sql_escape($lesson_status_value));
    $learnPathEvent = new Event('lp_user_module_progress_modified', $learnPathEventArgs);
    EventManager::notify($learnPathEvent);
}
// display the form to accept new commit and
// refresh TOC frame, has to be done here to show recorded progression as soon as it is recorded
?>

<!-- API form -->
<html>
<head>
   <title>update progression</title>
<?php 
if ($_POST['ump_id']) {
    ?>
    <script type="text/javascript">
    <!--//
      parent.tocFrame.location.href="<?php 
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:updateProgress.php

示例4: sendEvent

 /**
  * notify the event manager for an event occurence
  * @access public
  * @param Event event the event that occurs; an instance of the event class
  */
 public function sendEvent($event)
 {
     EventManager::notify($event);
 }
开发者ID:rhertzog,项目名称:lcs,代码行数:9,代码来源:event.lib.php


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