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;
    }