Ejemplo n.º 1
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
      FormLayoutContainer layout = (FormLayoutContainer) formLayout;
      layout.contextPut("numOfMembers", Integer.toString(numOfMembers));

      FormLayoutContainer layoutCont =
          FormLayoutContainer.createDefaultFormLayout("confirm", getTranslator());
      formLayout.add("confirm", layoutCont);
      layoutCont.setRootForm(mainForm);

      StringBuilder message = new StringBuilder();
      for (RepositoryEntry row : rows) {
        if (message.length() > 0) message.append(", ");
        message.append(StringHelper.escapeHtml(row.getDisplayname()));
      }

      String[] acknowledge = new String[] {translate("details.read.only.acknowledge.msg")};
      acknowledgeEl =
          uifactory.addCheckboxesHorizontal(
              "confirm",
              "details.read.only.acknowledge",
              layoutCont,
              new String[] {""},
              acknowledge);

      FormLayoutContainer buttonsCont =
          FormLayoutContainer.createButtonLayout("buttons", getTranslator());
      layoutCont.add(buttonsCont);
      uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
      readOnlyButton = uifactory.addFormLink("details.closed", buttonsCont, Link.BUTTON);
    }
  }
  public MembersManagementMainController(
      UserRequest ureq, WindowControl wControl, RepositoryEntry re) {
    super(ureq, wControl);
    this.repoEntry = re;
    acModule = CoreSpringFactory.getImpl(AccessControlModule.class);
    acService = CoreSpringFactory.getImpl(ACService.class);

    // logging
    getUserActivityLogger().setStickyActionType(ActionType.admin);
    ICourse course = CourseFactory.loadCourse(re.getOlatResource());
    addLoggingResourceable(LoggingResourceable.wrap(course));

    // ui stuff
    menuTree = new MenuTree("menuTree");
    menuTree.setTreeModel(buildTreeModel());
    menuTree.setRootVisible(false);
    menuTree.addListener(this);

    mainVC = createVelocityContainer("main_members");

    columnLayoutCtr =
        new LayoutMain3ColsController(
            ureq, getWindowControl(), menuTree, null, mainVC, "members-" + repoEntry.getKey());
    listenTo(columnLayoutCtr);
    putInitialPanel(columnLayoutCtr.getInitialComponent());

    selectMenuItem(ureq, CMD_MEMBERS);
  }
Ejemplo n.º 3
0
  @Override
  protected void initRuntimeTools(Dropdown toolsDropdown) {
    if (reSecurity.isEntryAdmin()) {
      membersLink =
          LinkFactory.createToolLink(
              "members", translate("details.members"), this, "o_sel_repo_members");
      membersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_membersmanagement");
      toolsDropdown.addComponent(membersLink);
    }

    if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach()) {
      assessmentLink =
          LinkFactory.createToolLink(
              "assessment", translate("command.openassessment"), this, "o_icon_assessment_tool");
      assessmentLink.setElementCssClass("o_sel_course_assessment_tool");
      toolsDropdown.addComponent(assessmentLink);
    }

    if (reSecurity.isEntryAdmin()) {
      RepositoryEntry re = getRepositoryEntry();
      ordersLink =
          LinkFactory.createToolLink(
              "bookings", translate("details.orders"), this, "o_sel_repo_booking");
      ordersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_booking");
      boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null);
      ordersLink.setEnabled(booking);
      toolsDropdown.addComponent(ordersLink);
    }
  }
  private void loadCourseModel(
      CourseNode courseNode,
      UserCourseEnvironment uce,
      List<CourseTemplateRow> rows,
      Set<CurrentBinder> currentSet) {
    if (courseNode instanceof PortfolioCourseNode) {
      PortfolioCourseNode pNode = (PortfolioCourseNode) courseNode;
      NodeEvaluation ne =
          pNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
      if (NavigationHandler.mayAccessWholeTreeUp(ne)) {
        RepositoryEntry refEntry = pNode.getReferencedRepositoryEntry();
        if ("BinderTemplate".equals(refEntry.getOlatResource().getResourceableTypeName())) {
          RepositoryEntry courseEntry =
              uce.getCourseEnvironment().getCourseGroupManager().getCourseEntry();

          CurrentBinder binderKey = new CurrentBinder(courseEntry.getKey(), pNode.getIdent());
          if (!currentSet.contains(binderKey)) {
            rows.add(new CourseTemplateRow(courseEntry, pNode, refEntry));
          }
        }
      }
    }

    for (int i = courseNode.getChildCount(); i-- > 0; ) {
      loadCourseModel((CourseNode) courseNode.getChildAt(i), uce, rows, currentSet);
    }
  }
Ejemplo n.º 5
0
  private void doLayout(UserRequest ureq) {
    RepositoryEntry entry = getRepositoryEntry();
    ScormPackageConfig scormConfig =
        ScormMainManager.getInstance().getScormPackageConfig(entry.getOlatResource());
    DeliveryOptions config = scormConfig == null ? null : scormConfig.getDeliveryOptions();
    final OLATResource resource = entry.getOlatResource();
    WindowControl bwControl = getSubWindowControl("Layout");
    final DeliveryOptionsConfigurationController deliveryOptionsCtrl =
        new DeliveryOptionsConfigurationController(
            ureq, addToHistory(ureq, bwControl), config, "Knowledge Transfer#_scorm_layout");

    deliveryOptionsCtrl.addControllerListener(
        new ControllerEventListener() {
          @Override
          public void dispatchEvent(UserRequest uureq, Controller source, Event event) {
            if (source == deliveryOptionsCtrl
                && (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT)) {
              DeliveryOptions newConfig = deliveryOptionsCtrl.getDeliveryOptions();
              ScormPackageConfig sConfig =
                  ScormMainManager.getInstance().getScormPackageConfig(resource);
              if (sConfig == null) {
                sConfig = new ScormPackageConfig();
              }
              sConfig.setDeliveryOptions(newConfig);
              ScormMainManager.getInstance().setScormPackageConfig(resource, sConfig);
            }
          }
        });

    pushController(ureq, translate("tab.layout"), deliveryOptionsCtrl);
    setActiveTool(deliveryOptionsLink);
  }
