original_string: public function prepare(renderer_base $output, moodle_page $page, $target) {
          if (empty($this->attemptids)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a attemptids value.');
          }
          if (!isset($this->attempt) || is_null($this->attempt)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a attempt value.');
          }
          if (empty($this->baseurl)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a baseurl value.');
          }
  
          if (count($this->attemptids) > 1) {
              $lastattempt = end($this->attemptids); // Get last attempt.
              $firstattempt = reset($this->attemptids); // get first attempt.
  
              $nextattempt = 0;
              $prevattempt = null;
              $previous = 0;
              foreach ($this->attemptids as $attemptid) {
                  if ($this->attempt == $attemptid) {
                      $this->attemptlinks[] = $attemptid;
                      $prevattempt = $previous;
                  } else {
                      $attemptlink = html_writer::link(
                          new moodle_url($this->baseurl, array($this->pagevar => $attemptid)), $attemptid);
                      $this->attemptlinks[] = $attemptlink;
                      if (empty($nextattempt) && $prevattempt !== null) {
                          // Set the nextattempt var as we have set previous attempt earlier.
                          $nextattempt = $attemptid;
                      }
                  }
                  $previous = $attemptid; // Store this attempt as previous in case we need it.
              }
  
              if ($this->attempt != $firstattempt) {
                  $this->previouslink = html_writer::link(
                      new moodle_url($this->baseurl, array($this->pagevar => $prevattempt)),
                      get_string('previous'), array('class' => 'previous'));
              }
  
              if ($this->attempt != $lastattempt) {
                  $this->nextlink = html_writer::link(
                      new moodle_url($this->baseurl, array($this->pagevar => $nextattempt)),
                      get_string('next'), array('class' => 'next'));
              }
          }
      }
code: public function prepare(renderer_base $output, moodle_page $page, $target) {
          if (empty($this->attemptids)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a attemptids value.');
          }
          if (!isset($this->attempt) || is_null($this->attempt)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a attempt value.');
          }
          if (empty($this->baseurl)) {
              throw new coding_exception('mod_scorm_attempt_bar requires a baseurl value.');
          }
  
          if (count($this->attemptids) > 1) {
              $lastattempt = end($this->attemptids); // Get last attempt.
              $firstattempt = reset($this->attemptids); // get first attempt.
  
              $nextattempt = 0;
              $prevattempt = null;
              $previous = 0;
              foreach ($this->attemptids as $attemptid) {
                  if ($this->attempt == $attemptid) {
                      $this->attemptlinks[] = $attemptid;
                      $prevattempt = $previous;
                  } else {
                      $attemptlink = html_writer::link(
                          new moodle_url($this->baseurl, array($this->pagevar => $attemptid)), $attemptid);
                      $this->attemptlinks[] = $attemptlink;
                      if (empty($nextattempt) && $prevattempt !== null) {
                          // Set the nextattempt var as we have set previous attempt earlier.
                          $nextattempt = $attemptid;
                      }
                  }
                  $previous = $attemptid; // Store this attempt as previous in case we need it.
              }
  
              if ($this->attempt != $firstattempt) {
                  $this->previouslink = html_writer::link(
                      new moodle_url($this->baseurl, array($this->pagevar => $prevattempt)),
                      get_string('previous'), array('class' => 'previous'));
              }
  
              if ($this->attempt != $lastattempt) {
                  $this->nextlink = html_writer::link(
                      new moodle_url($this->baseurl, array($this->pagevar => $nextattempt)),
                      get_string('next'), array('class' => 'next'));
              }
          }
      }
code_tokens: public function prepare ( renderer_base $ output , moodle_page $ page , $ target ) { if ( empty ( $ this -> attemptids ) ) { throw new coding_exception ( 'mod_scorm_attempt_bar requires a attemptids value.' ) ; } if ( ! isset ( $ this -> attempt ) || is_null ( $ this -> attempt ) ) { throw new coding_exception ( 'mod_scorm_attempt_bar requires a attempt value.' ) ; } if ( empty ( $ this -> baseurl ) ) { throw new coding_exception ( 'mod_scorm_attempt_bar requires a baseurl value.' ) ; } if ( count ( $ this -> attemptids ) > 1 ) { $ lastattempt = end ( $ this -> attemptids ) ; // Get last attempt. $ firstattempt = reset ( $ this -> attemptids ) ; // get first attempt. $ nextattempt = 0 ; $ prevattempt = null ; $ previous = 0 ; foreach ( $ this -> attemptids as $ attemptid ) { if ( $ this -> attempt == $ attemptid ) { $ this -> attemptlinks [ ] = $ attemptid ; $ prevattempt = $ previous ; } else { $ attemptlink = html_writer :: link ( new moodle_url ( $ this -> baseurl , array ( $ this -> pagevar => $ attemptid ) ) , $ attemptid ) ; $ this -> attemptlinks [ ] = $ attemptlink ; if ( empty ( $ nextattempt ) && $ prevattempt !== null ) { // Set the nextattempt var as we have set previous attempt earlier. $ nextattempt = $ attemptid ; } } $ previous = $ attemptid ; // Store this attempt as previous in case we need it. } if ( $ this -> attempt != $ firstattempt ) { $ this -> previouslink = html_writer :: link ( new moodle_url ( $ this -> baseurl , array ( $ this -> pagevar => $ prevattempt ) ) , get_string ( 'previous' ) , array ( 'class' => 'previous' ) ) ; } if ( $ this -> attempt != $ lastattempt ) { $ this -> nextlink = html_writer :: link ( new moodle_url ( $ this -> baseurl , array ( $ this -> pagevar => $ nextattempt ) ) , get_string ( 'next' ) , array ( 'class' => 'next' ) ) ; } } }
docstring: Prepares the scorm attempt bar for output.
  
  This method validates the arguments set up for the scorm attempt bar and then
  produces fragments of HTML to assist display later on.
  
  @param renderer_base $output
  @param moodle_page $page
  @param string $target
  @throws coding_exception
docstring_tokens: Prepares the scorm attempt bar for output .