Skip navigation
 

Context
Added by George Kroner, last edited by George Kroner on 23 Feb 2008 12:17 AM
(None)

Getting parent learning context information

NOTE: This applies to WebCT Vista 3.x. In Vista 4/CE 6, the getParent and getChildren methods were added to the ContextSDK to retrieve information about parent and child learning contexts.

A question that comes up often is:
"I have a section learning context object. How do I get information about it's parent course?"

Until recently, the answer was always:
"Query the RPT_LEARNING_CONTEXT view in the reporting interfaces."

This isn't always convenient nor even possible in some cases. There is an alternative however, that uses only SDK calls. Note that the procedure described here is a bit of a workaround and there is NO GUARANTEE IT WILL WORK in future versions of the SDK.

In a nutshell, here is how it works:

First, it assumes that the session user is enrolled in the section for which you want the parent course.

  1. Use the FileManager web service's getRootFolders method.
  2. Loop through the list of folders until you find the one that matches the section. (Compare the LearningCtxtVO's label to the FileManagerFolder's path)
  3. When you find the matching folder, remove the start of the folder's path from "/webct/WebCT Server" down to (and including) the institution name. Then remove the section name from the end of the folder's path. The resulting string will look something like this: /My Group/My Course

Here you already have your course name, but what if you want more, like the LCID?

  1. Pass the resulting string to the Context web service's getLearningContextIdByPath method and voilĂ ! You have the LCID of the course.

To get the actual learning context VO, pass the LCID to the getLearningContext method.

Here is some PHP code to demonstrate. $fm and $context are the FileManager and Context proxies respectively.

$roots = $fm->getRootFolders($session);
print "<pre>";
foreach($roots as $root)
{
    $path = $root->path;
    print $path;
    $parts = explode("/", $path);

    // find a section
    if($parts=="Section Content")
    {
        // chop off path from server down to institution
        array_splice($parts, 0, 6);

        // chop off the section name and section content
        array_splice($parts, 2, 2);
        $fixedPath = "/" . implode("/", $parts);
        $lcid = $context->getLearningContextIdByPath($session, $fixedPath);
        print "Course LCID: $lcid\n";
        $lc = $context->getLearningContext($session, $lcid);
        var_dump($lc);
    }
    print "\n";
}
print "</pre>";
This article originally authored by Paul Monk on the WebCT DevNet

The method I use to get the details of a parent learning context (e.g. the course from within a section) is to use the getParentLcId() method of the com.webct.platform.sdkext.authmoduledata.LearningContextVO object. This returns the ID of the parent learning context which can then be used to get its LearningContextVO object. This seems to me to be a lot simpler than the looping method described on this page.

My only outstanding query in relation to this solution (reported in Case #472522, 23 July 2007) is that under AP2 a section can now have two parents in the learning context hierarchy (a course and a term), so does the getParentLcId() method guarantee to return the course (rather than the term).

Adaptavist Theme Builder Powered by Atlassian Confluence

By accessing the Knowledge Base, you agree to the following: Blackboard makes no representations or warranties as to the accuracy of any information in the Knowledge Base. Blackboard is not responsible in any way for information provided to the Knowledge Base by third parties. Information in the Knowledge Base is not documentation for any Blackboard product. Nothing in the Knowledge Base shall be deemed to modify your license in any way to any Blackboard product. Blackboard reserves the right to use your name and the name of your institution in reference to any information submitted by you to the Knowledge Base. Blackboard may modify, distribute, republish in any format, delete, incorporate or use in any way the information that you contribute to the Knowledge Base.