Search in sources :

Example 86 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class StatisticCourseNodesController method buildTreeModel.

private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
    final GenericTreeModel gtm = new GenericTreeModel();
    final GenericTreeNode rootTreeNode = new GenericTreeNode();
    rootTreeNode.setTitle("start");
    gtm.setRootNode(rootTreeNode);
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    new TreeVisitor(new Visitor() {

        @Override
        public void visit(INode node) {
            CourseNode courseNode = (CourseNode) node;
            StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
            if (result != null) {
                StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
                rootTreeNode.addChild(courseNodeTreeNode);
                TreeModel subTreeModel = result.getSubTreeModel();
                if (subTreeModel != null) {
                    TreeNode subRootNode = subTreeModel.getRootNode();
                    List<INode> subNodes = new ArrayList<>();
                    for (int i = 0; i < subRootNode.getChildCount(); i++) {
                        subNodes.add(subRootNode.getChildAt(i));
                    }
                    for (INode subNode : subNodes) {
                        courseNodeTreeNode.addChild(subNode);
                    }
                }
            }
        }
    }, course.getRunStructure().getRootNode(), true).visitAll();
    return gtm;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) TreeVisitor(org.olat.core.util.tree.TreeVisitor) TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) CourseNode(org.olat.course.nodes.CourseNode)

Example 87 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class StatisticResult method getIndentednodeRendererMap.

private Map<String, Object> getIndentednodeRendererMap(int row) {
    if (row >= orderedNodesList_.size()) {
        throw new IllegalStateException("row count too big: " + row + ", only having " + orderedNodesList_.size() + " elements");
    }
    CourseNode node = orderedNodesList_.get(row);
    int recursionLevel = 0;
    INode parent = node.getParent();
    while (parent != null) {
        recursionLevel++;
        parent = parent.getParent();
    }
    // Store node data in hash map. This hash map serves as data model for
    // the user assessment overview table. Leave user data empty since not used in
    // this table. (use only node data)
    Map<String, Object> nodeData = new HashMap<String, Object>();
    // indent
    nodeData.put(AssessmentHelper.KEY_INDENT, new Integer(recursionLevel));
    // course node data
    nodeData.put(AssessmentHelper.KEY_TYPE, node.getType());
    nodeData.put(AssessmentHelper.KEY_TITLE_SHORT, node.getShortTitle());
    nodeData.put(AssessmentHelper.KEY_TITLE_LONG, node.getLongTitle());
    nodeData.put(AssessmentHelper.KEY_IDENTIFYER, node.getIdent());
    // plus the node
    nodeData.put(StatisticResult.KEY_NODE, node);
    return nodeData;
}
Also used : INode(org.olat.core.util.nodes.INode) HashMap(java.util.HashMap) CourseNode(org.olat.course.nodes.CourseNode)

Example 88 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class StatisticResult method doAddQueryListResultsForNodeAndChildren.

private void doAddQueryListResultsForNodeAndChildren(CourseNode node, List<Object[]> result, Set<String> groupByKeys) {
    orderedNodesList_.add(node);
    for (Iterator<?> it = result.iterator(); it.hasNext(); ) {
        Object[] columns = (Object[]) it.next();
        if (columns.length != 3) {
            throw new IllegalStateException("result should be three columns wide");
        }
        String businessPath = (String) columns[0];
        if (!businessPath.matches("\\[RepositoryEntry:.*\\]\\[CourseNode:" + node.getIdent() + "\\]")) {
            continue;
        }
        String groupByKey = String.valueOf(columns[1]);
        groupByKeys.add(groupByKey);
        int count = (Integer) columns[2];
        Map<String, Integer> nodeMap = statistic_.get(node);
        if (nodeMap == null) {
            nodeMap = new HashMap<String, Integer>();
            statistic_.put(node, nodeMap);
        }
        Integer existingCount = nodeMap.get(groupByKey);
        if (existingCount == null) {
            nodeMap.put(groupByKey, count);
        } else {
            nodeMap.put(groupByKey, existingCount + count);
        }
        it.remove();
    }
    int childCount = node.getChildCount();
    for (int i = 0; i < childCount; i++) {
        INode n = node.getChildAt(i);
        if (n instanceof CourseNode) {
            doAddQueryListResultsForNodeAndChildren((CourseNode) n, result, groupByKeys);
        }
    }
}
Also used : INode(org.olat.core.util.nodes.INode) CourseNode(org.olat.course.nodes.CourseNode)

Example 89 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class QTIEditorMainController method createReferenceesMsg.

/**
 * helper method to create the message about qti resource stakeholders and
 * from where the qti resource is referenced.
 *
 * @return
 */