Ejemplo n.º 6
0
 public Bookmark(Mark mark, RepositoryEntry entry) {
   this.mark = mark;
   title = entry.getDisplayname();
   description = entry.getDescription();
   statusCode = entry.getStatusCode();
   creationDate = entry.getCreationDate();
   displayrestype = entry.getOlatResource().getResourceableTypeName();
 }
 @Override
 public RepositoryEntryLifecycle getLifecycle() {
   if (lifecycle == null) {
     RepositoryEntry re = getCourseRepositoryEntry();
     if (re != null) {
       lifecycle = re.getLifecycle();
     }
   }
   return lifecycle;
 }
  private Controller selectMenuItem(UserRequest ureq, String cmd) {
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(cmd, 0l);
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(
        LoggingResourceable.wrapBusinessPath(ores));
    WindowControl bwControl =
        BusinessControlFactory.getInstance()
            .createBusinessWindowControl(ores, null, getWindowControl());
    addToHistory(ureq, bwControl);

    Controller selectedCtrl = null;
    if (CMD_MEMBERS.equals(cmd)) {
      if (membersOverviewCtrl == null) {
        membersOverviewCtrl = new MembersOverviewController(ureq, bwControl, repoEntry);
        listenTo(membersOverviewCtrl);
      }
      mainVC.put("content", membersOverviewCtrl.getInitialComponent());
      selectedCtrl = membersOverviewCtrl;
    } else if (CMD_GROUPS.equals(cmd)) {
      if (groupsCtrl == null) {
        groupsCtrl = new CourseBusinessGroupListController(ureq, bwControl, repoEntry);
        listenTo(groupsCtrl);
      }
      groupsCtrl.reloadModel();
      mainVC.put("content", groupsCtrl.getInitialComponent());
      selectedCtrl = groupsCtrl;
    } else if (CMD_BOOKING.equals(cmd)) {
      if (ordersController == null) {
        ordersController = new OrdersAdminController(ureq, bwControl, repoEntry.getOlatResource());
        listenTo(ordersController);
      }
      mainVC.put("content", ordersController.getInitialComponent());
      selectedCtrl = ordersController;
    } else if (CMD_RIGHTS.equals(cmd)) {
      if (rightsController == null) {
        rightsController =
            new GroupsAndRightsController(ureq, bwControl, repoEntry.getOlatResource());
        listenTo(rightsController);
      }
      mainVC.put("content", rightsController.getInitialComponent());
      selectedCtrl = rightsController;
    }

    TreeNode selTreeNode =
        TreeHelper.findNodeByUserObject(cmd, menuTree.getTreeModel().getRootNode());
    if (selTreeNode != null && !selTreeNode.getIdent().equals(menuTree.getSelectedNodeId())) {
      menuTree.setSelectedNodeId(selTreeNode.getIdent());
    }
    return selectedCtrl;
  }
  @Test
  public void testRemoveCoach_withBusinessGroups() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    // create a group with members
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-1");
    Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-2");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");

    repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());

    BusinessGroup businessGroup =
        businessGroupDao.createAndPersist(
            coach, "mbr-proc-1", "mbr-proc-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRelationToResource(businessGroup, re);

    // create a publisher
    SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
    PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
    Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
    Assert.assertNotNull(publisher);
    dbInstance.commitAndCloseSession();

    // subscribe
    notificationManager.subscribe(owner, context, publisherData);
    notificationManager.subscribe(member, context, publisherData);
    notificationManager.subscribe(coach, context, publisherData);
    dbInstance.commitAndCloseSession();

    // remove member and coach as coach of the repo entry
    List<Identity> removeIdentities = new ArrayList<>(2);
    removeIdentities.add(member);
    removeIdentities.add(coach);
    repositoryManager.removeTutors(owner, removeIdentities, re);

    // wait for the remove of subscription
    waitForCondition(
        new CheckUnsubscription(member, context, dbInstance, notificationManager), 5000);
    sleep(1000);

    // check that subscription of id1 was deleted but not the ones of id2 and coach
    boolean subscribedMember = notificationManager.isSubscribed(member, context);
    Assert.assertFalse(subscribedMember);
    boolean subscribedCoach = notificationManager.isSubscribed(coach, context);
    Assert.assertTrue(subscribedCoach);
    boolean subscribedOwner = notificationManager.isSubscribed(owner, context);
    Assert.assertTrue(subscribedOwner);
  }
Ejemplo n.º 10
0
 private boolean setReadOnlyEntries(UserRequest ureq, List<RepositoryEntry> entries) {
   boolean allOk = true;
   for (RepositoryEntry entry : entries) {
     RepositoryEntry reloadedEntry = repositoryService.loadByKey(entry.getKey());
     if (reloadedEntry != null) {
       repositoryService.closeRepositoryEntry(reloadedEntry);
       ThreadLocalUserActivityLogger.log(
           LearningResourceLoggingAction.LEARNING_RESOURCE_DEACTIVATE,
           getClass(),
           LoggingResourceable.wrap(reloadedEntry, OlatResourceableType.genRepoEntry));
       fireEvent(
           ureq, new EntryChangedEvent(reloadedEntry, getIdentity(), Change.closed, "closed"));
     }
   }
   return allOk;
 }
  private GenericTreeModel buildTreeModel() {
    GenericTreeModel gtm = new GenericTreeModel();
    GenericTreeNode root = new GenericTreeNode();
    root.setTitle(translate("menu.members"));
    root.setAltText(translate("menu.members.alt"));
    gtm.setRootNode(root);

    GenericTreeNode node = new GenericTreeNode(translate("menu.members"), CMD_MEMBERS);
    node.setAltText(translate("menu.members.alt"));
    root.addChild(node);

    node = new GenericTreeNode(translate("menu.groups"), CMD_GROUPS);
    node.setAltText(translate("menu.groups.alt"));
    root.addChild(node);

    if (acModule.isEnabled()) {
      // check if the course is managed and/or has offers
      if (!RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.bookings)
          || acService.isResourceAccessControled(repoEntry.getOlatResource(), null)) {
        node = new GenericTreeNode(translate("menu.orders"), CMD_BOOKING);
        node.setAltText(translate("menu.orders.alt"));
        root.addChild(node);
      }
    }

    node = new GenericTreeNode(translate("menu.rights"), CMD_RIGHTS);
    node.setAltText(translate("menu.rights.alt"));
    root.addChild(node);
    return gtm;
  }
Ejemplo n.º 12
0
  @Test
  public void isTemplateInUse() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-9");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // assign a template
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    Binder template = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
    dbInstance.commit();
    Assert.assertNotNull(template);

    boolean inUse = portfolioService.isTemplateInUse(templateBinder, templateEntry, null);
    Assert.assertTrue(inUse);
  }
Ejemplo n.º 13
0
  @Test
  public void createRepositoryEntry() {
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-1");

    String displayName = "ServiceTest";
    String resourceName = "ServiceTest";
    String description = "Test the brand new service";
    RepositoryEntry re =
        repositoryService.create(
            initialAuthor, null, resourceName, displayName, description, null, 0);
    dbInstance.commit();

    Assert.assertNotNull(re);
    Assert.assertNotNull(re.getCreationDate());
    Assert.assertNotNull(re.getLastModified());
    Assert.assertNotNull(re.getOlatResource());
  }
  @Test
  public void testRemoveParticipant() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    // create a group with members
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-1");
    Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("remp-proc-2");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-3");

    repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(member, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());

    // create a publisher
    SubscriptionContext context = new SubscriptionContext(re.getOlatResource(), "");
    PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
    Publisher publisher = notificationManager.getOrCreatePublisher(context, publisherData);
    Assert.assertNotNull(publisher);
    dbInstance.commitAndCloseSession();

    // subscribe
    notificationManager.subscribe(owner, context, publisherData);
    notificationManager.subscribe(member, context, publisherData);
    notificationManager.subscribe(participant, context, publisherData);
    dbInstance.commitAndCloseSession();

    // remove member and participant as participant of the repo entry
    List<Identity> removeIdentities = new ArrayList<>(2);
    removeIdentities.add(member);
    removeIdentities.add(participant);
    MailPackage mailing = new MailPackage(false);
    repositoryManager.removeParticipants(owner, removeIdentities, re, mailing, false);

    // wait for the remove of subscription
    waitForCondition(
        new CheckUnsubscription(participant, context, dbInstance, notificationManager), 5000);
    sleep(1000);

    // check that subscription of id1 was deleted but not the ones of id2 and coach
    boolean subscribedPart = notificationManager.isSubscribed(participant, context);
    Assert.assertFalse(subscribedPart);
    boolean subscribedMember = notificationManager.isSubscribed(member, context);
    Assert.assertTrue(subscribedMember);
    boolean subscribedOwner = notificationManager.isSubscribed(owner, context);
    Assert.assertTrue(subscribedOwner);
  }
