use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class IQTESTCourseNode method createStatisticNodeResult.
@Override
public StatisticResourceResult createStatisticNodeResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, StatisticResourceOption options, QTIType... types) {
if (!isQTITypeAllowed(types))
return null;
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", courseId);
RepositoryEntry qtiTestEntry = getReferencedRepositoryEntry();
if (ImsQTI21Resource.TYPE_NAME.equals(qtiTestEntry.getOlatResource().getResourceableTypeName())) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(qtiTestEntry, courseEntry, getIdent());
boolean admin = userCourseEnv.isAdmin();
if (options.getParticipantsGroups() != null) {
searchParams.setLimitToGroups(options.getParticipantsGroups());
}
QTI21StatisticsSecurityCallback secCallback = new QTI21StatisticsSecurityCallback(admin, admin && isGuestAllowedForQTI21(qtiTestEntry));
return new QTI21StatisticResourceResult(qtiTestEntry, courseEntry, this, searchParams, secCallback);
}
QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(courseOres.getResourceableId(), getIdent());
searchParams.setLimitToGroups(options.getParticipantsGroups());
return new QTIStatisticResourceResult(courseOres, this, qtiTestEntry, searchParams);
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class IQTESTCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long courseResourceableId = course.getResourceableId();
// 1) prepare result export
CourseEnvironment courseEnv = course.getCourseEnvironment();
try {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
if (onyx) {
return true;
} else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
// 2a) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
// excel results
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
qaf.exportCourseElement(exportStream);
return true;
} else {
// 2b) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
// excel results
String shortTitle = getShortTitle();
QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
if (options != null && options.getExportFormat() != null) {
Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
for (Class<?> itemClass : itemTypes) {
itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
}
qef.setMapWithExportItemConfigs(itemConfigs);
}
return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
}
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class IQSELFCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
try {
if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
qaf.exportCourseElement(exportStream);
return true;
} else {
QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatterCSVType1 qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
qef.setAnonymous(true);
if (options != null && options.getExportFormat() != null) {
Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
for (Class<?> itemClass : itemTypes) {
itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
}
qef.setMapWithExportItemConfigs(itemConfigs);
}
return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
}
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class QTIArchiver method hasResults.
public boolean hasResults() {
if (results != null)
return results.booleanValue();
ICourse course = CourseFactory.loadCourse(courseOres);
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
boolean success = false;
if (ImsQTI21Resource.TYPE_NAME.equals(testRe.getOlatResource().getResourceableTypeName())) {
type = Type.qti21;
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
success = new QTI21ArchiveFormat(locale, searchParams).hasResults();
} else {
type = Type.qti12;
success = qrm.hasResultSets(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey());
}
results = Boolean.valueOf(success);
return success;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getAssessmentStatistics.
@Override
public StatisticAssessment getAssessmentStatistics(QTI21StatisticSearchParams searchParams) {
StringBuilder sb = new StringBuilder();
sb.append("select asession.score, asession.manualScore, asession.passed, asession.duration from qtiassessmenttestsession asession ");
decorateRSet(sb, searchParams, true);
sb.append(" order by asession.key asc");
TypedQuery<Object[]> rawDataQuery = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(rawDataQuery, searchParams);
List<Object[]> rawDatas = rawDataQuery.getResultList();
int numOfPassed = 0;
int numOfFailed = 0;
double totalDuration = 0.0;
double maxScore = 0.0;
double minScore = Double.MAX_VALUE;
double[] scores = new double[rawDatas.size()];
double[] durationSeconds = new double[rawDatas.size()];
double minDuration = Double.MAX_VALUE;
double maxDuration = 0d;
int dataPos = 0;
boolean hasScore = false;
for (Object[] rawData : rawDatas) {
int pos = 0;
BigDecimal score = (BigDecimal) rawData[pos++];
BigDecimal manualScore = (BigDecimal) rawData[pos++];
if (score == null) {
score = manualScore;
} else if (manualScore != null) {
score = score.add(manualScore);
}
if (score != null) {
double scored = score.doubleValue();
scores[dataPos] = scored;
maxScore = Math.max(maxScore, scored);
minScore = Math.min(minScore, scored);
hasScore = true;
}
Boolean passed = (Boolean) rawData[pos++];
if (passed != null) {
if (passed.booleanValue()) {
numOfPassed++;
} else {
numOfFailed++;
}
}
Long duration = (Long) rawData[pos++];
if (duration != null) {
double durationd = duration.doubleValue();
double durationSecond = Math.round(durationd / 1000d);
durationSeconds[dataPos] = durationSecond;
totalDuration += durationd;
minDuration = Math.min(minDuration, durationSecond);
maxDuration = Math.max(maxDuration, durationSecond);
}
dataPos++;
}
if (rawDatas.size() == 0) {
minScore = 0;
}
Statistics statisticsHelper = new Statistics(scores);
int numOfParticipants = rawDatas.size();
StatisticAssessment stats = new StatisticAssessment();
stats.setNumOfParticipants(numOfParticipants);
stats.setNumOfPassed(numOfPassed);
stats.setNumOfFailed(numOfFailed);
long averageDuration = Math.round(totalDuration / numOfParticipants);
stats.setAverageDuration(averageDuration);
stats.setAverage(statisticsHelper.getMean());
if (hasScore) {
double range = maxScore - minScore;
stats.setRange(range);
stats.setMaxScore(maxScore);
stats.setMinScore(minScore);
}
stats.setStandardDeviation(statisticsHelper.getStdDev());
stats.setMedian(statisticsHelper.median());
stats.setMode(statisticsHelper.mode());
stats.setScores(scores);
stats.setDurations(durationSeconds);
return stats;
}
Aggregations