use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project openolat by klemens.
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 uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef 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 uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project openolat by klemens.
the class AssessmentTestComposerController method doInsert.
private void doInsert(UserRequest ureq, List<QuestionItemView> items) {
TreeNode selectedNode = menuTree.getSelectedNode();
TreeNode sectionNode = getNearestSection(selectedNode);
boolean allOk = true;
String firstItemId = null;
Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
try {
AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
for (QuestionItemView item : items) {
QuestionItemFull qItem = qti21QPoolServiceProvider.getFullQuestionItem(item);
AssessmentItem assessmentItem = qti21QPoolServiceProvider.exportToQTIEditor(qItem, getLocale(), unzippedDirRoot);
if (assessmentItem != null) {
AssessmentItemRef itemRef = doInsert(section, assessmentItem);
if (firstItemId == null) {
firstItemId = itemRef.getIdentifier().toString();
}
flyingObjects.put(itemRef, assessmentItem);
ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
metadata.appendMetadataFrom(qItem, assessmentItem, getLocale());
metadata.setOpenOLATMetadataCopiedAt(new Date());
} else {
allOk &= false;
}
}
} catch (IOException | URISyntaxException e) {
showError("error.import.question");
logError("", e);
}
if (!allOk) {
showError("error.import.question");
}
if (firstItemId != null) {
// persist metadata
doSaveAssessmentTest(ureq, flyingObjects);
doSaveManifest();
updateTreeModel(false);
TreeNode newItemNode = menuTree.getTreeModel().getNodeById(firstItemId);
menuTree.setSelectedNode(newItemNode);
menuTree.open(newItemNode);
partEditorFactory(ureq, newItemNode);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project openolat by klemens.
the class AssessmentTestComposerController method doDelete.
private void doDelete(UserRequest ureq, TreeNode selectedNode) {
Object uobject = selectedNode.getUserObject();
if (uobject instanceof TestPart) {
doDeleteTestPart(ureq, (TestPart) uobject);
} else if (uobject instanceof AssessmentSection) {
AssessmentSection section = (AssessmentSection) uobject;
if (checkAtLeastOneSection(section)) {
doDeleteAssessmentSection(ureq, section);
} else {
showWarning("warning.atleastonesection");
}
} else if (uobject instanceof AssessmentItemRef) {
doDeleteAssessmentItemRef(ureq, (AssessmentItemRef) uobject);
} else {
// cannot delete test or test part
return;
}
doSaveAssessmentTest(ureq, null);
doSaveManifest();
updateTreeModel(false);
if (selectedNode != null && selectedNode.getParent() != null) {
TreeNode parentNode = (TreeNode) selectedNode.getParent();
menuTree.setSelectedNode(parentNode);
menuTree.open(parentNode);
partEditorFactory(ureq, parentNode);
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef in project openolat by klemens.
the class AssessmentTestComposerController method doDeleteAssessmentItemRef.
private void doDeleteAssessmentItemRef(UserRequest ureq, AssessmentItemRef itemRef) {
ResourceType resource = getResourceType(itemRef);
if (resource != null) {
manifestBuilder.remove(resource);
}
boolean deleted = false;
boolean removed = itemRef.getParentSection().getSectionParts().remove(itemRef);
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (resolvedAssessmentItem != null) {
RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
if (rootNode != null) {
URI itemUri = rootNode.getSystemId();
List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(itemUri);
if (itemRefs.size() <= 1) {
File itemFile = new File(itemUri);
deleted = itemFile.delete();
}
}
}
if (deleted) {
assessmentChanged(ureq);
}
logAudit(removed + " " + deleted + " removed item ref", null);
}
Aggregations