original_string: public function solution() {
          global $CFG;
          list($missingparent, $loops) = $this->find_problems();
  
          $solution = '<p>Consider executing the following SQL queries. These fix ' .
                  'the problem by moving some categories to the top level.</p>';
  
          if (!empty($missingparent)) {
              $solution .= "<pre>UPDATE " . $CFG->prefix . "course_categories\n" .
                      "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" .
                      "        WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
          }
  
          if (!empty($loops)) {
              $solution .= "<pre>UPDATE " . $CFG->prefix . "course_categories\n" .
                      "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" .
                      "        WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
          }
  
          return $solution;
      }
code: public function solution() {
          global $CFG;
          list($missingparent, $loops) = $this->find_problems();
  
          $solution = '<p>Consider executing the following SQL queries. These fix ' .
                  'the problem by moving some categories to the top level.</p>';
  
          if (!empty($missingparent)) {
              $solution .= "<pre>UPDATE " . $CFG->prefix . "course_categories\n" .
                      "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" .
                      "        WHERE id IN (" . implode(',', array_keys($missingparent)) . ");</pre>\n";
          }
  
          if (!empty($loops)) {
              $solution .= "<pre>UPDATE " . $CFG->prefix . "course_categories\n" .
                      "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" .
                      "        WHERE id IN (" . implode(',', array_keys($loops)) . ");</pre>\n";
          }
  
          return $solution;
      }
code_tokens: public function solution ( ) { global $ CFG ; list ( $ missingparent , $ loops ) = $ this -> find_problems ( ) ; $ solution = '<p>Consider executing the following SQL queries. These fix ' . 'the problem by moving some categories to the top level.</p>' ; if ( ! empty ( $ missingparent ) ) { $ solution .= "<pre>UPDATE " . $ CFG -> prefix . "course_categories\n" . "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" . "        WHERE id IN (" . implode ( ',' , array_keys ( $ missingparent ) ) . ");</pre>\n" ; } if ( ! empty ( $ loops ) ) { $ solution .= "<pre>UPDATE " . $ CFG -> prefix . "course_categories\n" . "        SET parent = 0, depth = 1, path = CONCAT('/', id)\n" . "        WHERE id IN (" . implode ( ',' , array_keys ( $ loops ) ) . ");</pre>\n" ; } return $ solution ; }
docstring: Generate solution text.
  
  @uses $CFG
  @return string HTML containing the suggested solution.
docstring_tokens: Generate solution text .