Fork me on GitHub

CPD Results

The following document contains the results of PMD's CPD 5.5.1.

Duplications

File Line
fr/paris/lutece/plugins/quiz/business/QuizDAO.java 182
fr/paris/lutece/plugins/quiz/business/QuizDAO.java 219
        daoUtil.setInt( 1, nIdQuiz );
        daoUtil.executeQuery( );

        Quiz quiz = null;

        if ( daoUtil.next( ) )
        {
            quiz = new Quiz( );
            quiz.setIdQuiz( daoUtil.getInt( 1 ) );
            quiz.setName( daoUtil.getString( 2 ) );
            quiz.setIntroduction( daoUtil.getString( 3 ) );
            quiz.setConclusion( daoUtil.getString( 4 ) );
            quiz.setStatus( daoUtil.getInt( 5 ) );
            quiz.setActiveCaptcha( daoUtil.getInt( 6 ) );
            quiz.setActiveRequirement( daoUtil.getInt( 7 ) );
            quiz.setDateBeginDisponibility( daoUtil.getDate( 8 ) );
            quiz.setDateEndDisponibility( daoUtil.getDate( 9 ) );
            quiz.setDateCreation( daoUtil.getTimestamp( 10 ) );
            quiz.setCgu( daoUtil.getString( 11 ) );
            quiz.setTypeQuiz( daoUtil.getString( 12 ) );
            quiz.setDisplayStepByStep( daoUtil.getBoolean( 13 ) );
            quiz.setDisplayResultAfterEachStep( daoUtil.getBoolean( 14 ) );
        }

        daoUtil.free( );

        return quiz;
    }

    /**
     * load the data of Quiz from the table
     * 
     * @param plugin the plugin
     * @return The Instance of the object Quiz
     */
    public Quiz loadLastQuiz( Plugin plugin )
File Line
fr/paris/lutece/plugins/quiz/web/QuizJspBean.java 218
fr/paris/lutece/plugins/quiz/web/QuizJspBean.java 315
        String strType = request.getParameter( PARAMETER_TYPE );
        boolean bDisplayStepByStep = Boolean.parseBoolean( request.getParameter( PARAMETER_DISPLAY_STEP_BY_STEP ) );
        boolean bDisplayResultAfterEachStep = Boolean.parseBoolean( request
                .getParameter( PARAMETER_DISPLAY_RESULTS_AFTER_EACH_STEP ) );

        java.util.Date tDateBeginDisponibility = null;
        tDateBeginDisponibility = DateUtil.formatDate( strDateBeginDisponibility, getLocale( ) );

        String strDateEndDisponibility = request.getParameter( PARAMETER_DATE_END_DISPONIBILITY );
        java.util.Date tDateEndDisponibility = null;
        tDateEndDisponibility = DateUtil.formatDate( strDateEndDisponibility, getLocale( ) );

        int nCaptcha;
        int nRequirement;

        if ( request.getParameter( PARAMETER_ACTIVE_CAPTCHA ) == null )
        {
            nCaptcha = 0;
        }
        else
        {
            nCaptcha = Integer.parseInt( request.getParameter( PARAMETER_ACTIVE_CAPTCHA ) );
        }

        if ( request.getParameter( PARAMETER_ACTIVE_REQUIREMENT ) == null )
        {
            nRequirement = 0;
        }
        else
        {
            nRequirement = Integer.parseInt( request.getParameter( PARAMETER_ACTIVE_REQUIREMENT ) );
        }

        Quiz quiz = new Quiz( );
File Line
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 188
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 269
        daoUtil.setInt( 2, nIdQuiz );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            QuestionGroup group = new QuestionGroup( );

            group.setIdGroup( daoUtil.getInt( 1 ) );
            group.setLabelGroup( daoUtil.getString( 2 ) );
            group.setSubject( daoUtil.getString( 3 ) );
            group.setIdQuiz( daoUtil.getInt( 4 ) );
            group.setPositionGroup( daoUtil.getInt( 5 ) );
            group.setIsFreeHtml( daoUtil.getBoolean( 6 ) );
            group.setHtmlContent( daoUtil.getString( 7 ) );
            group.setIdImage( daoUtil.getInt( 8 ) );
            group.setDisplayScore( daoUtil.getBoolean( 9 ) );

            groupList.add( group );
        }

        daoUtil.free( );

        return groupList;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void delete( int nIdQuiz, int nGroupId, Plugin plugin )
