Creates an assignment plugin structure.

@return external_single_structure the plugin structure
516515
private static function get_plugin_structure() {
        return new external_single_structure(
            array(
                'type' => new external_value(PARAM_TEXT, 'submission plugin type'),
                'name' => new external_value(PARAM_TEXT, 'submission plugin name'),
                'fileareas' => new external_multiple_structure(
                    new external_single_structure(
                        array (
                            'area' => new external_value (PARAM_TEXT, 'file area'),
                            'files' => new external_files('files', VALUE_OPTIONAL),
                        )
                    ), 'fileareas', VALUE_OPTIONAL
                ),
                'editorfields' => new external_multiple_structure(
                    new external_single_structure(
                        array(
                            'name' => new external_value(PARAM_TEXT, 'field name'),
                            'description' => new external_value(PARAM_RAW, 'field description'),
                            'text' => new external_value (PARAM_RAW, 'field value'),
                            'format' => new external_format_value ('text')
                        )
                    )
                    , 'editorfields', VALUE_OPTIONAL
                )
            )
        );
    }
987103
public static function get_categories_returns() {
        return new external_multiple_structure(
            new external_single_structure(
                array(
                    'id' => new external_value(PARAM_INT, 'category id'),
                    'name' => new external_value(PARAM_TEXT, 'category name'),
                    'idnumber' => new external_value(PARAM_RAW, 'category id number', VALUE_OPTIONAL),
                    'description' => new external_value(PARAM_RAW, 'category description'),
                    'descriptionformat' => new external_format_value('description'),
                    'parent' => new external_value(PARAM_INT, 'parent category id'),
                    'sortorder' => new external_value(PARAM_INT, 'category sorting order'),
                    'coursecount' => new external_value(PARAM_INT, 'number of courses in this category'),
                    'visible' => new external_value(PARAM_INT, '1: available, 0:not available', VALUE_OPTIONAL),
                    'visibleold' => new external_value(PARAM_INT, '1: available, 0:not available', VALUE_OPTIONAL),
                    'timemodified' => new external_value(PARAM_INT, 'timestamp', VALUE_OPTIONAL),
                    'depth' => new external_value(PARAM_INT, 'category depth'),
                    'path' => new external_value(PARAM_TEXT, 'category path'),
                    'theme' => new external_value(PARAM_THEME, 'category theme', VALUE_OPTIONAL),
                ), 'List of categories'
            )
        );
    }
1014471
protected function construct():parent
	{
		$name= $this->line->pregGet('/(?<=^~)[\w-]*/');
		$this->name=$name;

		$this->loadConfig($name,$this->htsl);

		$this->param= $this->line->pregGet('/^~[\w-]*\( (.*) \)/',1);

		$this->structureName=$this->config['name']??$name;

		$this->id=strtoupper(uniqid());

		return $this;
	}
267745
protected function createAssignment()
    {
        $url = config('forge-publish.url') . config('forge-publish.store_assignment_uri');
        try {
            $response = $this->http->post($url, [
                'form_params' => [
                    'name' => $this->assignmentName,
                    'repository_uri' => $this->repository_uri,
                    'repository_type' => $this->repository_type,
                    'forge_site' => $this->forge_site,
                    'forge_server' => $this->forge_server
                ],
                'headers' => [
                    'X-Requested-With' => 'XMLHttpRequest',
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
                ]
            ]);
        } catch (\Exception $e) {
            $this->error('And error occurs connecting to the api url: ' . $url);
            $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
            return;
        }
        $assignment = json_decode((string) $response->getBody());
        $this->addValueToEnv('ACACHA_FORGE_ASSIGNMENT', $assignment->id);
        return $assignment;
    }
