Follow

Course Properties and the SCORM Cloud API

Avatar

 

In our introduction to course properties article we explain the function and common uses of the SCORM Cloud package properties editor. While having a visual properties editor is great for site users who wish to configure and experiment with their course properties, it’s not ideal for API users for whom logging into the SCORM Cloud website is outside of their portal workflow.

Which is exactly why we provide an API for issuing web requests to modify Course Properties. In this article we’ll take a more in-depth look at these APIs and some common ways to leverage them. This article is specifically intended for developers and thus requires a small amount of familiarity with common programming concepts. If you’re interested in using the SCORM Cloud API and have yet to set up an integration, this page is a great place to get started.

rustici.course.getAttributes

Our SCORM Cloud package properties APIs are self-documenting. That is to say, rather than publish an exhaustive list of all properties, we make them discoverable by means of a rustici.course.getAttributes call. I’ve linked our official API docs which explain the basics of using getAttributes, so let’s take a look at some code illustrating how one might leverage the getAttributes API to discover the key/value pairs of attributes.

In our SCORM Cloud Sample PHP Library we have a sample page dedicated to demonstrating two facets of the course properties APIs. The first facet is using the rustici.course.properties method to redirect to a Course Properties Editor widget. This is useful if you wish to supply the course admins on your portal with a properties editor without forcing them to log into the main cloud.scorm.com website. As the PHP example illustrates, you can embed this widget in an iframe to seamlessly integrate it into your portal.

The other aspect demonstrated by the sample page is making calls to rustici.course.getAttributes and parsing the returned XML output to determine the state of package properties for a given course. The following code excerpt demonstrates how one might get a list of properties, display only those with true/false values, and display them in a drop-down list:

    $attributes = $courseService->GetAttributes($courseId);
    …
    foreach ($attributes as $key => $value)
    {
        if ($value == 'true' || $value == 'false')
        {
            echo "<option value='" .$key."'>" .$key."</option>";
        }
    }

Similarly, this idea of calling getAttributes and reading their values can be generalized across the other package properties.

rustici.course.updateAttributes

Having established how to discover the key/value pairs of package properties from the API, we can move on to learning about the API call required to procedurally set package properties. As the documentation for rustici.course.updateAttributes explains, updateAttributes is called with a variable number of key/value pairs on the query string to set a course’s package property. Having discovered the key/value you wish to set by means of a getAttribute call, you can then append these values to an updateAttributes call to set them procedurally.

Common Use Cases

One frequent question we field is “How can I set a package property globally?” One of the simplest mechanisms for applying a uniform set of properties to your courses is to include a call to updateAttributes in the method handling the import of your courses. After receiving an “success” response from an importCourse, call updateAttributes to set the properties on a newly imported course. This is useful for properties such as setting SCO and Player launch type to “frameset” on all your courses.

To apply a batch update across your body of courses, a onetime script could be run to issue the API commands. Here is a small PHP example:

    $courseService = $ScormService->getCourseService();
    $allResults = $courseService->GetCourseList();
    $properties = array(
        "scoLaunchType" => "1"
    );
    foreach($allResults as $course)
    {
        $courseService->UpdateAttributes($course->getCourseId(), null, $properties);
    }

Conclusion

With these tools in hand, you will have the means of procedurally setting package properties on your SCORM Cloud courses. As always, contact us at support@rusticisoftware.com  if you have any questions!

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk