Ejemplo n.º 1
0
  private void init(final UserRequest ureq) {
    startButton = LinkFactory.createButton("start", myContent, this);
    // fetch disclaimer file
    String sDisclaimer = (String) modConfig.get(IQEditController.CONFIG_KEY_DISCLAIMER);
    if (sDisclaimer != null) {
      VFSContainer baseContainer = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
      final int lastSlash = sDisclaimer.lastIndexOf('/');
      if (lastSlash != -1) {
        baseContainer = (VFSContainer) baseContainer.resolve(sDisclaimer.substring(0, lastSlash));
        sDisclaimer = sDisclaimer.substring(lastSlash);
        // first check if disclaimer exists on filesystem
        if (baseContainer == null || baseContainer.resolve(sDisclaimer) == null) {
          showWarning("disclaimer.file.invalid", sDisclaimer);
        } else {
          // screenreader do not like iframes, display inline
          if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
            final HtmlStaticPageComponent disclaimerComp =
                new HtmlStaticPageComponent("disc", baseContainer);
            myContent.put("disc", disclaimerComp);
            disclaimerComp.setCurrentURI(sDisclaimer);
            myContent.contextPut("hasDisc", Boolean.TRUE);
          } else {
            iFrameCtr = new IFrameDisplayController(ureq, getWindowControl(), baseContainer);
            listenTo(iFrameCtr); // dispose automatically
            myContent.put("disc", iFrameCtr.getInitialComponent());
            iFrameCtr.setCurrentURI(sDisclaimer);
            myContent.contextPut("hasDisc", Boolean.TRUE);
          }
        }
      }
    }

    // push title and learning objectives, only visible on intro page
    myContent.contextPut("menuTitle", courseNode.getShortTitle());
    myContent.contextPut("displayTitle", courseNode.getLongTitle());

    // Adding learning objectives
    final String learningObj = courseNode.getLearningObjectives();
    if (learningObj != null) {
      final Component learningObjectives =
          ObjectivesHelper.createLearningObjectivesComponent(learningObj, ureq);
      myContent.put("learningObjectives", learningObjectives);
      myContent.contextPut("hasObjectives", learningObj); // dummy value, just an exists operator
    }

    if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
      checkChats(ureq);
      singleUserEventCenter.registerFor(this, getIdentity(), chatEventOres);
    }
  }
  public PortfolioCourseNodeEditController(
      final UserRequest ureq,
      final WindowControl wControl,
      final ICourse course,
      final PortfolioCourseNode node,
      final ModuleConfiguration config,
      final UserCourseEnvironment euce) {
    super(ureq, wControl);
    this.config = config;
    this.courseNode = node;

    configForm = new PortfolioConfigForm(ureq, wControl, course, node);
    listenTo(configForm);
    scoringController = new MSEditFormController(ureq, wControl, config);
    scoringContent = scoringController.getInitialComponent();
    listenTo(scoringController);
    textForm = new PortfolioTextForm(ureq, wControl, course, node);
    listenTo(textForm);

    configContent = createVelocityContainer("edit");
    configContent.put("configForm", configForm.getInitialComponent());
    configContent.put("textForm", textForm.getInitialComponent());

    // Accessibility precondition
    final CourseGroupManager groupMgr = course.getCourseEnvironment().getCourseGroupManager();
    final CourseEditorTreeModel editorModel = course.getEditorTreeModel();
    final Condition accessCondition = node.getPreConditionAccess();
    accessibilityCondContr =
        new ConditionEditController(
            ureq,
            getWindowControl(),
            groupMgr,
            accessCondition,
            "accessabilityConditionForm",
            AssessmentHelper.getAssessableNodes(editorModel, node),
            euce);
    listenTo(accessibilityCondContr);

    // if there is already user data available, make for read only
    final UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    hasLogEntries = am.hasUserNodeLogs(node);
    configContent.contextPut("hasLogEntries", new Boolean(hasLogEntries));
    if (hasLogEntries) {
      scoringController.setDisplayOnly(true);
    }
    // Initialstate
    configContent.contextPut("isOverwriting", new Boolean(false));
  }
