Note:

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

Exporting/importing several question categories at once

From MoodleDocs

Current save in XML file

I have this structure.

str.png

My first category contains these questins.

question for my first category .png

Subcategory first category contains these questins.

question for subcategory first category .png

Exporting My first category with "Write context to file", I get the current file structure.

structure with.jpeg

Exporting My first category without "Write context to file", I get the current file structure.

structure without.jpeg

The difference is this fact that "$course$" is written before the category name if I choose "Write context to file".

Also we see that subcategory saved too. And I don't know how to save only the questions from one category (without its subcategory).

If "export" already saves category and all subcategory, my task is exporting/importing several category (and its subcategory), which are located on one level? For example, exporting "First" and "Second".

example exporting.jpeg

Interface

The new interface, which lets you export several question categories at once.

To activate the export / import multiple categories question, select "Write a several question categories".

activate.jpg

After choosing "Write a several question categories" combobox list elements is replaced by a tree of categories as it shown on the picture.

tree categories.jpg

How to change the interface is described below .

1. Category you want to export, are chosen as you can watch at the image.

choose categories .jpg

2. To select a diapason of categories, select a category which is the first one in the diapason, hold down the Shift key and select the last category in diapason.

diapason categories .jpg

3. Select categories with subcategories. When you click on the category for the first time, only this category is selected. When you click on the category for the second time, the categories that are one level below, are selected too.

categories with subcategories .jpg

When you click on the category for the third time, all selections are canceled.

selections are canceled .jpg

To select a category with all its subcategories, press the Ctrl key and click on the category.

all subcategories .jpg

4. Select the diapason of categories with subcategories. To select a diapason of categories with all their subcategories, select a category which is the first one in diapason , hold down the Shift + Ctrl keys and select the last category in the diapason.

diapason with all subcategories .jpg

5. Select all categories. Select the top line in the drop-down box.

all categories .jpg

To achieve the desired result, I have to use it.

Change export/import function and file structure

As described in the first paragraph, the file structure is described as follows: a description of the category, followed by this categories questions. An example is described in "Current save in XML file".

If this method is used in Moodle now, then I can also use it.

But if you want to save the connection question and category, you can add a property "parent" to the tag "question". For example, "<question type="cloze" parent="По умолчанию для Главная страница/My first category">".