Index: dotlrn_packages/lams2int/tcl/lams2int-procs.tcl =================================================================== diff -u -r01b61a79cd4775716c20ad9d89d75e22447cd016 -ra95d33be448306177fa2d6df2026913484e1358d --- dotlrn_packages/lams2int/tcl/lams2int-procs.tcl (.../lams2int-procs.tcl) (revision 01b61a79cd4775716c20ad9d89d75e22447cd016) +++ dotlrn_packages/lams2int/tcl/lams2int-procs.tcl (.../lams2int-procs.tcl) (revision a95d33be448306177fa2d6df2026913484e1358d) @@ -6,7 +6,7 @@ @author Ernie Ghiglione (ErnieG@melcoe.mq.edu.au) @creation-date 2007-04-16 - @cvs-id $Id$ + @cvs-id lams2int-procs.tcl,v 1.1 2007/09/12 06:37:02 ernieg Exp } # @@ -136,4 +136,74 @@ set lams2conf_package_id [db_string pack_id_lams_conf {select package_id from apm_packages where package_key = 'lams2conf'}] return [parameter::get -parameter request_source -package_id $lams2conf_package_id] -} \ No newline at end of file +} + +ad_proc -public lams2int::process_sequence_xml { + -xml:required +} { + Gets the XML with the sequences and folder and process it. + +} { + + encoding convertfrom utf-8 $xml + set doc [dom parse $xml] + set content [$doc documentElement] + + set sequence_list [concat [lams2int::process_node -node $content] " \] "] + +} + +ad_proc -private lams2int::process_node { + -node:required + +} { + Process the XML nodes + +} { + + if {[string equal [$node nodeName] "Folder"]} { + + regsub -all {'} [$node getAttribute name] {\\'} folder_name + + append output "\[ '$folder_name', null , " + + if {[$node hasChildNodes]} { + + foreach child [$node childNodes] { + + append output [lams2int::process_node -node $child] + + if {[string equal [$child nodeName] "Folder"]} { + + if {![empty_string_p [$child nextSibling]]} { + append output " \], " + } else { + append output " \]" + } + } + + } + + } else { + + append output "\['', null\]" + + } + } else { + # the node is a LearningDesign + + regsub -all {'} [$node getAttribute name] {\\'} design_name + + append output "\[ '$design_name', 'javascript:selectSequence([$node getAttribute resourceId])' \] " + + if {![empty_string_p [$node nextSibling]]} { + append output ", " + } else { + append output "" + } + + } + + return $output +} + Index: dotlrn_packages/lams2int/www/admin/add.tcl =================================================================== diff -u -r303dd52bf511ddb6154b7b9607e411e85f751f67 -ra95d33be448306177fa2d6df2026913484e1358d --- dotlrn_packages/lams2int/www/admin/add.tcl (.../add.tcl) (revision 303dd52bf511ddb6154b7b9607e411e85f751f67) +++ dotlrn_packages/lams2int/www/admin/add.tcl (.../add.tcl) (revision a95d33be448306177fa2d6df2026913484e1358d) @@ -47,64 +47,12 @@ ns_log Notice "URL requested $get_sequences_url" - -set xml [lindex [ad_httpget -url $get_sequences_url -timeout 30] 1] - -set xml [encoding convertfrom utf-8 $xml] -set doc [dom parse $xml] -set content [$doc documentElement] - -proc process_node { node } { - - if {[string equal [$node nodeName] "Folder"]} { - - regsub -all {'} [$node getAttribute name] {\\'} folder_name - - append output "\[ '$folder_name', null , " - - if {[$node hasChildNodes]} { - - foreach child [$node childNodes] { - - append output [process_node $child] - - if {[string equal [$child nodeName] "Folder"]} { - - if {![empty_string_p [$child nextSibling]]} { - append output " \], " - } else { - append output " \]" - } - } - - } - - } else { - - append output "\['', null\]" - - } - } else { - # the node is a LearningDesign - - regsub -all {'} [$node getAttribute name] {\\'} design_name - - append output "\[ '$design_name', 'javascript:selectSequence([$node getAttribute resourceId])' \] " - - if {![empty_string_p [$node nextSibling]]} { - append output ", " - } else { - append output "" - } - - } - - return $output +if {[catch {set return_string [ad_httpget -url $get_sequences_url -timeout 30] } ] } { + ad_return_complaint 0 "It seems that the LAMS server you are trying to connect is down or there's a problem with the configuration. Please verify the connection setting or contact your system administrator." + ad_script_abort } +set xml [lindex $return_string 1] +set sequence_list [lams2int::process_sequence_xml -xml $xml] -set sequence_list [concat [process_node $content] " \] "] - -#regsub -all {'} $sequence_list {\\'} sequence_list -