Class ::xo::lti::LTI

::xo::lti::LTI[i] create ... \
           [ -context_id context_id ] \
           [ -context_label context_label ] \
           [ -context_title context_title ] \
           [ -launch_presentation_css_url launch_presentation_css_url ] \
           [ -launch_presentation_document_target (default "window") ] \
           [ -launch_presentation_height launch_presentation_height ] \
           [ -launch_presentation_return_url launch_presentation_return_url ] \
           [ -launch_presentation_width launch_presentation_width ] \
           [ -launch_url launch_url ] \
           [ -lis_outcome_service_url lis_outcome_service_url ] \
           [ -lis_person_contact_email_primary lis_person_contact_email_primary ] \
           [ -lis_person_name_family lis_person_name_family ] \
           [ -lis_person_name_full lis_person_name_full ] \
           [ -lis_person_name_given lis_person_name_given ] \
           [ -lis_result_sourcedid lis_result_sourcedid ] \
           [ -lti_message_type (default "basic-lti-launch-request") ] \
           [ -lti_version (default "LTI-1p0") ] \
           [ -oauth_consumer_key oauth_consumer_key ] \
           [ -oauth_nonce oauth_nonce ] \
           [ -oauth_signature_method (default "HMAC-SHA1") ] \
           [ -oauth_timestamp oauth_timestamp ] \
           [ -oauth_version (default "1.0") ] \
           [ -resource_link_id resource_link_id ] \
           [ -resource_link_title resource_link_title ] \
           [ -roles roles ] \
           [ -shared_secret shared_secret ] \
           [ -tool_consumer_info_product_family_code tool_consumer_info_product_family_code ] \
           [ -tool_consumer_instance_contact_email tool_consumer_instance_contact_email ] \
           [ -tool_consumer_instance_description tool_consumer_instance_description ] \
           [ -tool_consumer_instance_guid tool_consumer_instance_guid ] \
           [ -tool_consumer_instance_name tool_consumer_instance_name ] \
           [ -tool_consumer_instance_url tool_consumer_instance_url ]

Common Parameter
Defined in packages/xooauth/tcl/lti-procs.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nx::Object[i]
  • subclass: ::xo::lti::Jupyter[i], ::xo::lti::BBB[i], ::xo::lti::Zoom[i]
::nx::Class create ::xo::lti::LTI \
     -superclass ::nx::Object

Methods (to be applied on instances)

  • form_render (scripted, public)

     <instance of xo::lti::LTI[i]> form_render [ -height height ] \
        [ -sandbox sandbox ] [ -style style ] \
        [ -auto_launch_p auto_launch_p ]

    Set per-call parameters

    Switches:
    -height (optional, defaults to "700")
    -sandbox (optional)
    -style (optional, defaults to "min-width:100%;width:100%;min-height:100%;")
    -auto_launch_p (optional, defaults to "0")

    Testcases:
    No testcase defined.
    if {![info exists :oauth_timestamp]} {
        set :oauth_timestamp [::xo::oauth::timestamp]
    }
    if {![info exists :oauth_nonce]} {
        set :oauth_nonce [::xo::oauth::nonce]
    }
    :get_context
    
    #
    # Collect the provided parameters
    #
    set params {}
    set signature_parameters {}
    foreach param [::xo::lti::LTI cget -lti_params] {
        if {[info exists :$param]} {
            lappend params $param
            lappend signature_parameters [list $param [set :$param]]
        }
    }
    
    #
    # Add potential GET parameters from the launch_url to
    # the signature parameters.
    #
    set url_info [ns_parseurl ${:launch_url}]
    if {[dict exists $url_info query]} {
        foreach {key value} [ns_set array [ns_parsequery [dict get $url_info query]]] {
            lappend signature_parameters [list $key $value]
        }
    }
    
    security::csp::require form-action ${:launch_url}
    security::csp::require frame-src ${:launch_url}
    
    #
    # Create signature
    #
    set signature [[::xo::oauth::Signature new  -volatile  -base_string_uri [::xo::oauth::Signature base_string_from_url ${:launch_url}]  -signature_parameters $signature_parameters  -client_secret ${:shared_secret}] generate]
    
    set lti_form_parameters $signature_parameters
    lappend lti_form_parameters [list oauth_signature $signature]
    #ns_log notice "==================== lti_form_parameters = $lti_form_parameters"
    
    #
    # We need an autogenerated frame name, because otherwise,
    # cascaded LTI frames may have the same name, which causes
    # trouble. However, we might need a configuration option
    # to allow opening up in _parent frames.
    #
    if { ${:launch_presentation_document_target} eq "iframe"} {
        set iframe_name "ltiframe${:oauth_nonce}"
        set target "ltiframe${:oauth_nonce}"
    } else {
        set iframe_name ""
        set target "_blank"
    }
    
    set form_name ltiform_${:oauth_nonce}
    set wrapper_id ltiLaunchFormSubmitArea_${:oauth_nonce}
    
    #
    # Create the HTML form.
    #
    ::xo::require_html_procs
    dom createDocument div lti
    $lti appendFromScript {
        ::html::div id $wrapper_id  {
            ::html::form  target $target  action ${:launch_url}  name $form_name id $form_name method "POST"  encType "application/x-www-form-urlencoded" {
                    foreach pair $lti_form_parameters {
                        lassign $pair k v
                        ::html::input type hidden name $k value $v
                    }
                }
        }
        #
        # Add iframe if needed
        #
        if {${:launch_presentation_document_target} eq "iframe"} {
            ::html::iframe name $target  style $style  height $height  sandbox $sandbox
        }
    
    }
    
    # auto launch
    if {$auto_launch_p} {
        template::add_body_handler  -event onload  -script [subst -nocommands {document.getElementById('$form_name').submit();}]
    }
    
    set html [$lti asHTML]
    $lti delete
    
    if {${:launch_presentation_document_target} eq "window"} {
        ::template::add_footer -html $html
        set html ""
    }
    
    return [list HTML $html form_name $form_name iframe_name $iframe_name]