original_string: protected function update_course_sections_visibility($numsections) {
          global $DB;
  
          $backupinfo = $this->step->get_task()->get_info();
          foreach ($backupinfo->sections as $key => $section) {
              // For each section from the backup file check if it was restored and if was "orphaned" in the original
              // course and mark it as hidden. This will leave all activities in it visible and available just as it was
              // in the original course.
              // Exception is when we restore with merging and the course already had a section with this section number,
              // in this case we don't modify the visibility.
              if ($this->step->get_task()->get_setting_value($key . '_included')) {
                  $sectionnum = (int)$section->title;
                  if ($sectionnum > $numsections && $sectionnum > $this->originalnumsections) {
                      $DB->execute("UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?",
                          [$this->step->get_task()->get_courseid(), $sectionnum]);
                  }
              }
          }
      }
code: protected function update_course_sections_visibility($numsections) {
          global $DB;
  
          $backupinfo = $this->step->get_task()->get_info();
          foreach ($backupinfo->sections as $key => $section) {
              // For each section from the backup file check if it was restored and if was "orphaned" in the original
              // course and mark it as hidden. This will leave all activities in it visible and available just as it was
              // in the original course.
              // Exception is when we restore with merging and the course already had a section with this section number,
              // in this case we don't modify the visibility.
              if ($this->step->get_task()->get_setting_value($key . '_included')) {
                  $sectionnum = (int)$section->title;
                  if ($sectionnum > $numsections && $sectionnum > $this->originalnumsections) {
                      $DB->execute("UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?",
                          [$this->step->get_task()->get_courseid(), $sectionnum]);
                  }
              }
          }
      }
code_tokens: protected function update_course_sections_visibility ( $ numsections ) { global $ DB ; $ backupinfo = $ this -> step -> get_task ( ) -> get_info ( ) ; foreach ( $ backupinfo -> sections as $ key => $ section ) { // For each section from the backup file check if it was restored and if was "orphaned" in the original // course and mark it as hidden. This will leave all activities in it visible and available just as it was // in the original course. // Exception is when we restore with merging and the course already had a section with this section number, // in this case we don't modify the visibility. if ( $ this -> step -> get_task ( ) -> get_setting_value ( $ key . '_included' ) ) { $ sectionnum = ( int ) $ section -> title ; if ( $ sectionnum > $ numsections && $ sectionnum > $ this -> originalnumsections ) { $ DB -> execute ( "UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?" , [ $ this -> step -> get_task ( ) -> get_courseid ( ) , $ sectionnum ] ) ; } } } }
docstring: Handles updating the visibility of sections in the restored course.
  
  @param int $numsections The number of sections in the restored course.
docstring_tokens: Handles updating the visibility of sections in the restored course .