fr.paris.lutece.plugins.quiz.service
Class QuizService

java.lang.Object
  extended by fr.paris.lutece.plugins.quiz.service.QuizService

public class QuizService
extends Object

Quiz Service


Field Summary
static String BEAN_QUIZ_SERVICE
          Name of the bean of QuizService
static String KEY_ERROR
          Error key
static String KEY_QUIZ
          Quiz key
static String PARAMETER_ACTION
          Action parameter
static String PLUGIN_NAME
          Name of the quiz plugin
static String PROPERTY_INPUT_PREFIX
          Input prefix property
 
Constructor Summary
QuizService()
           
 
Method Summary
 Map<String,Object> calculateQuizProfile(int nIdQuiz, Map<String,String[]> parameterMap, Locale locale)
          Compute the profile of a user from his answers
 Map<String,Object> calculateQuizStepProfile(Quiz quiz, int nIdCurrentStep, Map<String,String[]> mapResponsesCurrentStep, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Compute the profile of a user from his answers
 Quiz findQuizById(int nQuizId)
          Find a quiz by its primary key
 Map<String,Object> getQuiz(int nId)
          Gets a quiz as a model map
 Map<String,Object> getQuizList()
          Gets the list of quiz
 Map<String,Object> getQuizNextStep(Quiz quiz, int nOldStepId)
          Gets a quiz step as a model map
 Map<String,Object> getResults(int nIdQuiz, Map<String,String[]> parameterMap, Locale locale)
          Get results
 Map<String,Object> getStepResults(Quiz quiz, int nIdCurrentStep, Map<String,String[]> mapResponsesCurrentStep, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Get results for the current step
 Map<String,String[]> getUserAnswersForGroup(int nIdQuiz, int nIdOldStep, Map<String,String[]> parameterMap, Locale locale, fr.paris.lutece.portal.service.plugin.Plugin plugin)
          Get the answers of a user to questions of a quiz
 void processEndOfQuiz(Quiz quiz, String strScore, Map<String,String[]> userAnswers)
          Process the end of the quiz
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_QUIZ_SERVICE

public static final String BEAN_QUIZ_SERVICE
Name of the bean of QuizService

See Also:
Constant Field Values

KEY_QUIZ

public static final String KEY_QUIZ
Quiz key

See Also:
Constant Field Values

KEY_ERROR

public static final String KEY_ERROR
Error key

See Also:
Constant Field Values

PLUGIN_NAME

public static final String PLUGIN_NAME
Name of the quiz plugin

See Also:
Constant Field Values

PARAMETER_ACTION

public static final String PARAMETER_ACTION
Action parameter

See Also:
Constant Field Values

PROPERTY_INPUT_PREFIX

public static final String PROPERTY_INPUT_PREFIX
Input prefix property

See Also:
Constant Field Values
Constructor Detail

QuizService

public QuizService()
Method Detail

getQuizList

public Map<String,Object> getQuizList()
Gets the list of quiz

Returns:
The model

findQuizById

public Quiz findQuizById(int nQuizId)
Find a quiz by its primary key

Parameters:
nQuizId - The id of the quiz
Returns:
The quiz with the given id, or null if no quiz was found

getQuiz

public Map<String,Object> getQuiz(int nId)
Gets a quiz as a model map

Parameters:
nId - The quiz Id
Returns:
The model

getQuizNextStep

public Map<String,Object> getQuizNextStep(Quiz quiz,
                                          int nOldStepId)
Gets a quiz step as a model map

Parameters:
quiz - The quiz
nOldStepId - The id of the last displayed step, or 0 to display the first step
Returns:
The model

getUserAnswersForGroup

public Map<String,String[]> getUserAnswersForGroup(int nIdQuiz,
                                                   int nIdOldStep,
                                                   Map<String,String[]> parameterMap,
                                                   Locale locale,
                                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
Get the answers of a user to questions of a quiz

Parameters:
nIdQuiz - The id of the quiz to get answers of
nIdOldStep - The last validated step
parameterMap - The map of HTTP parameters
locale - The locale to use to display error messages
plugin - The plugin
Returns:
A map containing question ids as keys and user answers as values

getResults

public Map<String,Object> getResults(int nIdQuiz,
                                     Map<String,String[]> parameterMap,
                                     Locale locale)
Get results

Parameters:
nIdQuiz - The quiz Id
parameterMap - The parameters map
locale - The current locale
Returns:
a model as a map

getStepResults

public Map<String,Object> getStepResults(Quiz quiz,
                                         int nIdCurrentStep,
                                         Map<String,String[]> mapResponsesCurrentStep,
                                         Locale locale,
                                         fr.paris.lutece.portal.service.plugin.Plugin plugin)
Get results for the current step

Parameters:
quiz - The quiz
nIdCurrentStep - The id of the step
mapResponsesCurrentStep - The parameters map
locale - The current locale
plugin - The plugin
Returns:
a model as a map

calculateQuizProfile

public Map<String,Object> calculateQuizProfile(int nIdQuiz,
                                               Map<String,String[]> parameterMap,
                                               Locale locale)
Compute the profile of a user from his answers

Parameters:
nIdQuiz - The id of the answered quiz
parameterMap - The map containing answers
locale - The locale
Returns:
The model

calculateQuizStepProfile

public Map<String,Object> calculateQuizStepProfile(Quiz quiz,
                                                   int nIdCurrentStep,
                                                   Map<String,String[]> mapResponsesCurrentStep,
                                                   Locale locale,
                                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
Compute the profile of a user from his answers

Parameters:
quiz - The quiz
nIdCurrentStep - The id of the current step
mapResponsesCurrentStep - The map containing answers
locale - The locale
plugin - The plugin
Returns:
The model

processEndOfQuiz

public void processEndOfQuiz(Quiz quiz,
                             String strScore,
                             Map<String,String[]> userAnswers)
Process the end of the quiz

Parameters:
quiz - The quiz
nScore - the score
userAnswers - The answers made by the use


Copyright © 2014 Mairie de Paris. All Rights Reserved.