original_string: public function start($preferredbehaviour, $variant, $submitteddata = array(),
              $timestamp = null, $userid = null, $existingstepid = null) {
  
          if ($this->get_num_steps() > 0) {
              throw new coding_exception('Cannot start a question that is already started.');
          }
  
          // Initialise the behaviour.
          $this->variant = $variant;
          if (is_string($preferredbehaviour)) {
              $this->behaviour =
                      $this->question->make_behaviour($this, $preferredbehaviour);
          } else {
              $class = get_class($preferredbehaviour);
              $this->behaviour = new $class($this, $preferredbehaviour);
          }
  
          // Record the minimum and maximum fractions.
          $this->minfraction = $this->behaviour->get_min_fraction();
          $this->maxfraction = $this->behaviour->get_max_fraction();
  
          // Initialise the first step.
          $firststep = new question_attempt_step($submitteddata, $timestamp, $userid, $existingstepid);
          if ($submitteddata) {
              $firststep->set_state(question_state::$complete);
              $this->behaviour->apply_attempt_state($firststep);
          } else {
              $this->behaviour->init_first_step($firststep, $variant);
          }
          $this->add_step($firststep);
  
          // Record questionline and correct answer.
          $this->questionsummary = $this->behaviour->get_question_summary();
          $this->rightanswer = $this->behaviour->get_right_answer_summary();
      }
code: public function start($preferredbehaviour, $variant, $submitteddata = array(),
              $timestamp = null, $userid = null, $existingstepid = null) {
  
          if ($this->get_num_steps() > 0) {
              throw new coding_exception('Cannot start a question that is already started.');
          }
  
          // Initialise the behaviour.
          $this->variant = $variant;
          if (is_string($preferredbehaviour)) {
              $this->behaviour =
                      $this->question->make_behaviour($this, $preferredbehaviour);
          } else {
              $class = get_class($preferredbehaviour);
              $this->behaviour = new $class($this, $preferredbehaviour);
          }
  
          // Record the minimum and maximum fractions.
          $this->minfraction = $this->behaviour->get_min_fraction();
          $this->maxfraction = $this->behaviour->get_max_fraction();
  
          // Initialise the first step.
          $firststep = new question_attempt_step($submitteddata, $timestamp, $userid, $existingstepid);
          if ($submitteddata) {
              $firststep->set_state(question_state::$complete);
              $this->behaviour->apply_attempt_state($firststep);
          } else {
              $this->behaviour->init_first_step($firststep, $variant);
          }
          $this->add_step($firststep);
  
          // Record questionline and correct answer.
          $this->questionsummary = $this->behaviour->get_question_summary();
          $this->rightanswer = $this->behaviour->get_right_answer_summary();
      }
code_tokens: public function start ( $ preferredbehaviour , $ variant , $ submitteddata = array ( ) , $ timestamp = null , $ userid = null , $ existingstepid = null ) { if ( $ this -> get_num_steps ( ) > 0 ) { throw new coding_exception ( 'Cannot start a question that is already started.' ) ; } // Initialise the behaviour. $ this -> variant = $ variant ; if ( is_string ( $ preferredbehaviour ) ) { $ this -> behaviour = $ this -> question -> make_behaviour ( $ this , $ preferredbehaviour ) ; } else { $ class = get_class ( $ preferredbehaviour ) ; $ this -> behaviour = new $ class ( $ this , $ preferredbehaviour ) ; } // Record the minimum and maximum fractions. $ this -> minfraction = $ this -> behaviour -> get_min_fraction ( ) ; $ this -> maxfraction = $ this -> behaviour -> get_max_fraction ( ) ; // Initialise the first step. $ firststep = new question_attempt_step ( $ submitteddata , $ timestamp , $ userid , $ existingstepid ) ; if ( $ submitteddata ) { $ firststep -> set_state ( question_state :: $ complete ) ; $ this -> behaviour -> apply_attempt_state ( $ firststep ) ; } else { $ this -> behaviour -> init_first_step ( $ firststep , $ variant ) ; } $ this -> add_step ( $ firststep ) ; // Record questionline and correct answer. $ this -> questionsummary = $ this -> behaviour -> get_question_summary ( ) ; $ this -> rightanswer = $ this -> behaviour -> get_right_answer_summary ( ) ; }
docstring: Start this question attempt.
  
  You should not call this method directly. Call
  {@link question_usage_by_activity::start_question()} instead.
  
  @param string|question_behaviour $preferredbehaviour the name of the
  desired archetypal behaviour, or an actual model instance.
  @param int $variant the variant of the question to start. Between 1 and
  $this->get_question()->get_num_variants() inclusive.
  @param array $submitteddata optional, used when re-starting to keep the same initial state.
  @param int $timestamp optional, the timstamp to record for this action. Defaults to now.
  @param int $userid optional, the user to attribute this action to. Defaults to the current user.
  @param int $existingstepid optional, if this step is going to replace an existing step
  (for example, during a regrade) this is the id of the previous step we are replacing.
docstring_tokens: Start this question attempt .