Search in sources :

Example 21 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class UserCourseInformationsManagerTest method updateInitialLaunchDates_loop.

/**
 * This test is to analyze a red screen
 */
@Test
public void updateInitialLaunchDates_loop() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsUser("user-launch-5-" + UUID.randomUUID().toString());
    ICourse course = CoursesWebService.createEmptyCourse(user, "course-launch-dates", "course long name", null);
    dbInstance.commitAndCloseSession();
    for (int i = 0; i < 10; i++) {
        OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
        userCourseInformationsManager.updateUserCourseInformations(courseResource, user);
    }
    dbInstance.commitAndCloseSession();
    List<Identity> users = Collections.singletonList(user);
    OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
    Map<Long, Date> launchDates = userCourseInformationsManager.getInitialLaunchDates(courseResource, users);
    Assert.assertNotNull(launchDates);
    Assert.assertEquals(1, launchDates.size());
    Assert.assertTrue(launchDates.containsKey(user.getKey()));
    Assert.assertNotNull(launchDates.get(user.getKey()));
}
Also used : OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 22 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class EditorUserCourseEnvironmentImpl method getLifecycle.

@Override
public RepositoryEntryLifecycle getLifecycle() {
    if (lifecycle == null) {
        CourseGroupManager cgm = courseEditorEnv.getCourseGroupManager();
        OLATResource courseResource = cgm.getCourseResource();
        RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(courseResource, false);
        if (re != null) {
            lifecycle = re.getLifecycle();
        }
    }
    return lifecycle;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 23 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class QTIPreWarm method run.

@Override
public void run() {
    long start = System.nanoTime();
    log.info("Start scanning for QTI resources");
    List<String> types = new ArrayList<>(2);
    types.add(TestFileResource.TYPE_NAME);
    types.add(SurveyFileResource.TYPE_NAME);
    List<OLATResource> qtiResources = olatResourceManager.findResourceByTypes(types);
    dbInstance.commitAndCloseSession();
    for (OLATResource qtiResource : qtiResources) {
        OnyxModule.isOnyxTest(qtiResource);
    }
    log.info(qtiResources.size() + " QTI Resources scanned in (ms): " + CodeHelper.nanoToMilliTime(start));
}
Also used : ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource)

Example 24 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class ScormCourseNodeIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, NODE_TYPE);
    Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
    indexWriter.addDocument(nodeDocument);
    RepositoryEntry repoEntry = courseNode.getReferencedRepositoryEntry();
    if (repoEntry != null) {
        OLATResource ores = repoEntry.getOlatResource();
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
        doIndex(courseNodeResourceContext, indexWriter, cpRoot);
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Document(org.apache.lucene.document.Document) CourseNodeDocument(org.olat.search.service.document.CourseNodeDocument) File(java.io.File)

Example 25 with OLATResource

use of org.olat.resource.OLATResource in project OpenOLAT by OpenOLAT.

the class PortfolioRepositoryIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext resourceContext, Object object, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    if (isLogDebugEnabled())
        logDebug("Index portfolio templates...");
    RepositoryEntry repositoryEntry = (RepositoryEntry) object;
    OLATResource ores = repositoryEntry.getOlatResource();
    PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
    // only index templates
    if (element instanceof EPStructuredMapTemplate) {
        resourceContext.setDocumentType(TYPE);
        resourceContext.setParentContextType(TYPE);
        resourceContext.setParentContextName(repositoryEntry.getDisplayname());
        resourceContext.setFilePath(element.getKey().toString());
        Document document = PortfolioMapDocument.createDocument(resourceContext, element);
        indexWriter.addDocument(document);
    }
}
Also used : EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document)

Aggregations

OLATResource (org.olat.resource.OLATResource)706 Test (org.junit.Test)304 RepositoryEntry (org.olat.repository.RepositoryEntry)198 Identity (org.olat.core.id.Identity)170 File (java.io.File)80 Date (java.util.Date)72 Feed (org.olat.modules.webFeed.Feed)72 ArrayList (java.util.ArrayList)64 ICourse (org.olat.course.ICourse)64 RepositoryService (org.olat.repository.RepositoryService)62 OLATResourceable (org.olat.core.id.OLATResourceable)60 BusinessGroup (org.olat.group.BusinessGroup)58 Item (org.olat.modules.webFeed.Item)44 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)38 OLATResourceManager (org.olat.resource.OLATResourceManager)34 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)34 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)30 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)30 FreeAccessMethod (org.olat.resource.accesscontrol.model.FreeAccessMethod)28 Group (org.olat.basesecurity.Group)26