Ejemplo n.º 15
0
  @Test
  public void syncBinder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    // add 2 sections
    for (int i = 0; i < 2; i++) {
      portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
      dbInstance.commit();
    }

    List<Section> templateSections = portfolioService.getSections(templateBinder);
    Assert.assertNotNull(templateSections);
    Assert.assertEquals(3, templateSections.size());

    // user get a the binder from the template
    Binder binder =
        portfolioService.assignBinder(id, templateBinder, templateEntry, "ac-234", new Date());
    dbInstance.commit();
    Assert.assertNotNull(binder);
    boolean inUse = portfolioService.isTemplateInUse(templateBinder, templateEntry, "ac-234");
    Assert.assertTrue(inUse);

    // update the template with 2 more sections
    for (int i = 2; i < 4; i++) {
      portfolioService.appendNewSection("Section " + i, "Section " + i, null, null, templateBinder);
      dbInstance.commit();
    }

    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    Assert.assertNotNull(synchedBinder);
    dbInstance.commit();
    Assert.assertTrue(synchedBinder.isChanged());
    Assert.assertEquals(binder, synchedBinder.getBinder());
    List<Section> synchedSections = portfolioService.getSections(synchedBinder.getBinder());
    Assert.assertEquals(5, synchedSections.size());
  }
  /** Same workflow as the repository. This workflow is pretty critical. */
  @Test
  public void isStructuredMapOwner() {
    final OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();

    // create a repository entry
    final RepositoryEntry addedEntry =
        repositoryManager.createRepositoryEntryInstance(ident1.getName());

    addedEntry.setCanDownload(false);
    addedEntry.setCanLaunch(true);
    addedEntry.setDisplayname("test repo");
    addedEntry.setResourcename("-");
    addedEntry.setAccess(RepositoryEntry.ACC_OWNERS);

    // Set the resource on the repository entry and save the entry.
    final OLATResource ores = resourceManager.findOrPersistResourceable(resource);
    addedEntry.setOlatResource(ores);

    // create security group
    final SecurityGroup newGroup = securityManager.createAndPersistSecurityGroup();
    securityManager.createAndPersistPolicy(newGroup, Constants.PERMISSION_ACCESS, newGroup);
    securityManager.createAndPersistPolicy(
        newGroup, Constants.PERMISSION_HASROLE, EPStructureManager.ORES_MAPOWNER);
    securityManager.addIdentityToSecurityGroup(ident1, newGroup);
    addedEntry.setOwnerGroup(newGroup);

    repositoryManager.saveRepositoryEntry(addedEntry);
    dbInstance.commitAndCloseSession();

    // create the template owned by ident1
    final PortfolioStructureMap template =
        epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    final PortfolioStructure page1 =
        epFrontendManager.createAndPersistPortfolioPage(template, "Page title", "Page description");
    assertNotNull(page1);

    dbInstance.commitAndCloseSession();

    // assign the template to ident2
    final PortfolioStructureMap map =
        epFrontendManager.assignStructuredMapToUser(ident2, template, null, null, null, null);
    assertNotNull(map);
    dbInstance.commitAndCloseSession();

    // check if ident2 is owner of the map
    assertTrue(epFrontendManager.isMapOwner(ident2, map.getOlatResource()));
    // check if ident1 is not the owner of the map
    assertFalse(epFrontendManager.isMapOwner(ident1, map.getOlatResource()));
    // check if ident1 is owner of the template
    assertTrue(epFrontendManager.isMapOwner(ident1, template.getOlatResource()));
  }
Ejemplo n.º 17
0
  private void addEnrollmentDate(
      RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
    RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
    rel.getGroup();

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(field, amount);

    GroupMembershipImpl membership = new GroupMembershipImpl();
    membership.setCreationDate(cal.getTime());
    membership.setLastModified(cal.getTime());
    membership.setGroup(rel.getGroup());
    membership.setIdentity(id);
    membership.setRole(role.name());
    dbInstance.getCurrentEntityManager().persist(membership);
    dbInstance.commit();
  }
Ejemplo n.º 18
0
  private void appendCourseCalendars(
      UserRequest ureq,
      WindowControl wControl,
      List<KalendarRenderWrapper> calendars,
      Map<CalendarKey, CalendarUserConfiguration> configMap) {
    if (calendarModule.isEnableCourseElementCalendar()
        || calendarModule.isEnableCourseToolCalendar()) {

      // add course calendars
      List<Object[]> resources = getCourses(ureq.getIdentity());
      Set<OLATResource> editoredResources = getEditorGrants(ureq.getIdentity());

      Set<Long> duplicates = new HashSet<>();

      for (Object[] resource : resources) {
        RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
        if (duplicates.contains(courseEntry.getKey())) {
          continue;
        }
        duplicates.add(courseEntry.getKey());

        String role = (String) resource[1];
        Long courseResourceableID = courseEntry.getOlatResource().getResourceableId();
        try {
          ICourse course = CourseFactory.loadCourse(courseEntry);
          if (isCourseCalendarEnabled(course)) {
            // calendar course aren't enabled per default but course node of type calendar are
            // always possible
            // REVIEW if (!course.getCourseEnvironment().getCourseConfig().isCalendarEnabled())
            // continue;
            // add course calendar
            KalendarRenderWrapper courseCalendarWrapper = calendarManager.getCourseCalendar(course);
            boolean isPrivileged =
                GroupRoles.owner.name().equals(role)
                    || editoredResources.contains(courseEntry.getOlatResource());
            if (isPrivileged) {
              courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
            } else {
              courseCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
            }

            if (role != null
                && (GroupRoles.owner.name().equals(role)
                    || GroupRoles.coach.name().equals(role)
                    || GroupRoles.participant.name().equals(role))) {
              courseCalendarWrapper.setPrivateEventsVisible(true);
            }

            CalendarUserConfiguration config =
                configMap.get(courseCalendarWrapper.getCalendarKey());
            if (config != null) {
              courseCalendarWrapper.setConfiguration(config);
            }
            courseCalendarWrapper.setLinkProvider(
                new CourseLinkProviderController(
                    course, Collections.singletonList(course), ureq, wControl));
            calendars.add(courseCalendarWrapper);
          }
        } catch (CorruptedCourseException e) {
          OLATResource olatResource = courseEntry.getOlatResource();
          log.error(
              "Corrupted course: "
                  + olatResource.getResourceableTypeName()
                  + " :: "
                  + courseResourceableID,
              null);
        }
      }
    }
  }
