net.sourceforge.pavlov.user
Class ChapterData

java.lang.Object
  extended by net.sourceforge.pavlov.user.ChapterData

public final class ChapterData
extends Object

Encapsulates a users responses to all questions in a chapter.

See Also:
Chapter, BookData, QuestionData

Field Summary
protected  Vector<QuestionData> exclusion
          QuestionData's we don't want to ask
protected  int exclusionSize
          QuestionData's we don't want to ask
 
Constructor Summary
ChapterData()
          Creates a ChapterData with title "Untitled"
ChapterData(String title)
          Creates a ChapterData with the given title
 
Method Summary
 void addQuizData(QuizData quizData)
          Adds the given QuizData object to this ChapterData's QuizCollection.
 void addRight(String id)
          Adds a correct response to the named QuestionData at the current time.
 void addRight(String id, Date when)
          Adds a correct response to the named QuestionData at the given time.
 void addRight(String id, long when)
          Adds a correct response to the named QuestionData at the given time.
 void addWrong(String id)
          Adds an incorrect response to the named QuestionData at the current time.
 void addWrong(String id, Date when)
          Adds an incorrect response to the named QuestionData at the given time.
 void addWrong(String id, long whe)
          Adds an incorrect response to the named QuestionData at the given time.
 void deleteQuestionID(String key)
          Removes the QuestionData corresponding to the given ID.
 Collection getAllQuestionData()
          Describe getAllQuestionData method here.
 ChapterStatistics getChapterStatistics()
          Returns the ChapterStatistics for this ChapterData.
 int getExclusionSize()
          Returns the size of the exclusion vector.
 int getNumberOfQuestions()
          Returns the number of questions in this chapter.
 QuestionData getQuestion()
          Returns a QuestionData using the current strategy.
 QuestionData getQuestionData(String qid)
          Returns the QuestionData for the question with the given ID or null if no such question exists.
 QuizCollection getQuizCollection()
          Describe getQuizCollection method here.
 QuizCollectionData getQuizCollectionData()
          Returns data for all quizzes the user has taken on this chapter.
 Vector getQuizPercentages()
          Returns a vector of percentages for all the quizzes the user has taken on this chapter.
 QuizCollectionData getStatistics()
          Deprecated. Misleading name. Use getQuizCollectionData()
 AbstractStrategy getStrategy()
          Returns the current question selection strategy.
 String getTitle()
          Returns the title of the Chapter this ChapterData refers to.
 void setExclusionSize(int newSize)
          Sets the size of the exclusion vector.
 void setStrategy(AbstractStrategy strat)
          Sets the question selection strategy and initializes it with the QuestionData for this chapter.
 void setTitle(String title)
          Sets the title of the Chapter this ChapterData refers to.
 void toXML(Writer writer)
          Converts this ChapterData to XML.
 void validate(AbstractChapter cp)
          Loop through all the questions in the chapter, ensuring a QuestionData exists for each.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exclusion

protected Vector<QuestionData> exclusion
QuestionData's we don't want to ask


exclusionSize

protected int exclusionSize
QuestionData's we don't want to ask

Constructor Detail

ChapterData

public ChapterData(String title)
Creates a ChapterData with the given title

Parameters:
_title - a String value

ChapterData

public ChapterData()
Creates a ChapterData with title "Untitled"

Method Detail

setTitle

public void setTitle(String title)
Sets the title of the Chapter this ChapterData refers to.

Parameters:
t - a String value

getTitle

public String getTitle()
Returns the title of the Chapter this ChapterData refers to.

Returns:
a String value

getQuestionData

public QuestionData getQuestionData(String qid)
Returns the QuestionData for the question with the given ID or null if no such question exists.

Parameters:
qid - a String value
Returns:
a QuestionData value

addRight

public void addRight(String id)
Adds a correct response to the named QuestionData at the current time.

Parameters:
id - a String value

addWrong

public void addWrong(String id)
Adds an incorrect response to the named QuestionData at the current time.

Parameters:
id - a String value

getNumberOfQuestions

public int getNumberOfQuestions()
Returns the number of questions in this chapter.

Returns:
an int value

addRight

public void addRight(String id,
                     long when)
Adds a correct response to the named QuestionData at the given time.

Parameters:
id - a String value
whe - a long value

addWrong

public void addWrong(String id,
                     long whe)
Adds an incorrect response to the named QuestionData at the given time.

Parameters:
id - a String value
whe - a long value

addRight

public void addRight(String id,
                     Date when)
Adds a correct response to the named QuestionData at the given time.

Parameters:
id - a String value
when - a Date value

addWrong

public void addWrong(String id,
                     Date when)
Adds an incorrect response to the named QuestionData at the given time.

Parameters:
id - a String value
when - a Date value

validate

public void validate(AbstractChapter cp)
Loop through all the questions in the chapter, ensuring a QuestionData exists for each. If not, create a new QuestionData.

Parameters:
cp - an AbstractChapter value

getExclusionSize

public int getExclusionSize()
Returns the size of the exclusion vector.

Returns:
an int value

setExclusionSize

public void setExclusionSize(int newSize)
Sets the size of the exclusion vector.

Parameters:
i - an int value

getQuestion

public QuestionData getQuestion()
Returns a QuestionData using the current strategy. If no strategy is current, create a BasicStrategy and use it.

Returns:
a QuestionData value

getStrategy

public final AbstractStrategy getStrategy()
Returns the current question selection strategy.

Returns:
an AbstractStrategy value

setStrategy

public final void setStrategy(AbstractStrategy strat)
Sets the question selection strategy and initializes it with the QuestionData for this chapter.

Parameters:
strat - an AbstractStrategy value

getChapterStatistics

public ChapterStatistics getChapterStatistics()
Returns the ChapterStatistics for this ChapterData.

Returns:
a ChapterStatistics value

deleteQuestionID

public void deleteQuestionID(String key)
Removes the QuestionData corresponding to the given ID.

Parameters:
key - a String value

toXML

public void toXML(Writer writer)
           throws IOException
Converts this ChapterData to XML.

Parameters:
writer - a java.io.Writer value
Throws:
IOException - if an error occurs

addQuizData

public void addQuizData(QuizData quizData)
Adds the given QuizData object to this ChapterData's QuizCollection.

Parameters:
quizData - a QuizData value

getStatistics

@Deprecated
public QuizCollectionData getStatistics()
Deprecated. Misleading name. Use getQuizCollectionData()

Describe getStatistics method here.

Returns:
a QuizCollectionData value

getQuizCollectionData

public QuizCollectionData getQuizCollectionData()
Returns data for all quizzes the user has taken on this chapter.

Returns:
a QuizCollectionData value

getQuizPercentages

public Vector getQuizPercentages()
Returns a vector of percentages for all the quizzes the user has taken on this chapter.

Returns:
a Vector value

getQuizCollection

public QuizCollection getQuizCollection()
Describe getQuizCollection method here.

Returns:
a QuizCollection value

getAllQuestionData

public Collection getAllQuestionData()
Describe getAllQuestionData method here.

Returns:
a Collection value