|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectexe.question
exe.msQuestion
public class msQuestion
This class extends question to provide support for
multiple-selection questions.
In order to use msQuestion or any of question's
other derived classes in a script-producing program, the script-producing
program must import the package exe.
An msQuestion is added to a showfile by placing a question
reference at the end of the snapshot in which the question is to appear and
then by appending the question information to the question section at the
end of the file.
Question reference for an msQuestion:
MSQUESTION id
Question information for an msQuestion:
MSQUESTION id
The question text appears here.
ENDTEXT
Correct answer choice 1 appears here.
ENDCHOICE
Incorrect answer choice 1 appears here.
ENDCHOICE
Correct answer choice 2 appears here.
ENDCHOICE
Incorrect answer choice 2 appears here.
ENDCHOICE
. . .
Incorrect answer choice n appears here.
ENDCHOICE
ANSWER
1
3
ENDANSWER
Note that if the correct answer is added first, the correct answer is 1; if
the correct answer is added second, the correct answer is 2; ...; if the
correct answer is added as item n, the correct answer is n.
After all the answers have been added and the correct answers have been set,
the answer choices can be shuffled using the shuffle() method.
| Field Summary | |
|---|---|
protected java.util.Vector<java.lang.String> |
choices
Holds the answer choices for this question. |
protected java.util.Vector<java.lang.Integer> |
correctChoices
Keeps tracks of the correct answers' positions in the Vector of choices. |
| Fields inherited from class exe.question |
|---|
id, mustBeAsked, out, questionText |
| Constructor Summary | |
|---|---|
msQuestion(java.io.PrintWriter out,
java.lang.String id)
Constructs a new msQuestion object that is distinguished
by id and outputs its information to out. |
|
| Method Summary | |
|---|---|
void |
addChoice(java.lang.String choice)
Adds an answer choice to the Vector that stores the answer
choices for this msQuestion. |
void |
animalInsertQuestion()
Writes a reference to this question at the current position
in the specified PrintWriter output stream using the ANIMAL
question reference format. |
void |
animalWriteQuestionInfo()
Writes this question's information at the current position
in the specified PrintWriter output stream using the ANIMAL
question format. |
void |
insertQuestion()
Writes a reference to this question at the current position
in the specified PrintWriter output stream using the GAIGS
question reference format. |
void |
setAnswer(int choice)
Adds a correct answer choice to the Vector that is used to
track the positions of the correct answers to this
msQuestion. |
void |
setAnswer(java.util.Vector<java.lang.Integer> correctChoices)
Sets the correct answers to this msQuestion with a single
method call. |
void |
shuffle()
Randomly exchanges the positions of the answer choices contained within choices so that the answer choices appear in a different
order than they were added. |
void |
writeQuestionInfo()
Writes this question's information at the current position
in the specified PrintWriter output stream using the GAIGS
question format. |
| Methods inherited from class exe.question |
|---|
getID, setMustBeAsked, setQuestionText |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Vector<java.lang.String> choices
protected java.util.Vector<java.lang.Integer> correctChoices
Vector of choices.
Note that the values stored are one greater than the index of the
answers in the Vector. For instance, if a correct answer is
the first answer stored in choices, the value of 1 will be
stored in correctChoices as an Integer value.
| Constructor Detail |
|---|
public msQuestion(java.io.PrintWriter out,
java.lang.String id)
msQuestion object that is distinguished
by id and outputs its information to out.
out - Specifies the output stream to which this
msQuestion should perform its write operations.id - Gives this msQuestion a String that
can be used to uniquely identify it from other
question objects in a collection.| Method Detail |
|---|
public void insertQuestion()
questionquestion at the current position
in the specified PrintWriter output stream using the GAIGS
question reference format.
insertQuestion in class questionpublic void animalInsertQuestion()
questionquestion at the current position
in the specified PrintWriter output stream using the ANIMAL
question reference format.
animalInsertQuestion in class questionpublic void addChoice(java.lang.String choice)
Vector that stores the answer
choices for this msQuestion.
The value passed to choice is added to the end of the
Vector of answer choices.
choice - Specifies the text of the answer choice that is to be
added to the Vector of choices. This is the
answer choice that appears in the question window when
this msQuestion is asked.public void setAnswer(int choice)
Vector that is used to
track the positions of the correct answers to this
msQuestion.
The value passed to choice is added as an
Integer value to correctChoices.
Note that the value passed to choice must be one greater
than the correct answer choice's index in the
choices Vector. For example, the first answer added via
addChoice(String) is 1.
choice - Indicates a correct answer to this
msQuestion. The value must be one greater
than the answer's index in the Vector of
choices, as described above.public void setAnswer(java.util.Vector<java.lang.Integer> correctChoices)
msQuestion with a single
method call.
The Vector passed to correctChoices is set as
the Vector of correct answers to this question.
Note that this Vector must contain Integer
values that are one greater than the correct answer choices' indices in
in the choices Vector. For example, the first answer added
via addChoice(String) is 1.
correctChoices - Contains the correct answer choices for this
msQuestion. This Vector
must contain Integer values one
greater than the correct choices' indices in the
choices Vector, as described above.public void shuffle()
choices so that the answer choices appear in a different
order than they were added.
Whenever a correct answer choice is swapped with another choice, the
corresponding value in correctChoices is changed so that
correctChoices accurately tracks the correct answers to
this msQuestion.
public void writeQuestionInfo()
questionquestion's information at the current position
in the specified PrintWriter output stream using the GAIGS
question format.
writeQuestionInfo in class questionpublic void animalWriteQuestionInfo()
questionquestion's information at the current position
in the specified PrintWriter output stream using the ANIMAL
question format.
animalWriteQuestionInfo in class question
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||