Export data.

@param renderer_base $output Renderer.
@return stdClass
439573
public function export_for_template(renderer_base $output) {
        $url = $this->method === 'get' ? $this->url->out_omit_querystring(true) : $this->url->out_omit_querystring();

        $data = new stdClass();
        $data->id = html_writer::random_id('single_button');
        $data->formid = $this->formid;
        $data->method = $this->method;
        $data->url = $url === '' ? '#' : $url;
        $data->label = $this->label;
        $data->classes = $this->class;
        $data->disabled = $this->disabled;
        $data->tooltip = $this->tooltip;
        $data->primary = $this->primary;

        // 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));

        // Button actions.
        $actions = $this->actions;
        $data->actions = array_map(function($action) use ($output) {
            return $action->export_for_template($output);
        }, $actions);
        $data->hasactions = !empty($data->actions);

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

        $target = $this->model->get_target();

        $data = new \stdClass();
        $data->insightname = format_string($target->get_name());

        $data->showpredictionheading = true;
        if (!$target->is_linear()) {
            $nclasses = count($target::get_classes());
            $nignoredclasses = count($target->ignored_predicted_classes());
            if ($nclasses - $nignoredclasses <= 1) {
                // Hide the prediction heading if there is only 1 class displayed. Otherwise it is redundant with the insight name.
                $data->showpredictionheading = false;
            }
        }

        $total = 0;

        if ($this->model->uses_insights()) {
            $predictionsdata = $this->model->get_predictions($this->context, true, $this->page, $this->perpage);

            if (!$this->model->is_static()) {
                $notification = new \core\output\notification(get_string('justpredictions', 'report_insights'));
                $data->nostaticmodelnotification = $notification->export_for_template($output);
            }

            $data->predictions = array();
            $predictionvalues = array();
            $insights = array();
            if ($predictionsdata) {
                list($total, $predictions) = $predictionsdata;

                foreach ($predictions as $prediction) {
                    $predictedvalue = $prediction->get_prediction_data()->prediction;

                    // Only need to fill this data once.
                    if (!isset($predictionvalues[$predictedvalue])) {
                        $preddata = array();
                        $preddata['predictiondisplayvalue'] = $target->get_display_value($predictedvalue);
                        list($preddata['style'], $preddata['outcomeicon']) =
                            insight::get_calculation_display($target, floatval($predictedvalue), $output);
                        $predictionvalues[$predictedvalue] = $preddata;
                    }

                    $insightrenderable = new \report_insights\output\insight($prediction, $this->model, true);
                    $insights[$predictedvalue][] = $insightrenderable->export_for_template($output);
                }

                // Order predicted values.
                if ($target->is_linear()) {
                    // During regression what we will be interested on most of the time is in low values so let's show them first.
                    ksort($predictionvalues);
                } else {
                    // During classification targets flag "not that important" samples as 0 so let's show them at the end.
                    krsort($predictionvalues);
                }

                // Ok, now we have all the data we want, put it into a format that mustache can handle.
                foreach ($predictionvalues as $key => $prediction) {
                    if (isset($insights[$key])) {
                        $prediction['insights'] = $insights[$key];
                    }

                    $data->predictions[] = $prediction;
                }
            }

            if (empty($insights) && $this->page == 0) {
                if ($this->model->any_prediction_obtained()) {
                    $data->noinsights = get_string('noinsights', 'analytics');
                } else {
                    $data->noinsights = get_string('nopredictionsyet', 'analytics');
                }
            }
        } else {
            $data->noinsights = get_string('noinsights', 'analytics');
        }

        if (!empty($data->noinsights)) {
            $notification = new \core\output\notification($data->noinsights);
            $data->noinsights = $notification->export_for_template($output);
        }

        if ($this->othermodels) {

            $options = array();
            foreach ($this->othermodels as $model) {
                $options[$model->get_id()] = $model->get_target()->get_name();
            }

            // New moodle_url instance returned by magic_get_url.
            $url = $PAGE->url;
            $url->remove_params('modelid');
            $modelselector = new \single_select($url, 'modelid', $options, '',
                array('' => get_string('selectotherinsights', 'report_insights')));
            $data->modelselector = $modelselector->export_for_template($output);
        }

        $data->pagingbar = $output->render(new \paging_bar($total, $this->page, $this->perpage, $PAGE->url));

        return $data;
    }
