protected function grading_details(qbehaviour_adaptive_mark_details $details, question_display_options $options) {

        $mark = $details->get_formatted_marks($options->markdp);

        if ($details->currentpenalty == 0 && $details->totalpenalty == 0) {
            return get_string('gradingdetails', 'qbehaviour_adaptive', $mark);
        }

        $output = '';

        // Print details of grade adjustment due to penalties
        if ($details->rawmark != $details->actualmark) {
            if (!$details->improvable) {
                return get_string('gradingdetailswithadjustment', 'qbehaviour_adaptive', $mark);
            } else if ($details->totalpenalty > $details->currentpenalty) {
                return get_string('gradingdetailswithadjustmenttotalpenalty', 'qbehaviour_adaptive', $mark);
            } else {
                return get_string('gradingdetailswithadjustmentpenalty', 'qbehaviour_adaptive', $mark);
            }

        } else {
            if (!$details->improvable) {
                return get_string('gradingdetails', 'qbehaviour_adaptive', $mark);
            } else if ($details->totalpenalty > $details->currentpenalty) {
                return get_string('gradingdetailswithtotalpenalty', 'qbehaviour_adaptive', $mark);
            } else {
                return get_string('gradingdetailswithpenalty', 'qbehaviour_adaptive', $mark);
            }
        }

        return $output;
    }