Search in sources :

Example 6 with IQSURVCourseNode

use of org.olat.course.nodes.IQSURVCourseNode in project openolat by klemens.

the class CourseQTIArchiveController method addQTINodesAndParentsToList.

/**
 * Recursive method that adds tasks nodes and all its parents to a list
 * @param recursionLevel
 * @param courseNode
 * @return A list of Object[indent, courseNode, selectable]
 */
private List<AssessmentNodeData> addQTINodesAndParentsToList(int recursionLevel, CourseNode courseNode) {
    // 1) Get list of children data using recursion of this method
    List<AssessmentNodeData> childrenData = new ArrayList<>();
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        List<AssessmentNodeData> childData = addQTINodesAndParentsToList((recursionLevel + 1), child);
        if (childData != null) {
            childrenData.addAll(childData);
        }
    }
    if (childrenData.size() > 0 || courseNode instanceof IQSURVCourseNode) {
        // Store node data in hash map. This hash map serves as data model for
        // the tasks overview table. Leave user data empty since not used in
        // this table. (use only node data)
        AssessmentNodeData nodeData = new AssessmentNodeData(recursionLevel, courseNode);
        if (courseNode instanceof IQSURVCourseNode) {
            nodeData.setSelectable(true);
        } else {
            nodeData.setSelectable(false);
        }
        List<AssessmentNodeData> nodeAndChildren = new ArrayList<>();
        nodeAndChildren.add(nodeData);
        nodeAndChildren.addAll(childrenData);
        return nodeAndChildren;
    }
    return null;
}
Also used : IQSURVCourseNode(org.olat.course.nodes.IQSURVCourseNode) ArrayList(java.util.ArrayList) IQSURVCourseNode(org.olat.course.nodes.IQSURVCourseNode) CourseNode(org.olat.course.nodes.CourseNode) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Aggregations

IQSURVCourseNode (org.olat.course.nodes.IQSURVCourseNode)6 CourseNode (org.olat.course.nodes.CourseNode)4 FOCourseNode (org.olat.course.nodes.FOCourseNode)4 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)4 TACourseNode (org.olat.course.nodes.TACourseNode)4 File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 HttpEntity (org.apache.http.HttpEntity)2 HttpResponse (org.apache.http.HttpResponse)2 HttpGet (org.apache.http.client.methods.HttpGet)2 HttpPut (org.apache.http.client.methods.HttpPut)2 Test (org.junit.Test)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 ICourse (org.olat.course.ICourse)2