use of org.olat.imscp.xml.manifest.ResourceType in project openolat by klemens.
the class QTI21QPoolServiceProvider method importExcelItem.
public QuestionItemImpl importExcelItem(Identity owner, AssessmentItemAndMetadata itemAndMetadata, Locale defaultLocale) {
QTI21ImportProcessor processor = new QTI21ImportProcessor(owner, defaultLocale);
String editor = itemAndMetadata.getEditor();
String editorVersion = itemAndMetadata.getEditorVersion();
AssessmentItemBuilder itemBuilder = itemAndMetadata.getItemBuilder();
itemBuilder.build();
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
QuestionItemImpl qitem = processor.processItem(assessmentItem, null, null, editor, editorVersion, itemAndMetadata);
String originalItemFilename = qitem.getRootFilename();
File itemStorage = qpoolFileStorage.getDirectory(qitem.getDirectory());
File itemFile = new File(itemStorage, originalItemFilename);
qtiService.persistAssessmentObject(itemFile, assessmentItem);
// create manifest
ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
ResourceType resource = manifest.appendAssessmentItem(UUID.randomUUID().toString(), originalItemFilename);
ManifestMetadataBuilder metadataBuilder = manifest.getMetadataBuilder(resource, true);
itemAndMetadata.toBuilder(metadataBuilder, defaultLocale);
manifest.write(new File(itemStorage, "imsmanifest.xml"));
return qitem;
}
use of org.olat.imscp.xml.manifest.ResourceType 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);
}
use of org.olat.imscp.xml.manifest.ResourceType in project openolat by klemens.
the class AssessmentTestComposerController method doSaveManifest.
private void doSaveManifest() {
List<ResourceType> resources = manifestBuilder.getResourceList();
for (ResourceType resource : resources) {
checkAndFixAbsolutePath(resource);
}
manifestBuilder.write(new File(unzippedDirRoot, "imsmanifest.xml"));
}
use of org.olat.imscp.xml.manifest.ResourceType in project openolat by klemens.
the class ExportBinderAsCPResource method createImsManifest.
private ManifestType createImsManifest(Binder binder, List<Section> sections, List<Page> pages) {
ManifestType manifest = cpObjectFactory.createManifestType();
manifest.setIdentifier(UUID.randomUUID().toString());
// schema
ManifestMetadataType metadataType = cpObjectFactory.createManifestMetadataType();
manifest.setMetadata(metadataType);
// organizations
OrganizationsType organizations = cpObjectFactory.createOrganizationsType();
manifest.setOrganizations(organizations);
OrganizationType organization = cpObjectFactory.createOrganizationType();
organization.setIdentifier("binder_" + binder.getKey());
organization.setTitle(binder.getTitle());
organization.setStructure("hierarchical");
organizations.getOrganization().add(organization);
organizations.setDefault(organization);
ResourcesType resources = cpObjectFactory.createResourcesType();
manifest.setResources(resources);
Map<Section, ItemType> sectionToItemMap = new HashMap<>();
for (Section section : sections) {
ItemType sectionItem = cpObjectFactory.createItemType();
String itemIdentifier = "section_" + section.getKey().toString();
String resourceIdentifier = "res_" + itemIdentifier;
sectionItem.setTitle(section.getTitle());
sectionItem.setIdentifier(itemIdentifier);
sectionItem.setIdentifierref(resourceIdentifier);
sectionItem.setIsvisible(Boolean.TRUE);
organization.getItem().add(sectionItem);
sectionToItemMap.put(section, sectionItem);
ResourceType resource = cpObjectFactory.createResourceType();
resource.setIdentifier(resourceIdentifier);
resource.setType("webcontent");
resource.setHref(sectionFilename(section));
resources.getResource().add(resource);
}
for (Page page : pages) {
ItemType sectionItem = sectionToItemMap.get(page.getSection());
if (sectionItem == null) {
continue;
}
ItemType pageItem = cpObjectFactory.createItemType();
pageItem.setTitle(page.getTitle());
String itemIdentifier = "page_" + page.getKey().toString();
String resourceIdentifier = "res_" + itemIdentifier;
pageItem.setIdentifier(itemIdentifier);
pageItem.setIdentifierref(resourceIdentifier);
pageItem.setIsvisible(Boolean.TRUE);
sectionItem.getItem().add(pageItem);
ResourceType resource = cpObjectFactory.createResourceType();
resource.setIdentifier(resourceIdentifier);
resource.setType("webcontent");
resource.setHref(pageFilename(page));
resources.getResource().add(resource);
}
return manifest;
}
use of org.olat.imscp.xml.manifest.ResourceType in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method doSaveManifest.
private void doSaveManifest() {
List<ResourceType> resources = manifestBuilder.getResourceList();
for (ResourceType resource : resources) {
checkAndFixAbsolutePath(resource);
}
manifestBuilder.write(new File(unzippedDirRoot, "imsmanifest.xml"));
}
Aggregations