[Xerte] xerte 2.n - Help needed to remove and then
re-duplicateicons
Julian Tenney
Julian.Tenney at nottingham.ac.uk
Wed Jun 9 17:03:15 BST 2010
Can you do it by having a protoNode somewhere the flow never goes, and
when you kick up the question get that node, append it to the
appropriate parent and then dupe it?
Then when you return, loop over childNodes, deleting each one using
removeNode(), then put back your protoNode and duplicate it. You might
need to make sure you are getting a copy of the protoNode and not a
reference.
Does that sound like what you are trying to do?
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Kemp
Johnathan
Sent: 09 June 2010 15:32
To: Xerte discussion list
Subject: Re: [Xerte] xerte 2.n - Help needed to remove and then
re-duplicateicons
No that's not it.
The page I am trying to create will allow the end user (not the designer
who sets up the wizard) to select options that will decide which
questions are offered to them. This means that each time they reach the
"quiz" end and click restart it will be necessary to as far as is
possible get back to the situation that applied before the page was
first run.
The quiz works by taking an icon structure called protoQuestion and
duplicating it to accomodate the number of questions to be displayed.
For my page to work, if built == true, I need to remove all nodes that
were duplications of protoQuestion and then re-duplicate the nodes the
number of times appropriate for the current selections the user has
made.
You will get a feel for what I am trying to achieve if you open the
project example I attached to my last email and use the TOC to go to the
randomSequence page. The part of the quiz code that builds the pages is
not run in the getPageID script. The user selections are processed first
to create an array with one element for each "question" "option". The
create questions script then runs to duplicate protoQuestion as many
times as is necessary based on the length of the array. The page works
once but fails on the restart - at present I have removed code that
represents early attempts to remove and re-duplicate the icons.
I have included the quiz page as a simpler example that is closer to the
original script for the quiz page. The only difference being that I have
separated out the part of the getPageId script that makes the pages and
moved it to the end of the icon sequence to just before the Decision
icon. The quiz page still works.
The challenge is to take the code in the "make questions" script of the
quiz page and add an else section to it.
e.g.
if (icon.attributes.built != 'true'){
icon.parentNode.getChildByName("questions").firstChild.duplicate(pageIco
n.templateData.learningObject[0].quiz[0].question.length - 1);
icon.attributes.built = 'true';
}
else {
// code needed here that will
// 1. remove all the pages created by the duplication that occurred in
the if section above;
// 2. duplicate the pages affresh, such that the page still works each
time it is restarted or revisited.
}
If I can find out how to do this it should be straight forward to modify
this so that the code
a) removes all the pages duplicated the last time the page was run
b) duplicates the appropriate number of new pages required to meet the
end users latest selection
which are the requirements of my new wizard.
The quiz page at present can remove nodes and re-create them, but
comparison of the xml of the pages that existed after the initial, build
by using debug, with the new pages created, shows them not to be the
same and the page fails to run correctly in the second running. .i.e.
when it is restarted or revisited.
Is what I am trying to achieve possible? I cannot recall a Xerte page
that actually allows the end user to take actions that effectively allow
the end user to configure in some way the pages structure.
Kind regards
Johnathan
On 9 June 2010 11:30, Julian Tenney <Julian.Tenney at nottingham.ac.uk>
wrote:
When you're manipulating xml, I always do:
If (icon.built != true){
//manipulate the xml
icon.built = true;
}
Then it will only happen once, and bult = true is set on the underlying
XML node itself. Is that it?
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Kemp
Johnathan
Sent: 09 June 2010 10:08
To: Xerte discussion list
Subject: [Xerte] xerte 2.n - Help needed to remove and then
re-duplicateicons
I am working on a new page wizard that is based on the quiz page.
As part of its functioning it presents the user with an option screen.
The selections the user makes will decide how many "questions" are
presented to the user.
The problem is that whilst I can get the page to run once, if the user
then clicks on the restart button, or returns to the page at a later
time, the page will not run correctly a second time as I am not able to
successfully remove and re-duplicate the "proQuestion" that is the
master for all the questions that are created at run time.
Can anyone see what I am doing wrong, or suggest the correct way to
achieve this?
I have attached a sample project which includes both a quiz page that
attempts to remove and re-duplicate the questions each time the page is
returned to or the Restart button is clicked. If I can get this to work
I should be able to get the same process to work in my new page.
The sample project also includes an example of my new page so that you
can see what I am trying to achieve.
The idea of the new page is to support music practice where for example
the end result may be to play a number of different scales with both
hands with variety of expression and style. Initially practice may be to
learn the scales playing only the left or right hand, and then later add
playing hands together, then later add variations of style and
expression. Selection of an easy level only offers for practice single
handed scales. Harder levels then introduce double handed play,
variation in style and expression.
In both example pages it is the "make pages" script icon that needs
attention. The quiz page gives you some idea of what I have tried so
far.
Any help would be most appreciated.
Kind regards
Johnathan
_______________________________________________
Xerte mailing list
Xerte at lists.nottingham.ac.uk
http://lists.nottingham.ac.uk/mailman/listinfo/xerte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20100609/805f582a/attachment.html
More information about the Xerte
mailing list