Can someone help me create this base script? I am trying to write an app that converts from one format to a custom one. The 1st line is the program version. The 2nd line is the name of the file. The 3rd line is the author of the file. The 4th line is the font of the file. I can discard the 1st and 4th lines of the file. Where I need help is the next section of the file. So far the file will look like this:
v1.0
File name
John Doe
Comic Sans
Then, there are questions, in a similar format.
Am I awesome? 'question
Yes 'answer 1
No 'answer 2
Maybe 'answer 3
So 'answer 4
0 'correct answer. can be 0 thru 4 (4 is none of the above). 0 thru 3 can be listed, so the answer can be 01 or 03 or 0123 or 12, etc. whenever it is 4, no other number appears
C 'randomize or not
A hint can go here 'obviously a hint
Explanation of answer 'self explanatory
I commented using apostrophies above, they are not really there in the file. The text repeats so a sample will look like this:
v1.0
Example file
josheee12
Comic Sans
Question 1 here
Q1A1
Q1A2
Q1A3
Q1A4
01
C
Answer text example Q1
Hint here Q1
Explanation here Q1
Question 2 here
q2A1
Q2A2
Q2A3
Q2A4
4
Answer text example Q2
Hint here Q2
Explanation here Q2
I want to create an XML-style format out of this, so I get something along the lines of:
<info version="v1.0">
<name>Example file</name>
<author>josheee12</author>
<font>Comic Sans</font>
<num>2</num>
</info>
<question id="1">
<ask>Question 1 here</ask>
<answer id="a">Q1A1</answer>
<answer id="b">Q1A2</answer>
<answer id="c">Q1A3</answer>
<answer id="d">Q1A4</answer>
<correct>ab</correct>
<answertext>Answer text example Q1</answertext>
<hint>Hint here Q1</hint>
<explanation>Explanation here Q1</explanation>
</question>
<question id="2">
<ask>Question 2 here</ask>
<answer id="a">Q2A1</answer>
<answer id="b">Q2A2</answer>
<answer id="c">Q2A3</answer>
<answer id="d">Q2A4</answer>
<correct>n</correct>
<answertext>Answer text example Q2</answertext>
<hint>Hint here Q2</hint>
<explanation>Explanation here Q2</explanation>
</question>
and so on.
For question #2 the value of "correct" is n for none. I know this is a large task, and any help is appreciated.