exe
Class msQuestion

java.lang.Object
  extended by exe.question
      extended by exe.msQuestion
Direct Known Subclasses:
XMLmsQuestion

public class msQuestion
extends question

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.

Author:
Andrew Jungwirth

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

choices

protected java.util.Vector<java.lang.String> choices
Holds the answer choices for this question.


correctChoices

protected java.util.Vector<java.lang.Integer> correctChoices
Keeps tracks of the correct answers' positions in the 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

msQuestion

public 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.

Parameters:
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

insertQuestion

public void insertQuestion()
Description copied from class: question
Writes a reference to this question at the current position in the specified PrintWriter output stream using the GAIGS question reference format.

Specified by:
insertQuestion in class question

animalInsertQuestion

public void animalInsertQuestion()
Description copied from class: question
Writes a reference to this question at the current position in the specified PrintWriter output stream using the ANIMAL question reference format.

Specified by:
animalInsertQuestion in class question

addChoice

public void addChoice(java.lang.String choice)
Adds an answer choice to the 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.

Parameters:
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.

setAnswer

public 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. 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.

Parameters:
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.

setAnswer

public void setAnswer(java.util.Vector<java.lang.Integer> correctChoices)
Sets the correct answers to this 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.

Parameters:
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.

shuffle

public 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. 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.


writeQuestionInfo

public void writeQuestionInfo()
Description copied from class: question
Writes this question's information at the current position in the specified PrintWriter output stream using the GAIGS question format.

Specified by:
writeQuestionInfo in class question

animalWriteQuestionInfo

public void animalWriteQuestionInfo()
Description copied from class: question
Writes this question's information at the current position in the specified PrintWriter output stream using the ANIMAL question format.

Specified by:
animalWriteQuestionInfo in class question