Export this data so it can be used as the context for a mustache template.

@param renderer_base $output
@return stdClass
490739
public function export_for_template(renderer_base $output) {
        global $PAGE;

        $context = \context_system::instance();

        $PAGE->requires->js_call_amd('tool_dataprivacy/categoriesactions', 'init');
        $PAGE->requires->js_call_amd('tool_dataprivacy/add_category', 'getInstance', [$context->id]);

        $data = new stdClass();

        // Navigation links.
        $data->navigation = [];
        $navigationlinks = $this->get_navigation();
        foreach ($navigationlinks as $navlink) {
            $data->navigation[] = $navlink->export_for_template($output);
        }

        $data->categories = [];
        foreach ($this->categories as $category) {
            $exporter = new category_exporter($category, ['context' => \context_system::instance()]);
            $exportedcategory = $exporter->export($output);

            $actionmenu = $this->action_menu('category', $exportedcategory, $category);
            $exportedcategory->actions = $actionmenu->export_for_template($output);
            $data->categories[] = $exportedcategory;
        }

        return $data;
    }
777
public function export_for_template(renderer_base $output) {
        global $USER, $OUTPUT;

        $data = new \stdClass();

        if (!isset($this->config->display_picture) || $this->config->display_picture == 1) {
            $data->userpicture = $OUTPUT->user_picture($USER, array('class' => 'userpicture'));
        }

        $data->userfullname = fullname($USER);

        if (!isset($this->config->display_country) || $this->config->display_country == 1) {
            $countries = get_string_manager()->get_list_of_countries(true);
            if (isset($countries[$USER->country])) {
                $data->usercountry = $countries[$USER->country];
            }
        }

        if (!isset($this->config->display_city) || $this->config->display_city == 1) {
            $data->usercity = $USER->city;
        }

        if (!isset($this->config->display_email) || $this->config->display_email == 1) {
            $data->useremail = obfuscate_mailto($USER->email, '');
        }

        if (!empty($this->config->display_icq) && !empty($USER->icq)) {
            $data->usericq = s($USER->icq);
        }

        if (!empty($this->config->display_skype) && !empty($USER->skype)) {
            $data->userskype = s($USER->skype);
        }

        if (!empty($this->config->display_yahoo) && !empty($USER->yahoo)) {
            $data->useryahoo = s($USER->yahoo);
        }

        if (!empty($this->config->display_aim) && !empty($USER->aim)) {
            $data->useraim = s($USER->aim);
        }

        if (!empty($this->config->display_msn) && !empty($USER->msn)) {
            $data->usermsn = s($USER->msn);
        }

        if (!empty($this->config->display_phone1) && !empty($USER->phone1)) {
            $data->userphone1 = s($USER->phone1);
        }

        if (!empty($this->config->display_phone2) && !empty($USER->phone2)) {
            $data->userphone2 = s($USER->phone2);
        }

        if (!empty($this->config->display_institution) && !empty($USER->institution)) {
            $data->userinstitution = format_string($USER->institution);
        }

        if (!empty($this->config->display_address) && !empty($USER->address)) {
            $data->useraddress = format_string($USER->address);
        }

        if (!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) {
            $data->userfirstaccess = userdate($USER->firstaccess);
        }

        if (!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) {
            $data->userlastaccess = userdate($USER->lastaccess);
        }

        if (!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) {
            $data->usercurrentlogin = userdate($USER->currentlogin);
        }

        if (!empty($this->config->display_lastip) && !empty($USER->lastip)) {
            $data->userlastip = $USER->lastip;
        }

        return $data;
    }
966519
public function export_for_template(\renderer_base $output) {
        $listofroles = [];
        $roleids = json_decode($this->value);
        $viewableroleids = array_intersect($roleids, array_merge($this->viewableroles, $this->assignableroles));

        foreach ($viewableroleids as $id) {
            // If this is a student, we only show a subset of the roles.
            if ($this->editable || array_key_exists($id, $this->profileroles)) {
                $listofroles[] = format_string($this->courseroles[$id]->localname, true, ['context' => $this->context]);
            }
        }

        if (!empty($listofroles)) {
            $this->displayvalue = implode($listofroles, ', ');
        } else if (!empty($roleids) && empty($viewableroleids)) {
            $this->displayvalue = get_string('novisibleroles', 'role');
        } else {
            $this->displayvalue = get_string('noroles', 'role');
        }
        return parent::export_for_template($output);
    }
