本文整理汇总了PHP中learnpath::getCalculateStars方法的典型用法代码示例。如果您正苦于以下问题:PHP learnpath::getCalculateStars方法的具体用法?PHP learnpath::getCalculateStars怎么用?PHP learnpath::getCalculateStars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类learnpath
的用法示例。
在下文中一共展示了learnpath::getCalculateStars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSessionStars
/**
* Get the number of stars achieved for an user in a session
* @param int $sessionId The session ID
* @param int $userId The user ID
*
* @return int The number of stars
*/
public static function getSessionStars($sessionId, $userId)
{
$totalStars = 0;
$courses = SessionManager::get_course_list_by_session_id($sessionId);
if (empty($courses)) {
return 0;
}
foreach ($courses as $course) {
$learnPathListObject = new LearnpathList($userId, $course['code'], $sessionId);
$learnPaths = $learnPathListObject->get_flat_list();
if (empty($learnPaths)) {
continue;
}
$stars = 0;
foreach ($learnPaths as $learnPathId => $learnPathInfo) {
if (empty($learnPathInfo['seriousgame_mode'])) {
continue;
}
$learnPath = new learnpath($course['code'], $learnPathId, $userId);
$stars += $learnPath->getCalculateStars($sessionId);
}
$totalStars += round($stars / count($learnPaths));
}
return round($totalStars / count($courses));
}