Ejemplo n.º 3
0
  @Override
  @SuppressWarnings("unused")
  protected void event(final UserRequest ureq, final Component source, final Event event) {
    if (STATISTICS_FULL_RECALCULATION_TRIGGER_BUTTON.equals(event.getCommand())) {
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {

        final String title = getTranslator().translate("statistics.fullrecalculation.really.title");
        final String text = getTranslator().translate("statistics.fullrecalculation.really.text");
        dialogCtr_ = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), title, text);
        listenTo(dialogCtr_);
        dialogCtr_.activate();
      }
    } else if (STATISTICS_UPDATE_TRIGGER_BUTTON.equals(event.getCommand())) {
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {
        statisticUpdateManager.updateStatistics(false, getUpdateFinishedCallback());
        refreshUIState();
        content.put(
            "updatecontrol",
            new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000));
        getInitialComponent().setDirty(true);
      }
    }
  }
Ejemplo n.º 4
0
 /**
  * refreshing the add elements link to actual structure
  *
  * @param ureq
  * @param struct maybe null -> hiding the add-button
  */
 private void refreshAddElements(final UserRequest ureq, final PortfolioStructure struct) {
   tocV.remove(tocV.getComponent("addElement"));
   removeAsListenerAndDispose(addElCtrl);
   if (struct != null) {
     addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
     if (struct instanceof EPPage) {
       if (secCallback.canAddStructure()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
       }
       if (secCallback.canAddArtefact()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
       }
     } else if (struct instanceof EPAbstractMap) {
       if (secCallback.canAddPage()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
       }
     } else { // its a structure element
       if (secCallback.canAddArtefact()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
       }
     }
     listenTo(addElCtrl);
     tocV.put("addElement", addElCtrl.getInitialComponent());
   }
 }
  /**
   * @param ureq
   * @param subscriptionContext
   * @param publisherData
   */
  public ContextualSubscriptionController(
      UserRequest ureq,
      WindowControl wControl,
      SubscriptionContext subscriptionContext,
      PublisherData publisherData) {
    super(ureq, wControl);
    this.subscriptionContext = subscriptionContext;
    this.publisherData = publisherData;
    isNewNotificationService = useNewNotificationService(publisherData);

    myContent = createVelocityContainer("consubs");

    if (subscriptionContext == null) {
      setInitialComponent(new Panel("empty:nosubscription"));
      return;
    }

    detailsPanel = new Panel("subscription_detail");
    allPanel = new Panel("subscription_all");

    subscribeButton = LinkFactory.createButtonSmall("command.subscribe", myContent, this);
    // subscribeButton.setCustomEnabledLinkCSS("b_noti_subscribe_link");

    this.unsubscribeButton = LinkFactory.createButtonSmall("command.unsubscribe", myContent, this);
    // unsubscribeButton.setCustomEnabledLinkCSS("b_noti_unsubscribe_link");

    if (isNewNotificationService) {
      log.info(
          "Notification-Service: " + publisherData.getType() + " is running with NEW notification");
      newNotificationService = getService(LearnServices.notificationLearnService);
      subscriptionContext.setContextId(
          getRepositoryService()
              .getRepositoryEntryIdFromResourceable(
                  subscriptionContext.getResId(),
                  subscriptionContext.getResName())); // TODO: LD: move this at construction of
      // subscriptionContext
      newSubscriptionContext =
          newNotificationService.createNotificationSubscriptionContext(
              ureq.getIdentity(), subscriptionContext, publisherData);
      isSubscribed = newNotificationService.isSubscribed(newSubscriptionContext);
    } else {
      log.info(
          "Notification-Service: "
              + publisherData.getType()
              + " is running with LEGACY notification");
      notifManager = getNotificationService();
      // if subscribed, offer a unsubscribe button and vica versa.
      isSubscribed = notifManager.isSubscribed(ureq.getIdentity(), subscriptionContext);
    }

    updateUI();
    myContent.put("detailsPanel", detailsPanel);
    allPanel.setContent(myContent);
    putInitialPanel(allPanel);
  }