581795
public function export_for_template(renderer_base $output) {
        global $PAGE;
        $data = new stdClass();
        if (empty($this->baseurl)) {
            $this->baseurl = $PAGE->url;
        }
        $data->action = $this->baseurl->out(false);

        foreach ($this->selectedoptions as $option) {
            if (!isset($this->filteroptions[$option])) {
                $this->filteroptions[$option] = $option;
            }
        }

        $data->filteroptions = [];
        $originalfilteroptions = [];
        foreach ($this->filteroptions as $value => $label) {
            $selected = in_array($value, $this->selectedoptions);
            $filteroption = (object)[
                'value' => $value,
                'label' => $label
            ];
            $originalfilteroptions[] = $filteroption;
            $filteroption->selected = $selected;
            $data->filteroptions[] = $filteroption;
        }
        $data->originaloptionsjson = json_encode($originalfilteroptions);
        return $data;
    }
1266910
public function export_for_template(\renderer_base $output) {

        $data = (object)[
            'statusicon' => '',
            'statustext' => '',
            'statuslink' => '',
            'actions' => [],
        ];

        if (count($this->versions) == 1) {
            // We represent one particular policy's agreement status.
            $versionname = reset($this->versions);
            $versionid = key($this->versions);

            $actionaccept = (object)[
                'text' => get_string('useracceptanceactionaccept', 'tool_policy'),
                'title' => get_string('useracceptanceactionacceptone', 'tool_policy', $versionname),
                'data' => 'acceptmodal',
                'url' => (new \moodle_url('/admin/tool/policy/accept.php', [
                    'userids[]' => $this->userid,
                    'versionids[]' => $versionid,
                    'action' => 'accept',
                    'returnurl' => $this->pageurl->out_as_local_url(false),
                ]))->out(false),
            ];

            $actionrevoke = (object)[
                'text' => get_string('useracceptanceactionrevoke', 'tool_policy'),
                'title' => get_string('useracceptanceactionrevokeone', 'tool_policy', $versionname),
                'data' => 'acceptmodal',
                'url' => (new \moodle_url('/admin/tool/policy/accept.php', [
                    'userids[]' => $this->userid,
                    'versionids[]' => $versionid,
                    'action' => 'revoke',
                    'returnurl' => $this->pageurl->out_as_local_url(false),
                ]))->out(false),
            ];

            $actiondecline = (object)[
                'text' => get_string('useracceptanceactiondecline', 'tool_policy'),
                'title' => get_string('useracceptanceactiondeclineone', 'tool_policy', $versionname),
                'data' => 'acceptmodal',
                'url' => (new \moodle_url('/admin/tool/policy/accept.php', [
                    'userids[]' => $this->userid,
                    'versionids[]' => $versionid,
                    'action' => 'decline',
                    'returnurl' => $this->pageurl->out_as_local_url(false),
                ]))->out(false),
            ];

            if ($this->accepted) {
                $data->statusicon = 'agreed';

                if ($this->onbehalf) {
                    $data->statustext = get_string('acceptancestatusacceptedbehalf', 'tool_policy');
                } else {
                    $data->statustext = get_string('acceptancestatusaccepted', 'tool_policy');
                }

                if ($this->canrevoke) {
                    $data->actions[] = $actionrevoke;
                }

            } else if ($this->declined) {
                $data->statusicon = 'declined';

                if ($this->onbehalf) {
                    $data->statustext = get_string('acceptancestatusdeclinedbehalf', 'tool_policy');
                } else {
                    $data->statustext = get_string('acceptancestatusdeclined', 'tool_policy');
                }

                if ($this->canaccept) {
                    $data->actions[] = $actionaccept;
                }

            } else {
                $data->statusicon = 'pending';
                $data->statustext = get_string('acceptancestatuspending', 'tool_policy');

                if ($this->canaccept) {
                    $data->actions[] = $actionaccept;
                    $data->actions[] = $actiondecline;
                }
            }

        } else if (count($this->versions) > 1) {
            // We represent the summary status for multiple policies.

            $data->actions[] = (object)[
                'text' => get_string('useracceptanceactiondetails', 'tool_policy'),
                'url' => (new \moodle_url('/admin/tool/policy/user.php', [
                    'userid' => $this->userid,
                    'returnurl' => $this->pageurl->out_as_local_url(false),
                ]))->out(false),
            ];

            // Prepare the action link to accept all pending policies.
            $accepturl = new \moodle_url('/admin/tool/policy/accept.php', [
                'userids[]' => $this->userid,
                'action' => 'accept',
                'returnurl' => $this->pageurl->out_as_local_url(false),
            ]);

            foreach (array_diff(array_keys($this->versions), $this->accepted, $this->declined) as $ix => $versionid) {
                $accepturl->param('versionids['.$ix.']', $versionid);
            }

            $actionaccept = (object)[
                'text' => get_string('useracceptanceactionaccept', 'tool_policy'),
                'title' => get_string('useracceptanceactionacceptpending', 'tool_policy'),
                'data' => 'acceptmodal',
                'url' => $accepturl->out(false),
            ];

            // Prepare the action link to revoke all agreed policies.
            $revokeurl = new \moodle_url('/admin/tool/policy/accept.php', [
                'userids[]' => $this->userid,
                'action' => 'revoke',
                'returnurl' => $this->pageurl->out_as_local_url(false),
            ]);

            foreach ($this->accepted as $ix => $versionid) {
                $revokeurl->param('versionids['.$ix.']', $versionid);
            }

            $actionrevoke = (object)[
                'text' => get_string('useracceptanceactionrevoke', 'tool_policy'),
                'title' => get_string('useracceptanceactionrevokeall', 'tool_policy'),
                'data' => 'acceptmodal',
                'url' => $revokeurl->out(false),
            ];

            // Prepare the action link to decline all pending policies.
            $declineurl = new \moodle_url('/admin/tool/policy/accept.php', [
                'userids[]' => $this->userid,
                'action' => 'decline',
                'returnurl' => $this->pageurl->out_as_local_url(false),
            ]);

            foreach (array_diff(array_keys($this->versions), $this->accepted, $this->declined) as $ix => $versionid) {
                $declineurl->param('versionids['.$ix.']', $versionid);
            }

            $actiondecline = (object)[
                'text' => get_string('useracceptanceactiondecline', 'tool_policy'),
                'title' => get_string('useracceptanceactiondeclinepending', 'tool_policy'),
                'data' => 'acceptmodal',
                'url' => $declineurl->out(false),
            ];

            $countversions = count($this->versions);
            $countaccepted = count($this->accepted);
            $countdeclined = count($this->declined);

            if ($countaccepted == $countversions) {
                // All policies accepted.
                $data->statusicon = 'agreed';
                $data->statustext = get_string('acceptancestatusaccepted', 'tool_policy');

                if ($this->canrevoke) {
                    $data->actions[] = $actionrevoke;
                }

            } else if ($countdeclined == $countversions) {
                // All policies declined.
                $data->statusicon = 'declined';
                $data->statustext = get_string('acceptancestatusdeclined', 'tool_policy');

            } else if ($countaccepted + $countdeclined == $countversions) {
                // All policies responded, only some of them accepted.
                $data->statusicon = 'partial';
                $data->statustext = get_string('acceptancestatuspartial', 'tool_policy');

                if ($this->accepted && $this->canrevoke) {
                    $data->actions[] = $actionrevoke;
                }

            } else {
                // Some policies are pending.
                $data->statusicon = 'pending';
                $data->statustext = get_string('acceptancestatuspending', 'tool_policy');

                if ($this->canaccept) {
                    $data->actions[] = $actionaccept;
                    $data->actions[] = $actiondecline;
                }
            }
        }

        return $data;
    }
