MDL-48709 mod_lesson: subclusters are not working

This commit is contained in:
Jean-Michel Vedrine 2014-12-27 18:15:51 +01:00
parent 7357af2b0c
commit fc16a1acba
2 changed files with 194 additions and 1 deletions

View file

@ -1478,8 +1478,24 @@ class lesson extends lesson_base {
$clusterpages = $this->get_sub_pages_of($pageid, array(LESSON_PAGE_ENDOFCLUSTER));
$unseen = array();
foreach ($clusterpages as $key=>$cluster) {
if ($cluster->type !== lesson_page::TYPE_QUESTION) {
// Remove the page if it is in a branch table or is an endofbranch.
if ($this->is_sub_page_of_type($cluster->id,
array(LESSON_PAGE_BRANCHTABLE), array(LESSON_PAGE_ENDOFBRANCH, LESSON_PAGE_CLUSTER))
|| $cluster->qtype == LESSON_PAGE_ENDOFBRANCH) {
unset($clusterpages[$key]);
} else if ($cluster->qtype == LESSON_PAGE_BRANCHTABLE) {
// If branchtable, check to see if any pages inside have been viewed.
$branchpages = $this->get_sub_pages_of($cluster->id, array(LESSON_PAGE_BRANCHTABLE, LESSON_PAGE_ENDOFBRANCH));
$flag = true;
foreach ($branchpages as $branchpage) {
if (array_key_exists($branchpage->id, $seenpages)) { // Check if any of the pages have been viewed.
$flag = false;
}
}
if ($flag && count($branchpages) > 0) {
// Add branch table.
$unseen[] = $cluster;
}
} elseif ($cluster->is_unseen($seenpages)) {
$unseen[] = $cluster;
}