[Xerte] Having problems duplicating nodes

Julian Tenney Julian.Tenney at nottingham.ac.uk
Thu Dec 11 09:25:30 GMT 2008


I got caught out by that one last week as well, and spent a long time
trying to figure out why things were going strange. The problem is
simply because when two pages have the same ID, things collide. Often
you can get away with duplicate IDs (in fact it is convenient) because
there is only ever one of these things on the screen when the ID is
used. I can't remember the details, but the parser works differently for
pages.

 

From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Paul Swanson
Sent: Wednesday, December 10, 2008 4:53 PM
To: Xerte discussion list
Subject: RE: [Xerte] Having problems duplicating nodes

 

Thanks for those tips Julian, it was the ID of the page being duplicated
that seems to have caused the problem. I had given the page an ID
attribute, but was never referencing it for anything, so I deleted the
ID attribute and now I get the questions to appear when navigating back.
My problem is now solved! Yay! That was a tricky one to debug -- thanks
for your patience.

 

Just for my own understanding: why would the duplicate IDs be a problem
in this case? I try to not make the same mistake twice, and would like
to know what the problem might have been.

 

Paul

	 

	
________________________________


	From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
	Sent: Wednesday, December 10, 2008 3:09 AM
	To: Xerte discussion list
	Subject: RE: [Xerte] Having problems duplicating nodes

	When you back up to the page, what do you get when you debug()
the various things you are expecting? Does all your data seem correct?
Can you display anything at all in that page, even hard-coded text
icons, like 'here is page one'? Do the icons you expect to be in that
page actually exist? You're not calling duplicate() more than once? The
pages themselves don't have duplicate IDs?

	 

	From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Paul Swanson
	Sent: Tuesday, December 09, 2008 11:33 PM
	To: Xerte discussion list
	Subject: RE: [Xerte] Having problems duplicating nodes

	 

	Making progress ... but not using your suggestion. I came up
with a different way.

	 

	I started to think that my lesson1quiz array was not being
appended to, but overwritten, when using the following code:

	 

	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

	 

	}

	 

	but by changing it to:

	 

	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.push(quizData.question[i]);
	    lesson1Counter++;

	 

	  } // end of quizData.question[i] conditional

	 

	}

	 

	and then changing the references that display the questions to
{lesson1quiz[questIndex].prompt}, I am getting the questions and answers
to display within the individual lesson. My only problem now is that if
the user tries to navigate back within the question framework, the page
appears blank. questIndex is set by this statement:

	 

	questIndex = icon.parentNode.index() - 1;

	 

	The page that the questIndex code is on is the first page of my
lesson1quiz framework, with an Entry Pane preceeding it. Any thoughts on
that?

	 

	Again, thanks for all the help. And a special thanks to Dave B,
who offered to take a look at my file and offer suggestions (even though
I didn't take him up on it).

	 

	Paul

	 

		 

		
________________________________


		From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
		Sent: Tuesday, December 09, 2008 1:39 AM
		To: Xerte discussion list
		Subject: RE: [Xerte] Having problems duplicating nodes

		I'd use decision icons, set to randomUnused to present
the questions - then there's no need to randomise your arrays. Pick out
each question using icon.parentNode.index() or similar, with a page on
the deision for each question - but you'll make those with duplicate().
You will still need to build some arrays for sec1Questions,
sec2Questions though. I might be tempted to make those arrays of
xmlNodes rather than the bits of templateData. You can get the
pre-XML2Object xml from your file with the variable extXML. I'd loop
over that, picking out your nodes and adding them to your arrays, then
use those arrays to drive your code.

		 

		HTH?

		 

		J

		 

		From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
		Sent: Monday, December 08, 2008 10:52 PM
		To: Xerte discussion list
		Subject: RE: [Xerte] Having problems duplicating nodes

		 

		how fussy are you about the .xml format?

		 

		could you work with:

		 

		<questions>

		 

		  <question section="1">

		    <!--data for question here -->

		  </question>

		 

		  <!--etc-->

		 

		</questions>

		 

		and generally, what does the .rlo need to do? Present a
framework of content for each section, and then show the quiz (on the
last page?). Do the page types vary?

		 

		and then a final section framework summarises and then
shows all questions, randomised?

		 

		 

		 

________________________________

		From: xerte-bounces at lists.nottingham.ac.uk on behalf of
Paul Swanson
		Sent: Mon 08/12/2008 19:15
		To: Xerte discussion list
		Subject: RE: [Xerte] Having problems duplicating nodes

		Commenting out the two randomQuizData lines doesn't
change anything. I've moved the statement that randomizes the questions
to the button that launches the final test, rather than have it in the
setup script.

		 

		Maybe I'm just going about this entirely the wrong way.
What I want to accomplish is to have all my test questions within one
setup.xml file. I have six lessons, and some of the questions will also
be presented at the end of each lesson. So I need to parse which
questions are for lesson 1, which are for lesson 2, etc. Once the
student has completed all of the lessons, they must take a test to pass
the course. This test will be comprised of all of the questions for all
of the lessons, with the questions randomized. Am I on the right track
with what I've been trying to do, or do I need to take a different
approach?

		 

		Paul

			 

			
________________________________


			From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
			Sent: Thursday, December 04, 2008 11:32 PM
			To: Xerte discussion list
			Subject: RE: [Xerte] Having problems duplicating
nodes

			You are creating references to the same array.

			 

			quizData = templateData.quiz[0]; //
non-randomized questions

			 

			randomQuizData = templateData.quiz[0]; // for
randomized questions
			randomQuizData.question.randomize(); //
randomize the list of questions.

			 

			quizData.question is also randomised.

			 

			 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20081211/99c5e292/attachment.html


More information about the Xerte mailing list