original_string: protected function format_average($record, $question = false) {
          if (is_null($record->grade)) {
              $average = '-';
          } else if ($question) {
              $average = quiz_format_question_grade($this->quiz, $record->grade);
          } else {
              $average = quiz_format_grade($this->quiz, $record->grade);
          }
  
          if ($this->download) {
              return $average;
          } else if (is_null($record->numaveraged) || $record->numaveraged == 0) {
              return html_writer::tag('span', html_writer::tag('span',
                      $average, array('class' => 'average')), array('class' => 'avgcell'));
          } else {
              return html_writer::tag('span', html_writer::tag('span',
                      $average, array('class' => 'average')) . ' ' . html_writer::tag('span',
                      '(' . $record->numaveraged . ')', array('class' => 'count')),
                      array('class' => 'avgcell'));
          }
      }
code: protected function format_average($record, $question = false) {
          if (is_null($record->grade)) {
              $average = '-';
          } else if ($question) {
              $average = quiz_format_question_grade($this->quiz, $record->grade);
          } else {
              $average = quiz_format_grade($this->quiz, $record->grade);
          }
  
          if ($this->download) {
              return $average;
          } else if (is_null($record->numaveraged) || $record->numaveraged == 0) {
              return html_writer::tag('span', html_writer::tag('span',
                      $average, array('class' => 'average')), array('class' => 'avgcell'));
          } else {
              return html_writer::tag('span', html_writer::tag('span',
                      $average, array('class' => 'average')) . ' ' . html_writer::tag('span',
                      '(' . $record->numaveraged . ')', array('class' => 'count')),
                      array('class' => 'avgcell'));
          }
      }
code_tokens: protected function format_average ( $ record , $ question = false ) { if ( is_null ( $ record -> grade ) ) { $ average = '-' ; } else if ( $ question ) { $ average = quiz_format_question_grade ( $ this -> quiz , $ record -> grade ) ; } else { $ average = quiz_format_grade ( $ this -> quiz , $ record -> grade ) ; } if ( $ this -> download ) { return $ average ; } else if ( is_null ( $ record -> numaveraged ) || $ record -> numaveraged == 0 ) { return html_writer :: tag ( 'span' , html_writer :: tag ( 'span' , $ average , array ( 'class' => 'average' ) ) , array ( 'class' => 'avgcell' ) ) ; } else { return html_writer :: tag ( 'span' , html_writer :: tag ( 'span' , $ average , array ( 'class' => 'average' ) ) . ' ' . html_writer :: tag ( 'span' , '(' . $ record -> numaveraged . ')' , array ( 'class' => 'count' ) ) , array ( 'class' => 'avgcell' ) ) ; } }
docstring: Format an entry in an average row.
  @param object $record with fields grade and numaveraged.
  @param bool $question true if this is a question score, false if it is an overall score.
  @return string HTML fragment for an average score (with number of things included in the average).
docstring_tokens: Format an entry in an average row .