protected function lookup_choice($choice) {
        if (array_key_exists($choice, $this->choices)) {
            // Easy case: choice is a key in the choices array.
            return $choice;
        } else {
            // But choice can also be the id of a shortanser correct answer
            // without been a key of the choices array, in that case we need
            // to first find the shortanswer id, then find the choices index
            // associated to it.
            $questionid = array_search($choice, $this->rightanswerid);
            if ($questionid) {
                return $this->right[$questionid];
            }
        }
        return null;
    }
protected function lookup_choice($choice) {
        if (array_key_exists($choice, $this->choices)) {
            // Easy case: choice is a key in the choices array.
            return $choice;
        } else {
            // But choice can also be the id of a shortanser correct answer
            // without been a key of the choices array, in that case we need
            // to first find the shortanswer id, then find the choices index
            // associated to it.
            $questionid = array_search($choice, $this->rightanswerid);
            if ($questionid) {
                return $this->right[$questionid];
            }
        }
        return null;
    }
protected function lookup_choice ( $ choice ) { if ( array_key_exists ( $ choice , $ this -> choices ) ) { // Easy case: choice is a key in the choices array. return $ choice ; } else { // But choice can also be the id of a shortanser correct answer // without been a key of the choices array, in that case we need // to first find the shortanswer id, then find the choices index // associated to it. $ questionid = array_search ( $ choice , $ this -> rightanswerid ) ; if ( $ questionid ) { return $ this -> right [ $ questionid ] ; } } return null ; }
Find the index corresponding to a choice

@param integer $choice
@return integer
Find the index corresponding to a choice