protected static function get_retention_display_text(purpose $effectivepurpose, $retentioncontextlevel, \context $context) {
        global $PAGE;

        $renderer = $PAGE->get_renderer('tool_dataprivacy');

        $exporter = new \tool_dataprivacy\external\purpose_exporter($effectivepurpose, ['context' => $context]);
        $exportedpurpose = $exporter->export($renderer);

        switch ($retentioncontextlevel) {
            case CONTEXT_COURSE:
            case CONTEXT_MODULE:
            case CONTEXT_BLOCK:
                $str = get_string('effectiveretentionperiodcourse', 'tool_dataprivacy',
                    $exportedpurpose->formattedretentionperiod);
                break;
            case CONTEXT_USER:
                $str = get_string('effectiveretentionperioduser', 'tool_dataprivacy',
                    $exportedpurpose->formattedretentionperiod);
                break;
            default:
                $str = $exportedpurpose->formattedretentionperiod;
        }

        return $str;
    }