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

Lesson subclusters are not working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.3, 2.8.1
    • Fix Version/s: 2.7.6, 2.8.4
    • Component/s: Lesson
    • Labels:
    • Testing Instructions:
      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
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:

      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

              Assignee:
              jmvedrine Jean-Michel Vedrine
              Reporter:
              jmvedrine Jean-Michel Vedrine
              Peer reviewer:
              Adrian Greeve
              Integrator:
              David Monllaó
              Tester:
              Dave Cooper
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Mar/15