original_string: public function prepare_package() {
  
          $canviewauthornames = has_capability('mod/workshop:viewauthornames', $this->workshop->context, $this->get('user'));
  
          // Prepare the submission record for rendering.
          $workshopsubmission = $this->workshop->prepare_submission($this->submission, $canviewauthornames);
  
          // Set up the LEAP2A writer if we need it.
          $writingleap = false;
  
          if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
              $leapwriter = $this->exporter->get('format')->leap2a_writer();
              $writingleap = true;
          }
  
          // If writing to HTML file, accumulate the exported hypertext here.
          $html = '';
  
          // If writing LEAP2A, keep track of all entry ids so we can add a selection element.
          $leapids = [];
  
          $html .= $this->export_header($workshopsubmission);
          $content = $this->export_content($workshopsubmission);
          // Get rid of the JS relics left by moodleforms.
          $content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
          $html .= $content;
  
          if ($writingleap) {
              $leapids[] = $this->export_content_leap2a($leapwriter, $workshopsubmission, $content);
          }
  
          // Export the files.
          foreach ($this->multifiles as $file) {
              $this->exporter->copy_existing_file($file);
          }
  
          if ($writingleap) {
              // Add an extra LEAP2A selection entry. In Mahara, this maps to a journal.
              $selection = new portfolio_format_leap2a_entry('workshop'.$this->workshop->id,
                  get_string('pluginname', 'mod_workshop').': '.s($this->workshop->name), 'selection');
              $leapwriter->add_entry($selection);
              $leapwriter->make_selection($selection, $leapids, 'Grouping');
              $leapxml = $leapwriter->to_xml();
              $name = $this->exporter->get('format')->manifest_name();
              $this->exporter->write_new_file($leapxml, $name, true);
  
          } else {
              $this->exporter->write_new_file($html, 'submission.html', true);
          }
      }
code: public function prepare_package() {
  
          $canviewauthornames = has_capability('mod/workshop:viewauthornames', $this->workshop->context, $this->get('user'));
  
          // Prepare the submission record for rendering.
          $workshopsubmission = $this->workshop->prepare_submission($this->submission, $canviewauthornames);
  
          // Set up the LEAP2A writer if we need it.
          $writingleap = false;
  
          if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
              $leapwriter = $this->exporter->get('format')->leap2a_writer();
              $writingleap = true;
          }
  
          // If writing to HTML file, accumulate the exported hypertext here.
          $html = '';
  
          // If writing LEAP2A, keep track of all entry ids so we can add a selection element.
          $leapids = [];
  
          $html .= $this->export_header($workshopsubmission);
          $content = $this->export_content($workshopsubmission);
          // Get rid of the JS relics left by moodleforms.
          $content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
          $html .= $content;
  
          if ($writingleap) {
              $leapids[] = $this->export_content_leap2a($leapwriter, $workshopsubmission, $content);
          }
  
          // Export the files.
          foreach ($this->multifiles as $file) {
              $this->exporter->copy_existing_file($file);
          }
  
          if ($writingleap) {
              // Add an extra LEAP2A selection entry. In Mahara, this maps to a journal.
              $selection = new portfolio_format_leap2a_entry('workshop'.$this->workshop->id,
                  get_string('pluginname', 'mod_workshop').': '.s($this->workshop->name), 'selection');
              $leapwriter->add_entry($selection);
              $leapwriter->make_selection($selection, $leapids, 'Grouping');
              $leapxml = $leapwriter->to_xml();
              $name = $this->exporter->get('format')->manifest_name();
              $this->exporter->write_new_file($leapxml, $name, true);
  
          } else {
              $this->exporter->write_new_file($html, 'submission.html', true);
          }
      }
code_tokens: public function prepare_package ( ) { $ canviewauthornames = has_capability ( 'mod/workshop:viewauthornames' , $ this -> workshop -> context , $ this -> get ( 'user' ) ) ; // Prepare the submission record for rendering. $ workshopsubmission = $ this -> workshop -> prepare_submission ( $ this -> submission , $ canviewauthornames ) ; // Set up the LEAP2A writer if we need it. $ writingleap = false ; if ( $ this -> exporter -> get ( 'formatclass' ) == PORTFOLIO_FORMAT_LEAP2A ) { $ leapwriter = $ this -> exporter -> get ( 'format' ) -> leap2a_writer ( ) ; $ writingleap = true ; } // If writing to HTML file, accumulate the exported hypertext here. $ html = '' ; // If writing LEAP2A, keep track of all entry ids so we can add a selection element. $ leapids = [ ] ; $ html .= $ this -> export_header ( $ workshopsubmission ) ; $ content = $ this -> export_content ( $ workshopsubmission ) ; // Get rid of the JS relics left by moodleforms. $ content = preg_replace ( '#<script(.*?)>(.*?)</script>#is' , '' , $ content ) ; $ html .= $ content ; if ( $ writingleap ) { $ leapids [ ] = $ this -> export_content_leap2a ( $ leapwriter , $ workshopsubmission , $ content ) ; } // Export the files. foreach ( $ this -> multifiles as $ file ) { $ this -> exporter -> copy_existing_file ( $ file ) ; } if ( $ writingleap ) { // Add an extra LEAP2A selection entry. In Mahara, this maps to a journal. $ selection = new portfolio_format_leap2a_entry ( 'workshop' . $ this -> workshop -> id , get_string ( 'pluginname' , 'mod_workshop' ) . ': ' . s ( $ this -> workshop -> name ) , 'selection' ) ; $ leapwriter -> add_entry ( $ selection ) ; $ leapwriter -> make_selection ( $ selection , $ leapids , 'Grouping' ) ; $ leapxml = $ leapwriter -> to_xml ( ) ; $ name = $ this -> exporter -> get ( 'format' ) -> manifest_name ( ) ; $ this -> exporter -> write_new_file ( $ leapxml , $ name , true ) ; } else { $ this -> exporter -> write_new_file ( $ html , 'submission.html' , true ) ; } }
docstring: Prepare the package ready to be passed off to the portfolio plugin.
docstring_tokens: Prepare the package ready to be passed off to the portfolio plugin .