public function resultFromState($translatorevent, $questionAttempt, $submittedState) {
        $maxMark = isset($questionAttempt->maxmark) ? $questionAttempt->maxmark : 100;
        $scaledScore = $submittedState->fraction;
        $rawScore = $scaledScore * floatval($maxMark);

        switch ($submittedState->state) {
            case "todo":
                $translatorevent['attempt_completed'] = false;
                $translatorevent['attempt_success'] = null;
                break;
            case "gaveup":
                $translatorevent['attempt_completed'] = false;
                $translatorevent['attempt_success'] = false;
                break;
            case "complete":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = null;
                break;
            case "gradedwrong":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = false;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            case "gradedpartial":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = false;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            case "gradedright":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = true;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            default:
                $translatorevent['attempt_completed'] = null;
                $translatorevent['attempt_success'] = null;
                break;
        }

        return $translatorevent;
    }
public function resultFromState($translatorevent, $questionAttempt, $submittedState) {
        $maxMark = isset($questionAttempt->maxmark) ? $questionAttempt->maxmark : 100;
        $scaledScore = $submittedState->fraction;
        $rawScore = $scaledScore * floatval($maxMark);

        switch ($submittedState->state) {
            case "todo":
                $translatorevent['attempt_completed'] = false;
                $translatorevent['attempt_success'] = null;
                break;
            case "gaveup":
                $translatorevent['attempt_completed'] = false;
                $translatorevent['attempt_success'] = false;
                break;
            case "complete":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = null;
                break;
            case "gradedwrong":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = false;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            case "gradedpartial":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = false;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            case "gradedright":
                $translatorevent['attempt_completed'] = true;
                $translatorevent['attempt_success'] = true;
                $translatorevent['attempt_score_scaled'] = $scaledScore;
                $translatorevent['attempt_score_raw'] = $rawScore;
                break;
            default:
                $translatorevent['attempt_completed'] = null;
                $translatorevent['attempt_success'] = null;
                break;
        }

        return $translatorevent;
    }
public function resultFromState ( $ translatorevent , $ questionAttempt , $ submittedState ) { $ maxMark = isset ( $ questionAttempt -> maxmark ) ? $ questionAttempt -> maxmark : 100 ; $ scaledScore = $ submittedState -> fraction ; $ rawScore = $ scaledScore * floatval ( $ maxMark ) ; switch ( $ submittedState -> state ) { case "todo" : $ translatorevent [ 'attempt_completed' ] = false ; $ translatorevent [ 'attempt_success' ] = null ; break ; case "gaveup" : $ translatorevent [ 'attempt_completed' ] = false ; $ translatorevent [ 'attempt_success' ] = false ; break ; case "complete" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = null ; break ; case "gradedwrong" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = false ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; case "gradedpartial" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = false ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; case "gradedright" : $ translatorevent [ 'attempt_completed' ] = true ; $ translatorevent [ 'attempt_success' ] = true ; $ translatorevent [ 'attempt_score_scaled' ] = $ scaledScore ; $ translatorevent [ 'attempt_score_raw' ] = $ rawScore ; break ; default : $ translatorevent [ 'attempt_completed' ] = null ; $ translatorevent [ 'attempt_success' ] = null ; break ; } return $ translatorevent ; }
Add some result data to translator event for an individual question attempt based on Moodle's question attempt state
@param [String => Mixed] $translatorevent
@param PHPObj $questionAttempt
@param PHPObj $submittedState
@return [String => Mixed]
Add some result data to translator event for an individual question attempt based on Moodle s question attempt state