Пример #1
0
  /** Used by to task executor, without any GUI */
  @Override
  public void run() {
    final List<BulkAssessmentFeedback> feedbacks = new ArrayList<>();
    try {
      log.audit("Start process bulk assessment");

      LoggingResourceable[] infos = new LoggingResourceable[2];
      if (task != null && task.getCreator() != null) {
        UserSession session = new UserSession();
        session.setIdentity(task.getCreator());
        session.setSessionInfo(
            new SessionInfo(task.getCreator().getKey(), task.getCreator().getName()));
        ThreadLocalUserActivityLoggerInstaller.initUserActivityLogger(session);
        infos[0] = LoggingResourceable.wrap(courseRes, OlatResourceableType.course);
        ThreadLocalUserActivityLogger.addLoggingResourceInfo(infos[0]);
        infos[1] = LoggingResourceable.wrap(getCourseNode());
        ThreadLocalUserActivityLogger.addLoggingResourceInfo(infos[1]);
      }

      doProcess(feedbacks);
      log.audit("End process bulk assessment");
      cleanup();

      ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_BULK, getClass(), infos);
    } catch (Exception e) {
      log.error("", e);
      feedbacks.add(new BulkAssessmentFeedback("", "bulk.assessment.error"));
      throw e;
    } finally {
      cleanupUnzip();
      sendFeedback(feedbacks);
    }
  }
  private void doInsert(UserRequest ureq, TreePosition tp) {
    ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());

    int insertPos = tp.getChildpos();
    CourseNode selectedNode = getCourseNode(tp.getParentTreeNode());
    CourseEditorTreeNode insertParent =
        course.getEditorTreeModel().getCourseEditorNodeById(selectedNode.getIdent());

    // check if insert position is within the to-be-copied tree
    if (course.getEditorTreeModel().checkIfIsChild(insertParent, moveCopyFrom)) {
      showError("movecopynode.error.overlap");
      fireEvent(ureq, Event.CANCELLED_EVENT);
    } else if (copy) { // do a copy
      // copy subtree and save model
      recursiveCopy(
          moveCopyFrom,
          insertParent,
          insertPos,
          true,
          CourseFactory.getCourseEditSession(ores.getResourceableId()));
      CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());

      ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_COPIED, getClass());
      fireEvent(ureq, Event.DONE_EVENT);
    } else { // move only
      if (insertParent.getIdent().equals(moveCopyFrom.getParent().getIdent())) {
        // same parent, adjust insertPos
        if (insertPos > moveCopyFrom.getPosition()) insertPos--;
      }
      insertParent.insert(moveCopyFrom, insertPos);

      moveCopyFrom.setDirty(true);
      // mark subtree as dirty
      TreeVisitor tv =
          new TreeVisitor(
              new Visitor() {
                @Override
                public void visit(INode node) {
                  CourseEditorTreeNode cetn = (CourseEditorTreeNode) node;
                  cetn.setDirty(true);
                }
              },
              moveCopyFrom,
              true);
      tv.visitAll();
      CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
      showInfo("movecopynode.info.condmoved");

      ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_MOVED, getClass());
      fireEvent(ureq, Event.DONE_EVENT);
    }
  }
Пример #3
0
  private Activateable2 doAssessmentTool(UserRequest ureq) {
    OLATResourceable ores = OresHelper.createOLATResourceableType("TestStatistics");
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(
        LoggingResourceable.wrapBusinessPath(ores));
    WindowControl swControl = addToHistory(ureq, ores, null);

    if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach()) {
      AssessmentToolSecurityCallback secCallback =
          new AssessmentToolSecurityCallback(
              reSecurity.isEntryAdmin(),
              reSecurity.isEntryAdmin(),
              reSecurity.isCourseCoach(),
              reSecurity.isGroupCoach(),
              null);

      AssessableResource el = getAssessableElement();
      AssessmentToolController ctrl =
          new AssessmentToolController(
              ureq, swControl, toolbarPanel, getRepositoryEntry(), el, secCallback);
      listenTo(ctrl);
      assessmentToolCtrl = pushController(ureq, "Statistics", ctrl);
      currentToolCtr = assessmentToolCtrl;
      setActiveTool(assessmentLink);
      enableRuntimeNavBar(false);
      return assessmentToolCtrl;
    }
    return null;
  }
  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;
  }