459159
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $compstoreview = array();
        foreach ($this->compstoreview['competencies'] as $compdata) {
            $ucexporter = new user_competency_exporter($compdata->usercompetency,
                array('scale' => $compdata->competency->get_scale()));
            $compexporter = new competency_exporter($compdata->competency,
                array('context' => $compdata->competency->get_context()));
            $userexporter = new user_summary_exporter($compdata->user);
            $compstoreview[] = array(
                'usercompetency' => $ucexporter->export($output),
                'competency' => $compexporter->export($output),
                'user' => $userexporter->export($output),
            );
        }

        $data = array(
            'competencies' => $compstoreview,
            'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false),
        );

        return $data;
    }
937561
public function export_for_template(\renderer_base $output) {
        global $DB;

        $plan = api::read_plan($this->planid);
        $pc = api::get_plan_competency($plan, $this->competencyid);
        $competency = $pc->competency;
        $usercompetency = $pc->usercompetency;
        $usercompetencyplan = $pc->usercompetencyplan;

        if (empty($competency)) {
            throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the plan.');
        }

        $relatedcompetencies = api::list_related_competencies($competency->get('id'));
        $userid = $plan->get('userid');
        $user = $DB->get_record('user', array('id' => $userid));
        $evidence = api::list_evidence($userid, $this->competencyid, $plan->get('id'));

        $params = array(
            'competency' => $competency,
            'usercompetency' => $usercompetency,
            'usercompetencyplan' => $usercompetencyplan,
            'evidence' => $evidence,
            'user' => $user,
            'plan' => $plan,
            'relatedcompetencies' => $relatedcompetencies
        );
        $exporter = new user_competency_summary_in_plan_exporter(null, $params);
        $data = $exporter->export($output);

        return $data;
    }
