A very very rough first stab at a Questionmark Perception importer
To install create a directory called 'questionmark' in question/format and dump the format.php file. You should then have the option in the import list.
Please don't use this for anything serious - it's only to get some feedback and to try and guilt QM users into sending me some .qml files so that I can do further development.
If anybody who can be bothered to try it, I would appreciate any feedback - good or bad
Re: A very very rough first stab at a Questionmark Perception importer
http://moodle.org/mod/data/view.php?d=13&rid=756
Re: A very very rough first stab at a Questionmark Perception importer
Howard,
Have you seen this post? Someone submitted some qml files
http://moodle.org/mod/forum/discuss.php?d=67429&parent=332772
One of the people at our site is trying to import qml into moodle. She's going to take a look at what you've done so far and will hopefully be able to give you some feedback and qml files so that you can continue to work on the plugin.
Thanks!
Re: A very very rough first stab at a Questionmark Perception importer
I've been totally tied up with other stuff but I do mean to get back to it when I get a minute
Re: A very very rough first stab at a Questionmark Perception importer
Dear Howard,
Do you have a minute yet
We seriously need to get QMP questions to Moodle. I don't care which format: Qpack, QML, XML, IMS-QTI 2.0, whatever it takes.
We have about 10.000 questions that need to be imported.
Re: A very very rough first stab at a Questionmark Perception importer
Re: A very very rough first stab at a Questionmark Perception importer
We also don't manage the QMP server, so we can not tweak it the right way.
And... QMP needs a license. It's not free-open source like Moodle.
The QMP conncetor is a very good backup idea though. We might have to fall back on that idea if we can't get the questions imported to Moodle.
Our preference though is to use one piece of software. We rather have our teacher learn all there is about Moodle then to tell them they need to work in Moodle except for tests... and that they need to make the tests in QMP.
After all, I'l final goal is to make Moodle the centre workspace for teachers. Connecting to get content from elsewhere is possible, but creating new content.. please do that in Moodle and not in other software.
Re: A very very rough first stab at a Questionmark Perception importer
Also, I discovered recently that the way Moodle question importers work makes it really easy to write automated tests for them. For example, have a look at http://github.com/timhunt/Moodle-Question-Engine-2/blob/new_qe/question/format/xml/simpletest/testxmlformat.php, which are some tests I made for the Moodle XML format - and I found that a really helpful way to develop some changes to the format.
If you have a lot of example questions, and a PHP developer for a few days, it would be pretty easy to make the QuestionMark importer much better.
Re: A very very rough first stab at a Questionmark Perception importer
Well, I'm trying to find out some stuff now. I already fixed an error in the QMP importer.
But now I'm stuck.. perhaps anyone can help:
<QUESTION ID="9621106044997714" DESCRIPTION="TC-8501-00040 preventie" TOPIC="lokaal\Thema Tuincentrum\10 Algemene zaken\01 Arbeidsomstandigheden" STATUS="Normal">
<CONTENT TYPE="text/html"><![CDATA[<h3>Veiligheid</h3>]]></CONTENT>
<CONTENT TYPE="image/" WIDTH="217" HEIGHT="167" BORDER="1"><![CDATA[topicresources/911682863/01oe15-Veiligheid_011.jpg]]></CONTENT>
<CONTENT TYPE="text/html"><![CDATA[<BR>]]></CONTENT>
<CONTENT TYPE="text/html"><![CDATA[Als je tijdens werkoverleg over veiligheid spreekt kom je al snel het woord preventie tegen. <BR><BR> Wat betekent dit woord? ]]></CONTENT>
<ANSWER QTYPE="MC" SHUFFLE="YES">
<CHOICE ID="0">
<CONTENT TYPE="text/html"><![CDATA[genezen]]></CONTENT>
</CHOICE>
<CHOICE ID="1">
<CONTENT TYPE="text/html"><![CDATA[bestrijden]]></CONTENT>
</CHOICE>
<CHOICE ID="2">
<CONTENT TYPE="text/html"><![CDATA[voorkomen]]></CONTENT>
</CHOICE>
<CHOICE ID="3">
<CONTENT TYPE="text/html"><![CDATA[veroorzaken]]></CONTENT>
</CHOICE>
</ANSWER>
<OUTCOME ID="2 voorkomen" SCORE="10">
<CONDITION>"2"</CONDITION>
<CONTENT TYPE="text/html"><![CDATA[Goed.]]></CONTENT>
</OUTCOME>
<OUTCOME ID="fout" SCORE="0">
<CONDITION>OTHER</CONDITION>
<CONTENT TYPE="text/html"><![CDATA[Fout.<BR> Preventie betekent: voorkomen]]></CONTENT>
</OUTCOME>
</QUESTION>
This will not be converted because the importer doesn't understand the condition 'OTHER' every other answer:
// run through outcomes
$outcomes = $question['#']['OUTCOME'];
foreach ($outcomes as $outcome) {
$condition = $outcome['#']['CONDITION'][0]['#'];
$id = intval( trim($condition,'"' ));
$qo->fraction[$id] = $outcome['@']['SCORE'] / 10;
$qo->feedback[$id] = $this->import_text($outcome['#']['CONTENT'][0]['#']);
}
Does anyone know how to fix this?
Re: A very very rough first stab at a Questionmark Perception importer
That is a rather brief description. I can write more if you like.
It would be really great if you could submit any fixes or improvements you can make to this importer to http://tracker.moodle.org/ attaching a patch or other description of the change.
Re: A very very rough first stab at a Questionmark Perception importer
I will, don't worry. This will take some time but the summer holiday will be here soon and I have the time to sink my teeth in this problem.
I know we need an if statement in there. It needs something like:
if ($condition == 'OTHER') {
$id = $choice['@']['ID']; }
ELSE {
$id = intval( trim($condition,'"' ));
}
But I'm not a php-programmer by far. I know what it need to do (Set all ID's feedback if condition is OTHER) but I have no clue as to how translate this into PHP.
If you could point any PHP programmer to this topic I'd be very happy!
Re: A very very rough first stab at a Questionmark Perception importer
I can't get it done... seems I really need someone who knows PHP here. I got to this part:
// run through outcomes
$outcomes = $question['#']['OUTCOME'];
$teller == 0;
$condition = $outcome['#']['CONDITION'][0]['#'];
print $condition;
if ($condition == 'OTHER') {
$id == $teller;
$qo->fraction[$teller] = $outcome['@']['SCORE'] / 10;
$qo->feedback[$teller] = $this->import_text($outcome['#']['CONTENT'][0]['#']);
} else {
$id = intval( trim($condition,'"' ));
$qo->fraction[$id] = $outcome['@']['SCORE'] / 10;
$qo->feedback[$id] = $this->import_text($outcome['#']['CONTENT'][0]['#']);
}
$teller++;
But this doesn't work, because it will find only one time 'OTHER' and I need to put the feedback + answers found in the 'OTHER' condition in all not-creect answers.
Re: A very very rough first stab at a Questionmark Perception importer
This any better? Stil not working though:
// run through the answers - choice bit
$teller == 0;
$choices = $question['#']['ANSWER'][0]['#']['CHOICE'];
foreach ($choices as $choice) {
$id = $choice['@']['ID'];
$qo->answer[$id] = $this->import_text($choice['#']['CONTENT'][0]['#']);
$teller++;
}
// run through outcomes
$outcomes = $question['#']['OUTCOME'];
$i == 0;
print_r($outcomes);
while($i<=$teller) {
$condition = $outcome['#']['CONDITION'][0]['#'];
if ($condition == 'OTHER') {
$id == $i;
$qo->fraction[$id] = $outcome['@']['SCORE'] / 10;
$qo->feedback[$id] = $this->import_text($outcome['#']['CONTENT'][0]['#']);
} else {
$id = intval( trim($condition,'"' ));
$qo->fraction[$id] = $outcome['@']['SCORE'] / 10;
$qo->feedback[$id] = $this->import_text($outcome['#']['CONTENT'][0]['#']);
}
$i++;
}
Re: A very very rough first stab at a Questionmark Perception importer
(Moodle forums always mess up the whitespace when I paste code here, hence the use of pastebin.)
Re: A very very rough first stab at a Questionmark Perception importer
Excellent Tim, this seems to work well. Do you feel up to another php challenge?
I think together with someone that knows PHP we will get a great Questionmark Perception importer out of this.
I can report problems accurately and can tell what goes wrong with several questions. The PHP programmer can try to fix it.
Next thing that goes wrong is this:
<QUESTION ID="3344896440979135" DESCRIPTION="TC-8501-00046 symbool veiligheidsbril" TOPIC="lokaal\Thema Tuincentrum\10 Algemene zaken\01 Arbeidsomstandigheden" STATUS="Normal">
<CONTENT TYPE="text/html"><![CDATA[<h3>Symbolen</h3>]]></CONTENT>
<CONTENT TYPE="text/html"><![CDATA[Waar staat dit teken voor?]]></CONTENT>
<CONTENT TYPE="text/html"><![CDATA[<IMG height=104 hspace=10 src="%SERVER.GRAPHICS%topicresources/911682863/01oe15-veiligheidbril_01.jpg" width=104 align=left vspace=10 border=1>]]></CONTENT>
The problem with this PHP routine is that it will only read the last content tag.
// process content tags
$contents = $question['#']['CONTENT'];
foreach ($contents as $content) {
$type = trim($content['@']['TYPE']);
$data = trim($content['#']);
if ($type=="image/") {
$qo->image = $data;
}
elseif ($type=="text/plain") {
$qo->questiontext = addslashes($data);
$qo->questiontextformat = 2; // plain_text
}
elseif ($type=="text/html") {
$qo->questiontext = addslashes($data);
$qo->questiontextformat = 1; // html
}
else {
$this->error( "Unknown content type in question header ($type)" );
$qo->questiontext = '';
}
}
The PHP routine only inserts the last CONTENT-tag as questiontext, but it should parse all CONTENT tags.
Any idea how to translate that to PHP?
Also, it would be great if this: %SERVER.GRAPHICS% would be removed.