code: protected function updateStats(&$target, $itemInfos)
      {
          if (!isset($target['stats'])) {
              $target['stats'] = [
                  'questions' => 0,
                  'answered' => 0,
                  'flagged' => 0,
                  'viewed' => 0,
                  'total' => 0,
                  'questionsViewed' => 0,
              ];
          }
  
          if (empty($itemInfos['informational'])) {
              $target['stats']['questions'] ++;
  
              if (!empty($itemInfos['answered'])) {
                  $target['stats']['answered'] ++;
              }
  
              if (!empty($itemInfos['viewed'])) {
                  $target['stats']['questionsViewed'] ++;
              }
          }
  
          if (!empty($itemInfos['flagged'])) {
              $target['stats']['flagged'] ++;
          }
  
          if (!empty($itemInfos['viewed'])) {
              $target['stats']['viewed'] ++;
          }
  
          $target['stats']['total'] ++;
      }
docs: Update the stats inside the target
  @param array $target
  @param array $itemInfos