MDL-61265 enrol: Add default numsections for external db
authorSara Arjona <sara@moodle.com>
Wed, 24 Jan 2018 08:48:01 +0000 (09:48 +0100)
committerSara Arjona <sara@moodle.com>
Fri, 16 Mar 2018 10:32:09 +0000 (11:32 +0100)
enrol/database/lib.php
enrol/database/tests/sync_test.php

index 11500fb..941fb99 100644 (file)
@@ -774,6 +774,7 @@ class enrol_database_plugin extends enrol_plugin {
                 $template->summary        = '';
                 $template->summaryformat  = FORMAT_HTML;
                 $template->format         = $courseconfig->format;
+                $template->numsections    = $courseconfig->numsections;
                 $template->newsitems      = $courseconfig->newsitems;
                 $template->showgrades     = $courseconfig->showgrades;
                 $template->showreports    = $courseconfig->showreports;
index 03ea36f..d7eacac 100644 (file)
@@ -730,6 +730,13 @@ class enrol_database_testcase extends advanced_testcase {
         $this->assertEquals(1, $DB->count_records('course', array('idnumber' => 'yy')));
         $this->assertEquals(1, $DB->count_records('course', array('shortname' => 'xx')));
 
+        // Check default number of sections matches with the created course sections.
+
+        $recordcourse1 = $DB->get_record('course', $course1);
+        $courseconfig = get_config('moodlecourse');
+        $numsections = $DB->count_records('course_sections', array('course' => $recordcourse1->id));
+        // To compare numsections we have to add topic 0 to default numsections.
+        $this->assertEquals(($courseconfig->numsections + 1), $numsections);
 
         // Test category mapping via idnumber.