345772
public function export_for_template(renderer_base $output) {
        global $PAGE;

        $params = [\context_system::instance()->id, $this->defaultcontextlevel, $this->defaultcontextid];
        $PAGE->requires->js_call_amd('tool_dataprivacy/data_registry', 'init', $params);

        $data = new stdClass();
        $defaultsbutton = new \action_link(
            new \moodle_url('/admin/tool/dataprivacy/defaults.php'),
            get_string('setdefaults', 'tool_dataprivacy'),
            null,
            ['class' => 'btn btn-primary']
        );
        $data->defaultsbutton = $defaultsbutton->export_for_template($output);

        $actionmenu = new \action_menu();
        $actionmenu->set_menu_trigger(get_string('edit'), 'btn btn-primary');
        $actionmenu->set_owner_selector('dataregistry-actions');
        $actionmenu->set_alignment(\action_menu::TL, \action_menu::BL);

        $url = new \moodle_url('/admin/tool/dataprivacy/categories.php');
        $categories = new \action_menu_link_secondary($url, null, get_string('categories', 'tool_dataprivacy'));
        $actionmenu->add($categories);

        $url = new \moodle_url('/admin/tool/dataprivacy/purposes.php');
        $purposes = new \action_menu_link_secondary($url, null, get_string('purposes', 'tool_dataprivacy'));
        $actionmenu->add($purposes);

        $data->actions = $actionmenu->export_for_template($output);

        if (!data_registry::defaults_set()) {
            $data->info = (object)[
                    'message' => get_string('dataregistryinfo', 'tool_dataprivacy'),
                    'announce' => 1
            ];
            $data->nosystemdefaults = (object)[
                'message' => get_string('nosystemdefaults', 'tool_dataprivacy'),
                'announce' => 1
            ];
        }

        $data->tree = $this->get_default_tree_structure();

        return $data;
    }
252728
public function export_for_template(renderer_base $output) {
        $args = !empty($this->jsfunctionargs) ? json_encode($this->jsfunctionargs) : false;
        return (object) [
            'event' => $this->event,
            'jsfunction' => $this->jsfunction,
            'jsfunctionargs' => $args,
        ];
    }
689814
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $data->actionurl = $this->actionurl->out(false);
        $data->instructions = (string) $this->instructions;
        $data->method = $this->method;
        $data->paramname = $this->paramname;
        $data->params = $this->params;
        $data->sesskey = sesskey();
        $data->title = (string) $this->title;

        $data->sections = array_map(function($section) use ($output) {
            return $section->export_for_template($output);
        }, $this->sections);

        return $data;
    }
757886
public function export_for_template(renderer_base $output) {
        $tabs = [];
        $secondrow = false;

        foreach ($this->subtree as $tab) {
            $tabs[] = $tab->export_for_template($output);
            if (!empty($tab->subtree) && ($tab->level == 0 || $tab->selected || $tab->activated)) {
                $secondrow = new tabtree($tab->subtree);
            }
        }

        return (object) [
            'tabs' => $tabs,
            'secondrow' => $secondrow ? $secondrow->export_for_template($output) : false
        ];
    }
