Follow

Importing Content With ScormEngineManager.CreatePackage

Avatar

When using a custom upload process or creating a program to import bulk courses from a CSV file or database table, the proper way to import the course to the SCORM Engine is to use ScormEngineManager.Implementation.CreatePackage with one if it's various signatures.

Here is a sample ASP.NET page that demonstrates how this can be done:

<%@ Page Language="C#" %>
<%@ Import Namespace="RusticiSoftware.ScormContentPlayer.Logic" %>
<%@ Import Namespace="RusticiSoftware.ScormEngine.VanillaIntegration" %> 

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // if you are looping through a database table or a flat file containing multiple courses,
            // you will want to include all of this code block in your iteration loop and change the paths
            // and package keys accordingly.
 
            string UnzippedLocation = @"http://yoursite.dom/courses/thisCourseFolder/"; //this can be a webpath or a physical file path                              
            string HttpPathToContentRoot = @"http://yoursite.dom/courses/thisCourseFolder/";
            
             //change this to your custom integration classes below
            VanillaExternalConfiguration externalConfig = (VanillaExternalConfiguration) Integration.Implementation.GetExternalConfigurationObject();
            VanillaExternalPackageId externalPackageId = (VanillaExternalPackageId) Integration.Implementation.GetExternalPackageIdObject();

            //set your package keys here (you may have several to set depending upon your integration keys
            //next, create the manifest object by parsing it from your UnzippedLocation's root
            //this sample only works with SCORM since it relies on hardcoding "imsmanifest.xml"
            Manifest manifest = ScormEngineManager.Implementation.ParseManifest(UnzippedLocation  + @"imsmanifest.xml", externalConfig); 

            
//now we actually do the import by calling CreatePackage and passing in the objects we just created
           ImportResult result = ScormEngineManager.Implementation.CreatePackage(externalPackageId, manifest, HttpPathToContentRoot, externalConfig); 

            
// check the results to see if it was successful
            if (result.WasSuccessful)
            {
               string manifestParserWarnings = result.FormattedParserWarnings;
                string message = result.Message;
                string title = result.Title;
                //do what you will with this information
            }

        }

    }

</
script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ScormEngineManager.CreatePackage Sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    </div>
    </form>
</body>
</html>

 

N.B. You will need to ensure that the primary Engine assembly (RusticiSoftware.ScormEngine.dll), your integration assembly, the log4net assembly, and your SCORMEngineSettings.config, are available to this page.

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