Ejemplo n.º 19
0
  @Test
  public void createAndLoadRepositoryEntry() {
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-1");

    String displayName = "Service test 2";
    String resourceName = "ServiceTest";
    String description = "Test the brand new service";
    RepositoryEntry re =
        repositoryService.create(
            initialAuthor, null, resourceName, displayName, description, null, 0);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(re);

    RepositoryEntry loadedEntry = repositoryService.loadByKey(re.getKey());
    Assert.assertNotNull(loadedEntry);
    Assert.assertNotNull(re.getCreationDate());
    Assert.assertNotNull(re.getLastModified());
    Assert.assertNotNull(re.getOlatResource());
    Assert.assertNotNull(loadedEntry.getGroups());
    Assert.assertEquals(1, loadedEntry.getGroups().size());
    // saved?
    Assert.assertEquals(displayName, re.getDisplayname());
    Assert.assertEquals(resourceName, re.getResourcename());
    Assert.assertEquals(description, re.getDescription());
    // default value
    Assert.assertFalse(re.getCanCopy());
    Assert.assertFalse(re.getCanDownload());
    Assert.assertFalse(re.getCanReference());
    Assert.assertEquals(0, re.getAccess());
  }
Ejemplo n.º 20
0
  @Test
  public void deleteCourseSoftly() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity coachGroup = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("re-soft-");
    Identity initialAuthor = JunitTestHelper.createAndPersistIdentityAsRndUser("auth-del-1");
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(initialAuthor);
    dbInstance.commitAndCloseSession();

    // add business group
    BusinessGroup group =
        businessGroupService.createBusinessGroup(
            coachGroup, "Relation 1", "tg", null, null, false, false, re);
    businessGroupService.addResourceTo(group, re);
    dbInstance.commit();

    // catalog
    List<CatalogEntry> rootEntries = catalogManager.getRootCatalogEntries();
    CatalogEntry catEntry = catalogManager.createCatalogEntry();
    catEntry.setName("Soft");
    catEntry.setRepositoryEntry(re);
    catEntry.setParent(rootEntries.get(0));
    catEntry.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
    catalogManager.saveCatalogEntry(catEntry);
    dbInstance.commit();

    // check the catalog
    List<CatalogEntry> catEntries = catalogManager.getCatalogCategoriesFor(re);
    Assert.assertNotNull(catEntries);
    Assert.assertEquals(1, catEntries.size());

    // add owner, coach...
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
    dbInstance.commit();

    // kill it softly like A. Keys
    repositoryService.deleteSoftly(re, initialAuthor, false);
    dbInstance.commit();

    // check that the members are removed
    List<Identity> coachAndParticipants =
        repositoryEntryRelationDao.getMembers(
            re,
            RepositoryEntryRelationType.both,
            GroupRoles.coach.name(),
            GroupRoles.participant.name());
    Assert.assertNotNull(coachAndParticipants);
    Assert.assertEquals(0, coachAndParticipants.size());

    // check the relations between course and business groups
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, re, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(0, groups.size());

    // check the catalog
    List<CatalogEntry> removedCatEntries = catalogManager.getCatalogCategoriesFor(re);
    Assert.assertNotNull(removedCatEntries);
    Assert.assertEquals(0, removedCatEntries.size());

    RepositoryEntry reloadEntry = repositoryService.loadByKey(re.getKey());
    Assert.assertNotNull(reloadEntry);
    Assert.assertEquals(0, reloadEntry.getAccess());
    Assert.assertNotNull(reloadEntry.getDeletionDate());
    Assert.assertEquals(initialAuthor, reloadEntry.getDeletedBy());
  }
Ejemplo n.º 21
0
  @Test
  public void assignTask_relativeToInitialLaunchDate() {
    // create a course with 3 members
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-3");

    ICourse course =
        CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
    RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();

    // create user course infos
    Long courseResId = course.getCourseEnvironment().getCourseResourceableId();
    userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1);
    userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2);
    userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3);
    dbInstance.commit();

    // fake the date
    updateInitialLaunchDate(courseResId, id1, -5, Calendar.DATE);
    updateInitialLaunchDate(courseResId, id2, -35, Calendar.DATE);
    updateInitialLaunchDate(courseResId, id3, -75, Calendar.DATE);
    dbInstance.commitAndCloseSession();

    // create a fake node
    GTACourseNode node = new GTACourseNode();
    node.getModuleConfiguration()
        .setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
    node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE, 40);
    node.getModuleConfiguration()
        .setStringValue(
            GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE_TO,
            GTARelativeToDates.courseLaunch.name());

    // need the task list
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(tasks);
    dbInstance.commit();

    { // check 3 days
      ReminderRuleImpl rule = getAssignedTaskRules(3, LaunchUnit.day);
      List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(1, all.size());
      Assert.assertTrue(all.contains(id3));
    }

    { // check 5 days
      ReminderRuleImpl rule = getAssignedTaskRules(5, LaunchUnit.day);
      List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(id2));
      Assert.assertTrue(all.contains(id3));
    }

    { // check 1 week
      ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.week);
      List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(id2));
      Assert.assertTrue(all.contains(id3));
    }

    { // check 1 month
      ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.month);
      List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(id2));
      Assert.assertTrue(all.contains(id3));
    }

    { // check 2 month
      ReminderRuleImpl rule = getAssignedTaskRules(2, LaunchUnit.month);
      List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(3, all.size());
      Assert.assertTrue(all.contains(id1));
      Assert.assertTrue(all.contains(id2));
      Assert.assertTrue(all.contains(id3));
    }
  }
