Index: openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 23 Nov 2005 11:06:33 -0000 1.9 +++ openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 23 Nov 2005 17:41:43 -0000 1.10 @@ -163,7 +163,7 @@ <ul> %first_or_next% Activity: %activity_name% Uploading and processing your course, please wait... Valid types are learning, support and structure - Warning: More than one learning object in environment %identifier%. Just one used (the first one) + More than one learning object in environment %identifier%. Just one used (the first one) We will continue automatically when processing is complete. When Last Act Completed? Mail Data Index: openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 23 Nov 2005 11:06:33 -0000 1.20 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 23 Nov 2005 17:41:43 -0000 1.21 @@ -502,81 +502,89 @@ @tmp_dir Temporary directory where the files were exctracted } { upvar files_struct_list files_struct_list - # now we proceed to get all the info of the resource - set resource_type [imsld::parse::get_attribute -node $resource_node -attr_name type] - set resource_href [imsld::parse::get_attribute -node $resource_node -attr_name href] + # verify that the resource hasn't been already created set resource_identifier [string tolower [imsld::parse::get_attribute -node $resource_node -attr_name identifier]] - set community_id [dotlrn_community::get_community_id] - - set acs_object_id [callback -catch imsld::import -res_type $resource_type -res_href $resource_href -tmp_dir $tmp_dir -community_id $community_id] - # Integration with other packages - # This callback gets the href of the imported content (if some package imported it) - - set resource_id [imsld::cp::resource_new -manifest_id $manifest_id \ - -identifier $resource_identifier \ - -type $resource_type \ - -href $resource_href \ - -acs_object_id $acs_object_id \ - -parent_id $parent_id] - - set found_p 0 - set filex_list [$resource_node child all imscp:file] - if { ![llength $filex_list] } { - set filex_list [$resource_node child all file] - } - foreach filex $filex_list { - set filex_href [imsld::parse::get_attribute -node $filex -attr_name href] - if { ![empty_string_p $resource_href] && [string eq $resource_href $filex_href] } { - # check if the referenced file in the resource exists - # if we finish with the files and the referenced one doesn't exist we raise an error - set found_p 1 + if { ![db_0or1row redundancy_protection { + select resource_id + from imsld_cp_resources + where identifier = :resource_identifier + and manifest_id = :manifest_id + }] } { + # now we proceed to get all the info of the resource + set resource_type [imsld::parse::get_attribute -node $resource_node -attr_name type] + set resource_href [imsld::parse::get_attribute -node $resource_node -attr_name href] + set community_id [dotlrn_community::get_community_id] + + set acs_object_id [callback -catch imsld::import -res_type $resource_type -res_href $resource_href -tmp_dir $tmp_dir -community_id $community_id] + # Integration with other packages + # This callback gets the href of the imported content (if some package imported it) + + set resource_id [imsld::cp::resource_new -manifest_id $manifest_id \ + -identifier $resource_identifier \ + -type $resource_type \ + -href $resource_href \ + -acs_object_id $acs_object_id \ + -parent_id $parent_id] + + set found_p 0 + set filex_list [$resource_node child all imscp:file] + if { ![llength $filex_list] } { + set filex_list [$resource_node child all file] } - set filex_id [imsld::fs::file_new -href $filex_href \ - -path_to_file $filex_href \ - -type file \ - -complete_path "${tmp_dir}/${filex_href}"] - if { !$filex_id } { - # an error ocurred when creating the file - return [list 0 "[_ imsld.lt_The_file_filex_href_w]"] + foreach filex $filex_list { + set filex_href [imsld::parse::get_attribute -node $filex -attr_name href] + if { ![empty_string_p $resource_href] && [string eq $resource_href $filex_href] } { + # check if the referenced file in the resource exists + # if we finish with the files and the referenced one doesn't exist we raise an error + set found_p 1 + } + set filex_id [imsld::fs::file_new -href $filex_href \ + -path_to_file $filex_href \ + -type file \ + -complete_path "${tmp_dir}/${filex_href}"] + if { !$filex_id } { + # an error ocurred when creating the file + return [list 0 "[_ imsld.lt_The_file_filex_href_w]"] + } + # map resource with file + relation_add imsld_res_files_rel $resource_id $filex_id } - # map resource with file - relation_add imsld_res_files_rel $resource_id $filex_id - } - - if { ![empty_string_p $resource_href] && !$found_p } { - # we should have fond the referenced file, aborting - return [list 0 "[_ imsld.lt_The_resource_resource]"] - } - - set resource_dependencies [$resource_node child all imscp:dependency] - if { ![llength $resource_dependencies] } { - set resource_dependencies [$resource_node child all dependency] - } - foreach dependency $resource_dependencies { - set dependency_identifierref [imsld::parse::get_attribute -node $dependency -attr_name identifierref] - set dependency_id [imsld::cp::dependency_new -resource_id $resource_id \ - -identifierref $dependency] - # look for the resource in the manifest and add it to the CR - set resources [$manifest child all imscp:resources] - if { ![llength $resources] } { - set imsld [$manifest child all resources] + + if { ![empty_string_p $resource_href] && !$found_p } { + # we should have fond the referenced file, aborting + return [list 0 "[_ imsld.lt_The_resource_resource]"] } - # there must be at least one reource for the learning objective - imsld::parse::validate_multiplicity -tree $resources -multiplicity 0 -element_name "resources (dependency)" -greather_than - - set resourcex [$resources find identifier $dependency_identifierref] - # this resourcex must match with exactly one resource - imsld::parse::validate_multiplicity -tree $resourcex -multiplicity 1 -element_name "resource ($dependency_identifierref) en $resourcex" -equal - set dependency_resource_list [imsld::parse::parse_and_create_resource -resource_node $resourcex \ - -manifest $manifest \ - -manifest_id $manifest_id \ - -parent_id $parent_id \ - -tmp_dir $tmp_dir] - if { ![lindex $dependency_resource_list 0] } { - # return this value and let the user know there was an error (becuase if succeded, it does nothing here) - return $dependency_resource_list + set resource_dependencies [$resource_node child all imscp:dependency] + if { ![llength $resource_dependencies] } { + set resource_dependencies [$resource_node child all dependency] } + foreach dependency $resource_dependencies { + set dependency_identifierref [imsld::parse::get_attribute -node $dependency -attr_name identifierref] + set dependency_id [imsld::cp::dependency_new -resource_id $resource_id \ + -identifierref $dependency] + # look for the resource in the manifest and add it to the CR + set resources [$manifest child all imscp:resources] + if { ![llength $resources] } { + set imsld [$manifest child all resources] + } + + # there must be at least one reource for the learning objective + imsld::parse::validate_multiplicity -tree $resources -multiplicity 0 -element_name "resources (dependency)" -greather_than + + set resourcex [$resources find identifier $dependency_identifierref] + # this resourcex must match with exactly one resource + imsld::parse::validate_multiplicity -tree $resourcex -multiplicity 1 -element_name "resource ($dependency_identifierref) en $resourcex" -equal + set dependency_resource_list [imsld::parse::parse_and_create_resource -resource_node $resourcex \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + if { ![lindex $dependency_resource_list 0] } { + # return this value and let the user know there was an error (becuase if succeded, it does nothing here) + return $dependency_resource_list + } + } } return [list $resource_id {}] } @@ -2920,6 +2928,36 @@ relation_add imsld_mp_completed_rel $method_id $play_id } } + + # look for the resource in the manifest and add it to the CR + set manifest_resources_list [$manifest child all imscp:resources] + if { ![llength $manifest_resources_list] } { + set manifest_resources_list [$manifest child all resources] + } + set resources_list [$manifest_resources_list child all imscp:resource] + if { ![llength $resources_list] } { + set resources_list [$manifest_resources_list child all resource] + } + + foreach resource_left $resources_list { + set resource_identifier [string tolower [imsld::parse::get_attribute -node $resource_left -attr_name identifier]] + # the resource can't be duplicated + if { ![db_0or1row already_created_p { + select 1 from imsld_cp_resources where identifier = :resource_identifier and manifest_id = :manifest_id + }] } { + imsld::parse::validate_multiplicity -tree $resource_left -multiplicity 1 -element_name "resources (cp resources)" -equal + set resource_list [imsld::parse::parse_and_create_resource -resource_node $resource_left \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir] + set resource_id [lindex $resource_list 0] + if { !$resource_id } { + # return the error + return $resource_list + } + } + } global warnings if { ![empty_string_p $warnings] } { Index: openacs-4/packages/imsld/tcl/imsld-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 23 Nov 2005 11:06:33 -0000 1.9 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 23 Nov 2005 17:41:43 -0000 1.10 @@ -168,14 +168,14 @@ ) } - if { [db_0or1row referenced_p { + db_foreach referencer_structure { select ias.structure_id, ias.item_id as structure_item_id from acs_rels ar, imsld_activity_structuresi ias, cr_items cri where ar.object_id_one = ias.item_id and ar.object_id_two = cri.item_id and cri.live_revision = :element_id - }] } { + } { # if this activity is part of an activity structure, let's check if the rest of referenced # activities are finished too, so we can mark finished the activity structure as well set scturcture_finished_p 1 @@ -283,8 +283,8 @@ where item_id = :object_id_two and content_revision__is_live(activity_id) = 't' } - if { ![db_0or1row completed_p { - select 1 + if { ![db_string completed_p { + select count(*) from imsld_status_user where completed_id = :learning_activity_id }] && ( [string eq "" $min_sort_order] || $sort_order < $min_sort_order ) } { @@ -302,8 +302,8 @@ where item_id = :object_id_two and content_revision__is_live(activity_id) = 't' } - if { ![db_0or1row completed_p { - select 1 + if { ![db_string completed_p { + select count(*) from imsld_status_user where completed_id = :support_activity_id }] && ( [string eq "" $min_sort_order] || $sort_order < $min_sort_order ) } { @@ -322,8 +322,8 @@ and content_revision__is_live(structure_id) = 't' } - if { ![db_0or1row completed_p { - select 1 + if { ![db_string completed_p { + select count(*) from imsld_status_user where completed_id = :structure_id }] && ( [string eq "" $min_sort_order] || $sort_order < $min_sort_order ) } { @@ -869,7 +869,7 @@ where fs.live_revision = :imsld_file_id }] set file_url "[apm_package_url_from_id $fs_package_id]view/${file_url}" - append files_lis " $file_name " + append files_lis " $file_name " } } } @@ -957,7 +957,11 @@ if { [string eq "" $one_activity_urls] } { lappend activity_items_list "[_ imsld.lt_li_desc_no_file_assoc]" } else { - set activity_items_list [concat [list $activity_items_list] [list $one_activity_urls]] + if { [llength $activity_items_list] } { + set activity_items_list [concat $activity_items_list [list $one_activity_urls]] + } else { + set activity_items_list [list $one_activity_urls] + } } } if_no_rows { ns_log notice "[_ imsld.lt_li_desc_no_file_assoc]" @@ -1042,7 +1046,11 @@ if { [string eq "" $one_activity_urls] } { lappend activity_items_list "[_ imsld.lt_li_desc_no_file_assoc]" } else { - set activity_items_list [concat [list $activity_items_list] [list $one_activity_urls]] + if { [llength $activity_items_list] } { + set activity_items_list [concat $activity_items_list [list $one_activity_urls]] + } else { + set activity_items_list [list $one_activity_urls] + } } } if_no_rows { ns_log notice "[_ imsld.lt_li_desc_no_file_assoc]" @@ -1446,12 +1454,17 @@ append environments "" regsub -all {
  • [ ]*
  • } $environments "" environments } + set files "" + if { [llength [lindex $activities_list 3]] } { + set files "[join [lindex $activities_list 3] "
    "]" + regsub -all {
  • [ ]*
  • } $files "" files + } template::multirow append imsld_multirow $prerequisites \ $objectives \ $environments \ $activity_title \ - [join [lindex $activities_list 3] "
    "] \ + $files \ {} \ "finish" }