41123
public function export_for_template(\renderer_base $output) {
        $data = array(
            'id'            => $this->id,
            'permalink'     => clean_param($this->permalink, PARAM_URL),
            'datepublished' => $output->format_published_date($this->timestamp),
            'link'          => clean_param($this->link, PARAM_URL),
        );

        // If the item does not have a title, create one from the description.
        $title = $this->title;
        if (!$title) {
            $title = strip_tags($this->description);
            $title = \core_text::substr($title, 0, 20) . '...';
        }

        // Allow the renderer to format the title and description.
        $data['title']          = strip_tags($output->format_title($title));
        $data['description']    = $this->showdescription ? $output->format_description($this->description) : null;

        return $data;
    }
1072083
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->relatedcompetencies = array();
        if ($this->relatedcompetencies) {
            foreach ($this->relatedcompetencies as $competency) {
                $exporter = new competency_exporter($competency, array('context' => $this->context));
                $record = $exporter->export($output);
                $data->relatedcompetencies[] = $record;
            }
        }

        // We checked the user permissions in the constructor.
        $data->showdeleterelatedaction = true;

        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;
    }
957464
public function export_for_template(renderer_base $output) {
        ob_start();
        $this->display();
        $formhtml = ob_get_contents();
        ob_end_clean();
        $context = [
            'formhtml' => $formhtml
        ];
        return $context;
    }
278996
public function export_for_template(renderer_base $output) {
        $context = parent::export_for_template($output);
        $context['valuechars'] = array_fill(0, strlen($context['value']), 'x');

        return $context;
    }
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;
    }
363898
public function export_for_template(\renderer_base $output) {
        $planexporter = new plan_exporter($this->plan, array('template' => $this->plan->get_template()));

        $data = new stdClass();
        $data->plan = $planexporter->export($output);
        $data->competencies = array();
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
        $data->contextid = $this->plan->get_context()->id;

        if ($data->plan->iscompleted) {
            $ucproperty = 'usercompetencyplan';
            $ucexporter = 'core_competency\\external\\user_competency_plan_exporter';
        } else {
            $ucproperty = 'usercompetency';
            $ucexporter = 'core_competency\\external\\user_competency_exporter';
        }

        $helper = new performance_helper();
        $pclist = api::list_plan_competencies($this->plan);
        $proficientcount = 0;
        foreach ($pclist as $pc) {
            $comp = $pc->competency;
            $usercomp = $pc->$ucproperty;

            $compcontext = $helper->get_context_from_competency($comp);
            $framework = $helper->get_framework_from_competency($comp);
            $scale = $helper->get_scale_from_competency($comp);

            // Prepare the data.
            $record = new stdClass();
            $exporter = new competency_exporter($comp, array('context' => $compcontext));
            $record->competency = $exporter->export($output);

            // Competency path.
            $exporter = new competency_path_exporter([
                'ancestors' => $comp->get_ancestors(),
                'framework' => $framework,
                'context' => $compcontext
            ]);
            $record->comppath = $exporter->export($output);

            $exporter = new $ucexporter($usercomp, array('scale' => $scale));
            $record->$ucproperty = $exporter->export($output);

            $data->competencies[] = $record;
            if ($usercomp->get('proficiency')) {
                $proficientcount++;
            }
        }
        $data->competencycount = count($data->competencies);
        $data->proficientcompetencycount = $proficientcount;
        if ($data->competencycount) {
            $data->proficientcompetencypercentage = ((float) $proficientcount / (float) $data->competencycount) * 100.0;
        } else {
            $data->proficientcompetencypercentage = 0.0;
        }
        $data->proficientcompetencypercentageformatted = format_float($data->proficientcompetencypercentage);
        return $data;
    }
903948
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->userid = $this->userid;
        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
        $data->canreaduserevidence = user_evidence::can_read_user($this->userid);
        $data->canmanageuserplans = plan::can_manage_user($this->userid);

        // Attach standard objects as mustache can not parse \core_competency\plan objects.
        $data->plans = array();
        if ($this->plans) {
            foreach ($this->plans as $plan) {
                $exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
                $record = $exporter->export($output);
                $data->plans[] = $record;
            }
        }

        $data->navigation = array();
        foreach ($this->navigation as $button) {
            $data->navigation[] = $output->render($button);
        }

        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;
    }
1189089
public function export_for_template(\renderer_base $output) {
        $data = array(
            'title' => $this->showtitle ? $this->title : null,
            'image' => null,
            'items' => array(),
        );

        if ($this->showimage && $this->image) {
            $data['image'] = $this->image->export_for_template($output);
        }

        foreach ($this->items as $item) {
            $data['items'][] = $item->export_for_template($output);
        }

        return $data;
    }
