All Packages Class Hierarchy This Package Previous Next Index
Class distans.PageData
java.lang.Object
|
+----java.util.Vector
|
+----distans.PageData
- public class PageData
- extends Vector
This class is responsible for storing of the QuestionPages. The data that have to be stored are the following.
and so on for all questions in the QuestionPage. The exception is the QuestionPages
of type written, as they don't have an AnswerText nor a Right answer Integer.
This could however be dealt by using dummy values.
Each QuestionPage is stored in one PageData. PageData extends
class java.util.Vector see Jdk for documentation. Each question
uses three elements in the Vector, a String for the QuestionText, a String
array for AnswerText and finally an integer for the RightAnswer. The Vector
thus has a structure like this.
String QuestionTextI <- element 0
String[] AnswerTextI <- element 1
Integer RightAnswerI <- element 2
String QuestionTextII <-element 3
String[] AnswerTextII <- element 4
Integer RightAnswerII <- element 5
.....
String QuestionTextN <- element (N-1)*3
String[] AnswerTextN <- element (N-1)*3 + 1
Integer RightAnswerN <- element (N-1)*3 + 2
The rest of the class has the following variables and methods:
Variables:
-
ALT
-
-
CROSS
-
-
feedback
- Is "auto" for QuestionPages that directly informs the student if he have
answered the questions correctly and "send" if the answers are saved on the server
-
NO_OF_DATA
-
-
scriptIsOnServer
- Is true if the QuestionPage is currently saved on the server
-
title
- The title of the page.
-
type
- The type of QuestionPage, could be ALT, CROSS or WRITTEN
-
TYPE_UNDEFINED
-
-
WRITTEN
-
-
PageData(String, int, String)
- Constructs an empty PageData
-
PageData(String, String, String)
- Constructor is like the other one except that type could be given as a String
-
addQuestion(String, String[], Integer)
- Adds a new Question to the PageData
-
answerIndex(int)
- This method is only used by PageData objects representing QuestionPages of type cross
-
convertType(String)
- Convert the type from String to the int representation used by PageData
-
getAnswerString(int)
-
-
getAnswerText(int, int)
-
-
getCorrectAnswer(int)
-
-
getFeedBack()
-
-
getNoOfLastFilledAlt(int)
-
-
getNoOfQuestions()
-
-
getQuestionText(int)
-
-
getScriptIsOnServer()
- Accesor method
-
getTitle()
-
-
getType()
-
-
hashCode()
-
-
isCorrect(int, int)
-
-
setCorrectAnswer(int, int)
- Sets the correct answer for a question
-
setCorrectAnswer(Integer, int)
- Sets the correct answer for a question
-
setFeedBack(String)
- Sets the feedback type used by the QuestionPage
-
setQuestion(String, String[], Integer, int)
- Changes the data for a question.
-
setRandomAnswers()
- Switches the right answers randomly for QuestionPages of type cross
-
setScriptIsOnServer(boolean)
- Tells the PageData object if the QuestionPage has been saved on or deleted from the server
-
setTitle(String)
-
title
String title
- The title of the page. The name used to identify the page on the server
type
int type
- The type of QuestionPage, could be ALT, CROSS or WRITTEN
NO_OF_DATA
final int NO_OF_DATA
feedback
String feedback
- Is "auto" for QuestionPages that directly informs the student if he have
answered the questions correctly and "send" if the answers are saved on the server
ALT
static final int ALT
CROSS
static final int CROSS
WRITTEN
static final int WRITTEN
TYPE_UNDEFINED
static final int TYPE_UNDEFINED
scriptIsOnServer
boolean scriptIsOnServer
- Is true if the QuestionPage is currently saved on the server
PageData
public PageData(String pageTitle,
int type,
String feedBack)
- Constructs an empty PageData
- Parameters:
- pageTitle - the title
- type - the type, CROSS,ALT, WRITTEN
- feedback - the feedback type "auto" or "send"
PageData
public PageData(String pageTitle,
String type,
String feedBack)
- Constructor is like the other one except that type could be given as a String
setScriptIsOnServer
public void setScriptIsOnServer(boolean s)
- Tells the PageData object if the QuestionPage has been saved on or deleted from the server
- Parameters:
- s - should be true if the QuestionPage is saved, false otherwise
getScriptIsOnServer
public boolean getScriptIsOnServer()
- Accesor method
convertType
public static int convertType(String s)
- Convert the type from String to the int representation used by PageData
- Parameters:
- s - the type to convert e.g. cross,alt or written
- Returns:
- the int representation
getTitle
public String getTitle()
- Returns:
- returns the title of the QuestionPage
setTitle
public void setTitle(String str)
- Parameters:
- sets - the title of the QuestionPage
setFeedBack
public void setFeedBack(String mode)
- Sets the feedback type used by the QuestionPage
- Parameters:
- mode - should be either "auto" or "send"
getFeedBack
public String getFeedBack()
- Returns:
- the feedback type for the QuestionPage
getNoOfQuestions
public int getNoOfQuestions()
- Returns:
- returns the number of questions in the QuestionPage
answerIndex
private int answerIndex(int crossAnswer)
- This method is only used by PageData objects representing QuestionPages of type cross
- Parameters:
- the - crossAnswer
- Returns:
- s the number of the question that has as correct answer crossAnswer
addQuestion
public void addQuestion(String questionText,
String answerText[],
Integer correctAnswer)
- Adds a new Question to the PageData
- Parameters:
- questionText - the QuestionText for the question
- answerText - the answer text, this should be only one Stirng for type cross. An array with the alternatives for type = alt and whatever for type written
- correctAnswer - the correctAnswer, the should be the row where the answer is placed for type = cross, the number of the right alternative for type =alt and -1 for type written
setQuestion
public void setQuestion(String questionText,
String answerText[],
Integer correctAnswer,
int i)
- Changes the data for a question.
- Parameters:
- questionText - the QuestionText for the question
- answerText - the answer text, this should be only one Stirng for type cross. An array with the alternatives for type = alt and whatever for type written
- correctAnswer - the correctAnswer, the should be the row where the answer is placed for type = cross, the number of the right alternative for type =alt and -1 for type written
getQuestionText
public String getQuestionText(int i)
- Returns:
- the QuestionText for question i
getCorrectAnswer
public int getCorrectAnswer(int i)
- Returns:
- the correct answer for question i
setCorrectAnswer
public void setCorrectAnswer(Integer correct,
int i)
- Sets the correct answer for a question
- Parameters:
- correct - the new answer
- i - the number of the question to set
setCorrectAnswer
public void setCorrectAnswer(int correct,
int i)
- Sets the correct answer for a question
- Parameters:
- correct - the new answer
- i - the number of the question to set
getNoOfLastFilledAlt
public int getNoOfLastFilledAlt(int i)
- Returns:
- s the number of alternative for an alt question
setRandomAnswers
public void setRandomAnswers()
- Switches the right answers randomly for QuestionPages of type cross
getAnswerText
public String getAnswerText(int i,
int studentAnswer)
- Parameters:
- i - the number of the question
- the - answer (not neccesarly correct)
- Returns:
- the AnswerText associated with an answer
getAnswerString
public String[] getAnswerString(int i)
- Returns:
- the answer to question number i
isCorrect
public boolean isCorrect(int i,
int studentAnswer)
- Parameters:
- i - the number of the question
- studentAnswer - the answer to be checked
- Returns:
- true if student answer was the correct answer to question i
getType
public int getType()
- Returns:
- the type of the QuestionPage
hashCode
public int hashCode()
- Returns:
- the hashCode for the QuestionPage, the hashCode is generated from the title.
- Overrides:
- hashCode in class Object
All Packages Class Hierarchy This Package Previous Next Index