use of org.olat.portfolio.model.structel.EPTargetResource in project OpenOLAT by OpenOLAT.
the class EPStructureManagerTest method testLoadPortfolioStructuredMap.
@Test
public void testLoadPortfolioStructuredMap() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
// create a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
// clone the template
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
((EPStructuredMap) map).setReturnDate(new Date());
EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
targetResource.setResourceableTypeName("CourseModule");
targetResource.setResourceableId(234l);
targetResource.setSubPath(UUID.randomUUID().toString());
targetResource.setBusinessPath("[RepositoryEntry:23647599][CourseNode:934599]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// load the cloned map another map
PortfolioStructureMap myClonedMap = epStructureManager.loadPortfolioStructuredMap(user, template, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
Assert.assertNotNull(myClonedMap);
}
use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.
the class EPStructureManager method createPortfolioStructuredMap.
protected PortfolioStructureMap createPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
EPStructuredMap el = new EPStructuredMap();
el.setStructuredMapSource((EPStructuredMapTemplate) template);
el.setStructureElSource(template.getKey());
if (template != null) {
copyOrUpdateCollectRestriction(template, el, false);
}
EPTargetResource targetResource = el.getTargetResource();
if (targetOres != null) {
targetResource.setResourceableId(targetOres.getResourceableId());
targetResource.setResourceableTypeName(targetOres.getResourceableTypeName());
}
if (StringHelper.containsNonWhitespace(targetSubPath)) {
targetResource.setSubPath(targetSubPath);
}
if (StringHelper.containsNonWhitespace(targetBusinessPath)) {
targetResource.setBusinessPath(targetBusinessPath);
}
fillStructureElement(el, title, description);
// create security group
EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
relations.add(ownerGroup);
el.setGroups(relations);
return el;
}
use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.
the class EPFrontendManager method submitMap.
private void submitMap(PortfolioStructureMap map, boolean logActivity, Role by) {
// add an exception
if (!(map instanceof EPStructuredMap))
return;
EPStructuredMap submittedMap = (EPStructuredMap) map;
structureManager.submitMap(submittedMap);
EPTargetResource resource = submittedMap.getTargetResource();
OLATResourceable courseOres = resource.getOLATResourceable();
ICourse course = CourseFactory.loadCourse(courseOres);
AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
List<Identity> owners = policyManager.getOwners(submittedMap);
for (Identity owner : owners) {
if (courseNode != null) {
// courseNode might have been deleted meanwhile
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(owner);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (logActivity) {
am.incrementNodeAttempts(courseNode, owner, uce, by);
} else {
am.incrementNodeAttemptsInBackground(courseNode, owner, uce);
}
RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
assessmentService.updateAssessmentEntry(owner, courseEntry, courseNode.getIdent(), referenceEntry, AssessmentEntryStatus.inReview);
}
assessmentNotificationsHandler.markPublisherNews(owner, course.getResourceableId());
log.audit("Map " + map + " from " + owner.getName() + " has been submitted.");
}
}
use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.
the class EPStructureManagerTest method testLoadPortfolioStructuredMaps.
@Test
public void testLoadPortfolioStructuredMaps() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
// a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
// clone the template
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
((EPStructuredMap) map).setReturnDate(new Date());
EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
targetResource.setResourceableTypeName("CourseModule");
targetResource.setResourceableId(234l);
targetResource.setSubPath(UUID.randomUUID().toString());
targetResource.setBusinessPath("[RepositoryEntry:23647600][CourseNode:934600]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// load the cloned map another map
List<PortfolioStructureMap> myCloneAlt = epStructureManager.loadPortfolioStructuredMaps(user, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
Assert.assertNotNull(myCloneAlt);
Assert.assertEquals(1, myCloneAlt.size());
Assert.assertEquals(map, myCloneAlt.get(0));
}
use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.
the class EPStructureManagerTest method testLoadPortfolioStructuredMap.
@Test
public void testLoadPortfolioStructuredMap() {
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
// create a template
PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
epStructureManager.savePortfolioStructure(template);
dbInstance.commitAndCloseSession();
// clone the template
PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
((EPStructuredMap) map).setReturnDate(new Date());
EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
targetResource.setResourceableTypeName("CourseModule");
targetResource.setResourceableId(234l);
targetResource.setSubPath(UUID.randomUUID().toString());
targetResource.setBusinessPath("[RepositoryEntry:23647599][CourseNode:934599]");
epStructureManager.savePortfolioStructure(map);
dbInstance.commitAndCloseSession();
// load the cloned map another map
PortfolioStructureMap myClonedMap = epStructureManager.loadPortfolioStructuredMap(user, template, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
Assert.assertNotNull(myClonedMap);
}
Aggregations