Unexpected "ERR" before answer text on imported multichoice questions

Unexpected "ERR" before answer text on imported multichoice questions

by Nate Hartmann -
Number of replies: 8
My school is currently migrating from Moodle 1.8.3 to 1.9+ (20080425).

An instructor exported his question bank from 1.8.3 as Moodle XML and imported it into 1.9, and all the multichoice questions had "ERR" before the answers' text (as shown in the attached screenshot. Apparently this is a result of a blank or invalid answernumbering value in the question_multichoice table.

I've created a tracker entry for it here.

Here's an easy workaround for anyone else having this problem: simply erase all the answernumbering entries from the XML file, which forces the import tools to pick the default. You can do this with a find and replace, or with sed:

sed -e 's/<\/answernumbering>/none<\/answernumbering>/' yourbrokenfile.xml >yournewfile.xml
Attachment err_prefix_on_multichoice_answers.jpg
Average of ratings: -
In reply to Nate Hartmann

Re: Unexpected "ERR" before answer text on imported multichoice questions

by philip torres -
good day,

i also have the same ERR prefix in my question text answer.may i ask your help on how did you do it,or what specific xml file(s) to edit.

thanks and more power!
In reply to philip torres

Re: Unexpected "ERR" before answer text on imported multichoice questions

by Nate Hartmann -
Hello Philip,

For me I had downloaded a set of questions as "Moodle XML" (there's my XML file) and it was after importing those questions that I had the "ERR" on all the question texts. Is this also how you came to see this bug? Or did you get to it via some other path?

In my case, I needed to find all the empty <answernumbering> tags and insert the value "none" into them. In my original post I used a sed statement to do this, but you could also use a text editor's "find and replace" tool to replace all instances of "<answernumbering></answernumbering>" with "<answernumbering>none</answernumbering>"

-Nate
In reply to Nate Hartmann

Re: Unexpected "ERR" before answer text on imported multichoice questions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is bug MDL-14764 - and your message reminded me to fix it.

(You will need to re-import the questions for the fix to work - or just edit the imported questions. Or execute the SQL
UPDATE mdl_question_multichoice SET answernumbering = 'abc' WHERE answernumbering = ''
in your database if you are sure you know what you are doing.)
In reply to Tim Hunt

Re: Unexpected "ERR" before answer text on imported multichoice questions

by philip torres -
hello good day,

thanks for the reply, by the i'm using postgresql and when i check the table mdl_question_multichoice, there is no answernumbering column,can i add the column manually?

In reply to Tim Hunt

Re: Unexpected "ERR" before answer text on imported multichoice questions

by philip torres -
hello again,

i added the answernumbering column in mdl_question_multichioce table. i update the mdl_question_multichioce table by setting 'none' value to answernumbering column. then everything when fine,i didn't anymore do the "importing portion".


thanks for the idea..... more power and bless you all !!!
In reply to Nate Hartmann

Re: Unexpected "ERR" before answer text on imported multichoice questions

by Milan Keršláger -

In the Moodle 2.6.6+ the tables were renamed, so I found that the missing "answernumbering" attribute is in the table "mdl_qtype_multichoice_options" so I did:

ALTER TABLE mdl_qtype_multichoice_options ADD answernumbering character varying(10) DEFAULT 'abc'::character varying NOT NULL;

But even that, I still see the "ERR" message in front of multichoice questions sad I tryed to create new test from these questions also but without luck sad All the lines in this table has now "abc" in this collumn.

Now I found that when the question is edited (with no change), the ERR text disappeares. Also export/reimport of questions fixes the problem too. As we have a lot of courses, this is not perfect, but it works. What I don't know, is what I'll break by exporting/importing of questions. Even that there must be something what is changed in the database (when saving the question without changing anything) and this could be done from commandline I bet... but what I have to do about this I don't know sad

In reply to Milan Keršláger

Re: Unexpected "ERR" before answer text on imported multichoice questions

by Milan Keršláger -

Also I had missing one another column:

ALTER TABLE mdl_forum_queue ADD timemodified bigint DEFAULT 0 NOT NULL;

There is more broken data structure during many updates I did in the past mainly in default values. But I did not checked them one by one yet.

In reply to Milan Keršláger

Re: Unexpected "ERR" before answer text on imported multichoice questions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That column was added long before Moodle 2.6.6, so, it was broken long before the table was renamed. Presumably it was broken by some upgrade failure in the past, what was not resolved at the time. However, Moodle upgrade works for most people, most of the time. This is something specific to your site.