protected function add_purpose_category($contextlevel = false) {

        $mform = $this->_form;

        $addcategorytext = $this->get_add_element_content(get_string('addcategory', 'tool_dataprivacy'));
        $categoryselect = $mform->createElement('select', 'categoryid', null, $this->_customdata['categories']);
        $addcategory = $mform->createElement('button', 'addcategory', $addcategorytext, ['data-add-element' => 'category']);
        $mform->addElement('group', 'categorygroup', get_string('category', 'tool_dataprivacy'),
            [$categoryselect, $addcategory], null, false);
        $mform->addHelpButton('categorygroup', 'category', 'tool_dataprivacy');
        $mform->setType('categoryid', PARAM_INT);
        $mform->setDefault('categoryid', 0);

        $addpurposetext = $this->get_add_element_content(get_string('addpurpose', 'tool_dataprivacy'));
        $purposeselect = $mform->createElement('select', 'purposeid', null, $this->_customdata['purposes']);
        $addpurpose = $mform->createElement('button', 'addpurpose', $addpurposetext, ['data-add-element' => 'purpose']);
        $mform->addElement('group', 'purposegroup', get_string('purpose', 'tool_dataprivacy'),
            [$purposeselect, $addpurpose], null, false);
        $mform->addHelpButton('purposegroup', 'purpose', 'tool_dataprivacy');
        $mform->setType('purposeid', PARAM_INT);
        $mform->setDefault('purposeid', 0);

        if (!empty($this->_customdata['currentretentionperiod'])) {
            $mform->addElement('static', 'retention_current', get_string('retentionperiod', 'tool_dataprivacy'),
                $this->_customdata['currentretentionperiod']);
            $mform->addHelpButton('retention_current', 'retentionperiod', 'tool_dataprivacy');
        }
    }