original_string: private function create_forum() {
          global $DB;
  
          $discussions = self::$paramforumdiscussions[$this->size];
          $posts = self::$paramforumposts[$this->size];
          $totalposts = $discussions * $posts;
  
          $this->log('createforum', $totalposts, true);
  
          // Create empty forum.
          $forumgenerator = $this->generator->get_plugin_generator('mod_forum');
          $record = array('course' => $this->course,
                  'name' => get_string('pluginname', 'forum'));
          $options = array('section' => 0);
          $forum = $forumgenerator->create_instance($record, $options);
  
          // Add discussions and posts.
          $sofar = 0;
          for ($i = 0; $i < $discussions; $i++) {
              $record = array('forum' => $forum->id, 'course' => $this->course->id,
                      'userid' => $this->get_target_user());
              $discussion = $forumgenerator->create_discussion($record);
              $parentid = $DB->get_field('forum_posts', 'id', array('discussion' => $discussion->id), MUST_EXIST);
              $sofar++;
              for ($j = 0; $j < $posts - 1; $j++, $sofar++) {
                  $record = array('discussion' => $discussion->id,
                          'userid' => $this->get_target_user(), 'parent' => $parentid);
                  $forumgenerator->create_post($record);
                  $this->dot($sofar, $totalposts);
              }
          }
  
          $this->end_log();
      }
code: private function create_forum() {
          global $DB;
  
          $discussions = self::$paramforumdiscussions[$this->size];
          $posts = self::$paramforumposts[$this->size];
          $totalposts = $discussions * $posts;
  
          $this->log('createforum', $totalposts, true);
  
          // Create empty forum.
          $forumgenerator = $this->generator->get_plugin_generator('mod_forum');
          $record = array('course' => $this->course,
                  'name' => get_string('pluginname', 'forum'));
          $options = array('section' => 0);
          $forum = $forumgenerator->create_instance($record, $options);
  
          // Add discussions and posts.
          $sofar = 0;
          for ($i = 0; $i < $discussions; $i++) {
              $record = array('forum' => $forum->id, 'course' => $this->course->id,
                      'userid' => $this->get_target_user());
              $discussion = $forumgenerator->create_discussion($record);
              $parentid = $DB->get_field('forum_posts', 'id', array('discussion' => $discussion->id), MUST_EXIST);
              $sofar++;
              for ($j = 0; $j < $posts - 1; $j++, $sofar++) {
                  $record = array('discussion' => $discussion->id,
                          'userid' => $this->get_target_user(), 'parent' => $parentid);
                  $forumgenerator->create_post($record);
                  $this->dot($sofar, $totalposts);
              }
          }
  
          $this->end_log();
      }
code_tokens: private function create_forum ( ) { global $ DB ; $ discussions = self :: $ paramforumdiscussions [ $ this -> size ] ; $ posts = self :: $ paramforumposts [ $ this -> size ] ; $ totalposts = $ discussions * $ posts ; $ this -> log ( 'createforum' , $ totalposts , true ) ; // Create empty forum. $ forumgenerator = $ this -> generator -> get_plugin_generator ( 'mod_forum' ) ; $ record = array ( 'course' => $ this -> course , 'name' => get_string ( 'pluginname' , 'forum' ) ) ; $ options = array ( 'section' => 0 ) ; $ forum = $ forumgenerator -> create_instance ( $ record , $ options ) ; // Add discussions and posts. $ sofar = 0 ; for ( $ i = 0 ; $ i < $ discussions ; $ i ++ ) { $ record = array ( 'forum' => $ forum -> id , 'course' => $ this -> course -> id , 'userid' => $ this -> get_target_user ( ) ) ; $ discussion = $ forumgenerator -> create_discussion ( $ record ) ; $ parentid = $ DB -> get_field ( 'forum_posts' , 'id' , array ( 'discussion' => $ discussion -> id ) , MUST_EXIST ) ; $ sofar ++ ; for ( $ j = 0 ; $ j < $ posts - 1 ; $ j ++ , $ sofar ++ ) { $ record = array ( 'discussion' => $ discussion -> id , 'userid' => $ this -> get_target_user ( ) , 'parent' => $ parentid ) ; $ forumgenerator -> create_post ( $ record ) ; $ this -> dot ( $ sofar , $ totalposts ) ; } } $ this -> end_log ( ) ; }
docstring: Creates one forum activity with a bunch of posts.
docstring_tokens: Creates one forum activity with a bunch of posts .