Search in sources :

Example 1 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project openolat by klemens.

the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.

/**
 * calculates the percentage of participants that answered a answer option
 * correctly.<br>
 * Number at index 0 = answer option 1, Number at index 1 = answer option 2,
 * etc.
 *
 * @param item
 * @param numberOfParticipants
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(answerIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        percentageRightAnswered.add(new StatisticChoiceOption(response, num));
    }
    return percentageRightAnswered;
}
Also used : StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Example 2 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project openolat by klemens.

the class QTIStatisticsManagerImpl method getNumOfAnswersPerSingleChoiceAnswerOption.

/**
 * calculates how many participants selected answer option 1 and/or option 2
 * and/or option 3...
 *
 * @param aQuestion
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfAnswersPerSingleChoiceAnswerOption(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> answerOptions = item.getQuestion().getResponses();
    List<StatisticChoiceOption> numOfAnswersPerOption = new ArrayList<>();
    for (int i = 0; i < answerOptions.size(); i++) {
        Response response = answerOptions.get(i);
        String responseIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(responseIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        numOfAnswersPerOption.add(new StatisticChoiceOption(response, num));
    }
    return numOfAnswersPerOption;
}
Also used : StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Example 3 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project openolat by klemens.

the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsOfItem.

private List<StatisticAnswerOption> getStatisticAnswerOptionsOfItem(String itemIdent, QTIStatisticSearchParams searchParams, boolean groupBy) {
    // the group by of mysql is case insensitive
    if (!groupBy && !dbInstance.getDbVendor().equals("mysql")) {
        groupBy = true;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select res.answer, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
    decorateRSet(sb, searchParams);
    sb.append(" and res.itemIdent=:itemIdent and res.duration > 0 ");
    if (groupBy) {
        sb.append("group by res.answer");
    } else {
        sb.append("group by res.key");
    }
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("itemIdent", itemIdent);
    decorateRSetQuery(query, searchParams);
    List<Object[]> results = query.getResultList();
    if (results.isEmpty()) {
        return Collections.emptyList();
    }
    List<StatisticAnswerOption> answerToNumberList = new ArrayList<>();
    for (Object[] result : results) {
        String answer = (String) result[0];
        Long numOfAnswers = (Long) result[1];
        answerToNumberList.add(new StatisticAnswerOption(answer, numOfAnswers.longValue()));
    }
    return answerToNumberList;
}
Also used : StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) ArrayList(java.util.ArrayList)

Example 4 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsOfItem.

private List<StatisticAnswerOption> getStatisticAnswerOptionsOfItem(String itemIdent, QTIStatisticSearchParams searchParams, boolean groupBy) {
    // the group by of mysql is case insensitive
    if (!groupBy && !dbInstance.getDbVendor().equals("mysql")) {
        groupBy = true;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select res.answer, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
    decorateRSet(sb, searchParams);
    sb.append(" and res.itemIdent=:itemIdent and res.duration > 0 ");
    if (groupBy) {
        sb.append("group by res.answer");
    } else {
        sb.append("group by res.key");
    }
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("itemIdent", itemIdent);
    decorateRSetQuery(query, searchParams);
    List<Object[]> results = query.getResultList();
    if (results.isEmpty()) {
        return Collections.emptyList();
    }
    List<StatisticAnswerOption> answerToNumberList = new ArrayList<>();
    for (Object[] result : results) {
        String answer = (String) result[0];
        Long numOfAnswers = (Long) result[1];
        answerToNumberList.add(new StatisticAnswerOption(answer, numOfAnswers.longValue()));
    }
    return answerToNumberList;
}
Also used : StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) ArrayList(java.util.ArrayList)

Example 5 with StatisticAnswerOption

use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.

/**
 * calculates the percentage of participants that answered a answer option
 * correctly.<br>
 * Number at index 0 = answer option 1, Number at index 1 = answer option 2,
 * etc.
 *
 * @param item
 * @param numberOfParticipants
 * @param olatResource
 * @param olatResourceDetail
 * @return
 */
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
    List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
    List<Response> responses = item.getQuestion().getResponses();
    List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
    for (Response response : responses) {
        String answerIdent = response.getIdent();
        long num = 0;
        for (StatisticAnswerOption answerToNumber : answerToNumberList) {
            String answer = answerToNumber.getAnswer();
            if (answer.indexOf(answerIdent) >= 0) {
                num += answerToNumber.getCount();
            }
        }
        percentageRightAnswered.add(new StatisticChoiceOption(response, num));
    }
    return percentageRightAnswered;
}
Also used : StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticAnswerOption(org.olat.ims.qti.statistics.model.StatisticAnswerOption) StatisticChoiceOption(org.olat.ims.qti.statistics.model.StatisticChoiceOption) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)10 StatisticAnswerOption (org.olat.ims.qti.statistics.model.StatisticAnswerOption)10 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)8 Response (org.olat.ims.qti.editor.beecom.objects.Response)8 StatisticSurveyItemResponse (org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)8 StatisticChoiceOption (org.olat.ims.qti.statistics.model.StatisticChoiceOption)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StatisticFIBOption (org.olat.ims.qti.statistics.model.StatisticFIBOption)2 StatisticKPrimOption (org.olat.ims.qti.statistics.model.StatisticKPrimOption)2