SiCawn
18 Apr 2011, 11:22 PM
I like to build a little app based on sencha touch which contains a quiz system. On a list (the items comes out of an existing xml file) you can choose one quiz and than the application loads the special xml file which describes the quiz question. I dont't want serverside solutions because it should be an offline PhoneGap Application.
A short example what i mean:
quiz.xml :
<allquiz>
<quiz>
<id>0</id>
<title>A quiz example</title>
<desc>A short quiz example</desc>
<quizfile>example_quiz.xml</quizfile>
</quiz>
</allquiz>
example_quiz.xml
<quiz>
<question>
<text>The 1st Question</text>
<correctAnswer>Correct</correctAnswer>
<wrongAnwer>Wrong</wrongAnswer>
</question>
<question>
<text>The 2nd Question</text>
<correctAnswer>Correct</correctAnswer>
<wrongAnwer>Wrong</wrongAnswer>
</question>
</quiz>
models:
Ext.regModel('Quiz', {
fields: [ 'id','title', 'desc', 'xmlfile'],
hasMany: { model: 'Answer', name: 'answers' }
});
Ext.regModel('Answer', {
fields: ['text','correctAnswer','wrongAnswer']
});
Is it possible to dynamic load xml files which specified in an xml file (in my example: quiz.xml)? I want to realize this with a dynamic created xmlReader which i add to a store if somebody has choosen a quiz. But i am not sure if this way is possible.
The second point i want to ask is how i can use associations in this example. I've read the API documentation for using associations but i am not sure how i can best use them.
Finally i want to say sorry for my bad english ^^ Nevertheless i hope you can understood what i mean.
A short example what i mean:
quiz.xml :
<allquiz>
<quiz>
<id>0</id>
<title>A quiz example</title>
<desc>A short quiz example</desc>
<quizfile>example_quiz.xml</quizfile>
</quiz>
</allquiz>
example_quiz.xml
<quiz>
<question>
<text>The 1st Question</text>
<correctAnswer>Correct</correctAnswer>
<wrongAnwer>Wrong</wrongAnswer>
</question>
<question>
<text>The 2nd Question</text>
<correctAnswer>Correct</correctAnswer>
<wrongAnwer>Wrong</wrongAnswer>
</question>
</quiz>
models:
Ext.regModel('Quiz', {
fields: [ 'id','title', 'desc', 'xmlfile'],
hasMany: { model: 'Answer', name: 'answers' }
});
Ext.regModel('Answer', {
fields: ['text','correctAnswer','wrongAnswer']
});
Is it possible to dynamic load xml files which specified in an xml file (in my example: quiz.xml)? I want to realize this with a dynamic created xmlReader which i add to a store if somebody has choosen a quiz. But i am not sure if this way is possible.
The second point i want to ask is how i can use associations in this example. I've read the API documentation for using associations but i am not sure how i can best use them.
Finally i want to say sorry for my bad english ^^ Nevertheless i hope you can understood what i mean.