original_string: public function for_subq($questionid, $variant = null) {
          if ($variant === null) {
              if (!isset($this->subquestionstats[$questionid])) {
                  throw new \coding_exception('Reference to unknown question id ' . $questionid);
              } else {
                  return $this->subquestionstats[$questionid];
              }
          } else {
              if (!isset($this->subquestionstats[$questionid]->variantstats[$variant])) {
                  throw new \coding_exception('Reference to unknown question id ' . $questionid .
                          ' variant ' . $variant);
              } else {
                  return $this->subquestionstats[$questionid]->variantstats[$variant];
              }
          }
      }
code: public function for_subq($questionid, $variant = null) {
          if ($variant === null) {
              if (!isset($this->subquestionstats[$questionid])) {
                  throw new \coding_exception('Reference to unknown question id ' . $questionid);
              } else {
                  return $this->subquestionstats[$questionid];
              }
          } else {
              if (!isset($this->subquestionstats[$questionid]->variantstats[$variant])) {
                  throw new \coding_exception('Reference to unknown question id ' . $questionid .
                          ' variant ' . $variant);
              } else {
                  return $this->subquestionstats[$questionid]->variantstats[$variant];
              }
          }
      }
code_tokens: public function for_subq ( $ questionid , $ variant = null ) { if ( $ variant === null ) { if ( ! isset ( $ this -> subquestionstats [ $ questionid ] ) ) { throw new \ coding_exception ( 'Reference to unknown question id ' . $ questionid ) ; } else { return $ this -> subquestionstats [ $ questionid ] ; } } else { if ( ! isset ( $ this -> subquestionstats [ $ questionid ] -> variantstats [ $ variant ] ) ) { throw new \ coding_exception ( 'Reference to unknown question id ' . $ questionid . ' variant ' . $ variant ) ; } else { return $ this -> subquestionstats [ $ questionid ] -> variantstats [ $ variant ] ; } } }
docstring: Reference for a item stats instance for a questionid and optional variant no.
  
  @param int  $questionid The id of the sub question.
  @param int|null $variant if not null then we want the object to store a variant of a sub-question's stats.
  @return calculated|calculated_for_subquestion stats instance for a questionid and optional variant no.
  Will be a calculated_for_subquestion if no variant specified.
  @throws \coding_exception if there is an attempt to respond to a non-existant set of stats.
docstring_tokens: Reference for a item stats instance for a questionid and optional variant no .