MDL-61476 mod_glossary: Support tags in entries export
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
3857876a58
commit
ff9019a16b
@@ -280,6 +280,19 @@ if ($xml = glossary_read_imported_file($result)) {
|
||||
$DB->update_record("glossary_entries", array('id' => $newentry->id, 'attachment' => '1'));
|
||||
}
|
||||
|
||||
// Import tags associated with the entry.
|
||||
if (core_tag_tag::is_enabled('mod_glossary', 'glossary_entries')) {
|
||||
$xmltags = @$xmlentry['#']['TAGS'][0]['#']['TAG']; // Ignore missing TAGS.
|
||||
$sizeofxmltags = count($xmltags);
|
||||
for ($k = 0; $k < $sizeofxmltags; $k++) {
|
||||
// Importing tags.
|
||||
$tag = $xmltags[$k]['#'];
|
||||
if (!empty($tag)) {
|
||||
core_tag_tag::add_item_tag('mod_glossary', 'glossary_entries', $newentry->id, $glossarycontext, $tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$entriesrejected++;
|
||||
if ( $newentry->concept and $newentry->definition ) {
|
||||
|
||||
@@ -2383,6 +2383,16 @@ function glossary_generate_export_file($glossary, $ignored = "", $hook = 0) {
|
||||
// Export attachments.
|
||||
$co .= glossary_xml_export_files('ATTACHMENTFILES', 4, $context->id, 'attachment', $entry->id);
|
||||
|
||||
// Export tags.
|
||||
$tags = core_tag_tag::get_item_tags_array('mod_glossary', 'glossary_entries', $entry->id);
|
||||
if (count($tags)) {
|
||||
$co .= glossary_start_tag("TAGS", 4, true);
|
||||
foreach ($tags as $tag) {
|
||||
$co .= glossary_full_tag("TAG", 5, false, $tag);
|
||||
}
|
||||
$co .= glossary_end_tag("TAGS", 4, true);
|
||||
}
|
||||
|
||||
$co .= glossary_end_tag("ENTRY",3,true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,3 +32,16 @@ Feature: Importing glossary entries
|
||||
And I am on "Course 1" course homepage
|
||||
And I should see "Added Glossary" in the "Recent activity" "block"
|
||||
And I should see "New glossary entries:" in the "Recent activity" "block"
|
||||
|
||||
@javascript @block_tags
|
||||
Scenario: Importing glossary entries and checking Tags block
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add the "Tags" block
|
||||
And I follow "Glossary 1"
|
||||
And I navigate to "Import entries" in current page administration
|
||||
And I upload "mod/glossary/tests/fixtures/musicians.xml" file to "File to import" filemanager
|
||||
When I press "Submit"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Beatles" "link" in the "Tags" "block"
|
||||
Then I should see "Paul McCartney"
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GLOSSARY>
|
||||
<INFO>
|
||||
<NAME>Musicians</NAME>
|
||||
<INTRO></INTRO>
|
||||
<INTROFORMAT>1</INTROFORMAT>
|
||||
<ALLOWDUPLICATEDENTRIES>0</ALLOWDUPLICATEDENTRIES>
|
||||
<DISPLAYFORMAT>dictionary</DISPLAYFORMAT>
|
||||
<SHOWSPECIAL>1</SHOWSPECIAL>
|
||||
<SHOWALPHABET>1</SHOWALPHABET>
|
||||
<SHOWALL>1</SHOWALL>
|
||||
<ALLOWCOMMENTS>0</ALLOWCOMMENTS>
|
||||
<USEDYNALINK>1</USEDYNALINK>
|
||||
<DEFAULTAPPROVAL>1</DEFAULTAPPROVAL>
|
||||
<GLOBALGLOSSARY>0</GLOBALGLOSSARY>
|
||||
<ENTBYPAGE>10</ENTBYPAGE>
|
||||
<ENTRIES>
|
||||
<ENTRY>
|
||||
<CONCEPT>Paul McCartney</CONCEPT>
|
||||
<DEFINITION><p>Popular British composer, guitarist, and vocalist. <br></p></DEFINITION>
|
||||
<FORMAT>1</FORMAT>
|
||||
<USEDYNALINK>1</USEDYNALINK>
|
||||
<CASESENSITIVE>0</CASESENSITIVE>
|
||||
<FULLMATCH>0</FULLMATCH>
|
||||
<TEACHERENTRY>1</TEACHERENTRY>
|
||||
<TAGS>
|
||||
<TAG>Beatles</TAG>
|
||||
<TAG>The Quarrymen</TAG>
|
||||
<TAG>Wings</TAG>
|
||||
</TAGS>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</INFO>
|
||||
</GLOSSARY>
|
||||
Reference in New Issue
Block a user