Copying banks, GIFT vs XML Moodle

Copying banks, GIFT vs XML Moodle

Stephen Francis -
回帖数:17

We have a course with 1000 MCQ questions in a bank that it categorised. We want this bank in another course as well (without publishing because eventually they will start to differ). These questions have images (inserted using drop down) and feedback images (inserted using url). Exporting as either XML Moodle or GIFT (using the file tick box because we need to keep the categorisation) works no problem, it made the backup file. Now, when we tried to import those files in the new course, only the GIFT one works; weird but true. Importing the XML Moodle file gave errors like, "file too big" and on the second time we tried it only brought one question across. I though the Moodle XML would be the best, apparently not. Try it for yourself, I've attached them in a zip if you hit the link. If it works for you, I'll eat my hat.

In fact the GIFT one wasn't a perfect import. A few of the categories got corrupted, but the question themselves very fine, just their categories.


Moodle 1.8.2+

www.oxfordaviation.net/downloads/moodleforums.zip
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
I'm looking !

EDIT:
The file doesn't seem to want to download for me, but looking at your directory listing it looks like it is 10Meg big!! The import of questions is governed by the same file upload restrictions as everywhere else - you do have your site set up to load files that big?

EDIT AGAIN:
Tried a few times now and the download gets to order of 100k and drops. Never going to download 10.5Meg like this 伤心
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Upload size isn't a problem, it's set for 32 MB. The XML file is 10.8 MB and the GIFT file is 700 KB and they are both from the same 1000 set of the questions. Our server and lines have had a glitch, try later perhaps?
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
Still doesn't download... I'll try tomorrow.

It still strikes me as a very big file. What are the sizes of your images in the questions? Are they perhaps too big - ie, not properly sorted for the web?
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Most images are less than 800 X 600. This is because they are aviation weather charts and can't just be shrunk, you need to see the data, and there is a lot of it in these charts. Anyway, it seems all is working, my internet and server seems sorted.
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
Still no result dowloading your file. I've actually tried it on a few (very differently connected) sites I have access to and all drop out.

Sorry - if I can't download the file there's nothing much I can do. There's nowhere else you can move it to is there?

 
7% [====> ] 849,422 --.--K/s ETA 2:57:54^ 7% [====> ] 849,422 --.--K/s ETA 2:59:25

09:51:42 (940.07 B/s) - Read error at byte 849422/10974851 (Connection timed out). Retrying.

