Follow

Advanced Versioning with the SCORM Engine

Avatar


The SCORM Engine has a built in way to _globally_ set how new package versions are delivered once updated. More about this can be read about here http://scorm.zendesk.com/entries/35948-versioning-in-scorm-engine-2008-1.


A more advanced way to handle this is to decide upon launch if the learner will continue on with the old version or if a new registration will be created for them using the new version. This is done by passing a configuration setting in on launch and evaluating that value based on this chart.

1 = "never"
2 = "when existing registration is complete and newer package version exists"
3 = "when newer package version exists"
4 = "when existing registration is complete"
5 = "when existing registration is satisfied"
6 = "when existing registration is satisfied and newer package version exists"
9 = "always"
0 = "use what the config file says"
First you will need to add a custom externalConfiguration property to your CLIENTNAMEExternalConfiguration class file.

public string NewRegBehavior = String.Empty;



Then you add this override to your CLIENTNAMEIntegration file:

/// <summary>
/// See <see cref="IntegrationInterface.ShouldCreateNewRegistrationInstance"> for a full description.
/// </see></summary>
/// <param name="externalReg" />External id associated with this registration
/// <param name="externalConfig" />External configuration information
/// <returns></returns>
public override bool ShouldCreateNewRegistrationInstance(ExternalRegistrationId externalReg,
                                                         ExternalConfiguration externalConfig)
{
    CLIENTNAMEExternalConfiguration config = (CLIENTNAMEExternalConfiguration)externalConfig;
    CLIENTNAMEExternalRegistrationId reg = (CLIENTNAMEExternalRegistrationId)externalReg;


    RegistrationInstanceIncrementTiming regInstanceIncrementTiming;
    if (ParserUtil.IsValidDouble(config.NewRegBehavior.ToString()))
    {
        if(config.NewRegBehavior==0) //set to use config file
        {
            return base.ShouldCreateNewRegistrationInstance(externalReg, externalConfig);
        }
        else if (config.NewRegBehavior == 9) //ALWAYS create new reg
        {
            return true;
        }
        else
        {
            //we're using one of Rustici's values so use the existing enum...
            regInstanceIncrementTiming = new RegistrationInstanceIncrementTiming((int)ParserUtil.ParseDouble(config.NewRegBehavior.ToString()));
        }
    }
    else
    {
        //use what is already in the ScormEngineSettings.config file.
        return base.ShouldCreateNewRegistrationInstance(externalReg, externalConfig);
    }


        if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.UNDEFINED)
        {
            return base.ShouldCreateNewRegistrationInstance(externalReg, externalConfig);
        }
        if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.NEVER)
        {
            return false;
        }
        else
        {
            string regId = GetScormRegistrationIdFromExternalRegistrationId(externalReg, externalConfig);
            RegistrationSummary regSummary = ScormEngineManager.GetRegistrationSummary(externalReg, externalConfig);


            if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.WHEN_EXISTING_REG_IS_COMPLETE)
            {
                return regSummary.CompletionStatus == Completion.COMPLETE;
            }
            else if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.WHEN_EXISTING_REG_IS_SATISFIED)
            {
                return regSummary.SuccessStatus == Success.PASSED;
            }
            else
            {
                ExternalPackageId packageId = GetExternalPackageIdFromExternalRegId(externalReg, externalConfig);
                bool doesNewerPackageExists = packageId.VersionId <
                                              ScormEngineManager.GetMaxVersionId(packageId, externalConfig);


                if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.WHEN_NEWER_PACKAGE_VERSION_EXISTS)
                {
                    return doesNewerPackageExists;
                }
                else if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.WHEN_EXISTING_REG_IS_COMPLETE_AND_NEWER_PACKAGE_VERSION_EXISTS)
                {
                    return doesNewerPackageExists && regSummary.CompletionStatus == Completion.COMPLETE;
                }
                else if (regInstanceIncrementTiming.Value == RegistrationInstanceIncrementTimingValue.WHEN_EXISTING_REG_IS_SATISFIED_AND_NEWER_PACKAGE_VERSION_EXISTS)
                {
                    return doesNewerPackageExists && regSummary.SuccessStatus == Success.PASSED;
                }
            }
        }


        throw new ScormContentPlayerApplicationException("Given RegistrationInstanceIncrementTimingValue not handled: " +
                                                         regInstanceIncrementTiming);
     }
}
Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request
Powered by Zendesk