1075779
private static function definition() {
        global $CFG;
        $definition = array();
        $definition['id']                = new external_value(PARAM_INT, 'definition id', VALUE_OPTIONAL);
        $definition['method']            = new external_value(PARAM_TEXT, 'method');
        $definition['name']              = new external_value(PARAM_TEXT, 'name');
        $definition['description']       = new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL);
        $definition['descriptionformat'] = new external_format_value('description', VALUE_OPTIONAL);
        $definition['status']            = new external_value(PARAM_INT, 'status');
        $definition['copiedfromid']      = new external_value(PARAM_INT, 'copied from id', VALUE_OPTIONAL);
        $definition['timecreated']       = new external_value(PARAM_INT, 'creation time');
        $definition['usercreated']       = new external_value(PARAM_INT, 'user who created definition');
        $definition['timemodified']      = new external_value(PARAM_INT, 'last modified time');
        $definition['usermodified']      = new external_value(PARAM_INT, 'user who modified definition');
        $definition['timecopied']        = new external_value(PARAM_INT, 'time copied', VALUE_OPTIONAL);
        foreach (self::get_grading_methods() as $method) {
            require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php');
            $details  = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details');
            if ($details != null) {
                $items = array();
                foreach ($details as $key => $value) {
                    $details[$key]->required = VALUE_OPTIONAL;
                    $items[$key] = $value;
                }
                $definition[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL);
            }
        }
        return new external_single_structure($definition);
    }
350523
public static function get_categories_returns() {
        return new external_single_structure(array(
            'count' => new external_value(PARAM_INT, 'The total number of records.'),
            'categories' => new external_multiple_structure(
                new external_single_structure(array(
                    'id' => new external_value(PARAM_INT, 'The category ID'),
                    'glossaryid' => new external_value(PARAM_INT, 'The glossary ID'),
                    'name' => new external_value(PARAM_RAW, 'The name of the category'),
                    'usedynalink' => new external_value(PARAM_BOOL, 'Whether the category is automatically linked'),
                ))
            ),
            'warnings' => new external_warnings()
        ));
    }
630445
private static function assign_user_mappings() {
        return new external_single_structure(
            array (
                'assignmentid'    => new external_value(PARAM_INT, 'assignment id'),
                'mappings'   => new external_multiple_structure(new external_single_structure(
                        array(
                            'id'     => new external_value(PARAM_INT, 'user mapping id'),
                            'userid' => new external_value(PARAM_INT, 'student id')
                        )
                    )
                )
            )
        );
    }
1024269
public static function add_entry_returns() {
        return new external_single_structure(
            array(
                'newentryid' => new external_value(PARAM_INT, 'True new created entry id. 0 if the entry was not created.'),
                'generalnotifications' => new external_multiple_structure(
                    new external_value(PARAM_RAW, 'General notifications')
                ),
                'fieldnotifications' => new external_multiple_structure(
                    new external_single_structure(
                        array(
                            'fieldname' => new external_value(PARAM_TEXT, 'The field name.'),
                            'notification' => new external_value(PARAM_RAW, 'The notification for the field.'),
                        )
                    )
                ),
                'warnings' => new external_warnings()
            )
        );
    }
286909
public static function can_add_discussion_returns() {
        return new external_single_structure(
            array(
                'status' => new external_value(PARAM_BOOL, 'True if the user can add discussions, false otherwise.'),
                'canpindiscussions' => new external_value(PARAM_BOOL, 'True if the user can pin discussions, false otherwise.',
                    VALUE_OPTIONAL),
                'cancreateattachment' => new external_value(PARAM_BOOL, 'True if the user can add attachments, false otherwise.',
                    VALUE_OPTIONAL),
                'warnings' => new external_warnings()
            )
        );
    }
