Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48709

Lesson subclusters are not working

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.3, 2.8.1
    • 2.7.6, 2.8.4
    • Lesson
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • Difficult
    • Hide

      Create a lesson with a cluster some questions in it (all questions correct answers should jump to the cluster page) and an end of cluster.
      You may find easier to put a content page before the cluster page and after the end of cluster page because as these pages aren't displayed to student it would help you to see when you enter the cluster and leave it
      Now define a subcluster inside your cluster, putting a content page to mark the beginning of the subcluster and an end of branch page to mark the end of the subcluster.
      Attempt the lesson as a student and verify you see

      • all questions in the cluster that are outside of the subcluster in random order
      • one and only one of the questions that are inside the subcluster

      Of course you can complicate the game by using several clusters and several subclusters in each cluster

      Show
      Create a lesson with a cluster some questions in it (all questions correct answers should jump to the cluster page) and an end of cluster. You may find easier to put a content page before the cluster page and after the end of cluster page because as these pages aren't displayed to student it would help you to see when you enter the cluster and leave it Now define a subcluster inside your cluster, putting a content page to mark the beginning of the subcluster and an end of branch page to mark the end of the subcluster. Attempt the lesson as a student and verify you see all questions in the cluster that are outside of the subcluster in random order one and only one of the questions that are inside the subcluster Of course you can complicate the game by using several clusters and several subclusters in each cluster

    Description

      Lesson subclusters working is described here: https://docs.moodle.org/28/en/Lesson_clusters#Sub-Clusters and I verified they were working exactly like that in Moodle 1.9.
      But the upgrade to Moodle 2.0 completely broke that.
      Questions pages inside the subclusters are now treated exactly like the other question pages in the cluster. So no error is produced but subclusters are simply ignored.
      Just looking at the code it's pretty evident it can't work !

             $unseen = array();
              foreach ($clusterpages as $key=>$cluster) {
                  if ($cluster->type !== lesson_page::TYPE_QUESTION) {
                      unset($clusterpages[$key]);
                  } elseif ($cluster->is_unseen($seenpages)) {
                      $unseen[] = $cluster;
                  }
              }
      

      So after this loop both the $clusterpages and $unseen arrays only contain question pages, all the other pages have been eliminated including content pages (that were called branchtables in Moodle 1.9) and end of branch pages
      So when a few lines after this the code

                  $nextpage = $unseen[rand(0, count($unseen)-1)];
                  if ($nextpage->qtype == LESSON_PAGE_BRANCHTABLE) {
                      // if branch table, then pick a random page inside of it
                      $branchpages = $this->get_sub_pages_of($nextpage->id, array(LESSON_PAGE_BRANCHTABLE, LESSON_PAGE_ENDOFBRANCH));
                      return $branchpages[rand(0, count($branchpages)-1)]->id;
                  } else { // otherwise, return the page's id
                      return $nextpage->id;
                  }
      

      the if condition can never be true and the code in the else is always executed.

      Attachments

        Issue Links

          Activity

            People

              jmvedrine Jean-Michel Vedrine
              jmvedrine Jean-Michel Vedrine
              Adrian Greeve Adrian Greeve
              David Monllaó David Monllaó
              Dave Cooper Dave Cooper
              Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/15