Пример #5
0
  public List<BulkAssessmentFeedback> process() {
    List<BulkAssessmentFeedback> feedbacks = new ArrayList<>();
    try {
      LoggingResourceable infos = LoggingResourceable.wrap(getCourseNode());
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(infos);

      doProcess(feedbacks);
      cleanup();
    } catch (Exception e) {
      log.error("", e);
      feedbacks.add(new BulkAssessmentFeedback("", "bulk.assessment.error"));
    } finally {
      cleanupUnzip();
    }
    return feedbacks;
  }
Пример #6
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;
 }
  /*
   * (non-Javadoc)
   * @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) {
    if (source == this.groupCreateController) {
      if (event == Event.DONE_EVENT) {
        final String bgDesc = this.groupCreateController.getGroupDescription();
        final Integer bgMax = this.groupCreateController.getGroupMax();
        final Integer bgMin = this.groupCreateController.getGroupMin();
        final Boolean enableWaitingList = this.groupCreateController.isWaitingListEnabled();
        final Boolean enableAutoCloseRanks = this.groupCreateController.isAutoCloseRanksEnabled();

        Set<String> allNames = new HashSet<String>();
        if (this.bulkMode) {
          allNames = this.groupCreateController.getGroupNames();
        } else {
          allNames.add(this.groupCreateController.getGroupName());
        }

        this.newGroups =
            this.groupManager.createUniqueBusinessGroupsFor(
                allNames,
                this.bgContext,
                bgDesc,
                bgMin,
                bgMax,
                enableWaitingList,
                enableAutoCloseRanks);
        if (this.newGroups != null) {
          for (final Iterator<BusinessGroup> iter = this.newGroups.iterator(); iter.hasNext(); ) {
            final BusinessGroup bg = iter.next();
            final LoggingResourceable resourceInfo = LoggingResourceable.wrap(bg);
            ThreadLocalUserActivityLogger.log(
                GroupLoggingAction.GROUP_CREATED, getClass(), resourceInfo);
          }
          // workflow successfully finished
          // so far no events on the systembus to inform about new groups in BGContext
          fireEvent(ureq, Event.DONE_EVENT);
        } else {
          // Could not create any group, because one or groups-name already exist. Set error of non
          // existing name
          this.groupCreateController.setGroupNameExistsError(null);
        }
      } else if (event == Event.CANCELLED_EVENT) {
        // workflow cancelled
        fireEvent(ureq, Event.CANCELLED_EVENT);
      }
    }
  }
Пример #8
0
  private Activateable2 doOptions(UserRequest ureq) {
    OLATResourceable ores = OresHelper.createOLATResourceableType("Options");
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(
        LoggingResourceable.wrapBusinessPath(ores));
    WindowControl swControl = addToHistory(ureq, ores, null);

    if (reSecurity.isEntryAdmin()) {
      Binder binder = portfolioService.getBinderByResource(getRepositoryEntry().getOlatResource());
      BinderDeliveryOptionsController ctrl =
          new BinderDeliveryOptionsController(ureq, swControl, binder);
      listenTo(ctrl);
      optionsCtrl = pushController(ureq, "Options", ctrl);
      currentToolCtr = optionsCtrl;
      setActiveTool(optionsLink);
      enableRuntimeNavBar(false);
      return optionsCtrl;
    }
    return null;
  }
  private AuthorListController doOpenMyEntries(UserRequest ureq) {
    if (myEntriesCtrl == null) {
      SearchAuthorRepositoryEntryViewParams searchParams =
          new SearchAuthorRepositoryEntryViewParams(
              getIdentity(), ureq.getUserSession().getRoles());
      searchParams.setOwnedResourcesOnly(true);

      OLATResourceable ores = OresHelper.createOLATResourceableInstance("My", 0l);
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(
          LoggingResourceable.wrapBusinessPath(ores));
      WindowControl bwControl =
          BusinessControlFactory.getInstance()
              .createBusinessWindowControl(ores, null, getWindowControl());
      myEntriesCtrl = new AuthorListController(ureq, bwControl, "search.my", searchParams, false);
      listenTo(myEntriesCtrl);
    }

    currentCtrl = myEntriesCtrl;
    addToHistory(ureq, myEntriesCtrl);
    mainVC.put("segmentCmp", myEntriesCtrl.getStackPanel());
    return myEntriesCtrl;
  }
Пример #10
0
 @Override
 public boolean delete(VFSItem item, boolean force) {
   if (item instanceof VFSContainer) {
     if (force) {
       VFSContainer container = (VFSContainer) item;
       VFSContainer versionContainer = getCanonicalVersionFolder(container, false);
       if (versionContainer == null) {
         return true;
       }
       return VFSConstants.YES.equals(versionContainer.delete());
     }
     return true;
   } else if (item instanceof VFSLeaf && item instanceof Versionable) {
     VFSLeaf leaf = (VFSLeaf) item;
     if (force || isTemporaryFile(leaf)) {
       cleanUp(leaf);
     } else {
       Identity identity = ThreadLocalUserActivityLogger.getLoggedIdentity();
       addToRevisions((Versionable) leaf, identity, null);
     }
   }
   return false;
 }
Пример #11
0
  /**
   * @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)
   */
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == startButton && startButton.isEnabled() && startButton.isVisible()) {
      long courseResId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
      String courseNodeIdent = courseNode.getIdent();
      removeAsListenerAndDispose(displayController);

      OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck("test");
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(
          LoggingResourceable.wrapBusinessPath(ores));
      WindowControl bwControl = addToHistory(ureq, ores, null);
      Controller returnController =
          iqManager.createIQDisplayController(
              modConfig, secCallback, ureq, bwControl, courseResId, courseNodeIdent, this);
      /*
       * 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.isClosed()) {
          // do nothing
        } else 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
          displayContainerController =
              new LayoutMain3ColsController(ureq, getWindowControl(), displayController);
          listenTo(displayContainerController); // autodispose

          // need to wrap a course restart controller again, because IQDisplay
          // runs on top of GUIStack
          ICourse course = CourseFactory.loadCourse(courseResId);
          RepositoryEntry courseRepositoryEntry =
              course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
          Panel empty = new Panel("empty"); // empty panel set as "menu" and "tool"
          Controller courseCloser =
              new DisposedCourseRestartController(ureq, getWindowControl(), courseRepositoryEntry);
          Controller disposedRestartController =
              new LayoutMain3ColsController(
                  ureq,
                  getWindowControl(),
                  empty,
                  courseCloser.getInitialComponent(),
                  "disposed course whily in iqRun" + courseResId);
          displayContainerController.setDisposedMessageController(disposedRestartController);

          final boolean fullWindow =
              modConfig.getBooleanSafe(IQEditController.CONFIG_FULLWINDOW, true);
          if (fullWindow) {
            displayContainerController.setAsFullscreen(ureq);
          }
          displayContainerController.activate();

          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) {
      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
        long callingResId =
            userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
        String callingResDetail = courseNode.getIdent();
        assessmentID =
            iqManager.getLastAssessmentID(ureq.getIdentity(), callingResId, callingResDetail);
      }
      if (assessmentID != null && !assessmentID.equals("")) {
        Document doc =
            iqManager.getResultsReportingFromFile(ureq.getIdentity(), type, assessmentID);
        // StringBuilder resultsHTML =
        // LocalizedXSLTransformer.getInstance(ureq.getLocale()).renderResults(doc);
        String summaryConfig = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
        int summaryType = AssessmentInstance.getSummaryType(summaryConfig);
        String resultsHTML =
            iqManager.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);
    }
  }