Exemplo n.º 1
0
 private void checkChats(final UserRequest ureq) {
   if (ureq != null) {
     allChats = (List) ureq.getUserSession().getEntry("chats");
   }
   if (allChats == null || allChats.size() == 0) {
     startButton.setEnabled(true);
     myContent.contextPut("hasChatWindowOpen", false);
   } else {
     startButton.setEnabled(false);
     myContent.contextPut("hasChatWindowOpen", true);
   }
 }
Exemplo n.º 2
0
 @SuppressWarnings("unused")
 @Override
 protected void event(final UserRequest ureq, final Component source, final Event event) {
   if (source instanceof Link) {
     final Link link = (Link) source;
     if (link.getCommand().equals(DELETE_LINK_CMD)) {
       if (artefactNodeClicked != null) {
         final AbstractArtefact artefact =
             ePFMgr.loadArtefactByKey(new Long(getArtefactIdFromNodeId(artefactNodeClicked)));
         final PortfolioStructure parentStruct =
             ePFMgr.loadPortfolioStructureByKey(
                 new Long(getArtefactParentStructIdFromNodeId(artefactNodeClicked)));
         ePFMgr.removeArtefactFromStructure(artefact, parentStruct);
         // refresh the view
         fireEvent(ureq, Event.CHANGED_EVENT);
       } else if (structureClicked != null) {
         if ((structureClicked instanceof EPPage)
             && !(structureClicked instanceof EPAbstractMap)) {
           PortfolioStructure ps = structureClicked;
           while (ePFMgr.loadStructureParent(ps) != null) {
             ps = ePFMgr.loadStructureParent(ps);
           }
           final int childPages = ePFMgr.countStructureChildren(ps);
           if (childPages > 1) {
             eSTMgr.removeStructureRecursively(structureClicked);
             // refresh the view
             fireEvent(ureq, Event.CHANGED_EVENT);
           } else {
             showError("last.page.not.deletable");
           }
         } else if (structureClicked instanceof EPStructureElement
             && !(structureClicked instanceof EPAbstractMap)) {
           // structures should always be deletable
           eSTMgr.removeStructureRecursively(structureClicked);
           // refresh the view
           fireEvent(ureq, Event.CHANGED_EVENT);
         } else {
           showInfo("element.not.deletable");
         }
       }
     }
   }
 }
Exemplo n.º 3
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);
  }
 public void setSubscribeButtonTitle(String i18nKey) {
   subscribeButton.setTitle(i18nKey);
 }
Exemplo n.º 5
0
  @Override
  protected void event(final UserRequest ureq, final Component source, final Event event) {
    if (source == startButton && startButton.isEnabled()) {
      final long callingResId =
          userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
      final String callingResDetail = courseNode.getIdent();
      removeAsListenerAndDispose(displayController);
      final Controller returnController =
          IQManager.getInstance()
              .createIQDisplayController(
                  modConfig, secCallback, ureq, getWindowControl(), callingResId, callingResDetail);
      /*
       * either returnController is a MessageController or it is a IQDisplayController this should not serve as pattern to be copy&pasted. FIXME:2008-11-21:pb
       * INTRODUCED because of read/write QTI Lock solution for scalability II, 6.1.x Release
       */
      if (returnController instanceof IQDisplayController) {
        displayController = (IQDisplayController) returnController;
        listenTo(displayController);
        if (displayController.isReady()) {
          // in case displayController was unable to initialize, a message was set by
          // displayController
          // this is the case if no more attempts or security check was unsuccessfull
          final LayoutMain3ColsController layoutCtr =
              new LayoutMain3ColsController(
                  ureq,
                  getWindowControl(),
                  null,
                  null,
                  displayController.getInitialComponent(),
                  null);
          listenTo(layoutCtr); // autodispose

          // need to wrap a course restart controller again, because IQDisplay
          // runs on top of GUIStack
          final ICourse course = CourseFactory.loadCourse(callingResId);
          final RepositoryEntry courseRepositoryEntry =
              RepositoryServiceImpl.getInstance().lookupRepositoryEntry(course, true);
          final Panel empty = new Panel("empty"); // empty panel set as "menu" and "tool"
          final Controller courseCloser =
              CourseFactory.createDisposedCourseRestartController(
                  ureq, getWindowControl(), courseRepositoryEntry.getResourceableId());
          final Controller disposedRestartController =
              new LayoutMain3ColsController(
                  ureq,
                  getWindowControl(),
                  empty,
                  empty,
                  courseCloser.getInitialComponent(),
                  "disposed course whily in iqRun" + callingResId);
          layoutCtr.setDisposedMessageController(disposedRestartController);

          getWindowControl().pushToMainArea(layoutCtr.getInitialComponent());
          if (modConfig
              .get(IQEditController.CONFIG_KEY_TYPE)
              .equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
            assessmentStopped = false;
            singleUserEventCenter.registerFor(this, getIdentity(), assessmentInstanceOres);
            singleUserEventCenter.fireEventToListenersOf(
                new AssessmentEvent(AssessmentEvent.TYPE.STARTED, ureq.getUserSession()),
                assessmentEventOres);
          }
        } // endif isReady
      } else {
        // -> qti file was locked -> show info message
        // user must click again on course node to activate
        mainPanel.pushContent(returnController.getInitialComponent());
      }
    } else if (source == showResultsButton) {
      final AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
      Long assessmentID = am.getAssessmentID(courseNode, ureq.getIdentity());
      if (assessmentID == null) {
        // fallback solution: if the assessmentID is not available via AssessmentManager than try to
        // get it via IQManager
        final long callingResId =
            userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
        final String callingResDetail = courseNode.getIdent();
        assessmentID =
            IQManager.getInstance()
                .getLastAssessmentID(ureq.getIdentity(), callingResId, callingResDetail);
      }
      if (assessmentID != null && !assessmentID.equals("")) {
        final Document doc =
            IQManager.getInstance()
                .getResultsReportingFromFile(ureq.getIdentity(), type, assessmentID);
        // StringBuilder resultsHTML =
        // LocalizedXSLTransformer.getInstance(ureq.getLocale()).renderResults(doc);
        final String summaryConfig = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
        final int summaryType = AssessmentInstance.getSummaryType(summaryConfig);
        final String resultsHTML =
            IQManager.getInstance().transformResultsReporting(doc, ureq.getLocale(), summaryType);
        myContent.contextPut("displayreporting", resultsHTML);
        myContent.contextPut("resreporting", resultsHTML);
        myContent.contextPut("showResults", Boolean.TRUE);
      }
    } else if (source == hideResultsButton) {
      myContent.contextPut("showResults", Boolean.FALSE);
    }
  }