242218
public function export_for_template(renderer_base $output) {
        global $CFG;

        $title = get_string($this->identifier, $this->component);

        if (empty($this->linktext)) {
            $alt = get_string('helpprefix2', '', trim($title, ". \t"));
        } else {
            $alt = get_string('helpwiththis');
        }

        $data = get_formatted_help_string($this->identifier, $this->component, false);

        $data->alt = $alt;
        $data->icon = (new pix_icon('help', $alt, 'core', ['class' => 'iconhelp']))->export_for_template($output);
        $data->linktext = $this->linktext;
        $data->title = get_string('helpprefix2', '', trim($title, ". \t"));

        $options = [
            'component' => $this->component,
            'identifier' => $this->identifier,
            'lang' => current_language()
        ];

        // Debugging feature lets you display string identifier and component.
        if (isset($CFG->debugstringids) && $CFG->debugstringids && optional_param('strings', 0, PARAM_INT)) {
            $options['strings'] = 1;
        }

        $data->url = (new moodle_url('/help.php', $options))->out(false);
        $data->ltr = !right_to_left();
        return $data;
    }
435803
public function export_for_template(\renderer_base $output) {
        if (!$this->editable) {
            return array(
                'displayvalue' => (string)$this->displayvalue
            );
        }

        return array(
            'component' => $this->component,
            'itemtype' => $this->itemtype,
            'itemid' => $this->itemid,
            'displayvalue' => (string)$this->displayvalue,
            'value' => (string)$this->value,
            'edithint' => (string)$this->edithint,
            'editlabel' => (string)$this->editlabel,
            'type' => $this->type,
            'options' => $this->options,
            'linkeverything' => $this->get_linkeverything() ? 1 : 0,
        );
    }
1079190
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        // Set tab URLs.
        $coursecaturl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSECAT]);
        $courseurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_COURSE]);
        $moduleurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_MODULE]);
        $blockurl = new moodle_url('/admin/tool/dataprivacy/defaults.php', ['mode' => CONTEXT_BLOCK]);
        $data->coursecaturl = $coursecaturl;
        $data->courseurl = $courseurl;
        $data->moduleurl = $moduleurl;
        $data->blockurl = $blockurl;

        // Set display mode.
        switch ($this->mode) {
            case CONTEXT_COURSECAT:
                $data->modecoursecat = true;
                break;
            case CONTEXT_COURSE:
                $data->modecourse = true;
                break;
            case CONTEXT_MODULE:
                $data->modemodule = true;
                break;
            case CONTEXT_BLOCK:
                $data->modeblock = true;
                break;
            default:
                $data->modecoursecat = true;
                break;
        }

        // Set config variables.
        $configname = \context_helper::get_class_for_level($this->mode);
        list($purposevar, $categoryvar) = data_registry::var_names_from_context($configname);
        $data->categoryvar = $categoryvar;
        $data->purposevar = $purposevar;

        // Set default category.
        $data->categoryid = $this->category;
        $data->category = category_exporter::get_name($this->category);

        // Set default purpose.
        $data->purposeid = $this->purpose;
        $data->purpose = purpose_exporter::get_name($this->purpose);

        // Set other defaults.
        $otherdefaults = [];
        $url = new moodle_url('#');
        foreach ($this->otherdefaults as $pluginname => $values) {
            $defaults = [
                'name' => $values->name,
                'category' => category_exporter::get_name($values->category),
                'purpose' => purpose_exporter::get_name($values->purpose),
            ];
            if ($this->canedit) {
                $actions = [];
                // Edit link.
                $editattrs = [
                    'data-action' => 'edit-activity-defaults',
                    'data-contextlevel' => $this->mode,
                    'data-activityname' => $pluginname,
                    'data-category' => $values->category,
                    'data-purpose' => $values->purpose,
                ];
                $editlink = new action_menu_link_primary($url, new \pix_icon('t/edit', get_string('edit')),
                    get_string('edit'), $editattrs);
                $actions[] = $editlink->export_for_template($output);

                // Delete link.
                $deleteattrs = [
                    'data-action' => 'delete-activity-defaults',
                    'data-contextlevel' => $this->mode,
                    'data-activityname' => $pluginname,
                    'data-activitydisplayname' => $values->name,
                ];
                $deletelink = new action_menu_link_primary($url, new \pix_icon('t/delete', get_string('delete')),
                    get_string('delete'), $deleteattrs);
                $actions[] = $deletelink->export_for_template($output);

                $defaults['actions'] = $actions;
            }
            $otherdefaults[] = (object)$defaults;
        }
        $data->otherdefaults = $otherdefaults;

        $data->canedit = $this->canedit;
        $data->contextlevel = $this->mode;

        return $data;
    }