831382
protected function define_question_plugin_structure() {

        // Define the virtual plugin element with the condition to fulfill.
        $plugin = $this->get_plugin_element(null, '../../qtype', 'match');

        // Create one standard named plugin element (the visible container).
        $pluginwrapper = new backup_nested_element($this->get_recommended_name());

        // Connect the visible container ASAP.
        $plugin->add_child($pluginwrapper);

        // Now create the qtype own structures.
        $matchoptions = new backup_nested_element('matchoptions', array('id'), array(
            'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
            'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
            'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));

        $matches = new backup_nested_element('matches');

        $match = new backup_nested_element('match', array('id'), array(
            'questiontext', 'questiontextformat', 'answertext'));

        // Now the own qtype tree.
        $pluginwrapper->add_child($matchoptions);
        $pluginwrapper->add_child($matches);
        $matches->add_child($match);

        // Set source to populate the data.
        $matchoptions->set_source_table('qtype_match_options',
                array('questionid' => backup::VAR_PARENTID));
        $match->set_source_table('qtype_match_subquestions', array('questionid' => backup::VAR_PARENTID), 'id ASC');

        // Don't need to annotate ids nor files.

        return $plugin;
    }
229085
public static function external_ratings_structure() {

        return new external_single_structure (
            [
                'contextid' => new external_value(PARAM_INT, 'Context id.'),
                'component' => new external_value(PARAM_COMPONENT, 'Context name.'),
                'ratingarea' => new external_value(PARAM_AREA, 'Rating area name.'),
                'canviewall' => new external_value(PARAM_BOOL, 'Whether the user can view all the individual ratings.',
                    VALUE_OPTIONAL),
                'canviewany' => new external_value(PARAM_BOOL, 'Whether the user can view aggregate of ratings of others.',
                    VALUE_OPTIONAL),
                'scales' => new external_multiple_structure(
                    new external_single_structure (
                        [
                            'id' => new external_value(PARAM_INT, 'Scale id.'),
                            'courseid' => new external_value(PARAM_INT, 'Course id.', VALUE_OPTIONAL),
                            'name' => new external_value(PARAM_TEXT, 'Scale name (when a real scale is used).', VALUE_OPTIONAL),
                            'max' => new external_value(PARAM_INT, 'Max value for the scale.'),
                            'isnumeric' => new external_value(PARAM_BOOL, 'Whether is a numeric scale.'),
                            'items' => new external_multiple_structure(
                                new external_single_structure (
                                    [
                                        'value' => new external_value(PARAM_INT, 'Scale value/option id.'),
                                        'name' => new external_value(PARAM_NOTAGS, 'Scale name.'),
                                    ]
                                ), 'Scale items. Only returned for not numerical scales.', VALUE_OPTIONAL
                            )
                        ], 'Scale information'
                    ), 'Different scales used information', VALUE_OPTIONAL
                ),
                'ratings' => new external_multiple_structure(
                    new external_single_structure (
                        [
                            'itemid' => new external_value(PARAM_INT, 'Item id.'),
                            'scaleid' => new external_value(PARAM_INT, 'Scale id.', VALUE_OPTIONAL),
                            'userid' => new external_value(PARAM_INT, 'User who rated id.', VALUE_OPTIONAL),
                            'aggregate' => new external_value(PARAM_FLOAT, 'Aggregated ratings grade.', VALUE_OPTIONAL),
                            'aggregatestr' => new external_value(PARAM_NOTAGS, 'Aggregated ratings as string.', VALUE_OPTIONAL),
                            'aggregatelabel' => new external_value(PARAM_NOTAGS, 'The aggregation label.', VALUE_OPTIONAL),
                            'count' => new external_value(PARAM_INT, 'Ratings count (used when aggregating).', VALUE_OPTIONAL),
                            'rating' => new external_value(PARAM_INT, 'The rating the user gave.', VALUE_OPTIONAL),
                            'canrate' => new external_value(PARAM_BOOL, 'Whether the user can rate the item.', VALUE_OPTIONAL),
                            'canviewaggregate' => new external_value(PARAM_BOOL, 'Whether the user can view the aggregated grade.',
                                VALUE_OPTIONAL),
                        ]
                    ), 'The ratings', VALUE_OPTIONAL
                ),
            ], 'Rating information', VALUE_OPTIONAL
        );
    }
1278873
public static function get_groupings_returns() {
        return new external_multiple_structure(
            new external_single_structure(
                array(
                    'id' => new external_value(PARAM_INT, 'grouping record id'),
                    'courseid' => new external_value(PARAM_INT, 'id of course'),
                    'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
                    'description' => new external_value(PARAM_RAW, 'grouping description text'),
                    'descriptionformat' => new external_format_value('description'),
                    'idnumber' => new external_value(PARAM_RAW, 'id number'),
                    'groups' => new external_multiple_structure(
                        new external_single_structure(
                            array(
                                'id' => new external_value(PARAM_INT, 'group record id'),
                                'courseid' => new external_value(PARAM_INT, 'id of course'),
                                'name' => new external_value(PARAM_TEXT, 'multilang compatible name, course unique'),
                                'description' => new external_value(PARAM_RAW, 'group description text'),
                                'descriptionformat' => new external_format_value('description'),
                                'enrolmentkey' => new external_value(PARAM_RAW, 'group enrol secret phrase'),
                                'idnumber' => new external_value(PARAM_RAW, 'id number')
                            )
                        ),
                    'optional groups', VALUE_OPTIONAL)
                )
            )
        );
    }
800809
private static function get_assignments_course_structure() {
        return new external_single_structure(
            array(
                'id' => new external_value(PARAM_INT, 'course id'),
                'fullname' => new external_value(PARAM_TEXT, 'course full name'),
                'shortname' => new external_value(PARAM_TEXT, 'course short name'),
                'timemodified' => new external_value(PARAM_INT, 'last time modified'),
                'assignments' => new external_multiple_structure(self::get_assignments_assignment_structure(), 'assignment info')
              ), 'course information object'
        );
    }
557908
protected function define_question_plugin_structure() {
        $paths = array();

        // This qtype uses question_answers, add them.
        $this->add_question_question_answers($paths);

        // Add own qtype stuff.
        $elepath = $this->get_pathfor('/' . $this->qtypeobj->name());
        $paths[] = new restore_path_element($this->qtypeobj->name(), $elepath);

        $elepath = $this->get_pathfor('/answers/answer/extraanswerdata');
        $paths[] = new restore_path_element('extraanswerdata', $elepath);

        return $paths;
    }
504622
protected function define_structure() {

        $paths = array();
        $userinfo = $this->get_setting_value('userinfo');

        $area = new restore_path_element('grading_area', '/areas/area');
        $paths[] = $area;
        // attach local plugin stucture to $area element
        $this->add_plugin_structure('local', $area);

        $definition = new restore_path_element('grading_definition', '/areas/area/definitions/definition');
        $paths[] = $definition;
        $this->add_plugin_structure('gradingform', $definition);
        // attach local plugin stucture to $definition element
        $this->add_plugin_structure('local', $definition);


        if ($userinfo) {
            $instance = new restore_path_element('grading_instance',
                '/areas/area/definitions/definition/instances/instance');
            $paths[] = $instance;
            $this->add_plugin_structure('gradingform', $instance);
            // attach local plugin stucture to $intance element
            $this->add_plugin_structure('local', $instance);
        }

        return $paths;
    }
1252202
public static function data_for_competency_frameworks_manage_page_returns() {
        return new external_single_structure(array (
            'competencyframeworks' => new external_multiple_structure(
                competency_framework_exporter::get_read_structure()
            ),
            'pluginbaseurl' => new external_value(PARAM_LOCALURL, 'Url to the tool_lp plugin folder on this Moodle site'),
            'navigation' => new external_multiple_structure(
                new external_value(PARAM_RAW, 'HTML for a navigation item that should be on this page')
            ),
            'pagecontextid' => new external_value(PARAM_INT, 'The page context id')
        ));

    }
1038762
protected function define_definition_plugin_structure() {

        // Append data only if the grand-parent element has 'method' set to 'guide'.
        $plugin = $this->get_plugin_element(null, '../../method', 'guide');

        // Create a visible container for our data.
        $pluginwrapper = new backup_nested_element($this->get_recommended_name());

        // Connect our visible container to the parent.
        $plugin->add_child($pluginwrapper);

        // Define our elements.

        $criteria = new backup_nested_element('guidecriteria');

        $criterion = new backup_nested_element('guidecriterion', array('id'), array(
            'sortorder', 'shortname', 'description', 'descriptionformat',
            'descriptionmarkers', 'descriptionmarkersformat', 'maxscore'));

        $comments = new backup_nested_element('guidecomments');

        $comment = new backup_nested_element('guidecomment', array('id'), array(
            'sortorder', 'description', 'descriptionformat'));

        // Build elements hierarchy.

        $pluginwrapper->add_child($criteria);
        $criteria->add_child($criterion);
        $pluginwrapper->add_child($comments);
        $comments->add_child($comment);

        // Set sources to populate the data.

        $criterion->set_source_table('gradingform_guide_criteria',
                array('definitionid' => backup::VAR_PARENTID));

        $comment->set_source_table('gradingform_guide_comments',
                array('definitionid' => backup::VAR_PARENTID));

        // No need to annotate ids or files yet (one day when criterion definition supports
        // embedded files, they must be annotated here).

        return $plugin;
    }