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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations