Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Save category description in Moodle XML import/export: Difference between revisions

From MoodleDocs
(Note about plan not to migrate this page to the new developer resources. See template for more info.)
 
(51 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:WillNotMigrate}}
== What is not saved? ==
== What is not saved? ==
At this format of import/export in not saved:


1. description of the imported/exported category,
Some things are not saved at this format of import/expor:


2. description of parental category(categories).
1. description of the exported category,
 
2. description of parent category,


== Current XML structure ==
== Current XML structure ==
<syntaxhighlight lang="xml">
<question type="category">
<question type="category">
  <category>
    <category>
      <text>$course$/My First Category\</text>
        <text>{<Context>}/{<Category>}[/<Subcategory>]...</text>
  </category>
    </category>
</question>
</question>
</syntaxhighlight>
Context:
#$course$ - сategory refers to the course,
#$system$ - Category refers to the system.
Category and Subcategory - name of category and subcategory written via '/' as path.


== Proposed XML structure ==
== Proposed XML structure ==
=== Simple situation ===
We have category without parent.
<syntaxhighlight lang="xml">
<question type="category">
<question type="category">
  <category>
<category>
      <text>$course$/My First Category</text>
<text>{<Context>}/{<Category>}</text>
  </category>
</category>
<description>
<text>{<Description>}</text>
<format>{<Format>}</format>
</description>
</question>
</question>
</syntaxhighlight>
In structure <question/> appended structure <description/> with description for last category in path.
=== Complex situation ===
We have category with parent.
<syntaxhighlight lang="xml">
<question type="category">
<category>
<text>{<Context>}/{<Category>}</text>
</category>
<description>
<text>{<Description>}</text>
<format>{<Format>}</format>
</description>
</question>
<question type="category">
<category>
<text>{<Context>}/{<Category>}{/<Subcategory>}</text>
</category>
<description>
<text>{<Description>}</text>
<format>{<Format>}</format>
</description>
</question>
...................................................................................
...................................................................................
<question type="category">
<category>
<text>{<Context>}/{<Category>}...{/<Subcategory>}</text>
</category>
<description>
<text>{<Description>}</text>
<format>{<Format>}</format>
</description>
</question>
</syntaxhighlight>
Block <description/> contains description for last category in path.
For category export we need export all categories with description which are parent for exported category.


== Old export compatibility problem ==
== Old export compatibility problem ==
If you use the suggested structure you will be able to save the category description and to import categories from XML  files which were exported with old format.

Latest revision as of 13:52, 24 June 2022


Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


What is not saved?

Some things are not saved at this format of import/expor:

1. description of the exported category,

2. description of parent category,

Current XML structure

<question type="category">
    <category>
        <text>{<Context>}/{<Category>}[/<Subcategory>]...</text>
    </category>
</question>

Context:

  1. $course$ - сategory refers to the course,
  2. $system$ - Category refers to the system.

Category and Subcategory - name of category and subcategory written via '/' as path.

Proposed XML structure

Simple situation

We have category without parent.

<question type="category">
	<category>
		<text>{<Context>}/{<Category>}</text>
	</category>
	<description>
		<text>{<Description>}</text>
		<format>{<Format>}</format>
	</description>
</question>

In structure <question/> appended structure <description/> with description for last category in path.

Complex situation

We have category with parent.

<question type="category">
	<category>
		<text>{<Context>}/{<Category>}</text>
	</category>
	<description>
		<text>{<Description>}</text>
		<format>{<Format>}</format>
	</description>
</question>

<question type="category">
	<category>
		<text>{<Context>}/{<Category>}{/<Subcategory>}</text>
	</category>
	<description>
		<text>{<Description>}</text>
		<format>{<Format>}</format>
	</description>
</question>
...................................................................................
...................................................................................
<question type="category">
	<category>
		<text>{<Context>}/{<Category>}...{/<Subcategory>}</text>
	</category>
	<description>
		<text>{<Description>}</text>
		<format>{<Format>}</format>
	</description>
</question>

Block <description/> contains description for last category in path.

For category export we need export all categories with description which are parent for exported category.

Old export compatibility problem

If you use the suggested structure you will be able to save the category description and to import categories from XML files which were exported with old format.