本文整理汇总了PHP中lesson::get_sub_pages_of方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson::get_sub_pages_of方法的具体用法?PHP lesson::get_sub_pages_of怎么用?PHP lesson::get_sub_pages_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lesson
的用法示例。
在下文中一共展示了lesson::get_sub_pages_of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lesson_random_question_jump
/**
* Handles the random jump between a branch table and end of branch or end of lesson (LESSON_RANDOMPAGE).
*
* @param lesson $lesson
* @param int $pageid The id of the page that we are jumping from (?)
* @return int The pageid of a random page that is within a branch table
**/
function lesson_random_question_jump($lesson, $pageid)
{
global $DB;
// get the lesson pages
$params = array("lessonid" => $lesson->id);
if (!($lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params))) {
print_error('cannotfindpages', 'lesson');
}
// go up the pages till branch table
while ($pageid != 0) {
// this condition should never be satisfied... only happens if there are no branch tables above this page
if ($lessonpages[$pageid]->qtype == LESSON_PAGE_BRANCHTABLE) {
break;
}
$pageid = $lessonpages[$pageid]->prevpageid;
}
// get the pages within the branch
$pagesinbranch = $lesson->get_sub_pages_of($pageid, array(LESSON_PAGE_BRANCHTABLE, LESSON_PAGE_ENDOFBRANCH));
if (count($pagesinbranch) == 0) {
// there are no pages inside the branch, so return the next page
return $lessonpages[$pageid]->nextpageid;
} else {
return $pagesinbranch[rand(0, count($pagesinbranch) - 1)]->id;
// returns a random page id for the next page
}
}