Ejemplo n.º 6
0
  public EPTOCController(
      final UserRequest ureq,
      final WindowControl wControl,
      final PortfolioStructure selectedEl,
      final PortfolioStructure rootNode,
      final EPSecurityCallback secCallback) {
    super(ureq, wControl);
    this.secCallback = secCallback;
    tocV = createVelocityContainer("toc");
    ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
    eSTMgr = (PortfolioStructureDao) CoreSpringFactory.getBean(PortfolioStructureDao.class);
    this.rootNode = rootNode;
    final AjaxTreeModel treeModel = buildTreeModel();
    treeCtr =
        new TreeController(
            ureq, getWindowControl(), translate("toc.root"), treeModel, "myjsCallback");
    treeCtr.setTreeSorting(false, false, false);
    listenTo(treeCtr);
    tocV.put("tocTree", treeCtr.getInitialComponent());
    delButton =
        LinkFactory.createCustomLink(
            "deleteButton", DELETE_LINK_CMD, "   ", Link.NONTRANSLATED, tocV, this);
    delButton.setTooltip(translate("deleteButton"), false);
    delButton.setCustomEnabledLinkCSS("b_delete_icon b_eportfolio_del_link ");
    tocV.put("deleteButton", delButton);

    if (selectedEl == null) {
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey()); // select map
      refreshAddElements(ureq, rootNode);
    } else {
      final String pagePath = calculatePathByDeepestNode(selectedEl);
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey() + pagePath);
      structureClicked = selectedEl;
      refreshAddElements(ureq, selectedEl);
    }

    putInitialPanel(tocV);
  }
Ejemplo n.º 7
0
 @Override
 protected void event(final UserRequest ureq, final Controller source, final Event event) {
   if (source == dialogCtr_) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
       if (statisticUpdateManager == null) {
         log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
       } else {
         statisticUpdateManager.updateStatistics(true, getUpdateFinishedCallback());
         refreshUIState();
         content.put(
             "updatecontrol",
             new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000));
         getInitialComponent().setDirty(true);
       }
     }
   }
 }
  /**
   * Constructor
   *
   * @param ureq
   * @param wControl
   */
  protected CalendarPortletRunController(final UserRequest ureq, final WindowControl wControl) {
    super(ureq, wControl);

    calendarVC = createVelocityContainer("calendarPortlet");
    showAllLink = LinkFactory.createLink("calendar.showAll", calendarVC, this);
    ComponentUtil.registerForValidateEvents(calendarVC, this);

    final Date date = new Date();
    final String today =
        DateFormat.getTimeInstance(DateFormat.MEDIUM, ureq.getLocale()).format(date);
    calendarVC.contextPut("today", today);

    final TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("calendar.noEvents"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("b_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    // dummy header key, won't be used since setDisplayTableHeader is set to
    // false
    tableController.addColumnDescriptor(
        new PortletDateColumnDescriptor("calendar.date", 0, getTranslator()));
    tableController.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "calendar.subject", 1, CMD_LAUNCH, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));

    final List events = getMatchingEvents(ureq, wControl);
    tableController.setTableDataModel(new EventsModel(events));
    listenTo(tableController);

    calendarVC.put("table", tableController.getInitialComponent());

    putInitialPanel(this.calendarVC);
  }
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == usersForm) {
      if (event == Event.DONE_EVENT) {
        // calc stuff, preview

        final List existIdents = securityManager.getIdentitiesOfSecurityGroup(securityGroup);
        oks = new ArrayList<Identity>();
        final List<String> anonymous = new ArrayList<String>();
        final List<String> notFounds = new ArrayList<String>();
        final List<String> alreadyIn = new ArrayList<String>();

        // get the logins
        final String inp = usersForm.getLoginsString();
        final String[] lines = inp.split("\r?\n");
        for (int i = 0; i < lines.length; i++) {
          final String username = lines[i].trim();
          if (!username.equals("")) { // skip empty lines
            final Identity ident = securityManager.findIdentityByName(username);
            if (ident == null) { // not found, add to not-found-list
              notFounds.add(username);
            } else if (getBaseSecurityEBL().isAnonymous(ident)) {
              anonymous.add(username);
            } else {
              // check if already in group
              final boolean inGroup = containsIdentity(existIdents, ident);
              if (inGroup) {
                // added to warning: already in group
                alreadyIn.add(ident.getName());
              } else {
                // ok to add -> preview (but filter duplicate entries)
                if (!containsIdentity(oks, ident)) {
                  oks.add(ident);
                }
              }
            }
          }
        }
        // push table and other infos to velocity
        removeAsListenerAndDispose(newTableC);
        newTableC =
            UserControllerFactory.createTableControllerFor(
                null, oks, ureq, getWindowControl(), null);
        listenTo(newTableC);

        mainVc.put("table", newTableC.getInitialComponent());
        mainVc.contextPut("isanonymous", listNames(anonymous));
        mainVc.contextPut("notfound", listNames(notFounds));
        mainVc.contextPut("alreadyin", listNames(alreadyIn));
        mainVc.contextPut("usercount", new Integer(oks.size()));
        // set table page as next wizard step
        setNextWizardStep(translate("import.title.finish"), mainVc);
      }

    } else if (source == mailCtr) {
      if (event == Event.DONE_EVENT) {
        final MultiIdentityChosenEvent multiEvent = new MultiIdentityChosenEvent(this.oks);
        multiEvent.setMailTemplate(mailCtr.getMailTemplate());
        fireEvent(ureq, multiEvent);
      }
    }
  }