1176413
public function export_for_template(renderer_base $output) {
        $attributes = $this->attributes;

        $data = new stdClass();
        $data->name = $this->name;
        $data->method = $this->method;
        $data->action = $this->method === 'get' ? $this->url->out_omit_querystring(true) : $this->url->out_omit_querystring();
        $data->classes = $this->class;
        $data->label = $this->label;
        $data->disabled = $this->disabled;
        $data->title = $this->tooltip;
        $data->formid = !empty($this->formid) ? $this->formid : html_writer::random_id('single_select_f');
        $data->id = !empty($attributes['id']) ? $attributes['id'] : html_writer::random_id('single_select');

        // Select element attributes.
        // Unset attributes that are already predefined in the template.
        unset($attributes['id']);
        unset($attributes['class']);
        unset($attributes['name']);
        unset($attributes['title']);
        unset($attributes['disabled']);

        // Map the attributes.
        $data->attributes = array_map(function($key) use ($attributes) {
            return ['name' => $key, 'value' => $attributes[$key]];
        }, array_keys($attributes));

        // Form parameters.
        $params = $this->url->params();
        if ($this->method === 'post') {
            $params['sesskey'] = sesskey();
        }
        $data->params = array_map(function($key) use ($params) {
            return ['name' => $key, 'value' => $params[$key]];
        }, array_keys($params));

        // Select options.
        $hasnothing = false;
        if (is_string($this->nothing) && $this->nothing !== '') {
            $nothing = ['' => $this->nothing];
            $hasnothing = true;
            $nothingkey = '';
        } else if (is_array($this->nothing)) {
            $nothingvalue = reset($this->nothing);
            if ($nothingvalue === 'choose' || $nothingvalue === 'choosedots') {
                $nothing = [key($this->nothing) => get_string('choosedots')];
            } else {
                $nothing = $this->nothing;
            }
            $hasnothing = true;
            $nothingkey = key($this->nothing);
        }
        if ($hasnothing) {
            $options = $nothing + $this->options;
        } else {
            $options = $this->options;
        }

        foreach ($options as $value => $name) {
            if (is_array($options[$value])) {
                foreach ($options[$value] as $optgroupname => $optgroupvalues) {
                    $sublist = [];
                    foreach ($optgroupvalues as $optvalue => $optname) {
                        $option = [
                            'value' => $optvalue,
                            'name' => $optname,
                            'selected' => strval($this->selected) === strval($optvalue),
                        ];

                        if ($hasnothing && $nothingkey === $optvalue) {
                            $option['ignore'] = 'data-ignore';
                        }

                        $sublist[] = $option;
                    }
                    $data->options[] = [
                        'name' => $optgroupname,
                        'optgroup' => true,
                        'options' => $sublist
                    ];
                }
            } else {
                $option = [
                    'value' => $value,
                    'name' => $options[$value],
                    'selected' => strval($this->selected) === strval($value),
                    'optgroup' => false
                ];

                if ($hasnothing && $nothingkey === $value) {
                    $option['ignore'] = 'data-ignore';
                }

                $data->options[] = $option;
            }
        }

        // Label attributes.
        $data->labelattributes = [];
        // Unset label attributes that are already in the template.
        unset($this->labelattributes['for']);
        // Map the label attributes.
        foreach ($this->labelattributes as $key => $value) {
            $data->labelattributes[] = ['name' => $key, 'value' => $value];
        }

        // Help icon.
        $data->helpicon = !empty($this->helpicon) ? $this->helpicon->export_for_template($output) : false;

        return $data;
    }