--09:51:43-- http://www.oxfordaviation.net/downloads/moodleforums.zip
(try: 2) => `moodleforums.zip'
Connecting to www.oxfordaviation.net|213.235.52.66|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 10,974,851 (10M), 10,125,429 (9.7M) remaining [application/x-zip-compressed]

9% [+++++> ] 1,012,584 --.--K/s ETA 51:20^ 9% [+++++> ] 1,012,584 --.--K/s ETA 1:52:13^
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Ok, Howard, I found the problem, not with my download site, but with why I can't import my Moodle XML file. The reason is a bug in the Moodle XML export coding. You see, I have categories called "Turbulence&Windshear" The problem is that in XML the ampersand symbol is code. The bug is that the export function needs to change the ampersand symbols in my text to this : "&". Using notepad++ I manually the "&" symbol to an "and"so it becomes "Turbulence and Windshear" in the XML and now it works perfectly. Imports like a dream.

Using XML Moodle ad an export and import has brought across my html embeded coding, my images and feedback and is the most comprehensive question bank copier. Phew, got there in the end. Perhaps we should report it to Tim.
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
No need - that bit is my problem 微笑

I'll check it out. Thanks for spotting that, although I'm surprised - I thought we'd got all of those bugs ages ago !!

EDIT:
I just tried doing an XML export with an ampersand in the category name and it worked fine (ie, the ampersand was converted). Can I confirm with you *exactly* where the ampersand was. Again even a snippet of the errant XML would be a big help.
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Found another bug in Moodle XML. I have a single category called "TAFS/METARS/SIGMETS" however, once I export and import the question bank, Moodle understandably thinks I'm making categories and sub-categories, so when it imports the bank it makes SIGMETS a sub of METARS and METARS a sub of TAFS.
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Here you go. See attached file.
Line 162,239,316
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
Yess... something wrong there.

However, where did that file come from? It looks a little strange to me - e.g., question name starting ":[HTML]".

EDIT:
Oh... the bug's in the export. It hasn't encoded the characters in the category properly.

I'll sort it asap. However, theoretically I'm on holiday at the moment so it might be a day or too. ( MDL-11425 )
回复Howard Miller

Re: Copying banks, XML Moodle and images

Stephen Francis -
Hi again Howard,

I did some more XML export and import (Q1000+). Again the "category info" text doesn't come across like I mentioned before, BUT i found something else as well.

My banks have images, these were attached using the drop down box in the edit question facility and not the HTML "add image" button. All of the images are in the course files in a folder called "Met_CMi_Question_Pictures"

Now, when I export and then import the whole question bank to another course, the images don't show up when i review a question in the new question bank. So i looked around. The images were correctly copied/loaded into the course files, but when I went in to MySQL and looked at the mdl_question table under the column "image" i see something different from the original text in the original bank.

In the correctly working bank it just says "Met_CMi_Question_Pictures/416.jpg" in the image column in MySQL. I presume it simply points to the course files, great.

But in the copied bank it has more text, it reads... "D:Moodle182/moodledata/3/Met_CMi_Question_Pictures/416.jpg"

If I manually delete the "D:Moodle182/moodledata/3" part the image shows perfectly in my new question bank!.

Might be just something on my system but it seems that the XML export adds more folder structures to the image pointing location, but this doesn't work for some reason, although it seems it should.

Now all I need is to find the MySQL query that will help me remove the text D:Moodle182/moodledata/3/ from every question in the mdl_questions table with an image wink.. wink...(anyone)

Enjoy the rest of your hols. I don't expect you to sort this out in the your holiday, so we are going to fix it manually, but I thought you should know.

Steve
回复Stephen Francis

Re: Copying banks, XML Moodle and images

David Fountain -
I'm no SQL expert but I used the following to replace some bits (I wanted to change thisisalessthantag into a < in the glossary table), so I'm sure you could adapt it:

update `mdl_glossary_entries` set `definition`= replace(`definition`, "thisisalessthantag", "<") where glossaryid=3;


回复Stephen Francis

Re: Copying banks, XML Moodle and images

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
We recently fixed a bug that sounds similar to this - the path was *not* being included. I'm wondering if there is something going wrong because you are on a Windows system. What's your $CFG->dataroot set to? If it's "D:Moodle182".... then it's wrong anyway surely?
回复Howard Miller

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Hi Howard,

I've attached a small sample in my second post from top about the ampersand thing.

Anyway, I was doing another question bank export using file to with xml moodle and encountered this error for every exported question (debugging on).
Notice: Undefined property: stdClass::$answernumbering in C:\MoodleWindowsInstaller-latest-18\moodle182\moodle\question\format\xml\format.php on line 846

Line 846 is this
$expout .= "
<answernumbering>{$question->options->answernumbering}</answernumbering>\n";

Also, when I imported the file in another course it didn't copy across the Category Info text. No idea if it's a bug or just my system.

1.8.2+
Localhost


Steve
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Stephen Francis -
Hmmm, the GIFT import doesn't seem to bring across the HTML text that is in the answer feedback boxes. It brings across the normal answer feedback text, but not the HTML <img src=""> url stuff. This HTML text simply displays images. Now thats a pain. If we fix the Moodle XML import, would it bring across the HTML text in the feedback boxes as well as the normal feedback text, or will I have to do all this manually again?
回复Stephen Francis

Re: Copying banks, GIFT vs XML Moodle

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
It should work - I've not heard of a problem.

Again can I get an example GIFT file (one small enough to post here perhaps? 微笑 )