File Line
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 156
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 336
        if ( daoUtil.next( ) )
        {
            group = new QuestionGroup( );

            group.setIdGroup( daoUtil.getInt( 1 ) );
            group.setLabelGroup( daoUtil.getString( 2 ) );
            group.setSubject( daoUtil.getString( 3 ) );
            group.setIdQuiz( daoUtil.getInt( 4 ) );
            group.setPositionGroup( daoUtil.getInt( 5 ) );
            group.setIsFreeHtml( daoUtil.getBoolean( 6 ) );
            group.setHtmlContent( daoUtil.getString( 7 ) );
            group.setIdImage( daoUtil.getInt( 8 ) );
            group.setDisplayScore( daoUtil.getBoolean( 9 ) );
        }

        daoUtil.free( );

        return group;
    }
File Line
fr/paris/lutece/plugins/quiz/service/QuizService.java 299
fr/paris/lutece/plugins/quiz/service/QuizService.java 386
            String strUserAnswer = values[0];

            if ( strUserAnswer != null )
            {
                int nUserAnswer = Integer.parseInt( strUserAnswer );
                Answer answer = AnswerHome.findByPrimaryKey( nUserAnswer, getPlugin( ) );

                // We add every answers to the map, whether they are correct or not.
                UserAnswer userAnswer = new UserAnswer( );
                userAnswer.setQuestionId( question.getIdQuestion( ) );
                userAnswer.setQuestion( question.getQuestionLabel( ) );
                userAnswer.setExplaination( question.getExplaination( ) );
                userAnswer.setAnswer( answer.getLabelAnswer( ) );
                listUserAnswers.add( userAnswer );

                if ( answer.isCorrect( ) )
                {
                    userAnswer.setIsValid( true );
                    nScore++;
                }
            }
            mapQuestionImages.put( strQuestionId, question.getIdImage( ) );
        }
File Line
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 210
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 304
        DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_QUESTIONS, plugin );
        daoUtil.setInt( 1, nIdQuiz );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            QuizQuestion quizQuestion = new QuizQuestion( );
            quizQuestion.setIdQuestion( daoUtil.getInt( 1 ) );
            quizQuestion.setQuestionLabel( daoUtil.getString( 2 ) );
            quizQuestion.setIdQuiz( daoUtil.getInt( 3 ) );
            quizQuestion.setIdGroup( daoUtil.getInt( 4 ) );
            quizQuestion.setExplaination( daoUtil.getString( 5 ) );
            quizQuestion.setIdImage( daoUtil.getInt( 6 ) );

            questionList.add( quizQuestion );
        }

        daoUtil.free( );

        return questionList;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Collection<Integer> getVerifyQuestionsByGroup( int nIdQuiz, int nIdGroup, Plugin plugin )
File Line
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 211
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 263
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 305
        daoUtil.setInt( 1, nIdQuiz );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            QuizQuestion quizQuestion = new QuizQuestion( );
            quizQuestion.setIdQuestion( daoUtil.getInt( 1 ) );
            quizQuestion.setQuestionLabel( daoUtil.getString( 2 ) );
            quizQuestion.setIdQuiz( daoUtil.getInt( 3 ) );
            quizQuestion.setIdGroup( daoUtil.getInt( 4 ) );
            quizQuestion.setExplaination( daoUtil.getString( 5 ) );
            quizQuestion.setIdImage( daoUtil.getInt( 6 ) );

            questionList.add( quizQuestion );
        }

        daoUtil.free( );

        return questionList;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Collection<Integer> getVerifyQuestionsByGroup( int nIdQuiz, int nIdGroup, Plugin plugin )
