lecturequiz.server.service
Class LectureQuizService

java.lang.Object
  extended by lecturequiz.server.service.LectureQuizService

public class LectureQuizService
extends java.lang.Object


Constructor Summary
LectureQuizService()
           
 
Method Summary
 int authenticate(java.lang.String username, java.lang.String password, boolean auth)
          Authenticate and create a session.
 int endQuiz()
          Ends the quiz the calling user is running
 int getAvailableGameModes(javax.xml.ws.Holder<java.util.List<GameModeInfo>> gameModes)
          Get a list of supported game modes on the server
 int getAvailableQuizzes(javax.xml.ws.Holder<java.util.List<QuizInfo>> quizzes)
          Get a list of the available quizzes
 int getCurrentGameStatus(javax.xml.ws.Holder<GameStatus> gameStatus)
          Get the status of the current game Can only be called by teacher clients.
 int getCurrentQuestion(javax.xml.ws.Holder<QuestionInfo> info)
          Returns the current question in the quiz
 int getGameModeInfo(java.lang.String quizCode, javax.xml.ws.Holder<GameModeInfo> info)
          Returns the running game mode of the supplied quiz code
 int getOverallStatistics(javax.xml.ws.Holder<java.util.List<StatisticsEntry>> stats)
          Get the overall statistics from the entire game
 int getQuestion(int id, javax.xml.ws.Holder<FullQuestionInfo> info)
           
 int getQuestionList(javax.xml.ws.Holder<java.util.List<FullQuestionInfo>> info)
          Returns a list of all questions stored in the database.
 int getQuestionStatistics(javax.xml.ws.Holder<java.util.List<StatisticsEntry>> stats)
          Get statistics for the last question answered
 int getQuiz(int id, javax.xml.ws.Holder<FullQuizInfo> quizInfo)
          Retrieve a full quiz with all questions and answers, used for editing Can only be called by teachers and admins
 int getServiceVersion(javax.xml.ws.Holder<java.lang.String> version)
          Get the version of lecture quiz this server is running
 int joinQuiz(java.lang.String quizCode, java.util.List<ParameterEntry> parameters)
          Attempt to join a quiz with the supplied quiz code
 int newQuiz(java.lang.String gameMode, int quizId, java.lang.String quizCode, java.util.List<ParameterEntry> parameters)
          Start a new quiz on the server.
 int saveQuiz(FullQuizInfo quizInfo)
          Saves a quiz
 int startNextQuestion(javax.xml.ws.Holder<QuestionInfo> info)
          Starts the next question.
 int submitAnswer(int answerId)
          Submits an answer to the current quiz.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LectureQuizService

public LectureQuizService()
Method Detail

authenticate

public int authenticate(java.lang.String username,
                        java.lang.String password,
                        boolean auth)
Authenticate and create a session.

Parameters:
username - The username to be used in the game.
password - A password to authenticate with.
auth - Set to true if the user should try to authenticate with the password, otherwise just check for username availability and log in as a normal student.
Returns:
Error codes:
0 - Success
1 - Authentication failed.
2 - Username already in use.
3 - Invalid parameters

getAvailableQuizzes

public int getAvailableQuizzes(javax.xml.ws.Holder<java.util.List<QuizInfo>> quizzes)
Get a list of the available quizzes

Parameters:
quizzes - OUT: An ArrayList of QuizInfo objects populated by this function in the form of a Hoder type.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - Error occurred on the server

getAvailableGameModes

public int getAvailableGameModes(javax.xml.ws.Holder<java.util.List<GameModeInfo>> gameModes)
Get a list of supported game modes on the server

Parameters:
gameModes -
Returns:
Error codes:
0 - Success

newQuiz

public int newQuiz(java.lang.String gameMode,
                   int quizId,
                   java.lang.String quizCode,
                   java.util.List<ParameterEntry> parameters)
Start a new quiz on the server. Does not start the first question.

Parameters:
gameMode - ID of the game mode to use with this quiz
quizId - ID of the quiz to start
quizCode - The code clients should supplement to join this quiz
parameters - Custom parameters sent to the game mode on creation. Can be null.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - Quiz code in use
5 - Unsupported game mode
6 - Quiz not found
7 - Invalid parameters