Exemplo n.º 6
0
 @Override
 protected void event(final UserRequest ureq, final Controller source, final Event event) {
   if (event instanceof TreeNodeClickedEvent) {
     resetClickedNodes();
     final TreeNodeClickedEvent treeEv = (TreeNodeClickedEvent) event;
     final String nodeClicked = treeEv.getNodeId();
     final boolean isArtefactNode = nodeClicked.startsWith(ARTEFACT_NODE_IDENTIFIER);
     if (!nodeClicked.equals(ROOT_NODE_IDENTIFIER) && !isArtefactNode) {
       structureClicked = ePFMgr.loadPortfolioStructureByKey(new Long(nodeClicked));
       refreshAddElements(ureq, structureClicked);
       delButton.setVisible(true);
       // send event to load this page
       fireEvent(
           ureq, new EPStructureChangeEvent(EPStructureChangeEvent.SELECTED, structureClicked));
       // needed because refreshAddElements set flc dirty, therefore selected node gets lost
       final String path = idToPath.get(structureClicked.getKey());
       treeCtr.selectPath(path);
     } else if (isArtefactNode) {
       artefactNodeClicked = nodeClicked;
       refreshAddElements(ureq, null);
       delButton.setVisible(true);
       final String artIdent = getArtefactIdFromNodeId(nodeClicked);
       final String path = idToPath.get(new Long(artIdent));
       final PortfolioStructure structure = pathToStructure.get(path);
       fireEvent(ureq, new EPArtefactClicked(ARTEFACT_NODE_CLICKED, structure));
       // needed because refreshAddElements set flc dirty, therefore selected node gets lost
       treeCtr.selectPath(path);
     } else {
       // root tree node clicked, no add/delete link
       delButton.setVisible(false);
       refreshAddElements(ureq, null);
       fireEvent(ureq, new Event(ARTEFACT_NODE_CLICKED));
     }
   } else if (event instanceof MoveTreeNodeEvent) {
     resetClickedNodes();
     final MoveTreeNodeEvent moveEvent = (MoveTreeNodeEvent) event;
     final String movedNode = moveEvent.getNodeId();
     final String oldParent = moveEvent.getOldParentNodeId();
     final String newParent = moveEvent.getNewParentNodeId();
     int newPos = moveEvent.getPosition();
     final boolean isArtefactNode = movedNode.startsWith(ARTEFACT_NODE_IDENTIFIER);
     if (isArtefactNode) {
       final String nodeId = getArtefactIdFromNodeId(movedNode);
       if (checkNewArtefactTarget(nodeId, newParent)) {
         if (moveArtefactToNewParent(nodeId, oldParent, newParent)) {
           if (log.isDebugEnabled()) {
             log.info(
                 "moved artefact " + nodeId + " from structure " + oldParent + " to " + newParent,
                 null);
           }
           moveEvent.setResult(true, null, null);
           // refresh the view
           final EPMoveEvent movedEvent = new EPMoveEvent(newParent, nodeId);
           fireEvent(ureq, movedEvent);
         } else {
           moveEvent.setResult(
               false, translate("move.error.title"), translate("move.artefact.error.move"));
         }
       } else {
         moveEvent.setResult(
             false, translate("move.error.title"), translate("move.artefact.error.target"));
       }
     } else {
       if (checkNewStructureTarget(movedNode, oldParent, newParent)) {
         if (moveStructureToNewParent(movedNode, oldParent, newParent, newPos)) {
           if (log.isDebugEnabled()) {
             log.debug(
                 "moved structure "
                     + movedNode
                     + " from structure "
                     + oldParent
                     + " to "
                     + newParent,
                 null);
           }
           moveEvent.setResult(true, null, null);
           // refresh the view
           final EPMoveEvent movedEvent = new EPMoveEvent(newParent, movedNode);
           fireEvent(ureq, movedEvent);
         } else {
           moveEvent.setResult(
               false, translate("move.error.title"), translate("move.struct.error.move"));
         }
       } else {
         moveEvent.setResult(
             false, translate("move.error.title"), translate("move.struct.error.target"));
       }
     }
   } else if (source == addElCtrl) {
     // refresh the view, this is a EPStructureChangeEvent
     fireEvent(ureq, event);
   }
 }