private String createReferenceesMsg(UserRequest ureq) {
    /*
		 * problems: A tries to reference this test, after test editor has been
		 * started
		 */
    changeEmail = new ContactMessage(ureq.getIdentity());
    // the owners of this qtiPkg
    RepositoryEntry myEntry = repositoryManager.lookupRepositoryEntry(qtiPackage.getRepresentingResourceable(), false);
    // add qti resource owners as group
    ContactList cl = new ContactList("qtiPkgOwners");
    cl.addAllIdentites(repositoryService.getMembers(myEntry, GroupRoles.owner.name()));
    changeEmail.addEmailTo(cl);
    StringBuilder result = new StringBuilder();
    result.append(translate("qti.restricted.leading"));
    for (Iterator<Reference> iter = referencees.iterator(); iter.hasNext(); ) {
        Reference element = iter.next();
        if ("CourseModule".equals(element.getSource().getResourceableTypeName())) {
            ICourse course = null;
            try {
                course = CourseFactory.loadCourse(element.getSource().getResourceableId());
                if (course == null) {
                    continue;
                }
            } catch (CorruptedCourseException ex) {
                logError("", ex);
                continue;
            }
            CourseNode cn = course.getEditorTreeModel().getCourseNode(element.getUserdata());
            if (cn == null) {
                logError("Cannot find course element " + element.getUserdata() + " in course " + course, null);
                continue;
            }
            String courseTitle = course.getCourseTitle();
            StringBuilder stakeHolders = new StringBuilder();
            // the course owners
            RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course, false);
            if (entry != null) {
                // OO-1300
                List<Identity> stakeHoldersIds = repositoryService.getMembers(entry, GroupRoles.owner.name());
                if (stakeHoldersIds != null && stakeHoldersIds.size() > 0) {
                    // add stakeholders as group
                    cl = new ContactList(courseTitle);
                    cl.addAllIdentites(stakeHoldersIds);
                    changeEmail.addEmailTo(cl);
                    for (Identity stakeHoldersId : stakeHoldersIds) {
                        if (stakeHolders.length() > 0)
                            stakeHolders.append(", ");
                        User user = stakeHoldersId.getUser();
                        stakeHolders.append(user.getProperty(UserConstants.FIRSTNAME, getLocale())).append(" ").append(user.getProperty(UserConstants.LASTNAME, getLocale()));
                    }
                }
            }
            String courseNodeTitle = cn.getShortTitle();
            result.append(translate("qti.restricted.course", StringHelper.escapeHtml(courseTitle)));
            result.append(translate("qti.restricted.node", StringHelper.escapeHtml(courseNodeTitle)));
            result.append(translate("qti.restricted.owners", stakeHolders.toString()));
        }
    }
    return result.toString();
}
Also used : User(org.olat.core.id.User) Reference(org.olat.resource.references.Reference) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) ContactList(org.olat.core.util.mail.ContactList) ContactMessage(org.olat.core.util.mail.ContactMessage) CorruptedCourseException(org.olat.course.CorruptedCourseException) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 90 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class EPFrontendManager method submitMap.

private void submitMap(PortfolioStructureMap map, boolean logActivity, Role by) {
    // add an exception
    if (!(map instanceof EPStructuredMap))
        return;
    EPStructuredMap submittedMap = (EPStructuredMap) map;
    structureManager.submitMap(submittedMap);
    EPTargetResource resource = submittedMap.getTargetResource();
    OLATResourceable courseOres = resource.getOLATResourceable();
    ICourse course = CourseFactory.loadCourse(courseOres);
    AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
    CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
    List<Identity> owners = policyManager.getOwners(submittedMap);
    for (Identity owner : owners) {
        if (courseNode != null) {
            // courseNode might have been deleted meanwhile
            IdentityEnvironment ienv = new IdentityEnvironment();
            ienv.setIdentity(owner);
            UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
            if (logActivity) {
                am.incrementNodeAttempts(courseNode, owner, uce, by);
            } else {
                am.incrementNodeAttemptsInBackground(courseNode, owner, uce);
            }
            RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            assessmentService.updateAssessmentEntry(owner, courseEntry, courseNode.getIdent(), referenceEntry, AssessmentEntryStatus.inReview);
        }
        assessmentNotificationsHandler.markPublisherNews(owner, course.getResourceableId());
        log.audit("Map " + map + " from " + owner.getName() + " has been submitted.");
    }
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) OLATResourceable(org.olat.core.id.OLATResourceable) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Aggregations

CourseNode (org.olat.course.nodes.CourseNode)402 ICourse (org.olat.course.ICourse)182 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)98 Identity (org.olat.core.id.Identity)74 STCourseNode (org.olat.course.nodes.STCourseNode)72 ArrayList (java.util.ArrayList)68 RepositoryEntry (org.olat.repository.RepositoryEntry)64 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)54 INode (org.olat.core.util.nodes.INode)44 GTACourseNode (org.olat.course.nodes.GTACourseNode)44 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)42 TACourseNode (org.olat.course.nodes.TACourseNode)40 TreeNode (org.olat.core.gui.components.tree.TreeNode)38 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)36 MSCourseNode (org.olat.course.nodes.MSCourseNode)36 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)30 Test (org.junit.Test)28 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)28 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)26