VBTrain.Net Documentation

LmsApi2.GetJsGetValue Function

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

Parameters

itemName
A GetValueEnum. Use this parameter to specify the value to retrieve with LMSGetValue (SCORM 1.2) or GetValue (SCORM 1.3). Choices represent SCORM defined items. If the item exists in both SCORM versions 1.2 and 1.3, it will have the 1.3 enum value. If it exists in only one version, it will have an enum prefaced with v1x_, where x is the version number. If an itemName contains an "n" (e.g., cmi.objectives.n.score.raw or cmi.interactions.n.objectives.n.id), then you should specify the value of the first "n" in n1 and of any second "n" in n2.
checkForError
Boolean indicating whether or not to include error checking code in the JavaScript.
includeScriptTags
Boolean indicating whether or not to include the JavaScript opening and closing script tags. (i.e. <script language = 'javascript'> and </script>)
returnVarName
Name of the JavaScript variable that will hold the LMSGetValue return value. The returnVarName parameter also serves as the prefix for any error checking variables, and as the prefix for the hidden field in which the return value is stored (<returnVarName>_hField). See Remarks below.
n1
Integer. When itemName contains an "n" (e.g., cmi.objectives.n.score.raw or cmi.interactions.n.objectives.n.id) then n1 should specify the value of the first "n".
n2
Integer. If itemName contains two "n"s (e.g., cmi.interactions.n.objectives.n.id) then n2 should specify value of the second "n".

Remarks

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:

Example

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

See Also

LmsApi2 Class | LmsApi Members | GetJsSetValue | GetJsApiLocate | GetJsInitialize