startNextQuestion

public int startNextQuestion(javax.xml.ws.Holder<QuestionInfo> info)
Starts the next question. This function is only available to authenticated users.

Parameters:
info - OUT: The question information of the question to be displayed is placed in this object.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No active quiz
5 - No more questions in this quiz
6 - Another question is currently active

getCurrentQuestion

public int getCurrentQuestion(javax.xml.ws.Holder<QuestionInfo> info)
Returns the current question in the quiz

Parameters:
info - OUT: The question information is placed in this object.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - No active quiz
4 - Cannot get question at this time
5 - No more questions in the quiz

getGameModeInfo

public int getGameModeInfo(java.lang.String quizCode,
                           javax.xml.ws.Holder<GameModeInfo> info)
Returns the running game mode of the supplied quiz code

Parameters:
quizCode - the code of the quiz to check
info - the game mode info is stored in this object
Returns:
Error codes:
0 - Success 1 - No such quiz

joinQuiz

public int joinQuiz(java.lang.String quizCode,
                    java.util.List<ParameterEntry> parameters)
Attempt to join a quiz with the supplied quiz code

Parameters:
quizCode - A code that identifies the quiz you want to join
parameters - Custom parameters sent to the game mode on join. Can be null.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - No such quiz
4 - Join denied

submitAnswer

public int submitAnswer(int answerId)
Submits an answer to the current quiz.

Parameters:
answerId - The ID of the answer.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Not a part of any quiz
4 - Not a valid answer
5 - User has already answered
6 - Quiz does not accept answers at this time

endQuiz

public int endQuiz()
Ends the quiz the calling user is running

Returns:
Error codes:
0 - Success 1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No active quiz

getQuestionStatistics

public int getQuestionStatistics(javax.xml.ws.Holder<java.util.List<StatisticsEntry>> stats)
Get statistics for the last question answered

Parameters:
stats - the statistics are places in this holder
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - No active quiz
4 - Cannot get statistics at this time

getOverallStatistics

public int getOverallStatistics(javax.xml.ws.Holder<java.util.List<StatisticsEntry>> stats)
Get the overall statistics from the entire game

Parameters:
stats - The statistics are placed in this holder
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - No active quiz
4 - Cannot get statistics at this time

getCurrentGameStatus

public int getCurrentGameStatus(javax.xml.ws.Holder<GameStatus> gameStatus)
Get the status of the current game Can only be called by teacher clients.

Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No active quiz

getQuiz

public int getQuiz(int id,
                   javax.xml.ws.Holder<FullQuizInfo> quizInfo)
Retrieve a full quiz with all questions and answers, used for editing Can only be called by teachers and admins

Parameters:
id - ID of the quiz to retrieve
quizInfo - The quiz information will be placed in this object
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No such quiz

getQuestionList

public int getQuestionList(javax.xml.ws.Holder<java.util.List<FullQuestionInfo>> info)
Returns a list of all questions stored in the database. Used in conjunction with quiz editing.

Parameters:
info - A list of FullQuestionInfo objects. The questions are stored in these objects. Be aware that only the correct answer is added to the list of answers in this section to increase performance.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - Could not get list from DB

getQuestion

public int getQuestion(int id,
                       javax.xml.ws.Holder<FullQuestionInfo> info)
Parameters:
id -
info -
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No such question

saveQuiz

public int saveQuiz(FullQuizInfo quizInfo)
Saves a quiz

Parameters:
quizInfo - the information about the quiz to save. If the FullQuizInfo.id is 0 a new quiz is created. A user with the role of teacher can only save his own quiz. Any question with the id of 0 is also created, answers should then be listed with ids of 0-n and correctAnswer should point to these ids.
Returns:
Error codes:
0 - Success
1 - Could not find a valid session
2 - Not logged in
3 - Access denied
4 - No such quiz
5 - Invalid data
6 - Unknown error

getServiceVersion

public int getServiceVersion(javax.xml.ws.Holder<java.lang.String> version)
Get the version of lecture quiz this server is running

Parameters:
version - The version number is put into this variable
Returns:
Error codes:
0 - Success