original_string: public function find_right_answer($wrappedquestion) {
          // We only take into account *one* (the first) correct answer.
          while ($answer = array_shift($wrappedquestion->answers)) {
              if (!question_state::graded_state_for_fraction(
                      $answer->fraction)->is_incorrect()) {
                  // Store this answer as a choice, only if this is a new one.
                  $key = array_search($answer->answer, $this->choices);
                  if ($key === false) {
                      $key = $answer->id;
                      $this->choices[$key] = $answer->answer;
                  }
                  return $key;
              }
          }
          // We should never get there.
          throw new coding_exception('shortanswerquestionwithoutrightanswer', $wrappedquestion->id);
  
      }
code: public function find_right_answer($wrappedquestion) {
          // We only take into account *one* (the first) correct answer.
          while ($answer = array_shift($wrappedquestion->answers)) {
              if (!question_state::graded_state_for_fraction(
                      $answer->fraction)->is_incorrect()) {
                  // Store this answer as a choice, only if this is a new one.
                  $key = array_search($answer->answer, $this->choices);
                  if ($key === false) {
                      $key = $answer->id;
                      $this->choices[$key] = $answer->answer;
                  }
                  return $key;
              }
          }
          // We should never get there.
          throw new coding_exception('shortanswerquestionwithoutrightanswer', $wrappedquestion->id);
  
      }
code_tokens: public function find_right_answer ( $ wrappedquestion ) { // We only take into account *one* (the first) correct answer. while ( $ answer = array_shift ( $ wrappedquestion -> answers ) ) { if ( ! question_state :: graded_state_for_fraction ( $ answer -> fraction ) -> is_incorrect ( ) ) { // Store this answer as a choice, only if this is a new one. $ key = array_search ( $ answer -> answer , $ this -> choices ) ; if ( $ key === false ) { $ key = $ answer -> id ; $ this -> choices [ $ key ] = $ answer -> answer ; } return $ key ; } } // We should never get there. throw new coding_exception ( 'shortanswerquestionwithoutrightanswer' , $ wrappedquestion -> id ) ; }
docstring: Find the corresponding choice id of the first correct answer of a shortanswer question.
  choice is added to the randomsamatch question if it doesn't already exist.
  @param object $wrappedquestion short answer question.
  @return int correct choice id.
docstring_tokens: Find the corresponding choice id of the first correct answer of a shortanswer question . choice is added to the randomsamatch question if it doesn t already exist .