[Xerte] Having problems duplicating nodes
Paul Swanson
Paul.Swanson at harlandfs.com
Wed Dec 3 18:59:26 GMT 2008
Hi,
Sorry for the length of this post. I've been banging my head on this for
a few days, trying to work it out for myself, but not having much
success.
I have a course with test questions in an external xml file. The course
is broken up into lessons with each lesson having some questions, but
the test includes the questions for all the lessons. The full test works
fine, but at the end of each lesson we want a Wrap Up Quiz, which
consists of the questions for just that lesson. I am struggling with
getting just the pertinent lesson questions to display. What is
happening is that the lesson questions duplicate the wrong number of
times, and only one question is displayed. And worst of all, it's
inconsistent in the behavior. Lesson 1 has 2 questions, but each time I
run it I get a different number of questions - sometimes it's 2, but
usually it is more - 3, 5, 10 - all over the place. Usually a question
only appears on one of the pages, when it appears on multiple pages it's
the same question on each page. Bizarre.
The structure of the xml file is as follows (for brevity, I've just
included a couple of questions for a couple of lessons):
<quiz>
<!-- Lesson 1 -->
<question lesson="1">
<prompt><![CDATA[What section of General System Setup allows you to
establish access rights to various levels of program use?]]></prompt>
<answer correct="false"><![CDATA[Tools > Security]]></answer>
<answer correct="false"><![CDATA[File > View Licenses]]></answer>
<answer correct="false"><![CDATA[General > Institution
Setup]]></answer>
<answer correct="true"><![CDATA[Personnel > Access
Groups]]></answer>
<answer correct="false"><![CDATA[Libraries > Financial
Institution]]></answer>
</question>
<question lesson="1">
<prompt><![CDATA[What telephone number would you call to inquire
about interpreting certain language in a Truth-In-Savings
Disclosure?]]></prompt>
<answer correct="false"><![CDATA[Training Dept:
800-274-7255]]></answer>
<answer correct="false"><![CDATA[Main HFS Line:
800-724-7280]]></answer>
<answer correct="true"><![CDATA[Compliance Support:
800-274-7287]]></answer>
<answer correct="false"><![CDATA[Sales: 800-274-7259]]></answer>
</question>
<!-- Lesson 2 -->
<question lesson="2">
<prompt><![CDATA[Which menu item(s) on the DepositPro Admin menu
allows you to set up your fee structure for Cashiers Checks?]]></prompt>
<answer correct="false"><![CDATA[Use Setup > Fees]]></answer>
<answer correct="true"><![CDATA[Use Policies > Policy
Components]]></answer>
<answer correct="false"><![CDATA[Use Products > Update
Fees]]></answer>
<answer correct="false"><![CDATA[None of the Above]]></answer>
</question>
<question lesson="2">
<prompt><![CDATA[How do you allow Options Other Than Those Listed
for Marketing Categories and Funds Sources Library?]]></prompt>
<answer correct="false"><![CDATA[Use an Edit Code of "Editable" on
the drop-down list]]></answer>
<answer correct="true"><![CDATA[Use the menu item Policies >
Marketing Categories and check the box labeled "During Transaction
Processing, Allow Options Other Than Those Listed"]]></answer>
<answer correct="false"><![CDATA[This is an editable field. You may
include any option at any time.]]></answer>
<answer correct="false"><![CDATA[None of the Above. Only listed
options are allowed.]]></answer>
</question>
</quiz>
The xml data is saved to a variable called quizData (quizData =
templateData.quiz[0];). In the Entry Frame of my lesson, I have the
following:
// create arrays for lesson 1 quiz
lesson1quiz = new Array ();
wrapupBuilt = new Array ();
wrapupTracking = new Array ();
wrapupAnswers = new Array ();
lesson1Counter = 0; // counter for number of questions
// loop through all questions to get lesson 1
for (i = 0; i < quizData.question.length; i++;) {
if (quizData.question[i].lesson == '1') {
lesson1quiz[lesson1Counter].question = quizData.question[i];
lesson1Counter++;
} // end of quizData.question[i] conditional
} // end of for loop
// create the right number of questions
icon.parentNode.nextSibling.nextSibling.childNodes[0].childNodes[1].dupl
icate(lesson1Counter-1);
The script icon is in the Entry Frame of the Lesson framework, and the
page with the wrap up questions follows one other page with introductory
text, so icon.parentNode.nextSibling.nextSibling should point to the
wrap up page. The wrap up page contains a framework as the first icon
(childNodes[0]) with an Entry Frame, and the proto Wrap Up page
(childNodes[0].childNodes[1]), which displays the question, and includes
radio buttons for the multiple-choice answers. The entry frame doesn't
include any code that deals with the actual questions. The proto Wrap Up
page includes a script icon that gets the current question number:
questIndex = icon.parentNode.index() - 1;. There is a text icon for
displaying the question using the following expression:
{lesson1quiz[questIndex].question.prompt}. And another icon that sets up
the answer radio buttons that seems to work properly, duplicating the
correct answers for the question.
I believe the problem is with the script that duplicates the questions,
which I've marked in maroon colored text. Not only is it creating the
wrong number of questions, but it also is affecting the display of Page
x of y that normally prints on the introductory page. The variable
lesson1Counter holds the correct value - as part of my debugging, I
started printing it out as part of the question, and it always prints
the correct number of questions for that lesson. So why is it creating
an inconsistent number of questions when I use that same variable for
the duplicate() method?
I can strip down the file and zip it for download, if that would help.
But I would really like to learn what I'm doing wrong so I don't do it
again.
Thanks for any assistance!
_____________________________
Paul Swanson
Instructional Designer
Harland Financial Solutions
800.274.7280 Ext. 2462
Paul.Swanson at harlandfs.com
_____________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20081203/3019189e/attachment.html
More information about the Xerte
mailing list