use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project openolat by klemens.
the class QTI21StatisticResourceResult method getController.
public Controller getController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, TreeNode selectedNode, boolean printMode) {
if (selectedNode instanceof StatisticResourceNode) {
return createAssessmentController(ureq, wControl, stackPanel, printMode);
} else {
Object uobject = selectedNode.getUserObject();
if (uobject instanceof AssessmentItemRef) {
TreeNode parentNode = (TreeNode) selectedNode.getParent();
String sectionTitle = parentNode.getTitle();
return createAssessmentItemController(ureq, wControl, (AssessmentItemRef) uobject, sectionTitle, printMode);
} else if (uobject instanceof AssessmentTest) {
return createAssessmentController(ureq, wControl, stackPanel, printMode);
}
}
return null;
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getStatisticPerItem.
@Override
public List<AssessmentItemStatistic> getStatisticPerItem(ResolvedAssessmentTest resolvedAssessmentTest, QTI21StatisticSearchParams searchParams, double numOfParticipants) {
StringBuilder sb = new StringBuilder();
sb.append("select isession.assessmentItemIdentifier, isession.score, isession.manualScore, count(*) from qtiassessmentitemsession isession").append(" inner join isession.assessmentTestSession asession");
decorateRSet(sb, searchParams, true);
sb.append(" and isession.duration > 0").append(" group by isession.assessmentItemIdentifier, isession.score, isession.manualScore");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return new ArrayList<>();
}
Map<String, AssessmentItemRef> itemMap = new HashMap<>();
List<AssessmentItemRef> itemRefs = new ArrayList<>(resolvedAssessmentTest.getAssessmentItemRefs());
for (AssessmentItemRef itemRef : itemRefs) {
itemMap.put(itemRef.getIdentifier().toString(), itemRef);
}
Map<String, AssessmentItemHelper> identifierToHelpers = new HashMap<>();
for (Object[] result : results) {
int pos = 0;
String identifier = PersistenceHelper.extractString(result, pos++);
BigDecimal score = (BigDecimal) result[pos++];
BigDecimal manualScore = (BigDecimal) result[pos++];
Long count = PersistenceHelper.extractLong(result, pos++);
if (score == null || identifier == null || count == null) {
continue;
}
AssessmentItemHelper helper = identifierToHelpers.get(identifier);
if (helper == null) {
AssessmentItemRef itemRef = itemMap.get(identifier);
if (itemRef == null) {
continue;
}
ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (item == null) {
continue;
}
helper = new AssessmentItemHelper(item.getRootNodeLookup().extractIfSuccessful());
identifierToHelpers.put(identifier, helper);
}
helper.addCount(count);
if (manualScore != null) {
helper.addTotalScore(count, manualScore);
} else {
helper.addTotalScore(count, score);
}
if (helper.getMaxScore() != null) {
double maxValue = helper.getMaxScore().doubleValue();
if (Math.abs(score.doubleValue() - maxValue) < 0.0001) {
helper.addCorrectAnswers(count);
}
}
}
List<AssessmentItemStatistic> statistics = new ArrayList<>(identifierToHelpers.size());
for (AssessmentItemRef itemRef : itemRefs) {
AssessmentItemHelper helper = identifierToHelpers.get(itemRef.getIdentifier().toString());
if (helper != null) {
long numOfAnswersItem = helper.count;
long numOfCorrectAnswers = helper.countCorrectAnswers;
double average = (helper.totalScore / helper.count);
double averageParticipants = (helper.totalScore / numOfParticipants);
statistics.add(new AssessmentItemStatistic(helper.getAssessmentItem(), average, averageParticipants, numOfAnswersItem, numOfCorrectAnswers));
} else {
ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (item != null) {
statistics.add(new AssessmentItemStatistic(item.getRootNodeLookup().extractIfSuccessful(), 0.0d, 0.0d, 0l, 0l));
}
}
}
return statistics;
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method writeDataRow.
private void writeDataRow(int num, SessionResponses responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
int col = 0;
Row dataRow = exportSheet.newRow();
// sequence number
dataRow.addCell(col++, num, null);
AssessmentTestSession testSession = responses.getTestSession();
AssessmentEntry entry = testSession.getAssessmentEntry();
Identity assessedIdentity = entry.getIdentity();
// user properties
if (assessedIdentity == null) {
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
if (userPropertyHandlers.get(0) == userPropertyHandler) {
dataRow.addCell(col++, translator.translate("anonym.user"), null);
} else {
col++;
}
}
}
} else if (anonymizerCallback != null) {
String anonymizedName = anonymizerCallback.getAnonymizedUserName(assessedIdentity);
dataRow.addCell(col++, anonymizedName, null);
} else {
User assessedUser = assessedIdentity.getUser();
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
dataRow.addCell(col++, property, null);
}
}
}
// homepage
if (anonymizerCallback == null) {
String homepage;
if (entry.getIdentity() == null) {
homepage = "";
} else {
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry.getIdentity());
homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
}
dataRow.addCell(col++, homepage, null);
}
// course node points and passed
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured()) {
if (entry.getScore() != null) {
dataRow.addCell(col++, entry.getScore(), null);
} else {
col++;
}
}
if (assessableCourseNode.hasPassedConfigured()) {
if (entry.getPassed() != null) {
dataRow.addCell(col++, entry.getPassed().toString(), null);
} else {
col++;
}
}
}
// assesspoints, passed, ipaddress, date, duration
if (testSession.getScore() != null) {
dataRow.addCell(col++, testSession.getScore(), null);
} else {
col++;
}
if (testSession.getManualScore() != null) {
dataRow.addCell(col++, testSession.getManualScore(), null);
} else {
col++;
}
if (testSession.getFinalScore() != null) {
dataRow.addCell(col++, testSession.getFinalScore(), null);
} else {
col++;
}
if (testSession.getPassed() != null) {
dataRow.addCell(col++, testSession.getPassed().toString(), null);
} else {
col++;
}
if (anonymizerCallback == null) {
dataRow.addCell(col++, testSession.getCreationDate(), workbook.getStyles().getDateStyle());
}
dataRow.addCell(col++, toDurationInMilliseconds(testSession.getDuration()), null);
List<AbstractInfos> infos = getItemInfos();
for (int i = 0; i < infos.size(); i++) {
AbstractInfos info = infos.get(i);
if (info instanceof ItemInfos) {
ItemInfos item = (ItemInfos) info;
AssessmentItemRef itemRef = item.getAssessmentItemRef();
String itemRefIdentifier = itemRef.getIdentifier().toString();
AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
if (exportConfig.isResponseCols()) {
List<Interaction> interactions = item.getInteractions();
for (int j = 0; j < interactions.size(); j++) {
Interaction interaction = interactions.get(j);
AssessmentResponse response = responses.getResponse(itemRefIdentifier, interaction.getResponseIdentifier());
col = interactionArchiveMap.get(interaction.getQtiClassName()).writeInteractionData(item.getAssessmentItem(), response, interaction, j, dataRow, col, workbook);
}
}
// score, start, duration
if (itemSession == null) {
if (exportConfig.isPointCol()) {
col++;
}
if (exportConfig.isCommentCol()) {
col++;
}
if (exportConfig.isTimeCols()) {
col += anonymizerCallback != null ? 1 : 2;
}
} else {
if (exportConfig.isPointCol()) {
if (itemSession.getManualScore() != null) {
dataRow.addCell(col++, itemSession.getManualScore(), null);
} else {
dataRow.addCell(col++, itemSession.getScore(), null);
}
}
if (exportConfig.isCommentCol()) {
dataRow.addCell(col++, itemSession.getCoachComment(), null);
}
if (exportConfig.isTimeCols()) {
if (anonymizerCallback == null) {
dataRow.addCell(col++, itemSession.getCreationDate(), workbook.getStyles().getTimeStyle());
}
dataRow.addCell(col++, toDurationInMilliseconds(itemSession.getDuration()), null);
}
}
} else if (numOfSections > 1 && info instanceof SectionInfos) {
SectionInfos section = (SectionInfos) info;
if (!section.getItemInfos().isEmpty()) {
BigDecimal score = calculateSectionScore(responses, section);
if (score != null) {
dataRow.addCell(col++, score, workbook.getStyles().getLightGrayStyle());
} else {
col++;
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.
the class QTI21ArchiveFormat method collectElementInfos.
private void collectElementInfos(AssessmentSection section) {
numOfSections++;
SectionInfos sectionInfos = new SectionInfos(section);
elementInfos.add(sectionInfos);
List<SectionPart> parts = section.getChildAbstractParts();
for (SectionPart part : parts) {
if (part instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) part;
ResolvedAssessmentItem resolvedItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem item = resolvedItem.getRootNodeLookup().extractIfSuccessful();
if (item != null) {
ItemInfos itemInfo = new ItemInfos(itemRef, item, item.getItemBody().findInteractions());
elementInfos.add(itemInfo);
sectionInfos.getItemInfos().add(itemInfo);
}
} else if (part instanceof AssessmentSection) {
collectElementInfos((AssessmentSection) part);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityListController method loadModel.
private void loadModel(boolean reset, boolean lastSessions) {
if (lastSessions) {
model.loadLastSessions();
}
List<AssessmentItemRef> itemRefs = model.getResolvedAssessmentTest().getAssessmentItemRefs();
Map<String, AssessmentItemRef> identifierToItemRefMap = new HashMap<>();
for (AssessmentItemRef itemRef : itemRefs) {
identifierToItemRefMap.put(itemRef.getIdentifier().toString(), itemRef);
}
List<AssessmentItemSession> itemSessions = qtiService.getAssessmentItemSessions(model.getCourseEntry(), model.getSubIdent(), model.getTestEntry(), null);
Map<ItemSessionKey, AssessmentItemSession> itemSessionMap = new HashMap<>();
for (AssessmentItemSession itemSession : itemSessions) {
AssessmentTestSession candidateSession = itemSession.getAssessmentTestSession();
if (model.getReversedLastSessions().containsKey(candidateSession)) {
// the map contains all test sessions the user is allowed to correct
String itemRefIdentifier = itemSession.getAssessmentItemIdentifier();
itemSessionMap.put(new ItemSessionKey(candidateSession.getKey(), itemRefIdentifier), itemSession);
}
}
int count = 0;
List<CorrectionIdentityRow> rows = new ArrayList<>(model.getNumberOfAssessedIdentities());
Map<Identity, CorrectionIdentityRow> identityToRows = new HashMap<>();
for (Map.Entry<Identity, AssessmentTestSession> entry : model.getLastSessions().entrySet()) {
String user = translate("number.assessed.identity", new String[] { Integer.toString(++count) });
CorrectionIdentityRow row = new CorrectionIdentityRow(user, entry.getKey(), entry.getValue(), userPropertyHandlers, getLocale());
rows.add(row);
identityToRows.put(entry.getKey(), row);
TestSessionState testSessionState = model.getTestSessionStates().get(entry.getKey());
for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
String itemRefIdentifier = itemEntry.getKey().getIdentifier().toString();
AssessmentItemRef itemRef = identifierToItemRefMap.get(itemRefIdentifier);
AssessmentItemSession itemSession = itemSessionMap.get(new ItemSessionKey(entry.getValue().getKey(), itemRefIdentifier));
appendStatistics(row, itemSession, itemEntry.getValue(), itemRef);
}
}
tableModel.setObjects(rows);
tableEl.reset(reset, reset, true);
}
Aggregations