public function recode_legacy_state_answer($state) {
        $answer = $state->answer;
        $resultarr = array();
        foreach (explode(',', $answer) as $pair) {
            $pairarr = explode('-', $pair);
            $id = $pairarr[0];
            $code = $pairarr[1];
            $newid = $this->get_mappingid('qtype_match_subquestions', $id);
            if ($code) {
                $newcode = $this->get_mappingid('qtype_match_subquestion_codes', $code);
            } else {
                $newcode = $code;
            }
            $resultarr[] = $newid . '-' . $newcode;
        }
        return implode(',', $resultarr);
    }
public function recode_legacy_state_answer($state) {
        $answer = $state->answer;
        $resultarr = array();
        foreach (explode(',', $answer) as $pair) {
            $pairarr = explode('-', $pair);
            $id = $pairarr[0];
            $code = $pairarr[1];
            $newid = $this->get_mappingid('qtype_match_subquestions', $id);
            if ($code) {
                $newcode = $this->get_mappingid('qtype_match_subquestion_codes', $code);
            } else {
                $newcode = $code;
            }
            $resultarr[] = $newid . '-' . $newcode;
        }
        return implode(',', $resultarr);
    }
public function recode_legacy_state_answer ( $ state ) { $ answer = $ state -> answer ; $ resultarr = array ( ) ; foreach ( explode ( ',' , $ answer ) as $ pair ) { $ pairarr = explode ( '-' , $ pair ) ; $ id = $ pairarr [ 0 ] ; $ code = $ pairarr [ 1 ] ; $ newid = $ this -> get_mappingid ( 'qtype_match_subquestions' , $ id ) ; if ( $ code ) { $ newcode = $ this -> get_mappingid ( 'qtype_match_subquestion_codes' , $ code ) ; } else { $ newcode = $ code ; } $ resultarr [ ] = $ newid . '-' . $ newcode ; } return implode ( ',' , $ resultarr ) ; }
Given one question_states record, return the answer
recoded pointing to all the restored stuff for match questions.

answer is one comma separated list of hypen separated pairs
containing question_match_sub->id and question_match_sub->code, which
has been remapped to be qtype_match_subquestions->id, since code no longer exists.
Given one question_states record return the answer recoded pointing to all the restored stuff for match questions .