original_string: public function preview($rows = 10, $tracker = null) {
          if ($this->processstarted) {
              throw new coding_exception('Process has already been started');
          }
          $this->processstarted = true;
  
          if (empty($tracker)) {
              $tracker = new tool_uploadcourse_tracker(tool_uploadcourse_tracker::NO_OUTPUT);
          }
          $tracker->start();
  
          // We might need extra time and memory depending on the number of rows to preview.
          core_php_time_limit::raise();
          raise_memory_limit(MEMORY_EXTRA);
  
          // Loop over the CSV lines.
          $preview = array();
          while (($line = $this->cir->next()) && $rows > $this->linenb) {
              $this->linenb++;
              $data = $this->parse_line($line);
              $course = $this->get_course($data);
              $result = $course->prepare();
              if (!$result) {
                  $tracker->output($this->linenb, $result, $course->get_errors(), $data);
              } else {
                  $tracker->output($this->linenb, $result, $course->get_statuses(), $data);
              }
              $row = $data;
              $preview[$this->linenb] = $row;
          }
  
          $tracker->finish();
  
          return $preview;
      }
code: public function preview($rows = 10, $tracker = null) {
          if ($this->processstarted) {
              throw new coding_exception('Process has already been started');
          }
          $this->processstarted = true;
  
          if (empty($tracker)) {
              $tracker = new tool_uploadcourse_tracker(tool_uploadcourse_tracker::NO_OUTPUT);
          }
          $tracker->start();
  
          // We might need extra time and memory depending on the number of rows to preview.
          core_php_time_limit::raise();
          raise_memory_limit(MEMORY_EXTRA);
  
          // Loop over the CSV lines.
          $preview = array();
          while (($line = $this->cir->next()) && $rows > $this->linenb) {
              $this->linenb++;
              $data = $this->parse_line($line);
              $course = $this->get_course($data);
              $result = $course->prepare();
              if (!$result) {
                  $tracker->output($this->linenb, $result, $course->get_errors(), $data);
              } else {
                  $tracker->output($this->linenb, $result, $course->get_statuses(), $data);
              }
              $row = $data;
              $preview[$this->linenb] = $row;
          }
  
          $tracker->finish();
  
          return $preview;
      }
code_tokens: public function preview ( $ rows = 10 , $ tracker = null ) { if ( $ this -> processstarted ) { throw new coding_exception ( 'Process has already been started' ) ; } $ this -> processstarted = true ; if ( empty ( $ tracker ) ) { $ tracker = new tool_uploadcourse_tracker ( tool_uploadcourse_tracker :: NO_OUTPUT ) ; } $ tracker -> start ( ) ; // We might need extra time and memory depending on the number of rows to preview. core_php_time_limit :: raise ( ) ; raise_memory_limit ( MEMORY_EXTRA ) ; // Loop over the CSV lines. $ preview = array ( ) ; while ( ( $ line = $ this -> cir -> next ( ) ) && $ rows > $ this -> linenb ) { $ this -> linenb ++ ; $ data = $ this -> parse_line ( $ line ) ; $ course = $ this -> get_course ( $ data ) ; $ result = $ course -> prepare ( ) ; if ( ! $ result ) { $ tracker -> output ( $ this -> linenb , $ result , $ course -> get_errors ( ) , $ data ) ; } else { $ tracker -> output ( $ this -> linenb , $ result , $ course -> get_statuses ( ) , $ data ) ; } $ row = $ data ; $ preview [ $ this -> linenb ] = $ row ; } $ tracker -> finish ( ) ; return $ preview ; }
docstring: Return a preview of the import.
  
  This only returns passed data, along with the errors.
  
  @param integer $rows number of rows to preview.
  @param object $tracker the output tracker to use.
  @return array of preview data.
docstring_tokens: Return a preview of the import .