All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class distans.AnswerData

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----java.util.Hashtable
                   |
                   +----distans.AnswerData

public class AnswerData
extends Hashtable
This class is responsible for storing the students answers. The class extends hashtable, the hashtable uses a PageData object as key. The key is associated to a String array that holds the answers and the grade. The String array thus has an structure like this answerI,gradeI,answerII,gradeII and so on.
For QuestionPages of type cross and alt the answers strings are integers, for written though a text string is used. The AnswerData also hold two Class variable (static) vectors with the cedulas and the name of the students as well as a hashtable for mapping between name and cedula.


Variable Index

 o ALT
 o cedulaNo
The CedulaNo of the student
 o CROSS
 o nameToCedulaHT
Hashtable with key == name value == cedula
 o NO_OF_DATA
 o studentCedulas
Static vector with all the cedulas
 o studentName
The name of the student (both first and last name)
 o studentNames
Static vector with all the student names
 o UNDEFINED_TYPE
 o WRITTEN

Constructor Index

 o AnswerData(String)
 o AnswerData(String, String, String)
Created a new AnswerData for a student, the first and last name are put in one string with space separating them.

Method Index

 o addStudentCedula(String)
A very primitive sort function, but it's only done once so no big deal.
 o addStudentName(String)
A very primitive sort function, but it's only done once so no big deal.
 o getGrade(PageData, int)
 o getNoOfCorrects(PageData)
 o getStudentAnswerNumerical(PageData, int)
 o getStudentAnswerText(PageData, int)
 o getStudentCedulas()
Static method returning all the student cedulas
 o getStudentName()
 o getStudentNames()
Static method returning all the student names
 o hasAnswered(PageData)
 o hashCode()
The hashcode is taken from the cedula number.
 o nameToCedula(String)
 o parseCedula(String)
Static method that parse a String into an int, if the String can't be parsed 0 is returned.
 o putStudentAnswers(PageData, String[])
puts a String array with the answers that the student has given for the PageData object into the hashtable
 o setGrade(PageData, int, int)
Sets the grade
 o setStudentName(String)
Sets the name of the student
 o toString()
This method writes the AnswerData on a String, used for debugging

Variables

 o ALT
 static final int ALT
 o CROSS
 static final int CROSS
 o WRITTEN
 static final int WRITTEN
 o UNDEFINED_TYPE
 static final int UNDEFINED_TYPE
 o NO_OF_DATA
 static final int NO_OF_DATA
 o cedulaNo
 private String cedulaNo
The CedulaNo of the student

 o studentCedulas
 static Vector studentCedulas
Static vector with all the cedulas

 o studentNames
 static Vector studentNames
Static vector with all the student names

 o nameToCedulaHT
 static Hashtable nameToCedulaHT
Hashtable with key == name value == cedula

 o studentName
 private String studentName
The name of the student (both first and last name)

Constructors

 o AnswerData
 public AnswerData(String cedulaNo,
                   String studentFirstName,
                   String studentLastName)
Created a new AnswerData for a student, the first and last name are put in one string with space separating them.

Parameters:
cedulaNo - the cedula number
studentFirstName - the First name of the student
studentLastName - the students family name.
 o AnswerData
 public AnswerData(String cedula)

Methods

 o hashCode
 public int hashCode()
The hashcode is taken from the cedula number.

Overrides:
hashCode in class Object
 o nameToCedula
 public static String nameToCedula(String name)
Parameters:
name - a student name
Returns:
the cedula number for a student name
 o toString
 public String toString()
This method writes the AnswerData on a String, used for debugging

Overrides:
toString in class Hashtable
 o getStudentAnswerNumerical
 public int getStudentAnswerNumerical(PageData pd,
                                      int question)
Parameters:
pd - a PageData object for a QuestionPage
question - the number of the subquestion on the QuestionPage
Returns:
the numerical answer given by the student for PageData pd and subquestion question. This method don't have a lot of meaning for QuestionPAges of type written.
 o getStudentAnswerText
 public String getStudentAnswerText(PageData pd,
                                    int question)
Returns:
the String answer for subquestion question and the given PageData object This is not nessecarally the correct answer.
 o getGrade
 public int getGrade(PageData pd,
                     int question)
Returns:
the grade for the given subquestion and PageData. This is however not used in the current version has there is no way to save the grades on the server.
 o setGrade
 public void setGrade(PageData pd,
                      int question,
                      int grade)
Sets the grade

Parameters:
pd - the PageData containing the questions
question - the subquestion
grade - the new grade
See Also:
getGrade
 o hasAnswered
 public boolean hasAnswered(PageData pd)
Returns:
true if a student has responded to the QuestionPage given by the PageData object
 o getNoOfCorrects
 public int getNoOfCorrects(PageData pd)
Returns:
the number of correctly answered subquestions for the QuestionPage given by the PageData object.
 o putStudentAnswers
 public void putStudentAnswers(PageData pd,
                               String answers[])
puts a String array with the answers that the student has given for the PageData object into the hashtable

 o getStudentName
 public String getStudentName()
Returns:
the name of the student
 o setStudentName
 public void setStudentName(String name)
Sets the name of the student

Parameters:
name - the students name
 o parseCedula
 static int parseCedula(String cedula)
Static method that parse a String into an int, if the String can't be parsed 0 is returned.

Parameters:
cedula - the String to parse
Returns:
the int parsed
 o getStudentNames
 public static Enumeration getStudentNames()
Static method returning all the student names

 o getStudentCedulas
 public static Enumeration getStudentCedulas()
Static method returning all the student cedulas

 o addStudentCedula
 private static void addStudentCedula(String cedula)
A very primitive sort function, but it's only done once so no big deal. It sorts the studentCedulas vector nummerically

 o addStudentName
 private static void addStudentName(String name)
A very primitive sort function, but it's only done once so no big deal. It sorts the studentNames Vector alphabetically.


All Packages  Class Hierarchy  This Package  Previous  Next  Index