lecturequiz.server.main
Interface DBInterface

All Known Implementing Classes:
MySQLDB

public interface DBInterface


Method Summary
 User authenticateUser(java.lang.String username, java.lang.String password)
          Tries to authenticate a user against the database.
 FullQuestionInfo getQuestion(int id)
          Returns all information on the question with the supplied id
 java.util.List<FullQuestionInfo> getQuestionList()
          Returns a list of all available questions.
 Quiz getQuiz(int id)
          Returns the quiz with the given ID from the database
 java.util.ArrayList<QuizInfo> getQuizList()
          Returns a list of all available quizzes
 User getUser(int id)
          Returns a user from the database with the supplied ID.
 int saveQuiz(FullQuizInfo fqi, User user)
          Saves a quiz to the database
 

Method Detail

getQuizList

java.util.ArrayList<QuizInfo> getQuizList()
Returns a list of all available quizzes

Returns:
A list of QuizInfo objects containing information about a quiz or null if an error occurs.

authenticateUser

User authenticateUser(java.lang.String username,
                      java.lang.String password)
Tries to authenticate a user against the database.

Parameters:
username - Username sent to the database.
password - Password sent to the database.
Returns:
User object with the authenticated user. null if authentication fails

getUser

User getUser(int id)
Returns a user from the database with the supplied ID.

Parameters:
id - ID of the user to retrieve
Returns:
A User-object with teh requested user, or null if the user was not found

getQuiz

Quiz getQuiz(int id)
Returns the quiz with the given ID from the database

Parameters:
id - ID of the quiz
Returns:
Quiz with the given ID or null if the quiz was not found

getQuestionList

java.util.List<FullQuestionInfo> getQuestionList()
Returns a list of all available questions. The list will only contain the correct answer of a question

Returns:
A list of FullQuestionInfo objects containing the information for all questions

getQuestion

FullQuestionInfo getQuestion(int id)
Returns all information on the question with the supplied id

Parameters:
id - ID of the question to retrieve
Returns:
A FullQuestionInfo object with all information, or null on error

saveQuiz

int saveQuiz(FullQuizInfo fqi,
             User user)
Saves a quiz to the database

Parameters:
fqi - All information of the quiz to be saved. If the ID of a quiz is 0 the quiz will be created. If any questions have the ID 0 they will be created and answers of this question should be give ID's of 0-n and correctAnswer should point to one of these IDs.
user - The user trying to save the quiz. If this is not done by a logged in user this can be null.
Returns:
Error codes:
0 - Success
1 - No such quiz
2 - Invalid data
3 - Access denied
4 - Other error