use of org.olat.ims.qti21.AssessmentItemSession in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityAssessmentItemListController method loadModel.
private void loadModel(boolean reset) {
ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
identifierToRefs.put(itemRef.getIdentifier(), itemRef);
}
List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(candidateSession);
Map<String, AssessmentItemSession> identifierToItemSessions = new HashMap<>();
for (AssessmentItemSession itemSession : allItemSessions) {
identifierToItemSessions.put(itemSession.getAssessmentItemIdentifier(), itemSession);
}
// reorder to match the list of assessment items
List<CorrectionIdentityAssessmentItemRow> rows = new ArrayList<>();
TestSessionState testSessionState = model.getTestSessionStates().get(assessedIdentity);
List<TestPlanNode> nodes = testSessionState.getTestPlan().getTestPlanNodeList();
for (TestPlanNode node : nodes) {
if (node.getTestNodeType() == TestNodeType.ASSESSMENT_ITEM_REF) {
TestPlanNodeKey key = node.getKey();
AssessmentItemRef itemRef = identifierToRefs.get(key.getIdentifier());
AssessmentItemSession itemSession = identifierToItemSessions.get(key.getIdentifier().toString());
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(key);
boolean manualCorrection = model.isManualCorrection(itemRef);
CorrectionIdentityAssessmentItemRow row = new CorrectionIdentityAssessmentItemRow(assessedIdentity, item, itemRef, metadata, candidateSession, itemSession, itemSessionState, manualCorrection);
row.setTitle(title);
row.setTitleCssClass("o_icon_user");
rows.add(row);
}
}
tableModel.setObjects(rows);
tableEl.reset(reset, reset, true);
}
use of org.olat.ims.qti21.AssessmentItemSession in project OpenOLAT by OpenOLAT.
the class CorrectionIdentityInteractionsController method getStatus.
protected String getStatus() {
AssessmentItemSession itemSession = correction.getItemSession();
StringBuilder sb = new StringBuilder();
if (itemSession != null) {
if (itemSession.getManualScore() != null) {
sb.append("<i class='o_icon o_icon_ok'> </i>");
} else if (!correction.isItemSessionStatusFinal()) {
sb.append("<i class='o_icon o_icon_warn'> </i> ").append(translate("warning.not.submitted"));
} else if (manualScore) {
sb.append("<i class='o_icon o_icon_warn'> </i>");
} else {
sb.append("<i class='o_icon o_icon_ok'> </i> <span class='badge'>").append(translate("correction.auto")).append("</span>");
}
} else {
sb.append("<i class='o_icon o_icon_warn'> </i> ").append(translate("warning.not.submitted"));
}
return sb.toString();
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class QTI21ServiceImpl method recalculateAssessmentTestSessionScores.
@Override
public AssessmentTestSession recalculateAssessmentTestSessionScores(Long sessionKey) {
dbInstance.commit();
// fresh and lock by the identity assessmentItem controller
AssessmentTestSession candidateSession = getAssessmentTestSession(sessionKey);
BigDecimal totalScore = BigDecimal.valueOf(0l);
BigDecimal totalManualScore = BigDecimal.valueOf(0l);
List<AssessmentItemSession> itemResults = itemSessionDao.getAssessmentItemSessions(candidateSession);
for (AssessmentItemSession itemResult : itemResults) {
if (itemResult.getManualScore() != null) {
totalManualScore = totalManualScore.add(itemResult.getManualScore());
} else if (itemResult.getScore() != null) {
totalScore = totalScore.add(itemResult.getScore());
}
}
candidateSession.setScore(totalScore);
candidateSession.setManualScore(totalManualScore);
return testSessionDao.update(candidateSession);
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class QTI21ArchiveFormat method calculateSectionScore.
private BigDecimal calculateSectionScore(SessionResponses responses, SectionInfos section) {
BigDecimal sectionScore = BigDecimal.valueOf(0l);
for (ItemInfos item : section.getItemInfos()) {
AssessmentItemRef itemRef = item.getAssessmentItemRef();
String itemRefIdentifier = itemRef.getIdentifier().toString();
AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
if (itemSession != null) {
if (itemSession.getManualScore() != null) {
sectionScore = sectionScore.add(itemSession.getManualScore());
} else if (itemSession.getScore() != null) {
sectionScore = sectionScore.add(itemSession.getScore());
}
}
}
return sectionScore;
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
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++;
}
}
}
}
}
Aggregations