Ejemplo n.º 22
0
  @Test
  public void syncBinder_moveInNewSection_moreComplexCase() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef0 = portfolioService.getSections(templateBinder).get(0);
    // add 2 sections
    SectionRef sectionRef1 =
        portfolioService.appendNewSection("1 section ", "Section 1", null, null, templateBinder);
    SectionRef sectionRef2 =
        portfolioService.appendNewSection("2 section ", "Section 2", null, null, templateBinder);
    dbInstance.commit();

    // make 4 assignments
    Section templateSection0 = portfolioService.getSection(sectionRef0);
    Section templateSection1 = portfolioService.getSection(sectionRef1);
    Section templateSection2 = portfolioService.getSection(sectionRef2);
    Assignment assignment0_1 =
        portfolioService.addAssignment(
            "0.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection0,
            false,
            false,
            false,
            null);
    Assignment assignment1_1 =
        portfolioService.addAssignment(
            "1.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection1,
            false,
            false,
            false,
            null);
    Assignment assignment1_2 =
        portfolioService.addAssignment(
            "1.2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection1,
            false,
            false,
            false,
            null);
    Assignment assignment2_1 =
        portfolioService.addAssignment(
            "2.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection2,
            false,
            false,
            false,
            null);
    Assignment assignment2_2 =
        portfolioService.addAssignment(
            "2.2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection2,
            false,
            false,
            false,
            null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(5, templateAssignments.size());

    // a user take the binder and synched it a first time
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, "74", null);
    dbInstance.commit();
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(synchedBinder);
    Assert.assertEquals(binder, synchedBinder.getBinder());

    // start all assignments
    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    Assert.assertEquals(5, assignments.size());
    for (Assignment assignment : assignments) {
      portfolioService.startAssignment(assignment, id);
      dbInstance.commit();
    }
    dbInstance.commit();

    // check that the student has it's 4 pages
    List<Page> pages = portfolioService.getPages(binder, null);
    Assert.assertEquals(5, pages.size());

    // author create 2 new sections, move the 4 to the top
    SectionRef sectionRef3 =
        portfolioService.appendNewSection("3 section ", "Section 3", null, null, templateBinder);
    SectionRef sectionRef4 =
        portfolioService.appendNewSection("4 section ", "Section 4", null, null, templateBinder);
    dbInstance.commit();

    Section templateSection3 = portfolioService.getSection(sectionRef3);
    Section templateSection4 = portfolioService.getSection(sectionRef4);

    templateBinder = portfolioService.moveUpSection(templateBinder, templateSection4);
    dbInstance.commit();
    templateBinder = portfolioService.moveUpSection(templateBinder, templateSection4);
    dbInstance.commit();
    templateBinder = portfolioService.moveUpSection(templateBinder, templateSection4);
    dbInstance.commit();
    templateBinder = portfolioService.moveUpSection(templateBinder, templateSection4);
    dbInstance.commit();

    // add new assignment
    Assignment assignment3_1 =
        portfolioService.addAssignment(
            "3.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection3,
            false,
            false,
            false,
            null);
    Assignment assignment4_1 =
        portfolioService.addAssignment(
            "4.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection4,
            false,
            false,
            false,
            null);
    dbInstance.commit();

    // the author move some assignments
    portfolioService.moveAssignment(templateSection1, assignment1_1, templateSection3);
    dbInstance.commit();
    portfolioService.moveAssignment(templateSection1, assignment1_2, templateSection2);
    dbInstance.commit();
    portfolioService.moveAssignment(templateSection2, assignment2_1, templateSection3);
    dbInstance.commit();
    portfolioService.moveAssignment(templateSection2, assignment2_2, templateSection4);
    dbInstance.commitAndCloseSession();

    // update the data of some assignments
    assignment2_1 = assignmentDao.loadAssignmentByKey(assignment2_1.getKey());
    assignment4_1 = assignmentDao.loadAssignmentByKey(assignment4_1.getKey());
    assignment2_1 =
        portfolioService.updateAssignment(
            assignment2_1,
            "2.1 Assignment",
            "Assignment 2 description",
            "",
            AssignmentType.essay,
            false,
            false,
            false,
            null);
    assignment4_1 =
        portfolioService.updateAssignment(
            assignment4_1,
            "4.1 Assignment",
            "Assignment 4 description",
            "",
            AssignmentType.document,
            false,
            false,
            false,
            null);
    dbInstance.commit();

    // check the move
    List<Assignment> templateAssignmentsSection0 =
        portfolioService.getAssignments(templateSection0, null);
    Assert.assertTrue(templateAssignmentsSection0.contains(assignment0_1));

    List<Assignment> templateAssignmentsSection1 =
        portfolioService.getAssignments(templateSection1, null);
    Assert.assertTrue(templateAssignmentsSection1.isEmpty());
    List<Assignment> templateAssignmentsSection2 =
        portfolioService.getAssignments(templateSection2, null);
    Assert.assertEquals(1, templateAssignmentsSection2.size());
    Assert.assertTrue(templateAssignmentsSection2.contains(assignment1_2));
    List<Assignment> templateAssignmentsSection3 =
        portfolioService.getAssignments(templateSection3, null);
    Assert.assertEquals(3, templateAssignmentsSection3.size());
    Assert.assertTrue(templateAssignmentsSection3.contains(assignment1_1));
    Assert.assertTrue(templateAssignmentsSection3.contains(assignment2_1));
    Assert.assertTrue(templateAssignmentsSection3.contains(assignment3_1));
    List<Assignment> templateAssignmentsSection4 =
        portfolioService.getAssignments(templateSection4, null);
    Assert.assertEquals(2, templateAssignmentsSection4.size());
    Assert.assertTrue(templateAssignmentsSection4.contains(assignment2_2));
    Assert.assertTrue(templateAssignmentsSection4.contains(assignment4_1));

    // synched and check the sections order
    SynchedBinder synchedBinder2 = portfolioService.loadAndSyncBinder(binder);
    Binder freshBinder = synchedBinder2.getBinder();
    dbInstance.commitAndCloseSession();

    List<Section> sections = portfolioService.getSections(freshBinder);
    Assert.assertEquals(5, sections.size());
    Section section4 = sections.get(0);
    Section section0 = sections.get(1);
    Section section1 = sections.get(2);
    Section section2 = sections.get(3);
    Section section3 = sections.get(4);
    Assert.assertEquals(templateSection0, section0.getTemplateReference());
    Assert.assertEquals(templateSection1, section1.getTemplateReference());
    Assert.assertEquals(templateSection2, section2.getTemplateReference());
    Assert.assertEquals(templateSection3, section3.getTemplateReference());
    Assert.assertEquals(templateSection4, section4.getTemplateReference());

    // load pages from section 0
    List<Page> pagesSection0 = portfolioService.getPages(section0);
    Assert.assertEquals(1, pagesSection0.size());
    Page page0_1 = pagesSection0.get(0);
    Assert.assertTrue(page0_1.getTitle().equals("0.1 Assignment"));
    // load pages from section 1
    List<Page> pagesSection1 = portfolioService.getPages(section1);
    Assert.assertTrue(pagesSection1.isEmpty());
    // and pages from section 2
    List<Page> pagesSection2 = portfolioService.getPages(section2);
    Assert.assertEquals(1, pagesSection2.size());
    Page page1_2 = pagesSection2.get(0);
    Assert.assertTrue(page1_2.getTitle().equals("1.2 Assignment"));
    // and pages from section 3
    List<Page> pagesSection3 = portfolioService.getPages(section3);
    Assert.assertEquals(2, pagesSection3.size());
    Page page1_1 = pagesSection3.get(0);
    Page page2_1 = pagesSection3.get(1);
    Assert.assertTrue(
        page1_1.getTitle().equals("1.1 Assignment") || page1_1.getTitle().equals("2.1 Assignment"));
    Assert.assertTrue(
        page2_1.getTitle().equals("1.1 Assignment") || page2_1.getTitle().equals("2.1 Assignment"));
    // and pages from section 4
    List<Page> pagesSection4 = portfolioService.getPages(section4);
    Assert.assertEquals(1, pagesSection4.size());
    Page page2_2 = pagesSection4.get(0);
    Assert.assertTrue(page2_2.getTitle().equals("2.2 Assignment"));

    // check the assignments
    // section 0
    List<Assignment> assignmentsSection0 = section0.getAssignments();
    Assert.assertEquals(1, assignmentsSection0.size());
    Assignment templateSynchedSection0a = assignmentsSection0.get(0).getTemplateReference();
    Assert.assertTrue(assignment0_1.equals(templateSynchedSection0a));
    // section 1
    List<Assignment> assignmentsSection1 = section1.getAssignments();
    Assert.assertTrue(assignmentsSection1.isEmpty());
    // section 2
    List<Assignment> assignmentsSection2 = section2.getAssignments();
    Assert.assertEquals(1, assignmentsSection2.size());
    Assignment templateSynchedSection2a = assignmentsSection2.get(0).getTemplateReference();
    Assert.assertTrue(assignment1_2.equals(templateSynchedSection2a));
    // section 3
    List<Assignment> assignmentsSection3 = section3.getAssignments();
    Assert.assertEquals(3, assignmentsSection3.size());
    Assignment templateSynchedSection3a = assignmentsSection3.get(0).getTemplateReference();
    Assignment templateSynchedSection3b = assignmentsSection3.get(1).getTemplateReference();
    Assignment templateSynchedSection3c = assignmentsSection3.get(2).getTemplateReference();
    Assert.assertTrue(
        assignment3_1.equals(templateSynchedSection3a)
            || assignment3_1.equals(templateSynchedSection3b)
            || assignment3_1.equals(templateSynchedSection3c));
    Assert.assertTrue(
        assignment2_1.equals(templateSynchedSection3a)
            || assignment2_1.equals(templateSynchedSection3b)
            || assignment2_1.equals(templateSynchedSection3c));
    Assert.assertTrue(
        assignment1_1.equals(templateSynchedSection3a)
            || assignment1_1.equals(templateSynchedSection3b)
            || assignment1_1.equals(templateSynchedSection3c));
    // section 4
    List<Assignment> assignmentsSection4 = section4.getAssignments();
    Assert.assertEquals(2, assignmentsSection4.size());
    Assignment templateSynchedSection4a = assignmentsSection4.get(0).getTemplateReference();
    Assignment templateSynchedSection4b = assignmentsSection4.get(1).getTemplateReference();
    Assert.assertTrue(
        assignment2_2.equals(templateSynchedSection4a)
            || assignment2_2.equals(templateSynchedSection4b));
    Assert.assertTrue(
        assignment4_1.equals(templateSynchedSection4a)
            || assignment4_1.equals(templateSynchedSection4b));

    // check update of assignments
    Assert.assertEquals("Assignment 2 description", assignment2_1.getSummary());
    Assert.assertEquals("Assignment 4 description", assignment4_1.getSummary());
  }