325811
public function export_for_template(\renderer_base $output) {
        $data = array('feeds' => array());

        foreach ($this->feeds as $feed) {
            $data['feeds'][] = $feed->export_for_template($output);
        }

        return $data;
    }
533075
public function export_for_template(renderer_base $output) {
        $data = new stdClass();
        $data->template = (new template_exporter($this->template))->export($output);
        $data->pagecontextid = $this->pagecontext->id;
        $data->competencies = array();
        $helper = new performance_helper();
        foreach ($this->competencies as $competency) {
            $context = $helper->get_context_from_competency($competency);
            $framework = $helper->get_framework_from_competency($competency);

            $courses = api::list_courses_using_competency($competency->get('id'));
            $relatedcompetencies = api::list_related_competencies($competency->get('id'));

            $related = array(
                'competency' => $competency,
                'linkedcourses' => $courses,
                'context' => $context,
                'relatedcompetencies' => $relatedcompetencies,
                'framework' => $framework
            );
            $exporter = new competency_summary_exporter(null, $related);
            $record = $exporter->export($output);

            array_push($data->competencies, $record);
        }

        $data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
        $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
        $data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies;
        $data->manageurl = $this->manageurl->out(true);
        $exporter = new template_statistics_exporter($this->templatestatistics);
        $data->statistics = $exporter->export($output);
        $data->showcompetencylinks = true;

        return $data;
    }
899663
public function export(\renderer_base $output) {

        \core_analytics\manager::check_can_manage_models();

        $data = clone $this->model;

        $data->name = $this->inplace_editable_name()->export_for_template($output);
        $data->target = $this->get_target()->get_name();
        $data->targetclass = $this->get_target()->get_id();

        if ($timesplitting = $this->get_time_splitting()) {
            $data->timesplitting = $timesplitting->get_name();
        }

        $data->indicators = array();
        foreach ($this->get_indicators() as $indicator) {
            $data->indicators[] = $indicator->get_name();
        }
        return $data;
    }
45065
public function export_for_template(renderer_base $output) {
        $data = new stdClass();

        $url = new moodle_url('/admin/tool/dataprivacy/datadeletion.php');
        $options = [
            CONTEXT_USER => get_string('user'),
            CONTEXT_COURSE => get_string('course'),
            CONTEXT_MODULE => get_string('activitiesandresources', 'tool_dataprivacy'),
            CONTEXT_BLOCK => get_string('blocks'),
        ];
        $filterselector = new single_select($url, 'filter', $options, $this->filter, null);
        $data->filter = $filterselector->export_for_template($output);

        ob_start();
        $this->expiredcontextstable->out(helper::DEFAULT_PAGE_SIZE, true);
        $expiredcontexts = ob_get_contents();
        ob_end_clean();
        $data->expiredcontexts = $expiredcontexts;

        $data->existingcontexts = $this->expiredcontextstable->rawdata ? true : false;

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

        $nocoursesurl = $output->image_url('courses', 'block_timeline')->out();
        $noeventsurl = $output->image_url('activities', 'block_timeline')->out();

        $requiredproperties = course_summary_exporter::define_properties();
        $fields = join(',', array_keys($requiredproperties));
        $courses = course_get_enrolled_courses_for_logged_in_user(0, 0, null, $fields);
        list($inprogresscourses, $processedcount) = course_filter_courses_by_timeline_classification(
            $courses,
            COURSE_TIMELINE_INPROGRESS,
            self::COURSES_PER_PAGE
        );
        $formattedcourses = array_map(function($course) use ($output) {
            \context_helper::preload_from_record($course);
            $context = \context_course::instance($course->id);
            $exporter = new course_summary_exporter($course, ['context' => $context]);
            return $exporter->export($output);
        }, $inprogresscourses);

        $filters = $this->get_filters_as_booleans();
        $offsets = $this->get_filter_offsets();
        $contextvariables = [
            'midnight' => usergetmidnight(time()),
            'coursepages' => [$formattedcourses],
            'urls' => [
                'nocourses' => $nocoursesurl,
                'noevents' => $noeventsurl
            ],
            'sorttimelinedates' => $this->order == BLOCK_TIMELINE_SORT_BY_DATES,
            'sorttimelinecourses' => $this->order == BLOCK_TIMELINE_SORT_BY_COURSES,
            'selectedfilter' => $this->filter,
            'hasdaysoffset' => true,
            'hasdayslimit' => $offsets['dayslimit'] !== false ,
            'nodayslimit' => $offsets['dayslimit'] === false ,
            'limit' => $this->limit
        ];
        return array_merge($contextvariables, $filters, $offsets);
    }