public function calculate($qubaids, $whichtries = \question_attempt::LAST_TRY) {
        // Load data.
        $dm = new \question_engine_data_mapper();
        $questionattempts = $dm->load_attempts_at_question($this->questiondata->id, $qubaids);

        // Analyse it.
        foreach ($questionattempts as $qa) {
            $responseparts = $qa->classify_response($whichtries);
            if ($this->breakdownbyvariant) {
                $this->analysis->count_response_parts($qa->get_variant(), $responseparts);
            } else {
                $this->analysis->count_response_parts(1, $responseparts);
            }

        }
        $this->analysis->cache($qubaids, $whichtries, $this->questiondata->id);
        return $this->analysis;
    }