use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class CorrectionIdentityInteractionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
TestPlanNode node = correction.getItemNode();
TestPlanNodeKey testPlanNodeKey = node.getKey();
AssessmentItemSession itemSession = correction.getItemSession();
AssessmentTestSession testSession = correction.getTestSession();
TestSessionState testSessionState = correction.getTestSessionState();
answerItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
formLayout.add("answer", answerItem);
viewSolutionButton = uifactory.addFormLink("view.solution", formLayout);
viewSolutionButton.setIconLeftCSS("o_icon o_icon_open_togglebox");
solutionItem = initFormExtendedTextInteraction(testPlanNodeKey, testSessionState, testSession, formLayout);
solutionItem.setVisible(false);
solutionItem.setShowSolution(true);
formLayout.add("solution", solutionItem);
List<InteractionResultFormItem> responseItems = new ArrayList<>(interactions.size());
for (Interaction interaction : interactions) {
if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
manualScore = true;
File submissionDir = qtiService.getSubmissionDirectory(testSession);
if (submissionDir != null) {
submissionDirectoryMaps.put(testSession.getKey(), submissionDir);
}
}
}
String mScore = "";
String coachComment = "";
if (itemSession != null) {
if (itemSession.getManualScore() != null) {
mScore = AssessmentHelper.getRoundedScore(itemSession.getManualScore());
}
coachComment = itemSession.getCoachComment();
}
FormLayoutContainer scoreCont = FormLayoutContainer.createDefaultFormLayout("score.container", getTranslator());
formLayout.add("score.container", scoreCont);
statusEl = uifactory.addStaticTextElement("status", "status", "", scoreCont);
statusEl.setValue(getStatus());
String fullname = userManager.getUserDisplayName(correction.getAssessedIdentity());
if (manualScore) {
scoreEl = uifactory.addTextElement("scoreItem", "score", 6, mScore, scoreCont);
} else {
overrideAutoScore = itemSession == null ? null : itemSession.getManualScore();
String page = velocity_root + "/override_score.html";
overrideScoreCont = FormLayoutContainer.createCustomFormLayout("extra.score", getTranslator(), page);
overrideScoreCont.setRootForm(mainForm);
scoreCont.add(overrideScoreCont);
overrideScoreCont.setLabel("score", null);
BigDecimal score = null;
if (itemSession != null) {
score = itemSession.getManualScore();
if (score == null) {
score = itemSession.getScore();
}
}
overrideScoreCont.contextPut("score", AssessmentHelper.getRoundedScore(score));
overrideScoreButton = uifactory.addFormLink("override.score", overrideScoreCont, Link.BUTTON_SMALL);
overrideScoreButton.setDomReplacementWrapperRequired(false);
}
commentEl = uifactory.addTextAreaElement("commentItem", "comment", 2500, 4, 60, false, coachComment, scoreCont);
commentEl.setHelpText(translate("comment.help"));
IdentityAssessmentItemWrapper wrapper = new IdentityAssessmentItemWrapper(fullname, assessmentItem, correction, responseItems, scoreEl, commentEl, statusEl);
toReviewEl = uifactory.addCheckboxesHorizontal("to.review", "to.review", scoreCont, onKeys, new String[] { "" });
if (itemSession != null && itemSession.isToReview()) {
toReviewEl.select(onKeys[0], true);
}
Double minScore = QtiNodesExtractor.extractMinScore(assessmentItem);
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
if (maxScore != null) {
if (minScore == null) {
minScore = 0.0d;
}
wrapper.setMinScore(AssessmentHelper.getRoundedScore(minScore));
wrapper.setMaxScore(AssessmentHelper.getRoundedScore(maxScore));
wrapper.setMinScoreVal(minScore);
wrapper.setMaxScoreVal(maxScore);
if (scoreEl != null) {
scoreEl.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
}
if (overrideScoreCont != null) {
overrideScoreCont.setExampleKey("correction.min.max.score", new String[] { wrapper.getMinScore(), wrapper.getMaxScore() });
}
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("interactionWrapper", wrapper);
}
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class CorrectionIdentityInteractionsController method doSetOverridenScore.
private void doSetOverridenScore(BigDecimal newScore) {
overrideAutoScore = newScore;
if (newScore == null) {
AssessmentItemSession itemSession = correction.getItemSession();
String score = itemSession == null ? "" : AssessmentHelper.getRoundedScore(itemSession.getScore());
overrideScoreCont.contextPut("score", score);
} else {
overrideScoreCont.contextPut("score", AssessmentHelper.getRoundedScore(newScore));
}
String dirtyOnLoad = FormJSHelper.setFlexiFormDirtyOnLoad(flc.getRootForm());
getWindowControl().getWindowBackOffice().sendCommandTo(new JSCommand(dirtyOnLoad));
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
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);
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class CorrectionAssessmentItemListController method doSelect.
private void doSelect(UserRequest ureq, AssessmentItemListEntry listEntry, List<? extends AssessmentItemListEntry> selectedItemSessions) {
removeAsListenerAndDispose(identityItemCtrl);
doUnlock();
AssessmentItemRef itemRef = listEntry.getItemRef();
AssessmentItemSession reloadItemSession = null;
if (listEntry.getItemSession() != null) {
reloadItemSession = qtiService.getAssessmentItemSession(listEntry.getItemSession());
}
// lock on item, need to check the lock on identity / test
String lockSubKey = "item-" + listEntry.getAssessedIdentity().getKey() + "-" + listEntry.getItemRef().getIdentifier().toString();
OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
if (lockResult.isSuccess()) {
Identity assessedIdentity = listEntry.getAssessedIdentity();
AssessmentTestSession candidateSession = listEntry.getTestSession();
TestSessionState testSessionState = qtiService.loadTestSessionState(listEntry.getTestSession());
List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
if (nodes.size() == 1) {
TestPlanNode itemNode = nodes.get(0);
ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
itemCorrection.setItemSession(reloadItemSession);
identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, listEntry, selectedItemSessions, model);
listenTo(identityItemCtrl);
updatePreviousNext();
stackPanel.pushController(listEntry.getLabel(), identityItemCtrl);
}
} else {
String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
}
}
use of org.olat.ims.qti21.AssessmentItemSession in project openolat by klemens.
the class CorrectionAssessmentItemListController method doSelect.
private void doSelect(UserRequest ureq, CorrectionAssessmentItemRow row, Predicate<AssessmentItemListEntry> filter) {
removeAsListenerAndDispose(identityItemCtrl);
AssessmentItemRef itemRef = row.getItemRef();
String itemRefIdentifier = row.getItemRef().getIdentifier().toString();
List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(model.getCourseEntry(), model.getSubIdent(), model.getTestEntry(), itemRefIdentifier);
Map<AssessmentTestSession, AssessmentItemSession> testToItemSession = new HashMap<>();
for (AssessmentItemSession itemSession : allItemSessions) {
AssessmentTestSession testSession = itemSession.getAssessmentTestSession();
testToItemSession.put(testSession, itemSession);
}
// reorder to match the list of identities
int count = 1;
List<Identity> assessedIdentities = model.getAssessedIdentities();
List<AssessmentItemListEntry> reorderItemSessions = new ArrayList<>(assessedIdentities.size());
for (Identity assessedIdentity : assessedIdentities) {
AssessmentTestSession testSession = model.getLastSessions().get(assessedIdentity);
if (testSession != null) {
AssessmentItemSession itemSession = testToItemSession.get(testSession);
String title;
if (anonymous) {
title = translate("number.assessed.identity", new String[] { Integer.toString(count++) });
} else {
title = userManager.getUserDisplayName(assessedIdentity);
}
AssessmentItemListEntry entry = new AssessmentItemListEntry(assessedIdentity, testSession, itemSession, itemRef, title, "o_icon_user");
if (filter.test(entry)) {
reorderItemSessions.add(entry);
}
}
}
if (!reorderItemSessions.isEmpty()) {
doSelect(ureq, reorderItemSessions.get(0), reorderItemSessions);
} else {
showWarning("waring.atleast.one");
}
}
Aggregations