use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getChoiceInteractionStatistics.
@Override
public List<ChoiceStatistics> getChoiceInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, ChoiceInteraction choiceInteraction, QTI21StatisticSearchParams searchParams) {
List<RawData> results = getRawDatas(itemRefIdent, choiceInteraction.getResponseIdentifier().toString(), searchParams);
List<SimpleChoice> simpleChoices = choiceInteraction.getSimpleChoices();
long[] counts = new long[simpleChoices.size()];
for (int i = counts.length; i-- > 0; ) {
counts[i] = 0l;
}
for (RawData result : results) {
Long numOfAnswers = result.getCount();
;
if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
String stringuifiedResponse = result.getStringuifiedResponse();
for (int i = simpleChoices.size(); i-- > 0; ) {
String identifier = simpleChoices.get(i).getIdentifier().toString();
if (stringuifiedResponse.contains(identifier)) {
counts[i] += numOfAnswers.longValue();
}
}
}
}
List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
for (int i = 0; i < simpleChoices.size(); i++) {
choicesStatistics.add(new ChoiceStatistics(simpleChoices.get(i), counts[i]));
}
return choicesStatistics;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class QTI21ResetDataController method archiveData.
private void archiveData(RepositoryEntry testEntry) {
// backup
String archiveName = "qti21test_" + StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".zip";
Path exportPath = Paths.get(FolderConfig.getCanonicalRoot(), FolderConfig.getUserHomes(), getIdentity().getName(), "private", "archive", StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()), archiveName);
File exportFile = exportPath.toFile();
exportFile.getParentFile().mkdirs();
try (FileOutputStream fileStream = new FileOutputStream(exportFile);
ZipOutputStream exportStream = new ZipOutputStream(fileStream)) {
// author can do this, also they can archive all users and anonyme users
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testEntry, null, null, true, true);
new QTI21ArchiveFormat(getLocale(), searchParams).exportResource(exportStream);
} catch (IOException e) {
logError("", e);
}
}
Aggregations