File Line
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 158
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 193
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 274
fr/paris/lutece/plugins/quiz/business/QuestionGroupDAO.java 338
            group = new QuestionGroup( );

            group.setIdGroup( daoUtil.getInt( 1 ) );
            group.setLabelGroup( daoUtil.getString( 2 ) );
            group.setSubject( daoUtil.getString( 3 ) );
            group.setIdQuiz( daoUtil.getInt( 4 ) );
            group.setPositionGroup( daoUtil.getInt( 5 ) );
            group.setIsFreeHtml( daoUtil.getBoolean( 6 ) );
            group.setHtmlContent( daoUtil.getString( 7 ) );
            group.setIdImage( daoUtil.getInt( 8 ) );
            group.setDisplayScore( daoUtil.getBoolean( 9 ) );
File Line
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 263
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 335
        daoUtil.setInt( 1, nIdGroup );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            QuizQuestion quizQuestion = new QuizQuestion( );
            quizQuestion.setIdQuestion( daoUtil.getInt( 1 ) );
            quizQuestion.setQuestionLabel( daoUtil.getString( 2 ) );
            quizQuestion.setIdQuiz( daoUtil.getInt( 3 ) );
            quizQuestion.setIdGroup( daoUtil.getInt( 4 ) );
            quizQuestion.setExplaination( daoUtil.getString( 5 ) );
            quizQuestion.setIdImage( daoUtil.getInt( 6 ) );

            questionList.add( quizQuestion );
        }

        daoUtil.free( );

        return questionList;
    }
File Line
fr/paris/lutece/plugins/quiz/service/QuizService.java 283
fr/paris/lutece/plugins/quiz/service/QuizService.java 432
        Map<String, Integer> mapQuestionImages = new HashMap<String, Integer>( questionsList.size( ) );

        for ( QuizQuestion question : questionsList )
        {
            String strQuestionId = String.valueOf( question.getIdQuestion( ) );
            String[] values = parameterMap.get( strQuestionId );

            if ( values == null )
            {
                String strMsgNoAnswserForQuestion = I18nService.getLocalizedString( PROPERTY_NO_ANSWER_FOR_QUESTION,
                        locale );
                model.put( KEY_ERROR, strMsgNoAnswserForQuestion + question.getQuestionLabel( ) );

                return model;
            }

            String strUserAnswer = values[0];

            if ( strUserAnswer != null )
            {
                int nUserAnswer = Integer.parseInt( strUserAnswer );
                Answer answer = AnswerHome.findByPrimaryKey( nUserAnswer, getPlugin( ) );
File Line
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 137
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 164
        daoUtil.setInt( 1, nIdQuizQuestion );
        daoUtil.executeQuery( );

        QuizQuestion quizQuestion = null;

        if ( daoUtil.next( ) )
        {
            quizQuestion = new QuizQuestion( );
            quizQuestion.setIdQuestion( daoUtil.getInt( 1 ) );
            quizQuestion.setQuestionLabel( daoUtil.getString( 2 ) );
            quizQuestion.setIdQuiz( daoUtil.getInt( 3 ) );
            quizQuestion.setIdGroup( daoUtil.getInt( 4 ) );
            quizQuestion.setExplaination( daoUtil.getString( 5 ) );
            quizQuestion.setIdImage( daoUtil.getInt( 6 ) );
        }

        daoUtil.free( );

        return quizQuestion;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public QuizQuestion loadLastQuestion( Plugin plugin )
File Line
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 211
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 305
fr/paris/lutece/plugins/quiz/business/QuizQuestionDAO.java 335
        daoUtil.setInt( 1, nIdQuiz );
        daoUtil.executeQuery( );

        while ( daoUtil.next( ) )
        {
            QuizQuestion quizQuestion = new QuizQuestion( );
            quizQuestion.setIdQuestion( daoUtil.getInt( 1 ) );
            quizQuestion.setQuestionLabel( daoUtil.getString( 2 ) );
            quizQuestion.setIdQuiz( daoUtil.getInt( 3 ) );
            quizQuestion.setIdGroup( daoUtil.getInt( 4 ) );
            quizQuestion.setExplaination( daoUtil.getString( 5 ) );
            quizQuestion.setIdImage( daoUtil.getInt( 6 ) );

            questionList.add( quizQuestion );
        }

        daoUtil.free( );

        return questionList;
    }