original_string: public function recode_legacy_state_answer($state) {
          $answer = $state->answer;
          $resultarr = array();
          foreach (explode(',', $answer) as $pair) {
              $pairarr = explode('-', $pair);
              $questionid = $pairarr[0];
              $answerid = $pairarr[1];
              $newquestionid = $questionid ? $this->get_mappingid('question', $questionid) : 0;
              $newanswerid = $answerid ? $this->get_mappingid('question_answer', $answerid) : 0;
              $resultarr[] = implode('-', array($newquestionid, $newanswerid));
          }
          return implode(',', $resultarr);
      }
code: public function recode_legacy_state_answer($state) {
          $answer = $state->answer;
          $resultarr = array();
          foreach (explode(',', $answer) as $pair) {
              $pairarr = explode('-', $pair);
              $questionid = $pairarr[0];
              $answerid = $pairarr[1];
              $newquestionid = $questionid ? $this->get_mappingid('question', $questionid) : 0;
              $newanswerid = $answerid ? $this->get_mappingid('question_answer', $answerid) : 0;
              $resultarr[] = implode('-', array($newquestionid, $newanswerid));
          }
          return implode(',', $resultarr);
      }
code_tokens: public function recode_legacy_state_answer ( $ state ) { $ answer = $ state -> answer ; $ resultarr = array ( ) ; foreach ( explode ( ',' , $ answer ) as $ pair ) { $ pairarr = explode ( '-' , $ pair ) ; $ questionid = $ pairarr [ 0 ] ; $ answerid = $ pairarr [ 1 ] ; $ newquestionid = $ questionid ? $ this -> get_mappingid ( 'question' , $ questionid ) : 0 ; $ newanswerid = $ answerid ? $ this -> get_mappingid ( 'question_answer' , $ answerid ) : 0 ; $ resultarr [ ] = implode ( '-' , array ( $ newquestionid , $ newanswerid ) ) ; } return implode ( ',' , $ resultarr ) ; }
docstring: Given one question_states record, return the answer
  recoded pointing to all the restored stuff for randomsamatch questions
  
  answer is one comma separated list of hypen separated pairs
  containing question->id and question_answers->id
docstring_tokens: Given one question_states record return the answer recoded pointing to all the restored stuff for randomsamatch questions