Returns JavaScript that calls the SCORM function LMSGetValue (SCORM 1.2) or GetValue (SCORM 1.3).
Overloads Public Function GetJsGetValue( _
ByVal itemName As GetValueEnum, _
ByVal checkForError As Boolean, _
ByVal includeScriptTags As Boolean, _
ByVal returnVarName As String, _
ByVal n1 As Integer, _
ByVal n2 As Integer _
) As String
Overloads Public Function GetJsGetValue( _
ByVal itemName As GetValueEnum, _
ByVal checkForError As Boolean, _
ByVal includeScriptTags As Boolean, _
ByVal returnVarName As String, _
ByVal n1 As Integer _
) As String
Overloads Public Function GetJsGetValue( _
ByVal itemName As GetValueEnum, _
ByVal checkForError As Boolean, _
ByVal includeScriptTags As Boolean, _
ByVal returnVarName As String _
) As String
The JavaScript from the GetJsApiLocate function must be added to your page prior to using the JavaScript from GetJsGetValue.
You can use the server side RegisterClientScriptBlock method to add the JavaScript from any LmsApi GetJs function to your HTML page.
The JavaScript returned from GetJsGetValue will do all of the following:
The following example assumes that the VBTrain.WebTracking namespace has been imported, and that the LmsApi for the session is stored as a property (LmsApiObject) of the current class.
This example demonstrates a technique for getting the student name using the JavaScript from GetJsGetValue and changing the page in the main frame using the JavaScript from the GetJsGetLessonLocationAndChangeInFrame function. It then forces a postback, allowing additional server side methods to access the student name (not shown).
[Visual Basic]
Private Sub InitApi() Dim apiObject As New LmsApi2 Dim js As String Dim sb As New StringBuilder Dim jsAndCrStr As String = String.Concat("{0}", CrLf) apiObject = New LmsApi2 apiObject.Enabled = True apiObject.ScormVersion = ScormVersionEnum.Version_13 Me.LmsApiObject = apiObject 'locate js = apiObject.GetJsApiLocate() Me.RegisterClientScriptBlock("apiLocate", js) ' register separately in case already there With sb 'initialize js = apiObject.GetJsInitialize(False, True) If js <> "0" Then ' not yet initialized .Append(js) End If 'studentName 'lesson_status .Append(apiObject.GetJsGetValue(GetValueEnum.learner_name, False, True, "studentName")) .Append(apiObject.GetJsGetValue(GetValueEnum.v13_completion_status, False, True, "statusVar")) 'lesson_location .Append(apiObject.GetJsGetLessonLocationAndChangeInFrame(False, , "lessonLocation")) ' force postback .Append(String.Format(jsAndCrStr, "<script language='javascript'>")) .Append(String.Format(jsAndCrStr, "document.navBar.submit();")) .Append(String.Format(jsAndCrStr, "</script>")) End With Me.RegisterClientScriptBlock("initCode", sb.ToString) End Sub
LmsApi2 Class | LmsApi Members | GetJsSetValue | GetJsApiLocate | GetJsInitialize