Ejemplo n.º 23
0
  @Test
  public void removeAssignment() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make the binder and the section
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();

    // make 4 assignments
    Section templateSection = portfolioService.getSection(sectionRef);
    Assignment assignment_1 =
        portfolioService.addAssignment(
            "1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_2 =
        portfolioService.addAssignment(
            "2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_3 =
        portfolioService.addAssignment(
            "3 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_4 =
        portfolioService.addAssignment(
            "3 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    dbInstance.commitAndCloseSession();

    boolean ok = portfolioService.deleteAssignment(assignment_3);
    Assert.assertTrue(ok);
    dbInstance.commitAndCloseSession();

    List<Assignment> assignments = portfolioService.getSection(sectionRef).getAssignments();
    Assert.assertNotNull(assignments);
    Assert.assertEquals(3, assignments.size());
    Assert.assertTrue(assignments.contains(assignment_1));
    Assert.assertTrue(assignments.contains(assignment_2));
    Assert.assertFalse(assignments.contains(assignment_3));
    Assert.assertTrue(assignments.contains(assignment_4));
  }
Ejemplo n.º 24
0
  @Test
  public void syncBinder_moveInNewSection() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef0 = portfolioService.getSections(templateBinder).get(0);
    // add 2 sections
    SectionRef sectionRef1 =
        portfolioService.appendNewSection("1 section ", "Section 1", null, null, templateBinder);
    SectionRef sectionRef2 =
        portfolioService.appendNewSection("2 section ", "Section 2", null, null, templateBinder);
    dbInstance.commit();

    // make 4 assignments
    Section templateSection0 = portfolioService.getSection(sectionRef0);
    Section templateSection1 = portfolioService.getSection(sectionRef1);
    Section templateSection2 = portfolioService.getSection(sectionRef2);
    Assignment assignment1_1 =
        portfolioService.addAssignment(
            "1.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection1,
            false,
            false,
            false,
            null);
    Assignment assignment1_2 =
        portfolioService.addAssignment(
            "1.2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection1,
            false,
            false,
            false,
            null);
    Assignment assignment2_1 =
        portfolioService.addAssignment(
            "2.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection2,
            false,
            false,
            false,
            null);
    Assignment assignment2_2 =
        portfolioService.addAssignment(
            "2.2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection2,
            false,
            false,
            false,
            null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(4, templateAssignments.size());

    // a user take the binder and synched it a first time
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, "72", null);
    dbInstance.commit();
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(synchedBinder);
    Assert.assertEquals(binder, synchedBinder.getBinder());

    // start all assignments
    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    Assert.assertEquals(4, assignments.size());
    for (Assignment assignment : assignments) {
      portfolioService.startAssignment(assignment, id);
      dbInstance.commit();
    }
    dbInstance.commit();

    // check that the student has it's 4 pages
    List<Page> pages = portfolioService.getPages(binder, null);
    Assert.assertEquals(4, pages.size());

    // author create a new section and move an assignment
    SectionRef sectionRef3 =
        portfolioService.appendNewSection("3 section ", "Section 3", null, null, templateBinder);
    dbInstance.commit();

    Section templateSection3 = portfolioService.getSection(sectionRef3);
    Assignment assignment3_1 =
        portfolioService.addAssignment(
            "3.1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection3,
            false,
            false,
            false,
            null);
    dbInstance.commit();

    // the author move an assigment
    portfolioService.moveAssignment(templateSection1, assignment1_1, templateSection2);
    dbInstance.commit();
    portfolioService.moveAssignment(templateSection2, assignment2_1, templateSection3);
    dbInstance.commitAndCloseSession();

    // check the move
    List<Assignment> templateAssignmentsSection1 =
        portfolioService.getAssignments(templateSection1, null);
    Assert.assertTrue(templateAssignmentsSection1.contains(assignment1_2));
    List<Assignment> templateAssignmentsSection2 =
        portfolioService.getAssignments(templateSection2, null);
    Assert.assertTrue(templateAssignmentsSection2.contains(assignment2_2));
    Assert.assertTrue(templateAssignmentsSection2.contains(assignment1_1));
    List<Assignment> templateAssignmentsSection3 =
        portfolioService.getAssignments(templateSection3, null);
    Assert.assertTrue(templateAssignmentsSection3.contains(assignment2_1));
    Assert.assertTrue(templateAssignmentsSection3.contains(assignment3_1));

    // synched and check the sections order
    SynchedBinder synchedBinder2 = portfolioService.loadAndSyncBinder(binder);
    Binder freshBinder = synchedBinder2.getBinder();
    List<Section> sections = portfolioService.getSections(freshBinder);
    Assert.assertEquals(4, sections.size());
    Section section0 = sections.get(0);
    Section section1 = sections.get(1);
    Section section2 = sections.get(2);
    Section section3 = sections.get(3);
    Assert.assertEquals(templateSection0, section0.getTemplateReference());
    Assert.assertEquals(templateSection1, section1.getTemplateReference());
    Assert.assertEquals(templateSection2, section2.getTemplateReference());
    Assert.assertEquals(templateSection3, section3.getTemplateReference());

    // load pages from section 1
    List<Page> pagesSection1 = portfolioService.getPages(section1);
    Assert.assertEquals(1, pagesSection1.size());
    Page page1_2 = pagesSection1.get(0);
    Assert.assertTrue(page1_2.getTitle().equals("1.2 Assignment"));

    // and pages from section 2
    List<Page> pagesSection2 = portfolioService.getPages(section2);
    Assert.assertEquals(2, pagesSection2.size());
    Page page2_2 = pagesSection2.get(0);
    Page page1_1 = pagesSection2.get(1);
    Assert.assertTrue(
        page2_2.getTitle().equals("1.1 Assignment") || page2_2.getTitle().equals("2.2 Assignment"));
    Assert.assertTrue(
        page1_1.getTitle().equals("1.1 Assignment") || page1_1.getTitle().equals("2.2 Assignment"));

    // and pages from section 3
    List<Page> pagesSection3 = portfolioService.getPages(section3);
    Assert.assertEquals(1, pagesSection3.size());
    Page page2_1 = pagesSection3.get(0);
    Assert.assertTrue(page2_1.getTitle().equals("2.1 Assignment"));

    List<Assignment> assignmentsSection3 = section3.getAssignments();
    Assert.assertEquals(2, assignmentsSection3.size());

    Assignment templateSynchedSection3a = assignmentsSection3.get(0).getTemplateReference();
    Assignment templateSynchedSection3b = assignmentsSection3.get(1).getTemplateReference();
    Assert.assertTrue(
        assignment3_1.equals(templateSynchedSection3a)
            || assignment3_1.equals(templateSynchedSection3b));
    Assert.assertTrue(
        assignment2_1.equals(templateSynchedSection3a)
            || assignment2_1.equals(templateSynchedSection3b));
  }
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(final UserRequest ureq, final Controller source, final Event event) {
    final String cmd = event.getCommand();
    if (source == searchCtr) {
      if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_ENTRY)) {
        // user selected entry to get a preview
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        final RepositoryEntry repositoryEntry = searchCtr.getSelectedEntry();
        final RepositoryHandler typeToLaunch =
            RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
        if (typeToLaunch == null) {
          final StringBuilder sb = new StringBuilder(translate("error.launch"));
          sb.append(": No launcher for repository entry: ");
          sb.append(repositoryEntry.getKey());
          throw new OLATRuntimeException(RepositoryDetailsController.class, sb.toString(), null);
        }
        // do skip the increment launch counter, this is only a preview!
        final OLATResourceable ores = repositoryEntry.getOlatResource();

        removeAsListenerAndDispose(previewCtr);
        previewCtr = typeToLaunch.createLaunchController(ores, null, ureq, getWindowControl());
        listenTo(previewCtr);

        removeAsListenerAndDispose(previewModalCtr);
        previewModalCtr =
            new CloseableModalController(
                getWindowControl(),
                translate("referencableSearch.preview.close"),
                previewCtr.getInitialComponent());
        listenTo(previewModalCtr);

        previewModalCtr.activate();

      } else if (cmd.equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
        // done, user selected a repo entry
        selectedRepositoryEntry = searchCtr.getSelectedEntry();
        fireEvent(ureq, EVENT_REPOSITORY_ENTRY_SELECTED);
      }
      initLinks();
    } else if (source == addController) {
      if (event.equals(Event.DONE_EVENT)) {
        cmc.deactivate();

        selectedRepositoryEntry = addController.getAddedEntry();
        fireEvent(ureq, EVENT_REPOSITORY_ENTRY_SELECTED);
        // info message
        final String message =
            translate(
                "message.entry.selected",
                new String[] {
                  addController.getAddedEntry().getDisplayname(),
                  addController.getAddedEntry().getResourcename()
                });
        getWindowControl().setInfo(message);
      } else if (event.equals(Event.CANCELLED_EVENT)) {
        cmc.deactivate();

      } else if (event.equals(Event.FAILED_EVENT)) {
        showError("add.failed");
      }
    }
  }
