original_string: private function _update($percent, $msg) {
          if (empty($this->time_start)) {
              throw new coding_exception('You must call create() (or use the $autostart ' .
                      'argument to the constructor) before you try updating the progress bar.');
          }
  
          if (CLI_SCRIPT) {
              return; // Temporary solution for cli scripts.
          }
  
          $estimate = $this->estimate($percent);
  
          if ($estimate === null) {
              // Always do the first and last updates.
          } else if ($estimate == 0) {
              // Always do the last updates.
          } else if ($this->lastupdate + 20 < time()) {
              // We must update otherwise browser would time out.
          } else if (round($this->percent, 2) === round($percent, 2)) {
              // No significant change, no need to update anything.
              return;
          }
  
          $estimatemsg = null;
          if (is_numeric($estimate)) {
              $estimatemsg = get_string('secondsleft', 'moodle', round($estimate, 2));
          }
  
          $this->percent = round($percent, 2);
          $this->lastupdate = microtime(true);
  
          echo html_writer::script(js_writer::function_call('updateProgressBar',
              array($this->html_id, $this->percent, $msg, $estimatemsg)));
          flush();
      }
code: private function _update($percent, $msg) {
          if (empty($this->time_start)) {
              throw new coding_exception('You must call create() (or use the $autostart ' .
                      'argument to the constructor) before you try updating the progress bar.');
          }
  
          if (CLI_SCRIPT) {
              return; // Temporary solution for cli scripts.
          }
  
          $estimate = $this->estimate($percent);
  
          if ($estimate === null) {
              // Always do the first and last updates.
          } else if ($estimate == 0) {
              // Always do the last updates.
          } else if ($this->lastupdate + 20 < time()) {
              // We must update otherwise browser would time out.
          } else if (round($this->percent, 2) === round($percent, 2)) {
              // No significant change, no need to update anything.
              return;
          }
  
          $estimatemsg = null;
          if (is_numeric($estimate)) {
              $estimatemsg = get_string('secondsleft', 'moodle', round($estimate, 2));
          }
  
          $this->percent = round($percent, 2);
          $this->lastupdate = microtime(true);
  
          echo html_writer::script(js_writer::function_call('updateProgressBar',
              array($this->html_id, $this->percent, $msg, $estimatemsg)));
          flush();
      }
code_tokens: private function _update ( $ percent , $ msg ) { if ( empty ( $ this -> time_start ) ) { throw new coding_exception ( 'You must call create() (or use the $autostart ' . 'argument to the constructor) before you try updating the progress bar.' ) ; } if ( CLI_SCRIPT ) { return ; // Temporary solution for cli scripts. } $ estimate = $ this -> estimate ( $ percent ) ; if ( $ estimate === null ) { // Always do the first and last updates. } else if ( $ estimate == 0 ) { // Always do the last updates. } else if ( $ this -> lastupdate + 20 < time ( ) ) { // We must update otherwise browser would time out. } else if ( round ( $ this -> percent , 2 ) === round ( $ percent , 2 ) ) { // No significant change, no need to update anything. return ; } $ estimatemsg = null ; if ( is_numeric ( $ estimate ) ) { $ estimatemsg = get_string ( 'secondsleft' , 'moodle' , round ( $ estimate , 2 ) ) ; } $ this -> percent = round ( $ percent , 2 ) ; $ this -> lastupdate = microtime ( true ) ; echo html_writer :: script ( js_writer :: function_call ( 'updateProgressBar' , array ( $ this -> html_id , $ this -> percent , $ msg , $ estimatemsg ) ) ) ; flush ( ) ; }
docstring: Update the progress bar.
  
  @param int $percent From 1-100.
  @param string $msg The message.
  @return void Echo's output
  @throws coding_exception
docstring_tokens: Update the progress bar .