Ejemplo n.º 10
0
  /**
   * @param ureq
   * @param cpRoot
   * @param showMenu
   * @param activateFirstPage
   */
  CPDisplayController(
      final UserRequest ureq,
      final WindowControl wControl,
      final VFSContainer rootContainer,
      final boolean showMenu,
      final boolean activateFirstPage,
      final String initialUri,
      final OLATResourceable ores) {
    super(ureq, wControl);
    this.rootContainer = rootContainer;

    // wrapper velocity container for page content
    this.myContent = createVelocityContainer("cpDisplay");
    // the cp component, added to the velocity

    if (!ureq.getUserSession().getRoles().isGuestOnly()) {
      final SearchServiceUIFactory searchServiceUIFactory =
          (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class);
      searchCtrl =
          searchServiceUIFactory.createInputController(ureq, wControl, DisplayOption.BUTTON, null);
      myContent.put("search_input", searchCtrl.getInitialComponent());
    }

    // TODO:gs:a
    // may add an additional config for disabling, enabling IFrame style or not in CP mode
    // but always disable IFrame display when in screenreader mode (no matter whether style gets
    // ugly)
    if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
      cpComponent = new HtmlStaticPageComponent("", rootContainer);
      cpComponent.addListener(this);
      myContent.put("cpContent", cpComponent);
    } else {
      cpContentCtr =
          new IFrameDisplayController(ureq, getWindowControl(), rootContainer, null, ores);
      cpContentCtr.setAllowDownload(true);
      listenTo(cpContentCtr);
      myContent.put("cpContent", cpContentCtr.getInitialComponent());
    }

    // even if we do not show the menu, we need to build parse the manifest and
    // find the first node to display at startup
    final VFSItem mani = rootContainer.resolve("imsmanifest.xml");
    if (mani == null || !(mani instanceof VFSLeaf)) {
      throw new OLATRuntimeException(
          "error.manifest.missing",
          null,
          this.getClass().getPackage().getName(),
          "CP " + rootContainer + " has no imsmanifest",
          null);
    }
    // initialize tree model in any case
    ctm = new CPManifestTreeModel((VFSLeaf) mani);

    if (showMenu) {
      // the menu is only initialized when needed.
      cpTree = new MenuTree("cpDisplayTree");
      cpTree.setTreeModel(ctm);
      cpTree.addListener(this);
    }

    LoggingResourceable nodeInfo = null;
    if (activateFirstPage) {
      // set content to first accessible child or root node if no children
      // available
      TreeNode node = ctm.getRootNode();
      if (node == null) {
        throw new OLATRuntimeException(
            CPDisplayController.class,
            "root node of content packaging was null, file:" + rootContainer,
            null);
      }
      while (node != null && !node.isAccessible()) {
        if (node.getChildCount() > 0) {
          node = (TreeNode) node.getChildAt(0);
        } else {
          node = null;
        }
      }
      if (node != null) { // node.isAccessible
        final String nodeUri = (String) node.getUserObject();
        if (cpContentCtr != null) {
          cpContentCtr.setCurrentURI(nodeUri);
        }
        if (cpComponent != null) {
          cpComponent.setCurrentURI(nodeUri);
        }
        if (showMenu) {
          cpTree.setSelectedNodeId(node.getIdent());
        }
        // activate the selected node in the menu (skips the root node that is
        // empty anyway and saves one user click)
        selNodeId = node.getIdent();

        nodeInfo = LoggingResourceable.wrapCpNode(nodeUri);
      }
    } else if (initialUri != null) {
      // set page
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(initialUri);
      }
      if (cpComponent != null) {
        cpComponent.setCurrentURI(initialUri);
      }
      // update menu
      final TreeNode newNode = ctm.lookupTreeNodeByHref(initialUri);
      if (newNode != null) { // user clicked on a link which is listed in the
        // toc
        if (cpTree != null) {
          cpTree.setSelectedNodeId(newNode.getIdent());
        } else {
          selNodeId = newNode.getIdent();
        }
      }
      nodeInfo = LoggingResourceable.wrapCpNode(initialUri);
    }
    // Note: the ores has a typename of ICourse - see
    // CPCourseNode.createNodeRunConstructorResult
    // which has the following line:
    // OresHelper.createOLATResourceableInstance(ICourse.class,
    // userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    // therefore we use OresHelper.calculateTypeName(ICourse.class) here
    if (ores != null
        && nodeInfo != null
        && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
      addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.cp));
      ThreadLocalUserActivityLogger.log(
          LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass(), nodeInfo);
    }

    putInitialPanel(myContent);
  }