Ejemplo n.º 26
0
  @Override
  public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
    List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();

    Map<CalendarKey, CalendarUserConfiguration> configMap =
        calendarManager.getCalendarUserConfigurationsMap(identity);

    // personal calendar
    CalendarKey personalCalendarKey =
        new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
    CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
    if (calendarModule.isEnablePersonalCalendar()
        && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
      File iCalFile =
          calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
      if (iCalFile != null) {
        aggregatedFiles.add(
            new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
      }

      // reload every hour
      List<CalendarFileInfos> importedCalendars =
          importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
      aggregatedFiles.addAll(importedCalendars);
    }

    // group calendars
    if (calendarModule.isEnableGroupCalendar()) {
      SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
      groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
      List<BusinessGroup> groups =
          businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
      for (BusinessGroup group : groups) {
        String calendarId = group.getKey().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
          }
        }
      }
    }

    if (calendarModule.isEnableCourseElementCalendar()
        || calendarModule.isEnableCourseToolCalendar()) {
      List<Object[]> resources = getCourses(identity);
      for (Object[] resource : resources) {
        RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
        String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
          }
        }
      }
    }

    return aggregatedFiles;
  }
Ejemplo n.º 27
0
  @Test
  public void deleteSynchedBinder() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-12");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-13");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // get section
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();

    // make 2 assignments
    Section templateSection = portfolioService.getSection(sectionRef);
    Assignment assignment_1 =
        portfolioService.addAssignment(
            "1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_2 =
        portfolioService.addAssignment(
            "2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(2, templateAssignments.size());

    // synched and check the sections order
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = synchedBinder.getBinder();
    dbInstance.commitAndCloseSession();

    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    Assignment startedAssignment_1 = portfolioService.startAssignment(assignments.get(0), id);
    Assignment startedAssignment_2 = portfolioService.startAssignment(assignments.get(1), id);
    Long startedPageKey_1 = startedAssignment_1.getPage().getKey();
    Long startedPageKey_2 = startedAssignment_2.getPage().getKey();
    dbInstance.commitAndCloseSession();

    // add some comments
    OLATResourceable startedPageOres_1 =
        OresHelper.createOLATResourceableInstance(Page.class, startedPageKey_1);
    userCommentsDao.createComment(id, startedPageOres_1, null, "Hello");

    // delete
    boolean deleted = portfolioService.deleteBinder(binder);
    dbInstance.commit();
    Assert.assertTrue(deleted);

    // check that the template is save
    Assignment reloadAssignment_1 = assignmentDao.loadAssignmentByKey(assignment_1.getKey());
    Assert.assertNotNull(reloadAssignment_1);
    Assignment reloadAssignment_2 = assignmentDao.loadAssignmentByKey(assignment_2.getKey());
    Assert.assertNotNull(reloadAssignment_2);

    // check that the binder is really deleted
    Binder reloadedBinder = binderDao.loadByKey(binder.getKey());
    Assert.assertNull(reloadedBinder);

    Assignment reloadStartedAssignment_1 =
        assignmentDao.loadAssignmentByKey(startedAssignment_1.getKey());
    Assert.assertNull(reloadStartedAssignment_1);
    Assignment reloadStartedAssignment_2 =
        assignmentDao.loadAssignmentByKey(startedAssignment_2.getKey());
    Assert.assertNull(reloadStartedAssignment_2);

    Page reloadedStartedPage_1 = pageDao.loadByKey(startedPageKey_1);
    Assert.assertNull(reloadedStartedPage_1);
    Page reloadedStartedPage_2 = pageDao.loadByKey(startedPageKey_2);
    Assert.assertNull(reloadedStartedPage_2);
  }
Ejemplo n.º 28
0
  @Test
  public void submitTask_relativeLifecycle() {
    // prepare a course with a volatile task
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
    repositoryEntryRelationDao.addRole(participant1, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant2, re, GroupRoles.participant.name());
    dbInstance.commit();

    String label = "Life cycle for relative date";
    String softKey = UUID.randomUUID().toString();
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DATE, -5);
    Date from = cal.getTime();
    cal.add(Calendar.DATE, 20);
    Date to = cal.getTime();
    RepositoryEntryLifecycle lifecycle = reLifeCycleDao.create(label, softKey, true, from, to);
    re.setLifecycle(lifecycle);
    re = dbInstance.getCurrentEntityManager().merge(re);
    dbInstance.commit();

    // create a fake node with a relative submit deadline 15 days after the start of the course
    GTACourseNode node = new GTACourseNode();
    node.getModuleConfiguration()
        .setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
    node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE, 15);
    node.getModuleConfiguration()
        .setStringValue(
            GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE_TO, GTARelativeToDates.courseStart.name());

    TaskList tasks = gtaManager.createIfNotExists(re, node);
    Assert.assertNotNull(tasks);
    dbInstance.commitAndCloseSession();

    // the course has start 5 days before, deadline is 15 days after it
    // conclusion the deadline is 10 days from now

    { // check before 5 days
      ReminderRuleImpl rule = getSubmitTaskRules(5, LaunchUnit.day);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(0, all.size());
    }

    { // check before 1 week
      ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.week);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(0, all.size());
    }

    { // check before 10 days
      ReminderRuleImpl rule = getSubmitTaskRules(10, LaunchUnit.day);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }

    { // check before 2 days
      ReminderRuleImpl rule = getSubmitTaskRules(10, LaunchUnit.week);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }

    { // check before 30 days
      ReminderRuleImpl rule = getSubmitTaskRules(30, LaunchUnit.day);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }

    { // check before 1 months
      ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.month);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }

    { // check before 5 months
      ReminderRuleImpl rule = getSubmitTaskRules(5, LaunchUnit.month);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }

    { // check before 1 year
      ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.year);
      List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);

      Assert.assertEquals(2, all.size());
      Assert.assertTrue(all.contains(participant1));
      Assert.assertTrue(all.contains(participant2));
    }
  }