16392
public function export_for_template(renderer_base $output) {

        $data = (object) [
            'pluginbaseurl' => (new moodle_url('/admin/tool/policy'))->out(false),
        ];

        $data->policies = array_values($this->policies);
        if (!empty($this->returnurl)) {
            $data->returnurl = $this->returnurl;
        }

        array_walk($data->policies, function($item, $key) {
            $item->policytypestr = get_string('policydoctype'.$item->type, 'tool_policy');
            $item->policyaudiencestr = get_string('policydocaudience'.$item->audience, 'tool_policy');
        });

        return $data;
    }
1028629
public function export_for_template(renderer_base $output) {
        global $CFG, $USER;

        $export = new stdClass();
        $export->userid = $this->userid;
        $export->assignmentid = $this->assignment->get_instance()->id;
        $export->cmid = $this->assignment->get_course_module()->id;
        $export->contextid = $this->assignment->get_context()->id;
        $export->groupid = $this->groupid;
        $export->name = $this->assignment->get_context()->get_context_name();
        $export->courseid = $this->assignment->get_course()->id;
        $export->participants = array();
        $export->filters = $this->assignment->get_filters();
        $export->markingworkflowfilters = $this->assignment->get_marking_workflow_filters(true);
        $export->hasmarkingworkflow = count($export->markingworkflowfilters) > 0;
        $export->markingallocationfilters = $this->assignment->get_marking_allocation_filters(true);
        $export->hasmarkingallocation = count($export->markingallocationfilters) > 0;

        $num = 1;
        foreach ($this->participants as $idx => $record) {
            $user = new stdClass();
            $user->id = $record->id;
            $user->fullname = fullname($record);
            $user->requiregrading = $record->requiregrading;
            $user->grantedextension = $record->grantedextension;
            $user->submitted = $record->submitted;
            if (!empty($record->groupid)) {
                $user->groupid = $record->groupid;
                $user->groupname = $record->groupname;
            }
            if ($record->id == $this->userid) {
                $export->index = $num;
                $user->current = true;
            }
            $export->participants[] = $user;
            $num++;
        }

        $feedbackplugins = $this->assignment->get_feedback_plugins();
        $showreview = false;
        foreach ($feedbackplugins as $plugin) {
            if ($plugin->is_enabled() && $plugin->is_visible()) {
                if ($plugin->supports_review_panel()) {
                    $showreview = true;
                }
            }
        }

        $export->actiongrading = 'grading';
        $export->viewgrading = get_string('viewgrading', 'mod_assign');

        $export->showreview = $showreview;

        $time = time();
        $export->count = count($export->participants);
        $export->coursename = $this->assignment->get_course_context()->get_context_name();
        $export->caneditsettings = has_capability('mod/assign:addinstance', $this->assignment->get_context());
        $export->duedate = $this->assignment->get_instance()->duedate;
        $export->duedatestr = userdate($this->assignment->get_instance()->duedate);

        // Time remaining.
        $due = '';
        if ($export->duedate - $time <= 0) {
            $due = get_string('assignmentisdue', 'assign');
        } else {
            $due = get_string('timeremainingcolon', 'assign', format_time($export->duedate - $time));
        }
        $export->timeremainingstr = $due;

        if ($export->duedate < $time) {
            $export->cutoffdate = $this->assignment->get_instance()->cutoffdate;
            $cutoffdate = $export->cutoffdate;
            if ($cutoffdate) {
                if ($cutoffdate > $time) {
                    $late = get_string('latesubmissionsaccepted', 'assign', userdate($export->cutoffdate));
                } else {
                    $late = get_string('nomoresubmissionsaccepted', 'assign');
                }
                $export->cutoffdatestr = $late;
            }
        }

        $export->defaultsendnotifications = $this->assignment->get_instance()->sendstudentnotifications;
        $export->rarrow = $output->rarrow();
        $export->larrow = $output->larrow();
        // List of identity fields to display (the user info will not contain any fields the user cannot view anyway).
        $export->showuseridentity = $CFG->showuseridentity;
        $export->currentuserid = $USER->id;
        $helpicon = new \help_icon('sendstudentnotifications', 'assign');
        $export->helpicon = $helpicon->export_for_template($output);
        return $export;
    }