private function getLastState($questionAttempt) {

        // Default placeholder to -1 so that the first item we check will always be greater than the placeholder.
        $sequencenumber = -1;

        // Default state in case there are no steps.
        $state = (object)[
            "state" => "todo",
            "timestamp" => null
        ];

        // Cycle through steps to find the last one (the one with the highest sequence number).
        foreach ($questionAttempt->steps as $stepId => $step) {
            if ($step->sequencenumber > $sequencenumber) {

                // Now this step has the highest sequence number we've seen.
                $sequencenumber = $step->sequencenumber;
                $state = (object)[
                    "state" => $step->state,
                    "timestamp" => $step->timecreated,
                    "fraction" => (is_null($step->fraction) || $step->fraction == '') ? 0 : floatval($step->fraction)
                ];
            }
        }
        return $state;
    }
private function getLastState($questionAttempt) {

        // Default placeholder to -1 so that the first item we check will always be greater than the placeholder.
        $sequencenumber = -1;

        // Default state in case there are no steps.
        $state = (object)[
            "state" => "todo",
            "timestamp" => null
        ];

        // Cycle through steps to find the last one (the one with the highest sequence number).
        foreach ($questionAttempt->steps as $stepId => $step) {
            if ($step->sequencenumber > $sequencenumber) {

                // Now this step has the highest sequence number we've seen.
                $sequencenumber = $step->sequencenumber;
                $state = (object)[
                    "state" => $step->state,
                    "timestamp" => $step->timecreated,
                    "fraction" => (is_null($step->fraction) || $step->fraction == '') ? 0 : floatval($step->fraction)
                ];
            }
        }
        return $state;
    }
private function getLastState ( $ questionAttempt ) { // Default placeholder to -1 so that the first item we check will always be greater than the placeholder. $ sequencenumber = - 1 ; // Default state in case there are no steps. $ state = ( object ) [ "state" => "todo" , "timestamp" => null ] ; // Cycle through steps to find the last one (the one with the highest sequence number). foreach ( $ questionAttempt -> steps as $ stepId => $ step ) { if ( $ step -> sequencenumber > $ sequencenumber ) { // Now this step has the highest sequence number we've seen. $ sequencenumber = $ step -> sequencenumber ; $ state = ( object ) [ "state" => $ step -> state , "timestamp" => $ step -> timecreated , "fraction" => ( is_null ( $ step -> fraction ) || $ step -> fraction == '' ) ? 0 : floatval ( $ step -> fraction ) ] ; } } return $ state ; }
Get pertient data from the last recorded step of a learners interactions within a question attempt.
@param PHPObj $questionAttempt
@return [String => Mixed]
Get pertient data from the last recorded step of a learners interactions within a question attempt .