Ejemplo n.º 29
0
  @Test
  public void removeAssignment_usedOne() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-10");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-11");
    RepositoryEntry templateEntry = createTemplate(owner, "Template", "TE");
    dbInstance.commitAndCloseSession();

    // make 2 sections
    Binder templateBinder = portfolioService.getBinderByResource(templateEntry.getOlatResource());
    SectionRef sectionRef = portfolioService.getSections(templateBinder).get(0);
    dbInstance.commit();

    // make 4 assignments
    Section templateSection = portfolioService.getSection(sectionRef);
    Assignment assignment_1 =
        portfolioService.addAssignment(
            "1 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_2 =
        portfolioService.addAssignment(
            "2 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_3 =
        portfolioService.addAssignment(
            "3 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    Assignment assignment_4 =
        portfolioService.addAssignment(
            "4 Assignment",
            "",
            "",
            AssignmentType.essay,
            templateSection,
            false,
            false,
            false,
            null);
    dbInstance.commit();
    List<Assignment> templateAssignments = portfolioService.getAssignments(templateBinder, null);
    Assert.assertEquals(4, templateAssignments.size());
    Assert.assertTrue(templateAssignments.contains(assignment_1));
    Assert.assertTrue(templateAssignments.contains(assignment_2));
    Assert.assertTrue(templateAssignments.contains(assignment_3));
    Assert.assertTrue(templateAssignments.contains(assignment_4));

    // synched and check the sections order
    Binder binder = portfolioService.assignBinder(id, templateBinder, templateEntry, null, null);
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = synchedBinder.getBinder();
    dbInstance.commitAndCloseSession();

    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    portfolioService.startAssignment(assignments.get(0), id);
    portfolioService.startAssignment(assignments.get(1), id);
    portfolioService.startAssignment(assignments.get(2), id);
    portfolioService.startAssignment(assignments.get(3), id);
    dbInstance.commit();

    List<Section> sections = portfolioService.getSections(binder);
    List<Page> pages = portfolioService.getPages(sections.get(0));
    Assert.assertEquals(4, pages.size());

    // delete an assignment
    boolean ok = portfolioService.deleteAssignment(assignment_3);
    Assert.assertTrue(ok);
    dbInstance.commitAndCloseSession();

    // sync the binder
    SynchedBinder reSynchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = reSynchedBinder.getBinder();
    dbInstance.commitAndCloseSession();

    // deleting an assignment doesn't delete the pages
    List<Page> allPages = portfolioService.getPages(sections.get(0));
    Assert.assertEquals(4, allPages.size());

    // sync twice
    SynchedBinder reReSynchedBinder = portfolioService.loadAndSyncBinder(binder);
    binder = reReSynchedBinder.getBinder();
    dbInstance.commitAndCloseSession();
  }
  /**
   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
   */
  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == onCommand) {
      // toggle on
      Preferences prefs = ureq.getUserSession().getGuiPreferences();
      prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.TRUE);
      prefs.save();
      // update gui
      mainVC.remove(onCommand);
      offCommand = LinkFactory.createLink("command.glossary.off", mainVC, this);
      offCommand.setTitle("command.glossary.off.alt");
      offCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
      // notify textmarker controller
      glossMarkupItmCtr.setTextMarkingEnabled(true);
      fireEvent(ureq, new Event("glossaryOn"));

    } else if (source == offCommand) {
      // toggle off
      Preferences prefs = ureq.getUserSession().getGuiPreferences();
      prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.FALSE);
      prefs.save();
      // update gui
      mainVC.remove(offCommand);
      onCommand = LinkFactory.createLink("command.glossary.on", mainVC, this);
      onCommand.setTitle("command.glossary.on.alt");
      onCommand.setCustomEnabledLinkCSS("b_toolbox_toggle");
      // notify textmarker controller
      glossMarkupItmCtr.setTextMarkingEnabled(false);
      fireEvent(ureq, new Event("glossaryOff"));
    } else if (source == mainVC && event.getCommand().equals("command.glossary")) {
      // start glossary in window
      final CourseConfig cc = courseEnvir.getCourseConfig(); // do not cache cc, not save

      // if glossary had been opened from LR as Tab before, warn user:
      DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
      RepositoryEntry repoEntry =
          RepositoryManager.getInstance()
              .lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
      DTab dt = dts.getDTab(repoEntry.getOlatResource());
      if (dt != null) {
        List<ContextEntry> entries =
            BusinessControlFactory.getInstance()
                .createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
        dts.activate(ureq, dt, entries);
      } else {
        ControllerCreator ctrlCreator =
            new ControllerCreator() {
              public Controller createController(UserRequest lureq, WindowControl lwControl) {
                GlossaryMainController glossaryController =
                    CourseGlossaryFactory.createCourseGlossaryMainRunController(
                        lwControl, lureq, cc, allowGlossaryEditing);
                listenTo(glossaryController);
                if (glossaryController == null) {
                  // happens in the unlikely event of a user who is in a course and
                  // now
                  // tries to access the glossary
                  String text = translate("error.noglossary");
                  return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
                } else {
                  // use a one-column main layout
                  LayoutMain3ColsController layoutCtr =
                      new LayoutMain3ColsController(
                          lureq,
                          lwControl,
                          null,
                          null,
                          glossaryController.getInitialComponent(),
                          null);
                  // dispose glossary on layout dispose
                  layoutCtr.addDisposableChildController(glossaryController);
                  return layoutCtr;
                }
              }
            };

        ControllerCreator layoutCtrlr =
            BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
        // open in new browser window
        openInNewBrowserWindow(ureq, layoutCtrlr);
        return; // immediate return after opening new browser window!
      }
    }
  }