Ejemplo n.º 11
0
  /**
   * @param ureq
   * @param wControl
   * @param rootDir The VFS root directory from which the linkable files should be read
   * @param uploadRelPath The relative path within the rootDir where uploaded files should be put
   *     into. If NULL, the root Dir is used
   * @param suffixes Array of allowed file types
   * @param fileName the path of the file currently edited (in order to compute the correct relative
   *     paths for links), e.g. bla/blu.html or index.html
   */
  public FileLinkChooserController(
      UserRequest ureq,
      WindowControl wControl,
      VFSContainer rootDir,
      String uploadRelPath,
      String[] suffixes,
      String fileName) {
    super(ureq, wControl);
    this.fileName = fileName;
    this.suffixes = suffixes;
    this.rootDir = rootDir;
    this.mainVC = createVelocityContainer("filechooser");

    // file uploads are relative to the currently edited file
    String[] dirs = this.fileName.split("/");
    VFSContainer fileUploadBase = rootDir;
    for (String subPath : dirs) {
      // try to resolve the given file path in the root container
      VFSItem subFolder = fileUploadBase.resolve(subPath);
      if (subFolder != null) {
        if (subFolder instanceof VFSContainer) {
          // a higher level found, use this one unless a better one is found
          fileUploadBase = (VFSContainer) subFolder;
        } else {
          // it is not a container - leaf reached
          break;
        }
      } else {
        // resolving was not possible??? stop here
        break;
      }
    }
    // create directory filter combined with suffix filter
    String[] dirFilters = {"_courseelementdata"};
    VFSItemFilter customFilter = null;
    VFSItemFilter dirFilter = new VFSItemExcludePrefixFilter(dirFilters);
    if (suffixes != null) {
      VFSItemFileTypeFilter typeFilter = new VFSItemFileTypeFilter(suffixes);
      typeFilter.setCompositeFilter(dirFilter);
      customFilter = typeFilter;
    } else {
      customFilter = dirFilter;
    }
    // hide file chooser title, we have our own title
    fileChooserController =
        FileChooserUIFactory.createFileChooserControllerWithoutTitle(
            ureq, getWindowControl(), rootDir, customFilter, true);
    listenTo(fileChooserController);
    mainVC.put("stTree", fileChooserController.getInitialComponent());

    // convert file endings to mime types as needed by file upload controller
    Set<String> mimeTypes = null;
    if (suffixes != null) {
      mimeTypes = new HashSet<String>();
      for (String suffix : suffixes) {
        String mimeType = WebappHelper.getMimeType("dummy." + suffix);
        if (mimeType != null) {
          if (!mimeTypes.contains(mimeType)) mimeTypes.add(mimeType);
        }
      }
    }
    uploadCtr =
        new FileUploadController(
            wControl,
            fileUploadBase,
            ureq,
            (int) FolderConfig.getLimitULKB(),
            Quota.UNLIMITED,
            mimeTypes,
            true);
    listenTo(uploadCtr);
    // set specific upload path
    uploadCtr.setUploadRelPath(uploadRelPath);

    mainVC.put("uploader", uploadCtr.getInitialComponent());

    putInitialPanel(mainVC);
  }