Index: openacs-4/packages/imsld/imsld.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/imsld.info,v diff -u -r1.10 -r1.10.6.1 --- openacs-4/packages/imsld/imsld.info 25 Apr 2007 10:52:29 -0000 1.10 +++ openacs-4/packages/imsld/imsld.info 24 Apr 2008 10:50:33 -0000 1.10.6.1 @@ -7,14 +7,14 @@ f f - + Jose Pablo Escobedo Del Cid IMS LD integration with dotLRN. - 2006-10-20 + 2007-06-25 This package is the implementation of IMS LD in dotLRN. The course admin can create a sequence of activities for the students, as well as decide who does what, when and using what resources. 0 - + 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 -r1.36 -r1.36.2.1 --- openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 30 May 2007 08:36:21 -0000 1.36 +++ openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 24 Apr 2008 10:50:33 -0000 1.36.2.1 @@ -1,20 +1,23 @@ - + - 1. Local Properties - 5. Global Properties | Assigned users: Component Identifier | Creation Date: | Status: The run is Act Identifier active + Activities + Activity Activity Identifier Activity Name + Activity report Activity Structures Activity Type Acts in play %count% + Add Members Admin IMS LD + Admin roles Back to admin Calculate(expression) Caluclate Identifier @@ -30,9 +33,12 @@ Confirm Confirm: New IMS-LD Confirm these changes - Context info + Environment + Create a new group Create New? + Create new create new run + Create role instance Creating default Run... Creating new IMS-LD... Creation Date @@ -50,19 +56,26 @@ Error parsing file Existing href Exit UoL + Exit Monitor Expression Extra Activities Feedbach Title Feedback File name + (finish) + finish activity Finish Date finished Finished Date + Global Properties Go back go back + Go to UoL page Group members + Group name Groups in role Hide + panel Href Identifier Identifier Reference @@ -137,26 +150,30 @@ <li> %activity_title% </li> <li> %file_name% </li> <li> impozzible </li> - 2. Local-personal Properties - 3. Local-role Properties - 4. Global-personal Properties + Local Properties + [_ imsld.create_new_run] Activity Description Identifier Activity Structure Identifier + Add selected members to the group Are all the students asigned to the proper roles? If you confirm now, no more changes will be acepted later. <br>\ Go to the activity <a href=\"%activity_url%\">%activity_title%</a> (of the UoL <a href=\"%imsld_url%\">%imsld_title%</a> in the community <a href=\"%community_url%\">%community_name%</a>) for further details. - <br>\ - Go to the UoL <a href=\"%imsld_url%\">$imsld_title</a> (in the <a href=\"%community_url%\">%community_name%</a> community) for further details. + <br> + Go to the Learning Unit <a href=\"%imsld_url%\">$imsld_title</a> (in the <a href=\"%community_url%\">%community_name%</a> community) for further details. <br /> Warnings: <ul> %warnings% </ul> Change Property Value Identifier Change Property Value XML %community_name%: %imsld_title% Complete Act Identifier + Confirm roles assignments Could not determine whit what program uncompress the file %upload_file% has. Aborting Couldn't determine if this is a well formed IMS-LD: %message% Creaginting new IMS-LD - Dear %recepient_name% <br> - %sender_name has% triggered this notification. Please do not replay to this email. <br> + Create a new instance of a role + Current Unit of Learning does not allow creation of multiple instances of this role. + Current UoL does not allow to include them in more than one subroles of the role. + Dear %recepient_name%. <br> + %sender_name% has triggered this notification. Please do not replay to this email. <br> Email Propery Identifier Environment Identifier Error creating folder @@ -167,6 +184,7 @@ Expression One Identifier Expression Two Identifer Finish role management + Global-personal Properties <h2>Uploading new IMS Learning Design</h2> If you are not sure that everything is OK, please Import IMS-LD ZIP File @@ -212,8 +230,11 @@ Learning Objectives ID Learning Unit finished <li> desc (no file associated) </li> + Local-personal Properties + Local-role Properties manifest namespace is not imscp Max. number of students per group: %max_persons% + Members $not_allowed_name are already members of other subroles of role $parent_role_name. Min. number of students per group: %min_persons% Monitoring One Activity More than one service in environment %identifier%. Just one used (the first one) @@ -223,6 +244,10 @@ No information found in the manifest file No parent folder found No parent folder found for the ims-ld in the community %community_id%. Please report this error to the administrator. + Number of members does not reach the minimum allowed number of users for this role. + There must be at least %min_persons% members. + Number of members exceded the allowed number for this role. + You must not select more than $max_persons members. Number of Organizations: On Completion Identifier Organization Identifier @@ -233,6 +258,7 @@ Parent Role Identifier Please, confirm the information you are uploading Please submit a value + Please wait for other users... Property String Identifier Referenced activity structure %ref% does not exist Referenced activity structure (%activity_structure_ref_ref%) in role part %identifier% does not exist. @@ -259,6 +285,7 @@ Referenced support activity %support_activity_ref_ref% in role part %identifier% is actually an activity structure. Referenced support activity %support_activity_ref% in role part %identifier% is actually a learning activity. Referenced support activity (%support_activity_ref%) from notification does not exist + Remove selected members from the group Select a role to send the email Select parent for the new instance Select role to support... @@ -269,6 +296,7 @@ Sorry, that service type (%service_type%) hasn't been implemented yet. Sorry, your browser doesn't support JavaScript (or it is disabled). This is needed to access the course. Support Activity Identifier + The course has been finished The decimal digits can't be more than %restriction_value% The file %filex_href% was not created, it wasn't found in the manifest The integer part can't have more than %restriction_value% digits @@ -320,13 +348,15 @@ Unestable state reached Unstable state reached when evaluating conditions (An infinite loop was detected). Please, contact the administrator and review the conditions of the UoL. Uploading and processing your course, please wait... + User does not belong to any role instance %username% <br> %sender_name% has triggered this notification. Please do not replay to this email. <br><br> Go to the UoL: <a href=\"%imsld_url%\">%imsld_title%</a> (in the community: <a href=\"%community_url%\">%community_name%</a> community) for further details. Username Property Identifier - Users who have <b>at least visited</b> the service - Users who have <b>viewed/visited all</b> the referenced resources from the environment - Users who have started and/or finished this activity + User's individual report + Users who have at least visited the service + Users who have viewed or visited all resources in the learning object + Users who have started and/or finished activity Valid types are learning, support and structure More than one learning object in environment %identifier%. Just one used (the first one) We will continue automatically when processing is complete. @@ -350,12 +380,16 @@ Monitor properties User Name + navigate through the content using the links above &nbsp;&nbsp;&nbsp;done New IMS-LD information found in the imsmanifest.xml file. Nothing to do. + No group selected No IMS LD No info was found No properties found. + No user selected. + No users None None, please select Not defined @@ -369,6 +403,7 @@ Parameter Identifier Parameters Parent role: + role info Party Identifier Path to File Play Identifier @@ -384,6 +419,7 @@ Recipients Reference Identifier Reference Type + Remove Members Resource Identifier Restriction Type Role Identifier @@ -394,17 +430,20 @@ Run(UoL) Name: Runs (IMS-LD instances) select user... + Select a group... Select a role... Select a role Select role... Self + mail send-mail service sendmail Sendmail Identifier Sequence Used Service Identifier Service Type Show + panel since Sort Sort Order @@ -414,12 +453,13 @@ Status stopped Structure Type + info Support Activities user: %supported_user_name% The selected role has no parent Then Identifier There are no descendant roles - is the list of activities started (and finished) by %member_name% + Activity report for user Time in Seconds Total Activities Parent Roles @@ -431,11 +471,17 @@ Units of Learning Administration Uploading IMS LD URI + user + User activity reports User Choice? + Users + users Value Version view file View members + View Roles + Viewed waiting When Condition True With Control Index: openacs-4/packages/imsld/catalog/imsld.es_ES.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/catalog/imsld.es_ES.ISO-8859-1.xml,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/imsld/catalog/imsld.es_ES.ISO-8859-1.xml 6 Apr 2006 14:25:02 -0000 1.2 +++ openacs-4/packages/imsld/catalog/imsld.es_ES.ISO-8859-1.xml 24 Apr 2008 10:50:33 -0000 1.2.6.1 @@ -1,8 +1,8 @@ - Informaci�n de Contexto + Entorno Material Unidades de Aprendizaje - Administraci�n de Unidades de Aprendizaje + Administración de Unidades de Aprendizaje Index: openacs-4/packages/imsld/lib/imsld-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/lib/imsld-chunk.tcl,v diff -u -r1.14 -r1.14.2.1 --- openacs-4/packages/imsld/lib/imsld-chunk.tcl 30 May 2007 08:36:22 -0000 1.14 +++ openacs-4/packages/imsld/lib/imsld-chunk.tcl 24 Apr 2008 10:50:33 -0000 1.14.2.1 @@ -6,7 +6,7 @@ [list label "[_ imsld.IMS_LD_Name]" \ orderby_asc {imsld_title asc} \ orderby_desc {imsld_title desc} \ - display_template {@imsld_runs.imsld_title@}] \ + display_template {@imsld_runs.imsld_title@}] \ user_roles \ [list label "[_ imsld.Roles_in_Run]" \ display_template {@imsld_runs.user_roles;noquote@}] \ Index: openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql,v diff -u -r1.3 -r1.3.6.1 --- openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql 23 Jan 2007 11:33:48 -0000 1.3 +++ openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql 24 Apr 2008 10:50:33 -0000 1.3.6.1 @@ -18,8 +18,7 @@ not null, activity_id integer constraint imsld_notif_act_fk - references cr_items --imsld_learning_activities/imsld_support_activities - not null, + references cr_items, --imsld_learning_activities/imsld_support_activities subject text ); Index: openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl,v diff -u -r1.24 -r1.24.6.1 --- openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 25 Apr 2007 10:52:30 -0000 1.24 +++ openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 24 Apr 2008 10:50:34 -0000 1.24.6.1 @@ -260,7 +260,7 @@ where complete_act_id = :complete_act_item_id and content_revision__is_live(activity_id) = 't' }] } { - # mark the act completed for all the users in the run + # mark the learning activity completed for all the users in the run set role_part_id_list [imsld::get_role_part_from_activity -activity_type learning -leaf_id $activity_item_id] set users_in_run [db_list get_users_in_run { @@ -302,8 +302,8 @@ where complete_act_id = :complete_act_item_id and content_revision__is_live(activity_id) = 't' }] } { - # mark the act completed for all the users in the run - set role_part_id_list [imsld::get_role_part_from_activity -activity_type learning -leaf_id $activity_item_id] + # mark the support activity completed for all the users in the run + set role_part_id_list [imsld::get_role_part_from_activity -activity_type support -leaf_id $activity_item_id] set users_in_run [db_list get_users_in_run { select gmm.member_id @@ -331,7 +331,7 @@ -act_id $act_id \ -role_part_id $role_part_id \ -element_id $activity_id \ - -type learning \ + -type support \ -code_call } } @@ -356,6 +356,7 @@ and ar1.object_id_one=gmm.group_id group by member_id }] + foreach user $users_in_run { if { [imsld::user_participate_p -run_id $run_id -act_id $act_id -user_id $user] } { imsld::mark_act_finished -act_id $act_id \ @@ -373,7 +374,7 @@ where complete_act_id = :complete_act_item_id and content_revision__is_live(play_id) = 't' }] } { - # mark the act completed for all the users in the run + # mark the play completed for all the users in the run set users_in_run [db_list get_users_in_run { select gmm.member_id from group_member_map gmm, Index: openacs-4/packages/imsld/tcl/imsld-cr-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-cr-procs.xql,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/tcl/imsld-cr-procs.xql 1 Feb 2006 11:34:48 -0000 1.1 +++ openacs-4/packages/imsld/tcl/imsld-cr-procs.xql 24 Apr 2008 10:50:34 -0000 1.1.6.1 @@ -1,14 +1,12 @@ - - - - - select 1 - from imsld_cp_files icf, cr_items cri - where cri.item_id = :item_id - and cri.live_revision = icf.imsld_file_id - - + + + select 1 + from imsld_cp_files icf, cr_items cri + where cri.item_id = :item_id + and cri.live_revision = icf.imsld_file_id + + Index: openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl,v diff -u -r1.6 -r1.6.6.1 --- openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl 25 Apr 2007 10:52:30 -0000 1.6 +++ openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl 24 Apr 2008 10:50:34 -0000 1.6.6.1 @@ -26,9 +26,14 @@ -edit:boolean -complete_path } { - Creates a file (file or directory) in the fs. If the type is file, the file is created with its attributes, which are: href, file_name, path_to_file and parent_id. + Creates a file (file or directory) in the fs. If the type is file, the file + is created with its attributes, which are: href, file_name, path_to_file + and parent_id. - All the parent dirs (lindex 0) of the corresponding file (path_to_file) that are found in the files_struct_list are created too (if they haven't been created yet). The file structure is the one created with the imsld::parse::get_files_structure proc. + All the parent dirs (lindex 0) of the corresponding file (path_to_file) + that are found in the files_struct_list are created too (if they haven't + been created yet). The file structure is the one created with the + imsld::parse::get_files_structure proc. Returns the file_id of the created file. @@ -186,15 +191,17 @@ -revision_id {-string ""} } { - Create an empty file and stores in the given revision id. - this is helpful for the property of type file (for instance), because when the properties are instantiated, there is no - file associated to them and the fs shows an error message. + Create an empty file and stores in the given revision id. This is helpful + for the property of type file (for instance), because when the properties + are instantiated, there is no file associated to them and the fs shows an + error message. @param revision_id @param string Optional string that will be written into the file } { - set string [expr { [string eq "" $string] ? "[_ imsld.Empty_property_value]" : "$string" }] + set string [expr { [string eq "" $string] ? \ + "[_ imsld.Empty_property_value]" : "$string" }] set tmpfile [ns_mktemp "/tmp/imsld_emtpyXXXXXX"] set file [open $tmpfile a] puts $file "$string" @@ -203,14 +210,21 @@ set mime_type "text/plain" # database_p according to the file storage parameter - set fs_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id [dotlrn_community::get_community_id]] \ - -package_key "file-storage"] - set database_p [parameter::get -parameter "StoreFilesInDatabaseP" -package_id $fs_package_id] + set fs_package_id \ + [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id \ + [dotlrn_community::get_community_id]] \ + -package_key "file-storage"] + set database_p [parameter::get \ + -parameter "StoreFilesInDatabaseP" \ + -package_id $fs_package_id] set content_length [file size $tmpfile] if { !$database_p } { # create the new item - set filename [cr_create_content_file [content::revision::item_id -revision_id $revision_id] $revision_id $tmpfile] + set filename [cr_create_content_file \ + [content::revision::item_id \ + -revision_id $revision_id] \ + $revision_id $tmpfile] db_dml set_file_content { update cr_revisions set content = :filename, @@ -220,16 +234,84 @@ } } else { # create the new item - db_dml lob_content " - update cr_revisions - set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] - where revision_id = :revision_id" -blob_files [list $tmpfile] + db_dml lob_content \ + "update cr_revisions + set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] + where revision_id = :revision_id" -blob_files [list $tmpfile] - # Unfortunately, we can only calculate the file size after the lob is uploaded + # Unfortunately, we can only calculate the file size after the lob is + # uploaded db_dml lob_size { update cr_revisions set content_length = :content_length where revision_id = :revision_id } } -} +} + +ad_proc -public imsld::fs::traverse_zip { + -dir:required + -pattern:required +} { + Function to recursively traverse the files in a ZIP to then detect those + that are not reerenced in a resource, but still need to be in the file + storate. +} { + upvar files_struct_list files_struct_list + # Iterate over all the files in the given directory + foreach fname [glob -nocomplain -tail -types f -directory $dir $pattern] { + # See if the file was already created + if { [imsld::fs::find_file_not_created \ + -file_name $fname \ + -file_list $files_struct_list \ + -path_prefix $dir] } { + # Create the new file + imsld::fs::file_new \ + -path_to_file $fname \ + -type file \ + -complete_path "[ns_urldecode ${dir}/${fname}]" + } + } + + # Recur over the directories + foreach subd [glob -tail -nocomplain -types d -directory $dir $pattern] { + imsld::fs::traverse_zip -dir $dir -pattern "$subd/*" + } +} + +ad_proc -public imsld::fs::find_file_not_created { + -file_name:required + -file_list:required + -path_prefix:required +} { + Procedure to search for a given file name in the given file list. This list + is assumed to have the structure derived from the parsing. It returns a + boolean encoding if the given file_name is in the list with an object_id + equal to zero. The files are supposed to be in the list with the given + path_prefix. + + @param file_name File to search for + @param file_list List of files contained in a UoL + @param path_prefix Prefix present in all the files +} { + while { [llength $file_list] > 0 } { + set dirx [lindex $file_list 0] + foreach content [lindex $dirx 1] { + if { [lsearch -exact [string tolower $content] \ + [string tolower "$path_prefix/$file_name"]] >=0 && \ + [lindex $content 1] eq "file" } { + # If the object_id is zero, the file was found + if { [lindex $content 2] == 0 } { + return 1 + } else { + # In this case, the file is already in the fs + return 0 + } + } + } + # Advance the processing + set file_list [lrange $file_list 1 [ expr [llength $file_list] -1]] + } + return 0 +} + Index: openacs-4/packages/imsld/tcl/imsld-instance-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-instance-procs.tcl,v diff -u -r1.13 -r1.13.6.1 --- openacs-4/packages/imsld/tcl/imsld-instance-procs.tcl 25 Apr 2007 10:52:30 -0000 1.13 +++ openacs-4/packages/imsld/tcl/imsld-instance-procs.tcl 24 Apr 2008 10:50:34 -0000 1.13.6.1 @@ -16,26 +16,42 @@ {-community_id ""} } { @param imsld_id the imsld_id to instantiate - @option community_id the community to which the imsld will be instantiated into + @option community_id the community to which the imsld will be instantiated + into @return the run_id created Instantiates an imsld, i.e. creates the run. - If community_id is given, the run is created for that community (the users associated to the run are the users of the community) + If community_id is given, the run is created for that community (the users + associated to the run are the users of the community) } { # 1. create the run (status = 'waiting') - set run_id [package_exec_plsql -var_list [list [list run_id ""] [list imsld_id $imsld_id] [list status "waiting"]] imsld_run new] + set run_id [package_exec_plsql -var_list [list [list run_id ""] \ + [list imsld_id $imsld_id] \ + [list status "waiting"]] \ + imsld_run new] # 2. create the run group - set group_run_id [package_instantiate_object -creation_user [ad_conn user_id] -creation_ip [ad_conn peeraddr] -package_name imsld_run_users_group -start_with "group" -var_list [list [list group_id ""] [list group_name "IMS-LD Run Group ($run_id)"] [list run_id $run_id]] imsld_run_users_group] + set group_run_id \ + [package_instantiate_object \ + -creation_user [ad_conn user_id] \ + -creation_ip [ad_conn peeraddr] \ + -package_name imsld_run_users_group \ + -start_with "group" \ + -var_list [list [list group_id ""] \ + [list group_name "IMS-LD Run Group ($run_id)"] \ + [list run_id $run_id]]\ + imsld_run_users_group] - # 3. if community_id is not empty, assign the community users to the run - if { ![string eq $community_id ""] } { - foreach user [dotlrn_community::list_users $community_id] { - set user_id [ns_set get $user user_id] - relation_add imsld_run_users_group_rel $group_run_id $user_id - } - } +# jopez: commented out so the users assigned to the run are the ones that the +# user actually assigns to the run... +# # 3. if community_id is not empty, assign the community users to the run +# if { ![string eq $community_id ""] } { +# foreach user [dotlrn_community::list_users $community_id] { +# set user_id [ns_set get $user user_id] +# relation_add imsld_run_users_group_rel $group_run_id $user_id +# } +# } imsld::instance::instantiate_activity_attributes -run_id $run_id return $run_id } @@ -44,7 +60,9 @@ -run_id:required {-community_id ""} } { - set community_id [expr { [empty_string_p $community_id] ? [dotlrn_community::get_community_id] : $community_id }] + set community_id [expr { [empty_string_p $community_id] ? \ + [dotlrn_community::get_community_id] : \ + $community_id }] db_1row get_context_inf { select org.manifest_id @@ -56,51 +74,71 @@ and iis.organization_id = org.item_id } # Gets file-storage root folder_id - set fs_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id $community_id] \ - -package_key "file-storage"] + set fs_package_id \ + [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id $community_id] \ + -package_key "file-storage"] set fs_root_folder_id [fs::get_root_folder -package_id $fs_package_id] - set fs_folder_id [content::item::get_id -item_path "manifest_${manifest_id}" -root_folder_id $fs_root_folder_id -resolve_index f] - set run_folder_id [content::item::get_id -item_path "run_${run_id}" -root_folder_id $fs_root_folder_id -resolve_index f] + set fs_folder_id [content::item::get_id \ + -item_path "manifest_${manifest_id}" \ + -root_folder_id $fs_root_folder_id \ + -resolve_index f] + set run_folder_id [content::item::get_id \ + -item_path "run_${run_id}" \ + -root_folder_id $fs_root_folder_id \ + -resolve_index f] if { [empty_string_p $run_folder_id] } { db_transaction { set folder_name "run_${run_id}" # checks for write permission on the parent folder if { ![empty_string_p $fs_root_folder_id] } { - ad_require_permission $fs_root_folder_id write + permission::require_permission \ + -object_id $fs_root_folder_id \ + -privilege write } # create the root cr dir + set run_folder_id [imsld::cr::folder_new \ + -parent_id $fs_folder_id \ + -folder_name $folder_name \ + -folder_label "Run-${run_id}-Folder"] - set run_folder_id [imsld::cr::folder_new -parent_id $fs_folder_id -folder_name $folder_name -folder_label "Run-${run_id}-Folder"] - # PERMISSIONS FOR FILE-STORAGE # Before we go about anything else, lets just set permissions straight. # Disable folder permissions inheritance permission::toggle_inherit -object_id $run_folder_id # Set read permissions for community/class dotlrn_member_rel - set party_id_member [dotlrn_community::get_rel_segment_id -community_id $community_id -rel_type dotlrn_member_rel] - permission::grant -party_id $party_id_member -object_id $run_folder_id -privilege read + set party_id_member [dotlrn_community::get_rel_segment_id \ + -community_id $community_id \ + -rel_type dotlrn_member_rel] + permission::grant -party_id $party_id_member \ + -object_id $run_folder_id -privilege read # Set read permissions for community/class dotlrn_admin_rel - set party_id_admin [dotlrn_community::get_rel_segment_id -community_id $community_id -rel_type dotlrn_admin_rel] - permission::grant -party_id $party_id_admin -object_id $run_folder_id -privilege read + set party_id_admin [dotlrn_community::get_rel_segment_id \ + -community_id $community_id \ + -rel_type dotlrn_admin_rel] + permission::grant -party_id $party_id_admin \ + -object_id $run_folder_id -privilege read # Set read permissions for *all* other professors within .LRN # (so they can see the content) - set party_id_professor [dotlrn::user::type::get_segment_id -type professor] - permission::grant -party_id $party_id_professor -object_id $run_folder_id -privilege read + set party_id_professor [dotlrn::user::type::get_segment_id \ + -type professor] + permission::grant -party_id $party_id_professor \ + -object_id $run_folder_id -privilege read # Set read permissions for *all* other admins within .LRN # (so they can see the content) set party_id_admins [dotlrn::user::type::get_segment_id -type admin] - permission::grant -party_id $party_id_admins -object_id $run_folder_id -privilege read + permission::grant -party_id $party_id_admins \ + -object_id $run_folder_id -privilege read } # register content types content::folder::register_content_type -folder_id $run_folder_id \ @@ -123,17 +161,23 @@ # There are 5 property types # 1. loc-proerty: same value for every user in the run # 2. locpers-property: different value for every user in the run - # 3. locrole-property: same value for every user in the same rol during the run - # 4. globpers-property: different value for every user (run and ims-ld independent) - # 5. glob-property: one value independent from the run, ims-ld, user or role + # 3. locrole-property: same value for every user in the same rol during the + # run + # 4. globpers-property: different value for every user (run and ims-ld + # independent) + # 5. glob-property: one value independent from the run, ims-ld, user or + # role db_1row context_info { select ic.item_id as component_item_id, ii.imsld_id, ii.item_id as imsld_item_id, rug.group_id as run_group_id, org.manifest_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug, + from imsld_componentsi ic, + imsld_imsldsi ii, + imsld_runs ir, + imsld_run_users_group_ext rug, imsld_cp_organizationsi org where ic.imsld_id = ii.item_id and content_revision__is_live(ii.imsld_id) = 't' @@ -143,104 +187,143 @@ and ii.organization_id = org.item_id } - # before we can continue we create the folder where the properties of type file will be stored + # before we can continue we create the folder where the properties of type + # file will be stored set run_folder_id [imsld::instance::create_run_folder -run_id $run_id] - set cr_root_folder_id [imsld::cr::get_root_folder -community_id [dotlrn_community::get_community_id]] - set cr_folder_id [content::item::get_id -item_path "cr_manifest_${manifest_id}" -root_folder_id $cr_root_folder_id -resolve_index f] + set cr_root_folder_id \ + [imsld::cr::get_root_folder \ + -community_id [dotlrn_community::get_community_id]] + set cr_folder_id [content::item::get_id \ + -item_path "cr_manifest_${manifest_id}" \ + -root_folder_id $cr_root_folder_id -resolve_index f] set global_folder_id [imsld::global_folder_id] - # 1. loc-property: We create only one entry in the imsld_property_instances table for each property of this type + # 1. loc-property: We create only one entry in the imsld_property_instances + # table for each property of this type db_foreach loc_property { select property_id, identifier, datatype, initial_value, title, - item_id as property_item_id + coalesce(title,identifier) as item_name from imsld_propertiesi where component_id = :component_item_id and type = 'loc' + and content_revision__is_live(property_id) = 't' } { if { ![db_0or1row loc_already_instantiated_p { select 1 - from imsld_property_instancesi + from imsld_property_instances where property_id = :property_id and identifier = :identifier and run_id = :run_id + and content_revision__is_live(instance_id) = 't' }] } { - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $initial_value] \ - [list identifier $identifier] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + set instance_id \ + [imsld::item_revision_new \ + -attributes [list [list run_id $run_id] \ + [list value $initial_value] \ + [list identifier $identifier] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -name $item_name \ + -title $title \ + -parent_id [expr [string eq $datatype "file"] ? \ + $run_folder_id : $cr_folder_id]] if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] + # initialize the file to an empty one so the fs doesn't + # generate an error when requesting the file + imsld::fs::empty_file \ + -revision_id [content::item::get_live_revision \ + -item_id $instance_id] } } } - # 2. locpers-property: Instantiate the property for each user assigned to the run + # 2. locpers-property: Instantiate the property for each user assigned to + # the run foreach property_list [db_list_of_lists locpers_property { select property_id, identifier, datatype, initial_value, title, - item_id as property_item_id + coalesce(title,identifier) from imsld_propertiesi where component_id = :component_item_id and type = 'locpers' + and content_revision__is_live(property_id) = 't' }] { set property_id [lindex $property_list 0] set identifier [lindex $property_list 1] set datatype [lindex $property_list 2] set initial_value [lindex $property_list 3] - set property_item_id [lindex $property_list 4] + set title [lindex $property_list 4] + set item_name [lindex $property_list 5] db_foreach user_in_run { select ar.object_id_two as party_id from acs_rels ar where ar.object_id_one = :run_group_id and ar.rel_type = 'imsld_run_users_group_rel' - } { + } { if { ![db_0or1row locrole_already_instantiated_p { select 1 - from imsld_property_instancesi + from imsld_property_instances where property_id = :property_id and identifier = :identifier and party_id = :party_id and run_id = :run_id + and content_revision__is_live(instance_id) = 't' }] } { - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $initial_value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + # Create a folder for each user in the run if needed. + set user_folder_id \ + [content::item::get_id \ + -item_path \ + [imsld::instance::user_folder_name -user_id $party_id] \ + -root_folder_id $run_folder_id] + if { $user_folder_id eq "" } { + set user_folder_id [imsld::instance::create_user_folder \ + -user_id $party_id \ + -parent_folder_id $run_folder_id] + } + set instance_id \ + [imsld::item_revision_new \ + -attributes [list [list run_id $run_id] \ + [list value $initial_value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -name $item_name \ + -title $title \ + -parent_id [expr [string eq $datatype "file"] ? \ + $user_folder_id : $cr_folder_id]] if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] + # initialize the file to an empty one so the fs doesn't + # generate an error when requesting the file + imsld::fs::empty_file \ + -revision_id [content::item::get_live_revision \ + -item_id $instance_id] } } } } - # 3. locrole-property: Instantiate the property for each role associated to the run + # 3. locrole-property: Instantiate the property for each role associated to + # the run db_foreach locrole_property { select property_id, identifier, datatype, initial_value, title, - item_id as property_item_id + coalesce(title,identifier) as item_name from imsld_propertiesi where component_id = :component_item_id and type = 'locrole' + and content_revision__is_live(property_id) = 't' } { db_foreach roles_instances_in_run { select ar1.object_id_two as party_id @@ -255,34 +338,44 @@ } { if { ![db_0or1row locrole_already_instantiated_p { select 1 - from imsld_property_instancesi + from imsld_property_instances where property_id = :property_id and identifier = :identifier and party_id = :party_id and run_id = :run_id + and content_revision__is_live(instance_id) = 't' }] } { - set instance_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $initial_value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $run_folder_id : $cr_folder_id]] + set instance_id \ + [imsld::item_revision_new \ + -attributes [list [list run_id $run_id] \ + [list value $initial_value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -name $item_name \ + -title $title \ + -parent_id [expr [string eq $datatype "file"] ? \ + $run_folder_id : $cr_folder_id]] if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] + # initialize the file to an empty one so the fs doesn't + # generate an error when requesting the file + imsld::fs::empty_file \ + -revision_id [content::item::get_live_revision \ + -item_id $instance_id] } } } } - # 4. globpers-property: Special case. The table imsld_property_instances must hold only one entrance for these properties. - # Besides, if existng href exists, the value of the property is taken from the URI. Otherwise, if - # global definition is not empty, then the property is defined. - # The global definition is stored in the same row of the property_id, so the initial_value of - # the global_definition is in fact the initial_value of the property + # 4. globpers-property: Special case. The table imsld_property_instances + # must hold only one entrance for these properties. + # Besides, if existng href exists, the value of the property is taken from + # the URI. Otherwise, if global definition is not empty, then the property + # is defined. The global definition is stored in the same row of the + # property_id, so the initial_value of the global_definition is in fact the + # initial_value of the property foreach property_list [db_list_of_lists globpers_property { select property_id, identifier, @@ -291,18 +384,20 @@ existing_href, uri, title, - item_id as property_item_id + coalesce(title,identifier) from imsld_propertiesi where component_id = :component_item_id and type = 'globpers' + and content_revision__is_live(property_id) = 't' }] { set property_id [lindex $property_list 0] set identifier [lindex $property_list 1] set datatype [lindex $property_list 2] set initial_value [lindex $property_list 3] set existing_href [lindex $property_list 4] set uri [lindex $property_list 5] - set property_item_id [lindex $property_list 6] + set title [lindex $property_list 6] + set item_name [lindex $property_list 7] db_foreach user_in_run { select ar.object_id_two as party_id from acs_rels ar @@ -314,32 +409,55 @@ from imsld_property_instances where identifier = :identifier and party_id = :party_id + and content_revision__is_live(instance_id) = 't' }] } { - # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? + # not instantiated... is it already defined (existing href)? or + # must we use the one of the global definition? if { ![string eq $existing_href ""] } { # it is already defined # NOTE: there must be a better way to deal with this, # but by the moment we treat the href as the property value set initial_value $existing_href } - # TODO: the property must be somehow instantiated in the given URI also - set instance_id [imsld::item_revision_new -attributes [list [list value $initial_value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $identifier \ - -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] + + # Create a folder for each user in the run if needed. + set user_folder_id \ + [content::item::get_id \ + -item_path \ + [imsld::instance::user_folder_name -user_id $party_id] \ + -root_folder_id $global_folder_id] + if { $user_folder_id eq "" } { + set user_folder_id [imsld::instance::create_user_folder \ + -user_id $party_id \ + -parent_folder_id $global_folder_id] + } + + # TODO: the property must be somehow instantiated in the given + # URI also + set instance_id \ + [imsld::item_revision_new \ + -attributes [list [list value $initial_value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -name $item_name \ + -title $title \ + -parent_id [expr [string eq $datatype "file"] ? \ + $user_folder_id : $cr_folder_id]] if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] + # initialize the file to an empty one so the fs doesn't + # generate an error when requesting the file + imsld::fs::empty_file \ + -revision_id [content::item::get_live_revision \ + -item_id $instance_id] } } } } - # 5. glob-property: Special case, just like the one above but with the difference that the checking - # is not done for all the users + # 5. glob-property: Special case, just like the one above but with the + # difference that the checking is not done for all the users db_foreach global_property { select property_id, identifier, @@ -348,31 +466,44 @@ existing_href, uri, title, - item_id as property_item_id + coalesce(title,identifier) as item_name from imsld_propertiesi where component_id = :component_item_id and type = 'global' + and content_revision__is_live(property_id) = 't' } { if { ![db_0or1row global_already_instantiated_p { select 1 from imsld_property_instances where identifier = :identifier + and content_revision__is_live(instance_id) = 't' }] } { - # not instantiated... is it already defined (existing href)? or must we use the one of the global definition? + # not instantiated... is it already defined (existing href)? or + # must we use the one of the global definition? if { ![string eq $existing_href ""] } { # it is already defined - # NOTE: there must be a better way to deal with this, but by the moment we treat the href as the property value + # NOTE: there must be a better way to deal with this, but by + # the moment we treat the href as the property value set initial_value $existing_href } - # TODO: the property must be somehow instantiated in the given URI also - set instance_id [imsld::item_revision_new -attributes [list [list value $initial_value] \ - [list identifier $identifier] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -parent_id [expr [string eq $datatype "file"] ? $global_folder_id : $cr_folder_id]] + # TODO: the property must be somehow instantiated in the given URI + # also + set instance_id \ + [imsld::item_revision_new \ + -attributes [list [list value $initial_value] \ + [list identifier $identifier] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -name $item_name \ + -title $title \ + -parent_id [expr [string eq $datatype "file"] ? \ + $global_folder_id : $cr_folder_id]] if { [string eq $datatype "file"] } { - # initialize the file to an empty one so the fs doesn't generate an error when requesting the file - imsld::fs::empty_file -revision_id [content::item::get_live_revision -item_id $instance_id] + # initialize the file to an empty one so the fs doesn't + # generate an error when requesting the file + imsld::fs::empty_file \ + -revision_id [content::item::get_live_revision \ + -item_id $instance_id] } } } @@ -385,16 +516,22 @@ } { @param run_id The run_id we are instantiating - There are some attributes (like isvisible or the class global attributes) which are not properties but - have to be instantiated because the context of those attributes is the context of the run. So anytime a run - is created, those attributes must be initialized according to the values parsed from the manifest, and not - from the possible changed values of a previous run. + There are some attributes (like isvisible or the class global attributes) + which are not properties but have to be instantiated because the context of + those attributes is the context of the run. So anytime a run is created, + those attributes must be initialized according to the values parsed from + the manifest, and not from the possible changed values of a previous run. } { - set involved_roles [imsld::roles::get_list_of_roles -imsld_id [db_string get_imsld_from_run {select imsld_id from imsld_runs where run_id=:run_id}] ] + set involved_roles \ + [imsld::roles::get_list_of_roles \ + -imsld_id [db_string get_imsld_from_run \ + {select imsld_id from imsld_runs where run_id=:run_id}] ] set involved_users [list] foreach role $involved_roles { - set involved_users [concat $involved_users [imsld::roles::get_users_in_role -role_id [lindex $role 0] -run_id $run_id]] + set involved_users [concat $involved_users \ + [imsld::roles::get_users_in_role \ + -role_id [lindex $role 0] -run_id $run_id]] } foreach user_id [lsort -unique $involved_users] { @@ -406,16 +543,20 @@ ii.prerequisite_id as imsld_prerequisite_id, ii.item_id as run_imsld_item_id, rug.group_id as run_group_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug + from imsld_componentsi ic, + imsld_imsldsi ii, + imsld_runs ir, + imsld_run_users_group_ext rug where ic.imsld_id = ii.item_id and content_revision__is_live(ii.imsld_id) = 't' and ii.imsld_id = ir.imsld_id and rug.run_id = ir.run_id and ir.run_id = :run_id } - # 1. items --> learning objectives, prerequisites, roles, - # learning objects, activity description, information(activity structures) + # 1. items --> learning objectives, prerequisites, roles, learning + # objects, activity description, information(activity structures), # + # feedback # 1.1 learning objectives items set linear_item_list [db_list item_in_imsld_loi { @@ -426,33 +567,42 @@ and lo.learning_objective_id = :imsld_learning_objective_id }] - set linear_item_list [concat $linear_item_list [db_list item_in_activity_loi { - select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_learning_activities ia, imsld_learning_objectivesi lo - where ar.object_id_one = lo.item_id - and ar.object_id_two = ii.item_id - and ia.learning_objective_id = lo.item_id - and ia.component_id = :component_item_id - }]] + set linear_item_list \ + [concat $linear_item_list [db_list item_in_activity_loi { + select ii.imsld_item_id + from acs_rels ar, + imsld_itemsi ii, + imsld_learning_activities ia, + imsld_learning_objectivesi lo + where ar.object_id_one = lo.item_id + and ar.object_id_two = ii.item_id + and ia.learning_objective_id = lo.item_id + and ia.component_id = :component_item_id + }]] # 1.2. prerequisites - set linear_item_list [concat $linear_item_list [db_list item_in_imsld_pre { - select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_prerequisitesi pre - where ar.object_id_one = pre.item_id - and ar.object_id_two = ii.item_id - and pre.prerequisite_id = :imsld_prerequisite_id - }]] + set linear_item_list \ + [concat $linear_item_list [db_list item_in_imsld_pre { + select ii.imsld_item_id + from acs_rels ar, imsld_itemsi ii, imsld_prerequisitesi pre + where ar.object_id_one = pre.item_id + and ar.object_id_two = ii.item_id + and pre.prerequisite_id = :imsld_prerequisite_id + }]] - set linear_item_list [concat $linear_item_list [db_list item_in_activity_pre { - select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_learning_activities ia, imsld_prerequisitesi pre - where ar.object_id_one = pre.item_id - and ar.object_id_two = ii.item_id - and ia.prerequisite_id = pre.item_id - and ia.component_id = :component_item_id - }]] - + set linear_item_list \ + [concat $linear_item_list [db_list item_in_activity_pre { + select ii.imsld_item_id + from acs_rels ar, + imsld_itemsi ii, + imsld_learning_activities ia, + imsld_prerequisitesi pre + where ar.object_id_one = pre.item_id + and ar.object_id_two = ii.item_id + and ia.prerequisite_id = pre.item_id + and ia.component_id = :component_item_id + }]] + # 1.3. roles set linear_item_list [concat $linear_item_list [db_list item_in_role { select ii.imsld_item_id @@ -461,11 +611,14 @@ and ar.object_id_two = ii.item_id and ir.component_id = :component_item_id }]] - + # 1.4. learning objects (environments) set linear_item_list [concat $linear_item_list [db_list item_in_lo { select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_learning_objectsi lo, imsld_environmentsi env + from acs_rels ar, + imsld_itemsi ii, + imsld_learning_objectsi lo, + imsld_environmentsi env where ar.object_id_one = lo.item_id and ar.object_id_two = ii.item_id and lo.environment_id = env.item_id @@ -475,7 +628,10 @@ # 1.5. activity description (learning activities) set linear_item_list [concat $linear_item_list [db_list item_in_la_desc { select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_learning_activitiesi la, imsld_activity_descsi ad + from acs_rels ar, + imsld_itemsi ii, + imsld_learning_activitiesi la, + imsld_activity_descsi ad where ar.object_id_one = ad.item_id and ar.object_id_two = ii.item_id and la.activity_description_id = ad.item_id @@ -485,31 +641,53 @@ # 1.6. activity description (support activities) set linear_item_list [concat $linear_item_list [db_list item_in_sa_desc { select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_support_activitiesi sa, imsld_activity_descsi ad + from acs_rels ar, + imsld_itemsi ii, + imsld_support_activitiesi sa, + imsld_activity_descsi ad where ar.object_id_one = ad.item_id and ar.object_id_two = ii.item_id and sa.activity_description_id = ad.item_id and sa.component_id = :component_item_id }]] # 1.7. information(activity structures) - set linear_item_list [concat $linear_item_list [db_list item_in_as_info { - select ii.imsld_item_id - from acs_rels ar, imsld_itemsi ii, imsld_activity_structuresi ast - where ar.object_id_one = ast.item_id - and ar.object_id_two = ii.item_id - and ast.component_id = :component_item_id - }]] + set linear_item_list \ + [concat $linear_item_list [db_list item_in_as_info { + select ii.imsld_item_id + from acs_rels ar, imsld_itemsi ii, + imsld_activity_structuresi ast + where ar.object_id_one = ast.item_id + and ar.object_id_two = ii.item_id + and ast.component_id = :component_item_id + }]] + # 1.8. feedbak (learning activities) + set linear_item_list \ + [concat $linear_item_list [db_list item_in_la_feedback { + select ii.imsld_item_id + from acs_rels ar, imsld_itemsi ii, + imsld_learning_activitiesi la + where ar.object_id_one = la.on_completion_id + and ar.object_id_two = ii.item_id + and ar.rel_type = 'imsld_feedback_rel' + and la.component_id = :component_item_id + }]] + foreach imsld_item_id $linear_item_list { db_foreach nested_associated_items { select ii.imsld_item_id, ii.item_id, coalesce(ii.is_visible_p, 't') as is_visible_p, ii.identifier from imsld_itemsi ii - where (imsld_tree_sortkey between tree_left((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) - and tree_right((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) - or ii.imsld_item_id = :imsld_item_id) + where + (imsld_tree_sortkey between + tree_left((select imsld_tree_sortkey from + imsld_items where imsld_item_id = :imsld_item_id)) + and + tree_right((select imsld_tree_sortkey from + imsld_items where imsld_item_id = :imsld_item_id)) + or ii.imsld_item_id = :imsld_item_id) } { if { ![db_0or1row info_as_already_instantiated_p { select 1 @@ -519,7 +697,18 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $imsld_item_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id $imsld_item_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } } @@ -540,7 +729,18 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $activity_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id $activity_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } @@ -560,7 +760,18 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $activity_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id $activity_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } @@ -582,17 +793,40 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $learning_object_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id $learning_object_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } - if { ![string eq "" $class] && ![db_0or1row lo_env_already_instantiated_p { - select 1 - from imsld_attribute_instances - where run_id = :run_id - and user_id= :user_id - and type = 'class' - and identifier = :class - }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id ""] [list type "class"] [list identifier $class] [list run_id $run_id] [list user_id $user_id] [list is_visible_p "t"] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + if { ![string eq "" $class] && + ![db_0or1row lo_env_already_instantiated_p { + select 1 + from imsld_attribute_instances + where run_id = :run_id + and user_id= :user_id + and type = 'class' + and identifier = :class + }] } { + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id ""] \ + [list type "class"] \ + [list identifier $class] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p "t"] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } @@ -614,17 +848,40 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $service_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql -var_list \ + [list [list instance_id ""] \ + [list owner_id $service_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } - if { ![string eq "" $class] && ![db_0or1row serv_env_already_instantiated_p { - select 1 - from imsld_attribute_instances - where run_id = :run_id - and user_id = :user_id - and type = 'class' - and identifier = :class - }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id ""] [list type "class"] [list identifier $class] [list run_id $run_id] [list user_id $user_id] [list is_visible_p "t"] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + if { ![string eq "" $class] && + ![db_0or1row serv_env_already_instantiated_p { + select 1 + from imsld_attribute_instances + where run_id = :run_id + and user_id = :user_id + and type = 'class' + and identifier = :class + }] } { + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id ""] \ + [list type "class"] \ + [list identifier $class] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p "t"] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } @@ -645,10 +902,21 @@ and user_id = :user_id and type = 'isvisible' }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id $play_id] [list type "isvisible"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p $is_visible_p] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id $play_id] \ + [list type "isvisible"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p $is_visible_p] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } - + # 7. classes db_foreach class { select cla.class_id, @@ -663,7 +931,18 @@ and run_id = :run_id and user_id = :user_id }] } { - set instance_id [package_exec_plsql -var_list [list [list instance_id ""] [list owner_id ""] [list type "class"] [list identifier $identifier] [list run_id $run_id] [list user_id $user_id] [list is_visible_p "t"] [list title ""] [list with_control_p ""]] imsld_attribute_instance new] + set instance_id \ + [package_exec_plsql \ + -var_list [list [list instance_id ""] \ + [list owner_id ""] \ + [list type "class"] \ + [list identifier $identifier] \ + [list run_id $run_id] \ + [list user_id $user_id] \ + [list is_visible_p "t"] \ + [list title ""] \ + [list with_control_p ""]] \ + imsld_attribute_instance new] } } } @@ -678,9 +957,113 @@ @return 1 if successful, 0 otherwise } { - return [package_exec_plsql -var_list [list [list run_id $run_id]] imsld_run del] + return [package_exec_plsql -var_list [list [list run_id $run_id]] \ + imsld_run del] } +ad_proc -public imsld::instance::create_user_folder { + -user_id:required + -parent_folder_id:required + {-community_id ""} +} { + Procedure that given a user id, creates inside the + given parent_id one folder with name user_NNNN_folder where + NNNN is the user_id within the platform. This folder is required to + store the values of locpers-property and globpers-property of type file. + Since each user may have an instance of the same file, separating them into + user folders facilitates its later manipulation. All the files submitted + for locpers-property or globpers-property for the same person are found in + one single folder. + As for the "folder_label" it is not given to the imsld::cr::folder_new on + purpose in order for it to reuse folder_name. Navigating through WebDAV in + one of this folders, only shows the folder_name, therefore, this duality + between folder_name and folder_label, has been avoided. + + Returns the item_id of the created folder + + @param user_id user id for which to create the folder + @param parent_folder_id cr_item from which to create the sub-folder +} { + # If the community_id is not given, obtained from the environment + if { [empty_string_p $community_id] } { + set community_id [dotlrn_community::get_community_id] + } + + # Require writing permission in the given parent_folder_id + permission::require_permission \ + -object_id $parent_folder_id \ + -privilege write + + db_transaction { + # First cook up the folder name. + set folder_name [imsld::instance::user_folder_name \ + -user_id $user_id] + + # Create the folder. No folder_label is given, therefore, the + # folder_name is reused. + set user_folder_id [imsld::cr::folder_new \ + -parent_id $parent_folder_id \ + -folder_name $folder_name] + # And now, the permissions. These folders should only be visible to + # the user + # Disable folder permissions inheritance + permission::toggle_inherit -object_id $user_folder_id + + # Set read permissions for the user + permission::grant -party_id $user_id \ + -object_id $user_folder_id -privilege read + + # Set admin permissions for community/class dotlrn_admin_rel + set party_id_admin [dotlrn_community::get_rel_segment_id \ + -community_id $community_id \ + -rel_type dotlrn_admin_rel] + permission::grant -party_id $party_id_admin \ + -object_id $user_folder_id \ + -privilege read + + # Set read permissions for *all* other professors within .LRN + # FIXME: This should be restricted to professors members of THIS + # community + set party_id_professor [dotlrn::user::type::get_segment_id \ + -type professor] + permission::grant -party_id $party_id_professor \ + -object_id $user_folder_id \ + -privilege read + + # Set read permissions for *all* other admins within .LRN + set party_id_admins [dotlrn::user::type::get_segment_id -type admin] + permission::grant -party_id $party_id_admins \ + -object_id $user_folder_id -privilege read + + # register content types + content::folder::register_content_type -folder_id $user_folder_id \ + -content_type imsld_property_instance + + # In principle no sub-folders are allowed in this folder. + } + + return $user_folder_id +} + +ad_proc -public imsld::instance::user_folder_name { + -user_id:required +} { + This procedure is to centralize the place where the user folder name is + computed. It is used to create this folder and access it to store + properties of type file. By centralizing here the name creation, when + modified, this is the only place in the code where the change needs to be + reflected. + + Returns the string used for folder identification + + @param user_id the user identifier for the folder name +} { + db_1row user_info { + select username as username from users where user_id=:user_id + } + return ${user_id}_$username +} + # LocalWords: type Index: openacs-4/packages/imsld/tcl/imsld-monitor-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-monitor-procs.tcl,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/imsld/tcl/imsld-monitor-procs.tcl 25 Apr 2007 10:52:30 -0000 1.2 +++ openacs-4/packages/imsld/tcl/imsld-monitor-procs.tcl 24 Apr 2008 10:50:34 -0000 1.2.6.1 @@ -67,30 +67,20 @@ db_1row get_sort_order { select sort_order from imsld_as_la_rels where rel_id = :rel_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node - - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" \ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node - - set completed_list [linsert $completed_list $sort_order [$activity_node asList]] + set completed_list [linsert $completed_list \ + $sort_order [$activity_node asList]] } imsld_as_sa_rel { - # add the activiti to the TCL list + # add the activity to the TCL list db_1row get_support_activity_info { select sa.title as activity_title, sa.item_id as activity_item_id, @@ -104,25 +94,14 @@ select sort_order from imsld_as_sa_rels where rel_id = :rel_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" \ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node - set completed_list [linsert $completed_list $sort_order [$activity_node asList]] } imsld_as_as_rel { @@ -139,25 +118,15 @@ select sort_order from imsld_as_as_rels where rel_id = :rel_id } - set structure_node [$dom_doc createElement li] - $structure_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "structure"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $structure_node appendChild $a_node + set structure_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {{activity_id "$structure_id"} run_id {type "structure"}}]" \ + -run_id $run_id \ + -revision_id $structure_id \ + -type "activity"] - set text [$dom_doc createTextNode " "] - $structure_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "structure"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $structure_id -type "activity"])"] - $info_node appendChild $text - $structure_node appendChild $info_node - set nested_activities_list [imsld::monitor::structure_activities_list -imsld_id $imsld_id \ -run_id $run_id \ -structure_item_id $structure_item_id \ @@ -236,25 +205,15 @@ from imsld_learning_activitiesi la where activity_id = :activity_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node - - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {activity_id run_id {type "learning"}}]" \ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node - $dom_node appendChild $activity_node } support { @@ -267,25 +226,15 @@ from imsld_support_activitiesi sa where sa.activity_id = :activity_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {activity_id run_id {type "support"}}]"\ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node - $dom_node appendChild $activity_node } structure { @@ -298,25 +247,15 @@ where structure_id = :activity_id } - set structure_node [$dom_doc createElement li] - $structure_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "structure"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $structure_node appendChild $a_node + set structure_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {activity_id run_id {type "structure"}}]" \ + -run_id $run_id \ + -revision_id $structure_id \ + -type "activity"] - set text [$dom_doc createTextNode " "] - $structure_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "structure"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $structure_id -type "activity"])"] - $info_node appendChild $text - $structure_node appendChild $info_node - set nested_list [imsld::monitor::structure_activities_list -imsld_id $imsld_id \ -run_id $run_id \ -structure_item_id $structure_item_id \ @@ -357,7 +296,7 @@ set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "properties-frame" -url {run_id {type "loc"}}]" $a_node setAttribute target "content" - set text [$dom_doc createTextNode "[_ imsld.1_Local_Properties]"] + set text [$dom_doc createTextNode "1. [_ imsld.Local_Properties]"] $a_node appendChild $text $local_node appendChild $a_node @@ -370,7 +309,7 @@ set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "properties-frame" -url {run_id {type "locpers"}}]" $a_node setAttribute target "content" - set text [$dom_doc createTextNode "[_ imsld.lt_2_Local-personal_Prop]"] + set text [$dom_doc createTextNode "2. [_ imsld.lt_Local-personal_Prop]"] $a_node appendChild $text $locpers_node appendChild $a_node @@ -379,8 +318,8 @@ # 3. loc-role properties: associated to each role in the run set locrole_node [$dom_doc createElement li] - $locrole_node setAttribute class "liClosed" - set text [$dom_doc createTextNode "[_ imsld.lt_3_Local-role_Properti]"] + $locrole_node setAttribute class "liOpen" + set text [$dom_doc createTextNode "3. [_ imsld.lt_Local-role_Properti]"] $a_node appendChild $text $locrole_node appendChild $text @@ -410,7 +349,7 @@ set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "properties-frame" -url {run_id {type "globpers"}}]" $a_node setAttribute target "content" - set text [$dom_doc createTextNode "[_ imsld.lt_4_Global-personal_Pro]"] + set text [$dom_doc createTextNode "4. [_ imsld.lt_Global-personal_Pro]"] $a_node appendChild $text $globpers_node appendChild $a_node @@ -423,7 +362,7 @@ set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "properties-frame" -url {run_id {type "glob"}}]" $a_node setAttribute target "content" - set text [$dom_doc createTextNode "[_ imsld.5_Global_Properties]"] + set text [$dom_doc createTextNode "5. [_ imsld.Global_Properties]"] $a_node appendChild $text $globpers_node appendChild $a_node @@ -496,23 +435,14 @@ where activity_id = :activity_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node - - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "learning"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {activity_id run_id {type "learning"}}]"\ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] $dom_node appendChild $activity_node } @@ -527,25 +457,15 @@ where sa.activity_id = :activity_id } - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + set activity_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $activity_title \ + -href "[export_vars -base "activity-frame" \ + -url {activity_id run_id {type "support"}}]"\ + -run_id $run_id \ + -revision_id $activity_id \ + -type "activity"] - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id {type "support"}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $activity_id -type "activity"])"] - $info_node appendChild $text - $activity_node appendChild $info_node - $dom_node appendChild $activity_node } } @@ -560,7 +480,6 @@ } { @param environment_item_id @param run_id - @option resource_mode @param dom_node @param dom_doc @@ -630,25 +549,16 @@ set resource_item_id [lindex $environments_list 1] set resource_type [lindex $environments_list 2] - set lo_node [$dom_doc createElement li] - $lo_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {run_id learning_object_id {type learning_object}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$lo_title"] - $a_node appendChild $text - $lo_node appendChild $a_node + set lo_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $lo_title \ + -href "[export_vars -base "activity-frame" \ + -url {run_id learning_object_id {type learning_object}}]"\ + -run_id $run_id \ + -revision_id $learning_object_id \ + -item_id $learning_object_item_id \ + -type "learning_object"] - set text [$dom_doc createTextNode " "] - $lo_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {run_id learning_object_id {type learning_object}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $learning_object_id -item_id $learning_object_item_id -type "learning_object"])"] - $info_node appendChild $text - $lo_node appendChild $info_node - $environment_node appendChild $lo_node } } @@ -673,25 +583,15 @@ set service_title [expr { [string eq [lindex $services_list 4] ""] ? $environment_title : [lindex $services_list 4] }] set class_name [lindex $services_list 5] - set service_node [$dom_doc createElement li] - $service_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {run_id service_id {type service}}]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$service_title"] - $a_node appendChild $text - $service_node appendChild $a_node + set service_node [imsld::monitor::link_to_visitors_info \ + -dom_doc $dom_doc \ + -title $service_title \ + -href "[export_vars -base "activity-frame" \ + -url {run_id service_id {type service}}]" \ + -run_id $run_id \ + -revision_id $service_id \ + -type "service"] - set text [$dom_doc createTextNode " "] - $service_node appendChild $text - - set info_node [$dom_doc createElement a] - $info_node setAttribute href "[export_vars -base "activity-frame" -url {run_id service_id {type service}}]" - $info_node setAttribute target "content" - set text [$dom_doc createTextNode "([imsld::monitor::number_of_visitors -run_id $run_id -revision_id $service_id -type "service"])"] - $info_node appendChild $text - $service_node appendChild $info_node - $environment_node appendChild $service_node } @@ -703,9 +603,9 @@ where ar.object_id_one = :environment_item_id and ar.rel_type = 'imsld_env_env_rel' }] { - imsld::monitor::process_environment_as_ul -environment_item_id $nested_environment_item_id \ + imsld::monitor::environment_as_ul \ + -environment_item_id $nested_environment_item_id \ -run_id $run_id \ - -resource_mode $resource_mode \ -dom_node $environment_node \ -dom_doc $dom_doc } @@ -928,3 +828,61 @@ } return $number_of_visitors } + +ad_proc -public imsld::monitor::link_to_visitors_info { + -dom_doc:required + -title:required + -href:required + -run_id:required + -revision_id:required + -type:required + -item_id +} { + @param dom_doc:required + @param href:required + @param run_id:required + @param revision_id:required + @param type:required + @param item_id + +

+ Adds to the given lo_node a link to the number of users visiting the + activity in activity_id/run_id +

+} { + set result [$dom_doc createElement li] + $result setAttribute class "liOpen" + + set a_node [$dom_doc createElement a] + $a_node setAttribute href $href + $a_node setAttribute target "content" + $result appendChild $a_node + + set text [$dom_doc createTextNode "$title "] + $a_node appendChild $text + + if { $type == "learning_object" } { + set visitors [imsld::monitor::number_of_visitors \ + -run_id $run_id \ + -revision_id $revision_id \ + -item_id $item_id \ + -type $type] + } else { + set visitors [imsld::monitor::number_of_visitors \ + -run_id $run_id \ + -revision_id $revision_id \ + -type $type] + } + + if { $visitors > 1 } { + set text [$dom_doc createTextNode "($visitors [_ imsld.users ])"] + } elseif { $visitors > 0 } { + set text [$dom_doc createTextNode "($visitors [_ imsld.user ])"] + } else { + set text [$dom_doc createTextNode "([_ imsld.No_users ])"] + } + + $result appendChild $text + + return $result +} 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 -r1.64 -r1.64.2.1 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 16 Jan 2008 10:30:40 -0000 1.64 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 24 Apr 2008 10:50:34 -0000 1.64.2.1 @@ -605,10 +605,6 @@ #revoke permissions until first usage of resources if {[info exist acs_object_id]} { permission::set_not_inherit -object_id $acs_object_id - set party_id [db_list get_allowed_parties {}] - foreach parti $party_id { - permission::revoke -party_id $parti -object_id $acs_object_id -privilege "read" - } } set resource_id [imsld::cp::resource_new -manifest_id $manifest_id \ @@ -647,12 +643,6 @@ permission::set_not_inherit -object_id $filex_id - set acs_object_id $filex_id - set party_id_list [db_list get_allowed_parties {}] - foreach party_id $party_id_list { - permission::revoke -party_id $party_id -object_id $filex_id -privilege "read" - } - # map resource with file relation_add -extra_vars $extra_vars imsld_res_files_rel $resource_id $filex_id } @@ -948,13 +938,16 @@ } { Parse a global definition and stores all the information in the database. - Returns a list with the new global_definition_id (item_id, actually a property_id) created if there were no errors, or 0 and an explanation messge if there was an error. + Returns a list with the new global_definition_id (item_id, actually a + property_id) created if there were no errors, or 0 and an explanation + messge if there was an error. @option global_def_node global_def node to parse @param identifier @param existing_href @param component_id Comoponent id of the one which owns the property - @param type Type of the property defined by this global definition, which can be globpers or glob + @param type Type of the property defined by this global definition, which + can be globpers or glob @param manifest Manifest tree @param manifest_id Manifest ID or the manifest being parsed @param parent_id Parent folder ID @@ -963,13 +956,25 @@ upvar files_struct_list files_struct_list if { ![empty_string_p $global_def_node] } { - set uri [imsld::parse::get_attribute -node $global_def_node -attr_name uri] - set title [imsld::parse::get_title -node $global_def_node -prefix imsld] - set datatype [$global_def_node selectNodes "*\[local-name()='datatype'\]" ] - imsld::parse::validate_multiplicity -tree $global_def_node -multiplicity 1 -element_name "global-definition datatype" -equal - set datatype [string tolower [imsld::parse::get_attribute -node $global_def_node -attr_name datatype]] - set initial_value [$global_def_node selectNodes "*\[local-name()='initial-value'\]"] - imsld::parse::validate_multiplicity -tree $initial_value -multiplicity 1 -element_name "global-definition initial-value" -lower_than + set uri [imsld::parse::get_attribute -node $global_def_node \ + -attr_name uri] + set title [imsld::parse::get_title \ + -node $global_def_node -prefix imsld] + set datatype \ + [$global_def_node selectNodes "*\[local-name()='datatype'\]" ] + imsld::parse::validate_multiplicity \ + -tree $global_def_node \ + -multiplicity 1 \ + -element_name "global-definition datatype" -equal + set datatype [string tolower \ + [imsld::parse::get_attribute \ + -node $datatype -attr_name datatype]] + set initial_value [$global_def_node selectNodes \ + "*\[local-name()='initial-value'\]"] + imsld::parse::validate_multiplicity \ + -tree $initial_value \ + -multiplicity 1 \ + -element_name "global-definition initial-value" -lower_than if { [llength $initial_value] } { set initial_value [imsld::parse::get_element_text -node $initial_value] } else { @@ -983,26 +988,31 @@ } - set globpers_property_id [imsld::item_revision_new -attributes [list [list component_id $component_id] \ - [list identifier $identifier] \ - [list existing_href $existing_href] \ - [list uri $uri] \ - [list type $type] \ - [list datatype $datatype] \ - [list initial_value $initial_value]] \ - -content_type imsld_property \ - -title $title \ - -parent_id $parent_id] + set globpers_property_id \ + [imsld::item_revision_new \ + -attributes [list [list component_id $component_id] \ + [list identifier $identifier] \ + [list existing_href $existing_href] \ + [list uri $uri] \ + [list type $type] \ + [list datatype $datatype] \ + [list initial_value $initial_value]] \ + -content_type imsld_property \ + -title $title \ + -parent_id $parent_id] if { ![empty_string_p $global_def_node] } { - set restrictions [$global_def_node selectNodes "*\[local-name()='restriction'\]"] + set restrictions \ + [$global_def_node selectNodes "*\[local-name()='restriction'\]"] foreach restriction $restrictions { - set restriction_list [imsld::parse::parse_and_create_restriction -manifest $manifest \ - -property_id $globpers_property_id \ - -manifest_id $manifest_id \ - -restriction_node $restriction \ - -parent_id $parent_id \ - -tmp_dir $tmp_dir] + set restriction_list \ + [imsld::parse::parse_and_create_restriction \ + -manifest $manifest \ + -property_id $globpers_property_id \ + -manifest_id $manifest_id \ + -restriction_node $restriction \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] set restriction_id [lindex $restriction_list 0] if { !$restriction_id } { @@ -1230,8 +1240,8 @@ imsld::parse::validate_multiplicity -tree $lrp_datatype -multiplicity 1 -element_name "locrole-property datatype" -equal set lrp_datatype [string tolower [imsld::parse::get_attribute -node $lrp_datatype -attr_name datatype]] - set role_ref [$lrp_datatype selectNodes "*\[local-name()='role-ref'\]"] - imsld::parse::validate_multiplicity -tree $lrp_datatype -multiplicity 1 -element_name "locrole-property role" -equal + set role_ref [$locrole_property selectNodes "*\[local-name()='role-ref'\]"] + imsld::parse::validate_multiplicity -tree $role_ref -multiplicity 1 -element_name "locrole-property role" -equal set ref [imsld::parse::get_attribute -node $role_ref -attr_name ref] if { ![db_0or1row get_role_id { select item_id as role_id @@ -1318,15 +1328,15 @@ foreach glob_property $glob_properties { set g_identifier [imsld::parse::get_attribute -node $glob_property -attr_name identifier] set g_existing [$glob_property selectNodes "*\[local-name()='existing'\]"] - imsld::parse::validate_multiplicity -tree $g_exiting -multiplicity 1 -element_name "existing(glob)" -lower_than + imsld::parse::validate_multiplicity -tree $g_existing -multiplicity 1 -element_name "existing(glob)" -lower_than if { [llength $g_existing] } { - set g_existing_href [imsld::parse::get_attribute -node $g_exiting -attr_name href] + set g_existing_href [imsld::parse::get_attribute -node $g_existing -attr_name href] } else { set g_existing_href "" } set global_def [$glob_property selectNodes "*\[local-name()='global-definition'\]"] - set global_def_list [imsld::parse::parse_and_create_global_def -type glob \ + set global_def_list [imsld::parse::parse_and_create_global_def -type global \ -identifier $g_identifier \ -existing_href $g_existing_href \ -global_def_node $global_def \ @@ -1590,11 +1600,6 @@ #revoke read permissions until first usage if {[info exist acs_object_id]} { permission::set_not_inherit -object_id $acs_object_id - - set party_id [db_list get_allowed_parties {}] - foreach parti $party_id { - permission::revoke -party_id $parti -object_id $acs_object_id -privilege "read" - } } return $acs_object_id } @@ -1649,7 +1654,8 @@ [list parameters $parameters] \ [list service_type send-mail]] \ -content_type imsld_service \ - -parent_id $parent_id] + -parent_id $parent_id \ + -title $title] # create the send mail service set send_mail_id [imsld::item_revision_new -attributes [list [list service_id $service_id] \ [list is_visible_p $is_visible_p] \ @@ -1754,19 +1760,20 @@ [list parameters $parameters] \ [list service_type conference]] \ -content_type imsld_service \ - -parent_id $parent_id] + -parent_id $parent_id \ + -title $title] if { [string eq $conference_type "asynchronous"] } { - set moderator_list [$conference selectNodes "*\[local-name()='moderator'\]"] - if { [llength $moderator_list] } { - set acs_object_id [imsld::parse::parse_and_create_forum -name $title -is_moderated] - - } else { - set acs_object_id [imsld::parse::parse_and_create_forum -name $title] - } + set moderator_list [$conference selectNodes "*\[local-name()='moderator'\]"] + if { [llength $moderator_list] } { + set acs_object_id [imsld::parse::parse_and_create_forum -name $title -is_moderated] + + } else { + set acs_object_id [imsld::parse::parse_and_create_forum -name $title] + } - + set resource_id [imsld::cp::resource_new -manifest_id $manifest_id \ -identifier "forumresource-$service_id" \ -type "forum" \ @@ -1785,7 +1792,7 @@ # map item with resource relation_add imsld_item_res_rel $imsld_item_id $resource_id - + } else { # item set conference_item [$conference selectNodes "*\[local-name()='item'\]"] @@ -1902,7 +1909,8 @@ [list service_type monitor]] \ -title $title \ -content_type imsld_service \ - -parent_id $parent_id] + -parent_id $parent_id \ + -title $title] # monitor: role-ref set role_ref [$monitor_service selectNodes "*\[local-name()='role-ref'\]"] @@ -2707,24 +2715,26 @@ set structure_information [$activity_node selectNodes "*\[local-name()='information'\]"] if { [llength $structure_information] } { # parse the item, create it and map it to the activity structure - set information_item [$structure_information selectNodes "*\[local-name()='item'\]"] - if { ![llength $information_item] } { + set information_item_list [$structure_information selectNodes "*\[local-name()='item'\]"] + if { ![llength $information_item_list] } { return [list 0 "[_ imsld.lt_Information_given_but_1]"] } - set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ - -manifest_id $manifest_id \ - -item_node $information_item \ - -parent_id $parent_id \ - -tmp_dir $tmp_dir] - - set information_id [lindex $item_list 0] - if { !$information_id } { - # an error happened, abort and return the list whit the error - return $item_list - } - # map information item with the activity structure - relation_add imsld_as_info_i_rel $activity_structure_id $information_id + foreach information_item $information_item_list { + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $information_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set information_id [lindex $item_list 0] + if { !$information_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map information item with the activity structure + relation_add imsld_as_info_i_rel $activity_structure_id $information_id + } } # store the order of the activities to display them later in the correct order @@ -3372,11 +3382,13 @@ } } - set complete_act_id [imsld::item_revision_new -attributes [list [list time_in_seconds $time_in_seconds] \ - [list when_condition_true_id $when_condition_true_id] \ - [list when_prop_val_is_set_xml $when_prop_value_is_set_xml]] \ - -content_type imsld_complete_act \ - -parent_id $parent_id] + if { ![string eq "" $time_in_seconds] || ![string eq "" $when_prop_value_is_set_xml] ||![string eq "" $when_condition_true_id] } { + set complete_act_id [imsld::item_revision_new -attributes [list [list time_in_seconds $time_in_seconds] \ + [list when_condition_true_id $when_condition_true_id] \ + [list when_prop_val_is_set_xml $when_prop_value_is_set_xml]] \ + -content_type imsld_complete_act \ + -parent_id $parent_id] + } if { [llength $when_prop_value_is_set] } { #search properties in expression @@ -4009,13 +4021,13 @@ # get the files structure set files_struct_list [imsld::parse::get_files_structure -tmp_dir $tmp_dir] - # Parser - # XML => DOM document - dom parse [::tDOM::xmlReadFile $xmlfile] document - - # DOM document => DOM root - $document documentElement manifest - + # Parser + # XML => DOM document + dom parse [::tDOM::xmlReadFile $xmlfile] document + + # DOM document => DOM root + $document documentElement manifest + # manifest set manifest_identifier [imsld::parse::get_attribute -node $manifest -attr_name identifier] set manifest_version [imsld::parse::get_attribute -node $manifest -attr_name version] @@ -4355,7 +4367,7 @@ relation_add imsld_feedback_rel $on_completion_id $item_id } } else { - set on_completion_id [imsld::item_revision_new -parent_id $parent_id \ + set on_completion_id [imsld::item_revision_new -parent_id $parent_id \ -content_type imsld_on_completion] } @@ -4566,8 +4578,12 @@ 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 \ + 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 \ @@ -4580,6 +4596,13 @@ } } + # At this point files_struct_list contain the list of all the files in the + # UoL. Those that were stored in the FS have an object_id attached to + # them. Those that still have a zero as object_id are files that are not + # referenced as resources by the manifest, but they are in the ZIP, + # therefore, they need to be moved to the FS. + imsld::fs::traverse_zip -dir $tmp_dir -pattern "*" + if { ![empty_string_p $warnings] } { set warnings "[_ imsld.lt_br__Warnings_ul_warni]" } Index: openacs-4/packages/imsld/tcl/imsld-parse-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-parse-procs.xql,v diff -u -r1.6 -r1.6.6.1 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.xql 24 Oct 2006 10:09:51 -0000 1.6 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.xql 24 Apr 2008 10:50:34 -0000 1.6.6.1 @@ -13,29 +13,6 @@ - - - select aopp.party_id - from acs_object_party_privilege_map aopp, - party_names pn - where aopp.privilege='read' and - aopp.party_id=pn.party_id and - aopp.object_id=:acs_object_id - - - - - - select aopp.party_id - from acs_object_party_privilege_map aopp, - party_names pn - where aopp.privilege='read' and - aopp.party_id=pn.party_id and - aopp.object_id=:acs_object_id - - - - select env.component_id 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 -r1.98 -r1.98.2.1 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 16 Jan 2008 10:35:46 -0000 1.98 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 24 Apr 2008 10:50:34 -0000 1.98.2.1 @@ -30,12 +30,14 @@ ad_proc -public imsld::object_type_image_path { -object_type } { - returns the path to the image representing the given object_type in the imsld package + returns the path to the image representing the given object_type in the + imsld package } { set community_id [dotlrn_community::get_community_id] - set imsld_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id $community_id] \ - -package_key "[imsld::package_key]"] + set imsld_package_id \ + [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id $community_id] \ + -package_key "[imsld::package_key]"] switch $object_type { forums_forum { set image_path "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/forums.png" @@ -382,13 +384,20 @@ ad_proc -public imsld::global_folder_id { {-community_id ""} } { - Returns the global folder id where the global properties of type file are stored. - This folder is a subfolder of the dotlrn root folder and there must be only one in the .LRN installation + Returns the global folder id where the global properties of type file are + stored. + This folder is a subfolder of the dotlrn root folder and there must be only + one in the .LRN installation } { - set community_id [expr { [empty_string_p $community_id] ? [dotlrn_community::get_community_id] : $community_id }] + set community_id [expr { [empty_string_p $community_id] ? \ + [dotlrn_community::get_community_id] : \ + $community_id }] set dotlrn_root_folder_id [dotlrn_fs::get_dotlrn_root_folder_id] - set global_folder_id [content::item::get_id -item_path "imsld_global_folder" -root_folder_id $dotlrn_root_folder_id -resolve_index f] + set global_folder_id [content::item::get_id \ + -item_path "imsld_global_folder" \ + -root_folder_id $dotlrn_root_folder_id \ + -resolve_index f] if { [empty_string_p $global_folder_id] } { db_transaction { @@ -399,11 +408,15 @@ # create the root cr dir - set global_folder_id [imsld::cr::folder_new -parent_id $dotlrn_root_folder_id -folder_name $folder_name -folder_label "IMS-LD"] + set global_folder_id [imsld::cr::folder_new \ + -parent_id $dotlrn_root_folder_id \ + -folder_name $folder_name \ + -folder_label "IMS-LD"] # PERMISSIONS FOR FILE-STORAGE - # Before we go about anything else, lets just set permissions straight. + # Before we go about anything else, lets just set permissions + # straight. # Disable folder permissions inheritance permission::toggle_inherit -object_id $global_folder_id @@ -488,9 +501,9 @@ dom createDocument foo foo_doc set foo_node [$foo_doc documentElement] - if { [string eq $$type "learning"] } { + if { [string eq $type "learning"] } { set resources_activities_list [imsld::process_learning_activity_as_ul -run_id $run_id -activity_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] - } elseif { [string eq $$type "support"] } { + } elseif { [string eq $type "support"] } { set resources_activities_list [imsld::process_support_activity_as_ul -run_id $run_id -activity_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] } else { set resources_activities_list [imsld::process_activity_structure_as_ul -run_id $run_id -structure_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] @@ -511,6 +524,7 @@ mark the act as finished, as well as all the referenced role_parts } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] + if { [imsld::act_finished_p -run_id $run_id -act_id $act_id -user_id $user_id] } { return } @@ -530,6 +544,7 @@ and content_revision__is_live(rp.role_part_id) = 't' }] { set role_part_id [lindex $referenced_role_part 0] + imsld::mark_role_part_finished -role_part_id $role_part_id \ -act_id $act_id \ -play_id $play_id \ @@ -691,6 +706,7 @@ ad_proc -public imsld::item_revision_new { {-attributes ""} {-item_id ""} + {-name ""} {-title ""} {-package_id ""} {-user_id ""} @@ -701,10 +717,17 @@ -parent_id } { Creates a new revision of a content item, calling the cr functions. - If editing, only a new revision is created, otherwise an item is created too. + If editing, only a new revision is created, otherwise an item is created + too. - @option attributes A list of lists of pairs of additional attributes and their values. + @option attributes A list of lists of pairs of additional attributes and + their values. @option title + @option name When given this parameter is to set the field name of the + newly created item. This field is important for two reasons. First, in the + absence of title in the corresponding cr_revision object, it is the string + shown when the item is a file and is visible in the FS. Second, it is the + ONLY name that appears when browsing the FS through WebDAV. @option package_id @option user_id @option creation_ip @@ -713,16 +736,34 @@ @param parent_id Identifier of the parent folder } { - set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] - set creation_ip [expr { [string eq "" $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] - set creation_date [expr { [string eq "" $creation_date] ? [dt_sysdate] : $creation_date }] - set package_id [expr { [string eq "" $package_id] ? [ad_conn package_id] : $package_id }] - + set user_id \ + [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [string eq "" $creation_ip] ? \ + [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [string eq "" $creation_date] ? \ + [dt_sysdate] : $creation_date }] + set package_id [expr { [string eq "" $package_id] ? \ + [ad_conn package_id] : $package_id }] + if { [string eq $item_id ""] } { # create the item set item_id [db_nextval "acs_object_id_seq"] + + # Decide the name + if { [string eq "" $name] } { + set name "${item_id}_content_type" + } else { + # If the given name collides with another item, it needs to be + # modified as to make it unique (parent_id, name) is what it needs + # to be made unique + if { ![string eq "" [content::item::get_id_by_name \ + -name $name -parent_id $parent_id]] } { + set name "${name}.${item_id}" + } + } + set item_id [content::item::new -item_id $item_id \ - -name "${item_id}_content_type" \ + -name $name \ -content_type $content_type \ -parent_id $parent_id \ -creation_user $user_id \ @@ -775,10 +816,10 @@ } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] - # notifications - # according to the spec: "The implementation should ensure that a user receives one notification only, - # even if the user is a member of several roles targeted by the notification", that's why we use the list - # notified_users_list and check before sending the notification. + # notifications according to the spec: "The implementation should ensure + # that a user receives one notification only, even if the user is a member + # of several roles targeted by the notification", that's why we use the + # list notified_users_list and check before sending the notification. set community_id [dotlrn_community::get_community_id] set community_name [dotlrn_community::get_community_name $community_id] set community_url [ns_conn location][dotlrn_community::get_community_url $community_id] @@ -909,10 +950,12 @@ regexp {finish-component-element-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([a-z]+).imsld$} $url match imsld_id run_id play_id act_id role_part_id element_id type } if { ![db_0or1row marked_as_started { *SQL* }] } { - # NOTE: this should not happen... UNLESS the activity is marked as finished automatically + # NOTE: this should not happen... UNLESS the activity is marked as + # finished automatically db_dml mark_element_started { *SQL* } } - # now that we have the necessary info, mark the finished element completed and return + # now that we have the necessary info, mark the finished element completed + # and return db_dml insert_element_entry { *SQL* } switch $type { @@ -1016,50 +1059,109 @@ } } } - + if { [string eq $type "learning"] || [string eq $type "support"] || [string eq $type "structure"] } { + # if the activity is referenced from an activity strucutre, that activity structure must be checked + # in order to know if the structure must be also marked as completed foreach referencer_structure_list [db_list_of_lists referencer_structure { *SQL* }] { set structure_id [lindex $referencer_structure_list 0] set structure_item_id [lindex $referencer_structure_list 1] set number_to_select [lindex $referencer_structure_list 2] - # 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 - set total_completed 0 - db_foreach referenced_activity { - select content_item__get_live_revision(ar.object_id_two) as activity_id - from acs_rels ar - where ar.object_id_one = :structure_item_id - and ar.rel_type in ('imsld_as_la_rel','imsld_as_sa_rel','imsld_as_as_rel') - } { - if { ![db_string completed_p { *SQL* }] } { - # there is at leas one no-completed activity, so we can't mark this activity structure yet - set scturcture_finished_p 0 - } else { - incr total_completed - } + set already_marked_p [db_0or1row not_marked { + select 1 + from imsld_status_user + where user_id = :user_id + and run_id = :run_id + and related_id = :structure_id + and status = 'finished' + }] + if { ![imsld::structure_finished_p -structure_id $structure_id -run_id $run_id -user_id $user_id] || !$already_marked_p } { + # 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 + set total_completed 0 + db_foreach referenced_activity { + select content_item__get_live_revision(ar.object_id_two) as activity_id + from acs_rels ar + where ar.object_id_one = :structure_item_id + and ar.rel_type in ('imsld_as_la_rel','imsld_as_sa_rel','imsld_as_as_rel') + } { + if { ![db_string completed_p { *SQL* }] } { + # there is at leas one no-completed activity, so we can't mark this activity structure yet + set scturcture_finished_p 0 + continue + } else { + incr total_completed + } + } + # If the structure has the flag number-to-select + if { $scturcture_finished_p && (($number_to_select > 0 && ($total_completed >= $number_to_select)) || !$already_marked_p) } { + imsld::finish_component_element -imsld_id $imsld_id \ + -run_id $run_id \ + -play_id $play_id \ + -act_id $act_id \ + -role_part_id $role_part_id \ + -element_id $structure_id \ + -type structure \ + -user_id $user_id \ + -code_call + } } - # If the structure has the flag number-to-select - if { $scturcture_finished_p || (![string eq $number_to_select ""] && ($total_completed >= $number_to_select)) } { - imsld::finish_component_element -imsld_id $imsld_id \ - -run_id $run_id \ - -play_id $play_id \ - -act_id $act_id \ - -role_part_id $role_part_id \ - -element_id $structure_id \ - -type structure \ - -user_id $user_id \ - -code_call - } } } - # we continue with A LOT of validations (in order to support the when-xxx-finished tag of the spec + if { [string eq $type "structure"] } { + # mark as finished all the referenced activities + foreach referenced_activities_list [db_list_of_lists referenced_activities { + select case when ar.rel_type = 'imsld_as_la_rel' + then 'learning' + when ar.rel_type = 'imsld_as_sa_rel' + then 'support' + when ar.rel_type = 'imsld_as_as_rel' + then 'structure' + end as ref_type, + content_item__get_live_revision(ar.object_id_two) as activity_id + from acs_rels ar, imsld_activity_structuresi ias + where ar.object_id_one = ias.item_id + and ias.structure_id = :element_id + and ar.rel_type in ('imsld_as_la_rel','imsld_as_sa_rel','imsld_as_as_rel') + }] { + set ref_type [lindex $referenced_activities_list 0] + set activity_id [lindex $referenced_activities_list 1] + if { ![db_0or1row already_finished_p { + select 1 + from imsld_status_user + where user_id = :user_id + and status = 'finished' + and run_id = :run_id + and related_id = :activity_id + }] } { + imsld::finish_component_element -imsld_id $imsld_id \ + -run_id $run_id \ + -play_id $play_id \ + -act_id $act_id \ + -role_part_id $role_part_id \ + -element_id $activity_id \ + -type $ref_type \ + -user_id $user_id \ + -code_call + } + } + } + + + + # we continue with A LOT of validations (in order to support the + # when-xxx-finished tag of the spec # -- with xxx in (role_part,act,play)): - # 1. let's see if the finished activity triggers the ending of the role_part - # 2. let's see if the finished role_part triggers the ending of the act which references it. - # 3. let's see if the finished act triggers the ending the play which references it - # 4. let's see if the finished play triggers the ending of the method which references it. + # 1. let's see if the finished activity triggers the ending of the + # role_part + # 2. let's see if the finished role_part triggers the ending of the act + # which references it. + # 3. let's see if the finished act triggers the ending the play which + # references it + # 4. let's see if the finished play triggers the ending of the method which + # references it. set role_part_id_list [imsld::get_role_part_from_activity -activity_type $type -leaf_id [db_string get_item_id { select item_id from cr_revisions where revision_id = :element_id}]] foreach role_part_id $role_part_id_list { db_1row context_info { @@ -1162,6 +1264,7 @@ } } } + imsld::mark_act_finished -act_id $act_id \ -play_id $play_id \ -imsld_id $imsld_id \ @@ -1385,28 +1488,57 @@ set object_id_two [lindex $referenced_activity 0] set rel_type [lindex $referenced_activity 1] switch $rel_type { - imsld_as_la_rel - + imsld_as_la_rel { + set complete_act_id [db_string completion_restriction { + select complete_act_id + from imsld_learning_activities + where activity_id = content_item__get_live_revision(:object_id_two) + } -default ""] + if { (![string eq [db_string finished_p { + select status from imsld_status_user + where related_id = content_item__get_live_revision(:object_id_two) + and user_id = :user_id + and status = 'finished' + and run_id = :run_id + } -default ""] "finished"] && ![string eq $complete_act_id ""]) \ + || (![string eq [db_string started_p { + select status from imsld_status_user + where related_id = content_item__get_live_revision(:object_id_two) + and user_id = :user_id + and status = 'started' + and run_id = :run_id + } -default ""] "started"] && [string eq $complete_act_id ""]) } { + set all_completed 0 + break + } + } imsld_as_sa_rel { - # is the activity finished ? - if { ![db_0or1row completed_p { - select 1 from imsld_status_user + set complete_act_id [db_string completion_restriction { + select complete_act_id + from imsld_support_activities + where activity_id = content_item__get_live_revision(:object_id_two) + } -default ""] + + if { (![string eq [db_string finished_p { + select status from imsld_status_user where related_id = content_item__get_live_revision(:object_id_two) and user_id = :user_id and status = 'finished' and run_id = :run_id - }] } { - set all_completed 0 - } + } -default ""] "finished"] && ![string eq $complete_act_id ""]) \ + || (![string eq [db_string started_p { + select status from imsld_status_user + where related_id = content_item__get_live_revision(:object_id_two) + and user_id = :user_id + and status = 'started' + and run_id = :run_id + } -default ""] "started"] && [string eq $complete_act_id ""]) } { + set all_completed 0 + break + } } imsld_as_as_rel { - # search recursively trough the referenced - db_1row get_activity_structure_info { - select structure_id - from imsld_activity_structuresi - where item_id = :object_id_two - and content_revision__is_live(structure_id) = 't' - } - # is the activity finished ? + # the activity structure must be marked as finished if { ![db_0or1row completed_p { select 1 from imsld_status_user where related_id = :structure_id @@ -1415,15 +1547,13 @@ and run_id = :run_id }] } { set all_completed 0 + break } - if { ![imsld::structure_finished_p -run_id $run_id -structure_id $structure_id -user_id $user_id] } { - set all_completed 0 - } } } } return $all_completed -} +} ad_proc -public imsld::role_part_finished_p { -role_part_id:required @@ -1563,13 +1693,19 @@ @return 0 if the user does not participate in the act. 1 otherwise } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] - set involved_roles [db_list get_roles_in_act {select irolei.role_id - from imsld_role_parts ir, - imsld_actsi iai, - imsld_rolesi irolei - where iai.act_id=:act_id - and iai.item_id=ir.act_id - and ir.role_id=irolei.item_id}] + set involved_roles [db_list get_roles_in_act { + select ir.role_id + from imsld_role_parts irp, + imsld_acts ia, + cr_items ca, + imsld_roles ir, + cr_items cr + where ia.act_id = :act_id + and ia.act_id = ca.live_revision + and ca.item_id = irp.act_id + and irp.role_id = cr.item_id + and cr.live_revision = ir.role_id + }] set involved_users [list] foreach role $involved_roles { set involved_users [concat $involved_users [imsld::roles::get_users_in_role -role_id $role -run_id $run_id ]] @@ -2113,10 +2249,12 @@ set file_url [acs_sc::invoke -contract FtsContentProvider -operation url -impl $object_type -call_args [list $acs_object_id]] set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]imsld-finish-resource" {file_url $file_url resource_item_id $resource_item_id run_id $run_id}]" + $a_node setAttribute title "$object_title" set img_node [$dom_doc createElement img] $img_node setAttribute src "[imsld::object_type_image_path -object_type $object_type]" $img_node setAttribute border "0" $img_node setAttribute alt "$object_title" + $img_node setAttribute title "$object_title" $a_node appendChild $img_node if { $li_mode_p } { set file_node [$dom_doc createElement li] @@ -2140,10 +2278,12 @@ set file_url "imsld-content-serve" set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]imsld-finish-resource" {file_url $file_url resource_item_id $resource_item_id run_id $run_id}]" + $a_node setAttribute title "$file_name" set img_node [$dom_doc createElement img] $img_node setAttribute src "[imsld::object_type_image_path -object_type file-storage]" $img_node setAttribute border "0" $img_node setAttribute alt "$file_name" + $img_node setAttribute title "$file_name" $a_node appendChild $img_node if { $li_mode_p } { set file_node [$dom_doc createElement li] @@ -2167,10 +2307,12 @@ set file_url "[apm_package_url_from_id $fs_package_id]view/${file_url}" set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]imsld-finish-resource" {file_url $file_url resource_item_id $resource_item_id run_id $run_id}]" + $a_node setAttribute title "$file_name" set img_node [$dom_doc createElement img] $img_node setAttribute src "[imsld::object_type_image_path -object_type file-storage]" $img_node setAttribute border "0" $img_node setAttribute alt "$file_name" + $img_node setAttribute title "$file_name" $a_node appendChild $img_node if { $li_mode_p } { set file_node [$dom_doc createElement li] @@ -2184,10 +2326,12 @@ db_foreach associated_urls { *SQL* } { set a_node [$dom_doc createElement a] $a_node setAttribute href "[export_vars -base "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]imsld-finish-resource" { {file_url "[export_vars -base $url]"} resource_item_id run_id}]" + $a_node setAttribute title "$url" set img_node [$dom_doc createElement img] $img_node setAttribute src "[imsld::object_type_image_path -object_type url]" $img_node setAttribute border "0" $img_node setAttribute alt "$url" + $img_node setAttribute title "$url" $a_node appendChild $img_node if { $li_mode_p } { set file_node [$dom_doc createElement li] @@ -2236,6 +2380,7 @@ -resource_mode $resource_mode \ -dom_node $dom_node \ -dom_doc $dom_doc + } elseif { [db_0or1row is_support { select 1 from imsld_support_activitiesi where item_id = :activity_item_id }] } { @@ -2428,7 +2573,9 @@ } } } - if { [llength $linear_item_list ] > 0 } { $dom_node appendChild $description_node } + if { [llength $linear_item_list ] > 0 } { + $dom_node appendChild $description_node + } # prerequisites set prerequisites_node [$dom_doc createElement div] @@ -2478,7 +2625,7 @@ $feedback_head_node appendChild $text $feedback_node appendChild $feedback_head_node if { [db_0or1row completed_activity { *SQL* }] } { - if { ![string eq "" $on_completion_item_id] } { + if { ![string eq "" $on_completion_item_id] && [db_string is_feedback { *SQL* }] > 0 } { # the feedback is not processed to ckeck if all the activity resources have been finished # so we don't need to store the result imsld::process_feedback_as_ul -on_completion_item_id $on_completion_item_id \ @@ -2678,10 +2825,17 @@ @return A list of lists of the activities referenced from the activity structure } { + set imsld_package_id [ad_conn package_id] # auxiliary list to store the activities set completed_list [list] # get the structure info db_1row structure_info { *SQL* } + + # if any of the referenced activities from the activity structure doesn't have a completion restriction + # and the activity structure is of type "sequence", there wouldn't be a way to advance in the structure, + # so, if this is the case, the structure is treated as of type "selection" + set completion_restriction [imsld::structure_completion_resctriction_p -run_id $run_id -structure_item_id $structure_item_id] + # get the referenced activities which are referenced from the structure foreach referenced_activity [db_list_of_lists struct_referenced_activities { *SQL* }] { # get all the directly referenced activities (from the activity structure) @@ -2696,38 +2850,77 @@ select sort_order from imsld_as_la_rels where rel_id = :rel_id } set completed_p [db_0or1row completed_p { *SQL* }] + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] # show the activity only if: + # 0. the activity is visible # 1. it has been already completed # 2. if the structure-type is "selection" - # 3. if it is the next activity to be done (and structure-type is "sequence") - if { $completed_p || [string eq $complete_act_id ""] || [string eq $structure_type "selection"] || ([string eq $is_visible_p "t"] && [lsearch -exact $next_activity_id_list $activity_id] != -1) } { - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" + # 3. if the activity has no completion restriction + # 4. if it is the next activity to be done (and structure-type is "sequence") - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + if { $completed_p || [string eq $complete_act_id ""] || [string eq $structure_type "selection"] || (([lsearch -exact $next_activity_id_list $activity_id] != -1) || !$completion_restriction) && [string eq $is_visible_p "t"] } { - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text + if { !$started_activity_p && [string eq $is_visible_p "t"] } { + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # bold letters + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } - if { !$completed_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node - } + if { $completed_p } { + if { ![string eq $complete_act_id ""] } { + # the activity is finished + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + } + } else { + + if { [string eq $user_choice_p "t"] } { + + # show the finish button + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $activity_node appendChild $input_node + } + } set completed_list [linsert $completed_list $sort_order [$activity_node asList]] } } @@ -2737,38 +2930,77 @@ db_1row get_sort_order { select sort_order from imsld_as_sa_rels where rel_id = :rel_id } + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] set completed_p [db_0or1row completed_p { *SQL* }] + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] + # show the activity only if: + # 0. the activity is visible # 1. it has been already completed # 2. if the structure-type is "selection" # 3. if it is the next activity to be done (and structure-type is "sequence") - if { $completed_p || [string eq $complete_act_id ""] || [string eq $structure_type "selection"] || ([string eq $is_visible_p "t"] && [lsearch -exact $next_activity_id_list $activity_id] != -1) } { - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + # 4. if the activity has no completion restriction + if { [string eq $is_visible_p "t"] && ($completed_p || [string eq $complete_act_id ""] || [string eq $structure_type "selection"] || (([lsearch -exact $next_activity_id_list $activity_id] != -1) || !$completion_restriction) && [string eq $is_visible_p "t"] } { - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - if { !$completed_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node - } + if { !$started_activity_p && [string eq $is_visible_p "t"] } { + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # bold letters + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + + } + if { $completed_p } { + if { ![string eq $complete_act_id ""] } { + # the activity is finished + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + } + } else { + if { [string eq $user_choice_p "t"] } { + + # show the finish button + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $activity_node appendChild $input_node + } + } set completed_list [linsert $completed_list $sort_order [$activity_node asList]] } } @@ -2782,16 +3014,32 @@ db_1row get_sort_order { select sort_order from imsld_as_as_rels where rel_id = :rel_id } - set started_p [db_0or1row as_completed_p { *SQL* }] + set started_p [db_0or1row as_started_p { *SQL* }] + set completed_p [db_0or1row as_completed_p { *SQL* }] + + if { $started_p || [string eq $structure_type "selection"] } { - set structure_node [$dom_doc createElement li] - $structure_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $structure_node appendChild $a_node + if { $completed_p } { + set structure_node [$dom_doc createElement li] + $structure_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $structure_node appendChild $a_node + } else { + set structure_node [$dom_doc createElement li] + $structure_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $structure_node appendChild $b_node + } set nested_activities_list [imsld::generate_structure_activities_list -imsld_id $imsld_id \ -run_id $run_id \ @@ -2834,6 +3082,7 @@ where run_id = :run_id } # start with the role parts + set imsld_package_id [ad_conn package_id] set user_role_id [db_string current_role { select map.active_role_id as user_role_id @@ -2845,98 +3094,175 @@ and ar.object_id_two = :user_id and iruge.run_id = :run_id }] + set active_acts_list [imsld::active_acts -run_id $run_id -user_id $user_id] # get the referenced role parts foreach role_part_list [db_list_of_lists referenced_role_parts { *SQL* }] { set type [lindex $role_part_list 0] set activity_id [lindex $role_part_list 1] set role_part_id [lindex $role_part_list 2] - set act_id [lindex $role_part_list 3] - set play_id [lindex $role_part_list 4] + set act_id [lindex $role_part_list 3] + set act_item_id [lindex $role_part_list 4] + set play_id [lindex $role_part_list 5] + switch $type { learning { # add the learning activity to the tree db_1row get_learning_activity_info { *SQL* } + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] set completed_activity_p [db_0or1row already_completed { select 1 from imsld_status_user where related_id = :activity_id and user_id = :user_id and run_id = :run_id and status = 'finished' }] - if { $completed_activity_p || [lsearch -exact $next_activity_id_list $activity_id] != -1 && ([string eq $complete_act_id ""] || [string eq $is_visible_p "t"]) } { - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] + if { $completed_activity_p || ([lsearch -exact $next_activity_id_list $activity_id] != -1) || ([string eq $complete_act_id ""] && [string eq $is_visible_p "t"] && [lsearch -exact $active_acts_list $act_item_id] != -1) } { - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - if { !$completed_activity_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node - } + if { !$started_activity_p && [string eq $is_visible_p "t"] } { + # bold letters + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # the activity has been started + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + + } + if { $completed_activity_p } { + + if { ![string eq $complete_act_id ""] } { + # the activity is finished + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + } + } elseif { [string eq $is_visible_p "t"] } { + + if { [string eq $user_choice_p "t"] } { + + # show the finish button + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $activity_node appendChild $input_node + } + } + $dom_node appendChild $activity_node } } support { # add the support activity to the tree db_1row get_support_activity_info { *SQL* } + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] set completed_activity_p [db_0or1row already_completed { select 1 from imsld_status_user where related_id = :activity_id and user_id = :user_id and run_id = :run_id and status = 'finished' }] - if { $completed_activity_p || [lsearch -exact $next_activity_id_list $activity_id] != -1 && ([string eq $complete_act_id ""] || [string eq $is_visible_p "t"]) } { - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - if { !$completed_activity_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node - } + if { $completed_activity_p || ([lsearch -exact $next_activity_id_list $activity_id] != -1) || ([string eq $complete_act_id ""] && [string eq $is_visible_p "t"] && [lsearch -exact $active_acts_list $act_item_id] != -1) } { + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + if { !$started_activity_p && [string eq $is_visible_p "t"] } { + # bold letters + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # bold letters + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } + if { $completed_activity_p } { + + if { ![string eq $complete_act_id ""] } { + # the activity is finished + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + } + } else { + if { [string eq $user_choice_p "t"] } { + # show the finish button + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $activity_node appendChild $input_node + } + } $dom_node appendChild $activity_node } } structure { # this is a special case since there are some conditions to check - # in order to determine if the referenced activities have to be shown + # in order to determine if the referenced activities have to be shown. # because of that the proc generate_structure_activities_list is called, # which returns a tcl list in tDOM format. @@ -2946,16 +3272,31 @@ # (if it is the next activity to be done then it should had been marked as started # in the "structure_next_activity" function. which is the case when structure-type is "sequence") db_1row get_activity_structure_info { *SQL* } - set started_p [db_0or1row as_completed_p { *SQL* }] + set started_p [db_0or1row as_started_p { *SQL* }] + set completed_p [db_0or1row as_completed_p { *SQL* }] if { $started_p } { - set structure_node [$dom_doc createElement li] - $structure_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $structure_node appendChild $a_node + if { $completed_p } { + set structure_node [$dom_doc createElement li] + $structure_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $structure_node appendChild $a_node + } else { + set structure_node [$dom_doc createElement li] + $structure_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $structure_node appendChild $b_node + } + set nested_list [imsld::generate_structure_activities_list -imsld_id $imsld_id \ -run_id $run_id \ -structure_item_id $structure_item_id \ @@ -2997,8 +3338,8 @@ # NOTE: the activity will be shown only once, no matter from how many role parts it is referenced set user_role_id [db_string current_role { *SQL* }] + set imsld_package_id [ad_conn package_id] - # get the referenced activities to the role, assigned at runtime (notifications, level C) foreach activity_id [db_list runtime_activities { *SQL* } ] { @@ -3017,71 +3358,339 @@ learning { # add the learning activity to the tree db_1row get_learning_activity_info { *SQL* } + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] set completed_activity_p [db_0or1row la_already_completed { *SQL* }] - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node - - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - if { !$completed_activity_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] + + if { !$started_activity_p } { + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # bold letters + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } + + + if { $completed_activity_p } { + + if { [string eq $user_choice_p "t"] } { + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + + } + } else { + + if { [string eq $user_choice_p "t"] } { + + # show the button to finish the activity + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $b_node appendChild $input_node + + } } - $dom_node appendChild $activity_node } support { # add the support activity to the tree db_1row get_support_activity_info { *SQL* } + set started_activity_p [db_0or1row already_started { + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] + set user_choice_p [db_string user_choice_p {select user_choice_p from imsld_complete_actsi where item_id = :complete_act_id and content_revision__is_live(complete_act_id) = 't'} -default "f"] set completed_activity_p [db_0or1row sa_already_completed { *SQL* }] - set activity_node [$dom_doc createElement li] - $activity_node setAttribute class "liOpen" - set a_node [$dom_doc createElement a] - $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" - $a_node setAttribute target "content" - set text [$dom_doc createTextNode "$activity_title"] - $a_node appendChild $text - $activity_node appendChild $a_node - - set text [$dom_doc createTextNode " "] - $activity_node appendChild $text - - if { !$completed_activity_p } { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute style "vertical-align: bottom;" - $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld\"" - $activity_node appendChild $input_node - } else { - set input_node [$dom_doc createElement input] - $input_node setAttribute type "checkbox" - $input_node setAttribute checked "true" - $input_node setAttribute disabled "true" - $activity_node appendChild $input_node + + if { !$started_activity_p } { + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set b_node [$dom_doc createElement b] + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $b_node appendChild $a_node + $activity_node appendChild $b_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } else { + # bold letters + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + } + + if { $completed_activity_p } { + + if { [string eq $user_choice_p "t"] } { + set img_node [$dom_doc createElement img] + $img_node setAttribute src "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" + $img_node setAttribute border "0" + $img_node setAttribute alt "[_ imsld.finished]" + $img_node setAttribute title "[_ imsld.finished]" + $activity_node appendChild $img_node + + } + } else { + if { [string eq $user_choice_p "t"] } { + + # show the button to finish the activity + set b_node [$dom_doc createElement b] + set input_node [$dom_doc createElement a] + $input_node setAttribute href "finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld" + $input_node setAttribute class "finish" + $input_node setAttribute title "[_ imsld.finish_activity]" + set text [$dom_doc createTextNode "[_ imsld.finish]"] + $input_node appendChild $text + $b_node appendChild $input_node + $activity_node appendChild $b_node + + } } - $dom_node appendChild $activity_node } } } } +ad_proc -public imsld::structure_completion_resctriction_p { + -run_id:required + -structure_item_id:required +} { + @param run_id + @param structure_item_id + + @return Returns 0 if any of the referenced activities from the structure_id doesn't have a completion restriction +} { + + foreach referenced_activity [db_list_of_lists struct_referenced_activities { + select ar.object_id_two, + ar.rel_type + from acs_rels ar, imsld_activity_structuresi ias + where ar.object_id_one = ias.item_id + and ias.item_id = :structure_item_id + and content_revision__is_live(ias.structure_id) = 't' + order by ar.object_id_two + }] { + # get all the directly referenced activities (from the activity structure) + set object_id_two [lindex $referenced_activity 0] + set rel_type [lindex $referenced_activity 1] + switch $rel_type { + imsld_as_la_rel { + if { [string eq "" [db_string la_completion_restriction { + select complete_act_id + from imsld_learning_activitiesi + where item_id = :object_id_two + and content_revision__is_live(activity_id) = 't' + }]] } { + # no restriction found, break + return 0 + } + } + imsld_as_sa_rel { + if { [string eq "" [db_string sa_completion_restriction { + select complete_act_id + from imsld_support_activitiesi + where item_id = :object_id_two + and content_revision__is_live(activity_id) = 't' + }]] } { + # no restriction found, break + return 0 + } + } + imsld_as_as_rel { + # search recursively trough the referenced activities + return [imsld::structure_completion_resctriction_p -run_id $run_id -structure_item_id $object_id_two] + } + } + } + # every referenced activity has a completion restriction + return 1 +} + +ad_proc -public imsld::active_acts { + -run_id:required + -user_id:required + {-previous_list {}} +} { + @param run_id + @param user + @param previous_list + + @return Returns the list of possible active acts for the user +} { + set active_acts_list [list] + + set all_acts_list [db_list get_acts_in_run { + select ia.act_id + from imsld_runs ir, + imsld_imslds ii, + cr_items ci, + imsld_methods im, + cr_items cm, + imsld_plays ip, + cr_items cp, + imsld_acts ia + where ir.run_id = :run_id + and ii.imsld_id = ir.imsld_id + and ii.imsld_id = ci.live_revision + and ci.item_id = im.imsld_id + and im.method_id = cm.live_revision + and cm.item_id = ip.method_id + and ip.play_id = cp.live_revision + and cp.item_id = ia.play_id + order by ip.sort_order, ia.sort_order + }] + set i 0 + set continue 1 + while { $i < [llength $all_acts_list] && $continue == 1 } { + set act_in_run [lindex $all_acts_list $i] + incr i + # let's see if the user participates in the act + if { [imsld::user_participate_p -run_id $run_id -act_id $act_in_run -user_id $user_id] \ + && ![imsld::act_finished_p -run_id $run_id -act_id $act_in_run -user_id $user_id] } { + # let's see if the act doesn't have any completion restriction: + # 1. time-limit + # 2. when-property-is-set + # 3. when-condition-true + # 4. when role-part-is-completed + # 5. any referenced activity structure (which by default have a completion restriction) + set act_in_run_item_id [content::revision::item_id -revision_id $act_in_run] + + # 1. time-limit, 2. when-property-is-set, 3. when-condition-true: all the info is stored via complete_act_id in the acts table + if { ![string eq "" [db_string complete_act_id {select complete_act_id from imsld_acts where act_id = :act_in_run}]] && [lsearch -exact $previous_list $act_in_run_item_id] == -1 } { + # there is a completion restriction, stop here + lappend active_acts_list $act_in_run_item_id + break + } + + # 4. when role-part-is-completed, 5. referenced activity structures + # This is a special case, since if any of the activities referenced by the role part doesn't have a completion restriction + # then the act has to be appended to the list + # Note: The role parts that finish the act are mapped to the act via imsld_act_rp_completed_rel (acs_rels) + + set role_parts_list [db_list related_role_parts { + select item_id + from imsld_role_partsi + where act_id = :act_in_run_item_id + and content_revision__is_live(role_part_id) = 't' + order by sort_order + }] + foreach role_part_item_id $role_parts_list { + # get all the activities in the role part and see if none has any compleion resctriction + + db_1row get_role_part_activity { + select case + when learning_activity_id is not null + then 'learning' + when support_activity_id is not null + then 'support' + when activity_structure_id is not null + then 'structure' + else 'none' + end as type, + learning_activity_id, + support_activity_id, + activity_structure_id + from imsld_role_partsi + where item_id = :role_part_item_id + and content_revision__is_live(role_part_id) = 't' + } + set continue 0 + # check if the referenced activities have been finished + switch $type { + learning { + if { [string eq "" [db_string la_completion_restriction { + select complete_act_id + from imsld_learning_activitiesi + where item_id = :learning_activity_id + and content_revision__is_live(activity_id) = 't' + }]] } { + # activity without restriction found, + # append the act to the list of active acts + set continue 1 + break + } + } + support { + if { [string eq "" [db_string sa_completion_restriction { + select complete_act_id + from imsld_support_activitiesi + where item_id = :support_activity_id + and content_revision__is_live(activity_id) = 't' + }]] } { + # activity without restriction found, + # append the act to the list of active acts + set continue 1 + break + } + } + structure { + # every activity structure has a completion restriction (at leat, every activity must be visited) + # so we can stop here + set continue 0 + break + } + } + } + # if we reached this point, the act must be shown + if { [lsearch -exact $previous_list $act_in_run_item_id] == -1 } { + # add the act to the list only if it wasn't in the list already + lappend active_acts_list $act_in_run_item_id + } + } + } + return [concat $previous_list $active_acts_list] +} + ad_proc -public imsld::get_next_activity_list { -run_id:required {-user_id ""} @@ -3182,6 +3791,7 @@ } continue } + if { ![imsld::act_finished_p -run_id $run_id -act_id $act_id -user_id $user_id] } { if {[imsld::user_participate_p -run_id $run_id -act_id $act_id -user_id $user_id]} { lappend next_act_item_id_list [content::revision::item_id -revision_id $act_id] @@ -3233,6 +3843,9 @@ } } + # append to the list of "active acts" those which don't have any "completion" restrictions + set next_act_item_id_list [imsld::active_acts -run_id $run_id -user_id $user_id -previous_list $next_act_item_id_list] + # 1. for each act in the next_act_id_list # 1.2. for each role_part in the act # 1.2.1 find the next activity referenced by the role_part @@ -3241,7 +3854,6 @@ # 2.2.1.2 if it is an activity structure we have verify which activities are already completed and return the next # activity in the activity structure, handling the case when the next activity is also an activity structure - set user_roles_list [imsld::roles::get_user_roles -user_id $user_id -run_id $run_id] set next_activity_id_list [list] foreach act_item_id $next_act_item_id_list { @@ -3509,7 +4121,7 @@ set activity_id [lindex $activity_list 0] set activity_item_id [lindex $activity_list 1] set activity_type [lindex $activity_list 2] - + #get info set role_part_id_list [imsld::get_role_part_from_activity -activity_type $activity_type -leaf_id $activity_item_id] set imsld_id [imsld::get_imsld_from_activity -activity_id $activity_id -activity_type $activity_type] @@ -3526,12 +4138,23 @@ switch $activity_type { learning { set first_resources_item_list [imsld::process_learning_activity_as_ul -run_id $run_id -activity_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] + set completion_restriction [db_string la_completion_restriction { + select complete_act_id + from imsld_learning_activities + where activity_id = :activity_id + } -default ""] } support { set first_resources_item_list [imsld::process_support_activity_as_ul -run_id $run_id -activity_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] + set completion_restriction [db_string la_completion_restriction { + select complete_act_id + from imsld_support_activities + where activity_id = :activity_id + } -default ""] } structure { set first_resources_item_list [imsld::process_activity_structure_as_ul -run_id $run_id -structure_item_id $activity_item_id -resource_mode "t" -dom_node $foo_node -dom_doc $foo_doc] + set completion_restriction t } } @@ -3561,7 +4184,7 @@ } #if all are finished, tag the activity as finished - if { $all_finished_p && ![db_0or1row already_finished { *SQL* }] } { + if { $all_finished_p && ![db_0or1row already_finished { *SQL* }] && [string eq $completion_restriction ""] } { foreach role_part_id $role_part_id_list { db_1row context_info { select acts.act_id, @@ -3871,5 +4494,6 @@ } } } + ad_register_proc GET /finish-component-element* imsld::finish_component_element ad_register_proc POST /finish-component-element* imsld::finish_component_element Index: openacs-4/packages/imsld/tcl/imsld-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.xql,v diff -u -r1.37 -r1.37.6.1 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 25 Apr 2007 10:52:30 -0000 1.37 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 24 Apr 2008 10:50:34 -0000 1.37.6.1 @@ -750,7 +750,7 @@ select ias.structure_id, ias.item_id as structure_item_id, - ias.number_to_select + coalesce(ias.number_to_select, 0) as number_to_select 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 @@ -898,7 +898,8 @@ - select la.activity_id as learning_activity_id + select la.activity_id as learning_activity_id, + complete_act_id from imsld_learning_activitiesi la where la.item_id = :object_id_two and content_revision__is_live(la.activity_id) = 't' @@ -1165,14 +1166,16 @@ - select cpr.resource_id, - cpr.item_id as resource_item_id, - cpr.type as resource_type - from imsld_cp_resourcesi cpr, imsld_itemsi ii, + select icr.resource_id, + cr.item_id as resource_item_id, + icr.type as resource_type + from imsld_cp_resources icr, imsld_items ii, cr_items ci, cr_items cr, acs_rels ar - where ar.object_id_one = ii.item_id - and ar.object_id_two = cpr.item_id - and content_revision__is_live(cpr.resource_id) = 't' + where ar.object_id_one = ci.item_id + and ci.live_revision = ii.imsld_item_id + and ar.object_id_two = cr.item_id + and cr.live_revision = icr.resource_id + and content_revision__is_live(icr.resource_id) = 't' and (imsld_tree_sortkey between tree_left((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) and tree_right((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) or ii.imsld_item_id = :imsld_item_id) @@ -1597,19 +1600,24 @@ - select la.on_completion_id as on_completion_item_id, - la.prerequisite_id as prerequisite_item_id, - la.learning_objective_id as learning_objective_item_id, - la.activity_id, - la.title as activity_title - from imsld_learning_activitiesi la, imsld_attribute_instances attr - where la.item_id = :activity_item_id - and content_revision__is_live(la.activity_id) = 't' - and attr.owner_id = la.activity_id - and attr.run_id = :run_id - and attr.user_id = :user_id - and attr.type = 'isvisible' - and attr.is_visible_p = 't' + select la.on_completion_id as on_completion_item_id, + la.prerequisite_id as prerequisite_item_id, + la.learning_objective_id as learning_objective_item_id, + la.activity_id, + rla.title as activity_title + from imsld_attribute_instances attr, + imsld_learning_activities la, + cr_items cla, + cr_revisions rla + where cla.item_id = :activity_item_id + and cla.live_revision = la.activity_id + and cla.live_revision = rla.revision_id + and content_revision__is_live(la.activity_id) = 't' + and attr.owner_id = la.activity_id + and attr.run_id = :run_id + and attr.user_id = :user_id + and attr.type = 'isvisible' + and attr.is_visible_p = 't' @@ -1635,22 +1643,24 @@ - select cpr.resource_id, - cpr.item_id as resource_item_id, - cpr.type as resource_type - from imsld_cp_resourcesi cpr, imsld_itemsi ii, imsld_attribute_instances attr, - acs_rels ar - where ar.object_id_one = ii.item_id - and ar.object_id_two = cpr.item_id - and content_revision__is_live(cpr.resource_id) = 't' - and (imsld_tree_sortkey between tree_left((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) - and tree_right((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) - or ii.imsld_item_id = :imsld_item_id) - and attr.owner_id = ii.imsld_item_id - and attr.run_id = :run_id - and attr.user_id = :user_id - and attr.type = 'isvisible' - and attr.is_visible_p = 't' + select icr.resource_id, + cp.item_id as resource_item_id, + icr.type as resource_type + from imsld_cp_resources icr, imsld_items ii, imsld_attribute_instances iai, cr_items ci, cr_items cp, + acs_rels ar + where ii.imsld_item_id = ci.live_revision + and ar.object_id_one = ci.item_id + and icr.resource_id = cp.live_revision + and ar.object_id_two = cp.item_id + and content_revision__is_live(icr.resource_id) = 't' + and (imsld_tree_sortkey between tree_left((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) + and tree_right((select imsld_tree_sortkey from imsld_items where imsld_item_id = :imsld_item_id)) + or ii.imsld_item_id = :imsld_item_id) + and iai.owner_id = ii.imsld_item_id + and iai.run_id = :run_id + and iai.user_id = :user_id + and iai.type = 'isvisible' + and iai.is_visible_p = 't' @@ -1668,6 +1678,14 @@ + + + + select count(*) from acs_rels where object_id_one = :on_completion_item_id and rel_type = 'imsld_feedback_rel' + + + + @@ -1834,20 +1852,21 @@ - select la.title as activity_title, - la.item_id as activity_item_id, - la.activity_id, - la.complete_act_id, - attr.is_visible_p - from imsld_learning_activitiesi la, imsld_attribute_instances attr - where la.item_id = :object_id_two - and content_revision__is_live(la.activity_id) = 't' - and attr.owner_id = la.activity_id - and attr.run_id = :run_id - and attr.user_id = :user_id - and attr.type = 'isvisible' + select cr.title as activity_title, + ci.item_id as activity_item_id, + la.activity_id, + la.complete_act_id, + attr.is_visible_p + from imsld_learning_activities la, imsld_attribute_instances attr, cr_items ci, cr_revisions cr + where ci.item_id = :object_id_two + and ci.live_revision = cr.revision_id + and ci.live_revision = la.activity_id + and content_revision__is_live(la.activity_id) = 't' + and attr.owner_id = la.activity_id + and attr.run_id = :run_id + and attr.user_id = :user_id + and attr.type = 'isvisible' - @@ -1896,7 +1915,7 @@ - + select 1 from imsld_status_user @@ -1908,6 +1927,18 @@ + + + + select 1 from imsld_status_user + where related_id = :structure_id + and user_id = :user_id + and status = 'finish' + and run_id = :run_id + + + + @@ -1926,35 +1957,41 @@ - select case - when rp.learning_activity_id is not null - then 'learning' - when rp.support_activity_id is not null - then 'support' - when rp.activity_structure_id is not null - then 'structure' - else 'none' - end as type, - content_item__get_live_revision(coalesce(rp.learning_activity_id,rp.support_activity_id,rp.activity_structure_id)) as activity_id, - rp.role_part_id, - ia.act_id, - ip.play_id - from imsld_role_partsi rp, imsld_actsi ia, imsld_playsi ip, imsld_imsldsi ii, imsld_attribute_instances attr, - imsld_methodsi im,imsld_rolesi iri - where rp.act_id = ia.item_id - and ia.play_id = ip.item_id - and ip.method_id = im.item_id - and im.imsld_id = ii.item_id - and ii.imsld_id = :imsld_id - and rp.role_id = iri.item_id - and iri.role_id = :user_role_id - and content_revision__is_live(rp.role_part_id) = 't' - and attr.owner_id = ip.play_id - and attr.run_id = :run_id - and attr.user_id = :user_id - and attr.type = 'isvisible' - and attr.is_visible_p = 't' - order by ip.sort_order, ia.sort_order, rp.sort_order + select case + when irp.learning_activity_id is not null + then 'learning' + when irp.support_activity_id is not null + then 'support' + when irp.activity_structure_id is not null + then 'structure' + else 'none' + end as type, + content_item__get_live_revision(coalesce(irp.learning_activity_id, irp.support_activity_id, irp.activity_structure_id)) as activity_id, + irp.role_part_id, + ia.act_id, + ca.item_id as act_item_id, + ip.play_id + from imsld_role_parts irp, imsld_acts ia, imsld_plays ip, imsld_imslds ii, imsld_attribute_instances iai, + imsld_methods im, imsld_roles ir, cr_items ca, cr_items cp, cr_items cm, cr_items ci, cr_items cr + where irp.act_id = ca.item_id + and ca.live_revision = ia.act_id + and ia.play_id = cp.item_id + and cp.live_revision = ip.play_id + and ip.method_id = cm.item_id + and cm.live_revision = im.method_id + and im.imsld_id = ci.item_id + and ci.live_revision = ii.imsld_id + and ii.imsld_id = :imsld_id + and irp.role_id = cr.item_id + and cr.live_revision = ir.role_id + and ir.role_id = :user_role_id + and content_revision__is_live(irp.role_part_id) = 't' + and iai.owner_id = ip.play_id + and iai.run_id = :run_id + and iai.user_id = :user_id + and iai.type = 'isvisible' + and iai.is_visible_p = 't' + order by ip.sort_order, ia.sort_order, irp.sort_order @@ -2008,7 +2045,7 @@ - + select 1 from imsld_status_user @@ -2020,6 +2057,18 @@ + + + + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and status = 'finished' + and run_id = :run_id + + + + Index: openacs-4/packages/imsld/tcl/imsld-roles-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-roles-procs.xql,v diff -u -r1.5 -r1.5.6.1 --- openacs-4/packages/imsld/tcl/imsld-roles-procs.xql 26 Sep 2006 09:42:24 -0000 1.5 +++ openacs-4/packages/imsld/tcl/imsld-roles-procs.xql 24 Apr 2008 10:50:34 -0000 1.5.6.1 @@ -189,24 +189,27 @@ - select iri.role_id - from imsld_rolesi iri, - group_member_map gmm, - acs_objects ao, - acs_rels ar, - acs_rels ar2 , - imsld_run_users_group_ext iruge - where ao.object_id=gmm.group_id - and ao.object_type='imsld_role_group' - and ar.object_id_one=gmm.group_id - and ar.rel_type='imsld_roleinstance_run_rel' - and gmm.member_id=:user_id - and iruge.group_id=ar.object_id_two - and iruge.run_id=:run_id - and gmm.container_id = gmm.group_id - and ar2.object_id_two=gmm.group_id - and ar2.rel_type='imsld_role_group_rel' - and ar2.object_id_one=iri.item_id + + select ir.role_id + from imsld_roles ir, + group_member_map gmm, + acs_objects ao, + acs_rels ar, + acs_rels ar2 , + imsld_run_users_group_ext iruge, + cr_items cr + where ao.object_id=gmm.group_id + and ao.object_type='imsld_role_group' + and ar.object_id_one=gmm.group_id + and ar.rel_type='imsld_roleinstance_run_rel' + and gmm.member_id=:user_id + and iruge.group_id=ar.object_id_two + and iruge.run_id=:run_id + and gmm.container_id = gmm.group_id + and ar2.object_id_two=gmm.group_id + and ar2.rel_type='imsld_role_group_rel' + and ar2.object_id_one=cr.item_id + and cr.live_revision=ir.role_id Index: openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl,v diff -u -r1.17 -r1.17.2.1 --- openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 16 Jan 2008 10:30:40 -0000 1.17 +++ openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 24 Apr 2008 10:50:34 -0000 1.17.2.1 @@ -40,21 +40,25 @@ imsld_properties prop where ins.instance_id = :instance_id and ins.property_id = prop.property_id + and content_revision__is_live(ins.instance_id) = 't' } # db_dml update_instance_value { *SQL* } - set instance_item_id [imsld::item_revision_new -attributes [list [list run_id $run_id] \ - [list value $value] \ - [list identifier $identifier] \ - [list party_id $party_id] \ - [list property_id $property_id]] \ - -content_type imsld_property_instance \ - -title $title \ - -item_id $item_id] + set instance_item_id \ + [imsld::item_revision_new -attributes \ + [list [list run_id $run_id] \ + [list value $value] \ + [list identifier $identifier] \ + [list party_id $party_id] \ + [list property_id $property_id]] \ + -content_type imsld_property_instance \ + -title $title \ + -item_id $item_id] if { [string eq "file" $datatype] } { - set instance_id [content::item::get_live_revision -item_id $instance_item_id] + set instance_id \ + [content::item::get_live_revision -item_id $instance_item_id] # Get the filename part of the upload file if { ![regexp {[^//\\]+$} $upload_file file_name] } { @@ -64,10 +68,13 @@ set mime_type [cr_filename_to_mime_type -create $file_name] # database_p according to the file storage parameter - set fs_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id [dotlrn_community::get_community_id]] \ - -package_key "file-storage"] - set database_p [parameter::get -parameter "StoreFilesInDatabaseP" -package_id $fs_package_id] + set fs_package_id \ + [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id \ + [dotlrn_community::get_community_id]] \ + -package_key "file-storage"] + set database_p [parameter::get -parameter \ + "StoreFilesInDatabaseP" -package_id $fs_package_id] set content_length [file size $tmpfile] if { !$database_p } { # create the new item @@ -86,7 +93,8 @@ set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] where revision_id = :instance_id" -blob_files [list $tmpfile] - # Unfortunately, we can only calculate the file size after the lob is uploaded + # Unfortunately, we can only calculate the file size after the lob + # is uploaded db_dml lob_size { update cr_revisions set content_length = :content_length @@ -104,26 +112,25 @@ {-property_id ""} {-upload_file ""} {-tmpfile ""} + {-role_instance_id ""} } { - Sets a property to the given value. If some restriction is violated returns 0 and an explanation. + Sets a property to the given value. If some restriction is violated returns + 0 and an explanation. } { upvar recursivity_count recursivity_count - # context info - db_1row context_info { - select ic.item_id as component_item_id, - ii.imsld_id, - rug.group_id as run_group_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug - where ic.imsld_id = ii.item_id - and content_revision__is_live(ii.imsld_id) = 't' - and ii.imsld_id = ir.imsld_id - and rug.run_id = ir.run_id - and ir.run_id = :run_id - } - # property info if { [string eq $property_id ""] } { + # context info in case we need to obtain the property_id from the identifier + db_1row context_info { + select ic.item_id as component_item_id + from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug + where ic.imsld_id = ii.item_id + and content_revision__is_live(ii.imsld_id) = 't' + and ii.imsld_id = ir.imsld_id + and rug.run_id = ir.run_id + and ir.run_id = :run_id + } db_1row property_info_from_identifier { select type, property_id, @@ -144,16 +151,19 @@ } } - # instance info - set role_instance_id "" - if { ![string eq $role_id ""] } { - # find the role instance which the user belongs to - set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] - if { !$role_instance_id } { - # runtime error... the user doesn't belong to any role instance - ns_log notice "User does not belong to any role instance" - continue - } + # instance info there are two places where this proc is called: from + # run-time procs or from the monitor interface if we are inside the monitor + # interface, we know the role_instance_id, otherwise we have to find it out + if { [string eq "" $role_instance_id] && [string eq $type "locrole"] } { + if { ![string eq $role_id ""] } { + # find the role instance we are working on + set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] + if { !$role_instance_id } { + # runtime error... the user doesn't belong to any role instance + util_user_message -message "[_ imsld.lt_User_does_not_belong_]" + ad_script_abort + } + } } db_1row get_property_instance { @@ -248,7 +258,8 @@ # Recursive call only if the property value has changed if { $old_value != $value } { - # There might be infinite recursive loops, so the counter recursivity_count is used to avoid crashing the server + # There might be infinite recursive loops, so the counter + # recursivity_count is used to avoid crashing the server if { ![exists_and_not_null recursivity_count] } { # this is the first recursive call, initialize the variable set recursivity_count 1 @@ -266,14 +277,14 @@ } set conditions_list [db_list get_conditions_from_property { - select ici.condition_id - from imsld_conditionsi ici, - acs_rels ar, - imsld_propertiesi ipi - where ipi.property_id = :property_id - and ipi.item_id = ar.object_id_one - and ar.rel_type = 'imsld_prop_cond_rel' - and ar.object_id_two = ici.item_id + select ici.condition_id + from imsld_conditionsi ici, + acs_rels ar, + imsld_propertiesi ipi + where ipi.property_id = :property_id + and ipi.item_id = ar.object_id_one + and ar.rel_type = 'imsld_prop_cond_rel' + and ar.object_id_two = ici.item_id }] #property conditions foreach member_id [db_list user_in_run { @@ -300,11 +311,11 @@ } # when-condition-true: - # foreach when-condition-true related with the property, evaluate the whole expression - # referenced from the table when-condition-true to all the members of the referenced role (in the same table), - # and if it's true, set the act (in the table complete-acts) completed - # n.b. this won't generate endless loops - + # foreach when-condition-true related with the property, evaluate the + # whole expression referenced from the table when-condition-true to all + # the members of the referenced role (in the same table), and if it's + # true, set the act (in the table complete-acts) completed # n.b. this + # won't generate endless loops foreach when_cond_true_item_id [db_list when_condition_true { select ar.object_id_two as when_cond_true_item_id from acs_rels ar, @@ -317,10 +328,10 @@ } # when-property-vale-is-set: - # foreach when-property-value-is-set related with the property, evaluete the expression - # and compare it with the referenced property, and if they have the same value, mark the referencer - # activity as completed - # n.b. this won't generate endless loops + # foreach when-property-value-is-set related with the property, + # evaluete the expression and compare it with the referenced property, + # and if they have the same value, mark the referencer activity as + # completed # n.b. this won't generate endless loops foreach complete_act_item_id [db_list when_prop_value_is_set { select ar.object_id_two as complete_act_item_id @@ -330,10 +341,12 @@ and ipi.item_id = ar.object_id_one and ar.rel_type = 'imsld_prop_wpv_is_rel' }] { - imsld::condition::eval_when_prop_value_is_set -complete_act_item_id $complete_act_item_id -run_id $run_id + imsld::condition::eval_when_prop_value_is_set \ + -complete_act_item_id $complete_act_item_id -run_id $run_id } - # role conditions, time conditions... the rest of conditions must be evaluated every time a property value changes + # role conditions, time conditions... the rest of conditions must be + # evaluated every time a property value changes imsld::condition::execute_time_role_conditions -run_id $run_id } } @@ -399,8 +412,8 @@ set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $user_id] if { !$role_instance_id } { # runtime error... the user doesn't belong to any role instance - ns_log notice "User does not belong to any role instance" - continue + util_user_message -message "[_ imsld.lt_User_does_not_belong_]" + ad_script_abort } } @@ -602,7 +615,7 @@ select gmm.member_id from group_member_map gmm, imsld_run_users_group_ext iruge, - acs_rels ar1 + acs_rels ar1 where iruge.run_id=:run_id and ar1.object_id_two=iruge.group_id and ar1.object_id_one=gmm.group_id Index: openacs-4/packages/imsld/www/activity-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/activity-frame.adp,v diff -u -r1.15 -r1.15.2.1 --- openacs-4/packages/imsld/www/activity-frame.adp 30 May 2007 08:36:22 -0000 1.15 +++ openacs-4/packages/imsld/www/activity-frame.adp 24 Apr 2008 10:50:34 -0000 1.15.2.1 @@ -1,137 +1,37 @@ - - - - + + init_activity() + + - - - + document.write(' - - - - - -#imsld.Hide# - - - - - - -
- -
-
- -@activities;noquote@ - - - - - - - - - - - - - - - - Index: openacs-4/packages/imsld/www/activity-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/activity-frame.tcl,v diff -u -r1.16 -r1.16.6.1 --- openacs-4/packages/imsld/www/activity-frame.tcl 25 Apr 2007 10:52:30 -0000 1.16 +++ openacs-4/packages/imsld/www/activity-frame.tcl 24 Apr 2008 10:50:34 -0000 1.16.6.1 @@ -52,6 +52,167 @@ ) } +set activity_item_id [content::revision::item_id -revision_id $activity_id] + +set referencer_structure_item_id "" + +if { [string eq $activity_type "learning"] } { + if { [string eq "" [db_string completion_restriction {select complete_act_id from imsld_learning_activities where activity_id = :activity_id}]] } { + # the learning activity has been visited and doesn't have any completion restriction. + # if it is referenced from an activity structure, verify if every referenced activity have been visted + db_0or1row referenced_from_structure_p { + select ar.object_id_one as referencer_structure_item_id + from acs_rels ar + where ar.object_id_two = :activity_item_id + } + } +} elseif { [string eq $activity_type "support"] } { + if { [string eq "" [db_string completion_restriction {select complete_act_id from imsld_support_activities where activity_id = :activity_id}]] } { + # the learning activity has been visited and doesn't have any completion restriction. + # if it is referenced from an activity structure, verify if every referenced activity have been visted + db_0or1row referenced_from_structure_p { + select ar.object_id_one as referencer_structure_item_id + from acs_rels ar + where ar.object_id_two = :activity_item_id + } + } +} + +if { ![string eq "" $referencer_structure_item_id] } { + db_1row get_structure_info { + select structure_id, + number_to_select + from imsld_activity_structuresi + where item_id = :referencer_structure_item_id + and content_revision__is_live(structure_id) = 't' + } + + # if the structure hasn't been finished + if { ![db_0or1row already_finished { + select 1 + from imsld_status_user + where related_id = :structure_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + }] } { + set mark_structure_finished_p 1 + set total_completed 0 + foreach referenced_activity [db_list_of_lists struct_referenced_activities { + select ar.object_id_two, + ar.rel_type + from acs_rels ar + where ar.object_id_one = :referencer_structure_item_id + order by ar.object_id_two + }] { + set object_id_two [lindex $referenced_activity 0] + set rel_type [lindex $referenced_activity 1] + switch $rel_type { + imsld_as_la_rel { + # if the activity doesn't have any completrion restriction + # and it hasn't been started, cancel the completion of the structure + set referenced_activity_id [content::item::get_live_revision -item_id $object_id_two] + set la_completion_restriction [db_string la_completion_restriction { + select complete_act_id + from imsld_learning_activities + where activity_id = :referenced_activity_id + }] + if { ([db_0or1row la_already_started_p { + select 1 + from imsld_status_user + where related_id = :referenced_activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] && [string eq "" $la_completion_restriction]) \ + || [db_0or1row la_already_finished { + select 1 + from imsld_status_user + where related_id = :referenced_activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + }] } { + # the activity has been visited + incr total_completed + } else { + set mark_structure_finished_p 0 + continue + } + } + imsld_as_sa_rel { + # if the activity doesn't have any completrion restriction + # and it hasn't been started, cancel the completion of the structure + set referenced_activity_id [content::item::get_live_revision -item_id $object_id_two] + if { ([db_0or1row la_already_started_p { + select 1 + from imsld_status_user + where related_id = :referenced_activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'started' + }] && [string eq "" $sa_completion_restriction]) \ + || [db_0or1row la_already_finished { + select 1 + from imsld_status_user + where related_id = :referenced_activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + }] } { + # the activity has been visited + incr total_completed + } else { + set mark_structure_finished_p 0 + continue + } + } imsld_as_as_rel { + # if the referenced activity structure hasn't been finished, don't finish the activity structure + set structure_id [content::item::get_live_revision -item_id $object_id_two] + if { ![db_0or1row sa_already_finished_p { + select 1 + from imsld_status_user + where related_id = :referenced_activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + }] } { + set mark_structure_finished_p 0 + continue + } else { + incr total_completed + } + } + } + } + if { $mark_structure_finished_p || (![string eq $number_to_select ""] && ($total_completed >= $number_to_select)) } { + # mark the structure as finished + + set role_part_id_list [imsld::get_role_part_from_activity -activity_type structure -leaf_id $referencer_structure_item_id] + foreach role_part_id $role_part_id_list { + db_1row context_info { + select acts.act_id, + plays.play_id + from imsld_actsi acts, imsld_playsi plays, imsld_role_parts rp + where rp.role_part_id = :role_part_id + and rp.act_id = acts.item_id + and acts.play_id = plays.item_id + } + + imsld::finish_component_element -imsld_id $imsld_id \ + -run_id $run_id \ + -play_id $play_id \ + -act_id $act_id \ + -role_part_id $role_part_id \ + -element_id $structure_id \ + -type structure \ + -user_id $user_id \ + -code_call + } + } + } +} + set supported_roles [db_list supported_roles_list { select iri.role_id from imsld_rolesi iri, acs_rels ar, @@ -74,7 +235,6 @@ set activity_item_id [content::revision::item_id -revision_id $activity_id] imsld::process_activity_as_ul -activity_item_id $activity_item_id -run_id $run_id -dom_doc $doc -dom_node $dom_root - if { ![string eq $activity_id ""] && [db_0or1row get_table_name { select case @@ -161,6 +321,5 @@ set activities [export_vars -base "imsld-content-serve" -url { run_id resource_item_id role_id {owner_user_id $supported_user_id} }] } - set page_title {} set context [list] Index: openacs-4/packages/imsld/www/environment-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/environment-frame.adp,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/imsld/www/environment-frame.adp 30 May 2007 08:36:22 -0000 1.6 +++ openacs-4/packages/imsld/www/environment-frame.adp 24 Apr 2008 10:50:34 -0000 1.6.2.1 @@ -1,36 +1,19 @@ - - - - - - - - - + + @page_title;noquote@ + @context;noquote@ + 1 -@environments;noquote@ +
@frame_header@
- + @environments;noquote@ - + - + + Index: openacs-4/packages/imsld/www/environment-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/environment-frame.tcl,v diff -u -r1.9 -r1.9.2.1 --- openacs-4/packages/imsld/www/environment-frame.tcl 30 May 2007 08:36:22 -0000 1.9 +++ openacs-4/packages/imsld/www/environment-frame.tcl 24 Apr 2008 10:50:34 -0000 1.9.2.1 @@ -11,36 +11,28 @@ set user_id [ad_conn user_id] +set frame_header "[_ imsld.Context_info]" +set page_title $frame_header +set context [list] + dom createDocument ul doc set dom_root [$doc documentElement] -#set environments_node_ul [$doc createElement ul] -set environments_node_li [$doc createElement li] -set text [$doc createTextNode "[_ imsld.Context_info]"] -$environments_node_li appendChild $text -set environments_node [$doc createElement ul] -$environments_node setAttribute class "mktree" -$environments_node setAttribute style "white-space: nowrap;" +# Create the ul element which will hold all the environment info +$dom_root setAttribute class "mktree" +$dom_root setAttribute style "white-space: nowrap;" -# FIX-ME: if the ul is empty, the browser shows the ul incorrectly -set text [$doc createTextNode ""] -$environments_node appendChild $text - +# Create the li nodes for each environment set activity_item_id [content::revision::item_id -revision_id $activity_id] - -imsld::process_activity_environments_as_ul -activity_item_id $activity_item_id \ +imsld::process_activity_environments_as_ul \ + -activity_item_id $activity_item_id \ -run_id $run_id \ - -dom_node $environments_node \ + -dom_node $dom_root \ -dom_doc $doc -$dom_root appendChild $environments_node_li -set environments_node_li [$doc createElement li] -$environments_node_li setAttribute class "liOpen" +# Set the result only if it is not empty +if { [$dom_root hasChildNodes]} { + # Set the result + set environments [$dom_root asXML] +} -$environments_node_li appendChild $environments_node -$dom_root appendChild $environments_node_li - -set environments [$dom_root asXML] - -set page_title {} -set context [list] Index: openacs-4/packages/imsld/www/imsld-content-serve.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-content-serve.tcl,v diff -u -r1.20 -r1.20.6.1 --- openacs-4/packages/imsld/www/imsld-content-serve.tcl 25 Apr 2007 10:52:30 -0000 1.20 +++ openacs-4/packages/imsld/www/imsld-content-serve.tcl 24 Apr 2008 10:50:34 -0000 1.20.6.1 @@ -1,7 +1,8 @@ # packages/imsld/www/imsld-content-serve.tcl ad_page_contract { - Process an imsldcontent resource, changing the view and set properties tags with their respective HTML + Process an imsldcontent resource, changing the view and set properties tags + with their respective HTML @creation-date Jun 2006 @author jopez@inv.it.uc3m.s @@ -18,6 +19,22 @@ set owner_user_id [ad_conn user_id] } +# If no role_id is given, take the active role +if { [string eq $role_id ""] } { + #get the user active role + db_1row get_active_role { + select iruns.active_role_id as role_id + from imsld_run_users_group_rels iruns, + acs_rels ar, + imsld_run_users_group_ext iruge + where iruge.run_id=:run_id + and ar.object_id_one=iruge.group_id + and ar.object_id_two=:owner_user_id + and ar.rel_type='imsld_run_users_group_rel' + and ar.rel_id=iruns.rel_id + } +} + # get file info db_1row get_info { select cr.revision_id, @@ -41,7 +58,10 @@ select ic.item_id as component_item_id, ii.imsld_id, rug.group_id as run_group_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug + from imsld_componentsi ic, + imsld_imsldsi ii, + imsld_runs ir, + imsld_run_users_group_ext rug where ic.imsld_id = ii.item_id and content_revision__is_live(ii.imsld_id) = 't' and ii.imsld_id = ir.imsld_id @@ -51,9 +71,9 @@ # Get file-storage root folder_id set fs_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id [dotlrn_community::get_community_id]] \ + -package_id [dotlrn_community::get_package_id \ + [dotlrn_community::get_community_id]] \ -package_key "file-storage"] -set root_folder_id [fs::get_root_folder -package_id $fs_package_id] # Parser # XML => DOM document @@ -67,12 +87,17 @@ $dom_doc documentElement dom_root # procedure: -# currently we only deliver properties of one user at the same time in one given role +# currently we only deliver properties of one user at the same time in one +# given role # 1. replace the view-property tags with the property title(optional) and value -# 2. replace the view-property-group tags with the properties titles(optional) and value of all the referenced properties -# 3. replace the set-property tags with input fields depending on the property type -# 4. replace the set-groperty-group tags with one input field per each referenced property in the group -# 5. if there was at least one set-property* tag, add a submit button (FIX ME: currently for each set-property* a new form is added) +# 2. replace the view-property-group tags with the properties titles(optional) +# and value of all the referenced properties +# 3. replace the set-property tags with input fields depending on the property +# type +# 4. replace the set-groperty-group tags with one input field per each +# referenced property in the group +# 5. if there was at least one set-property* tag, add a submit button (FIX ME: +# currently for each set-property* a new form is added) # 6. for each class, check the visibility value in the database # 1. view-property nodes @@ -83,8 +108,8 @@ set view [$view_property_node getAttribute view "value"] set property_of [$view_property_node getAttribute property-of "self"] - # get the value, depending on the property type. - # the only different case is when viewing the proprty in the context of the role + # get the value, depending on the property type. the only different case + # is when viewing the proprty in the context of the role set role_instance_id 0 # get property info @@ -96,9 +121,14 @@ and identifier = :identifier } - if { ![string eq $property_of "self"] } { + if { ![string eq $property_of "self"] || + [string eq $type "locrole"] } { # find the role instance which the user belongs to - set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $owner_user_id] + set role_instance_id \ + [imsld::roles::get_user_role_instance \ + -run_id $run_id \ + -role_id $role_id \ + -user_id $owner_user_id] if { !$role_instance_id } { # runtime error... the user doesn't belong to any role instance ns_log notice "User does not belong to any role instance" @@ -110,34 +140,54 @@ select ins.property_id, prop.datatype, coalesce(ins.value, prop.initial_value) as value, - ins.title, + coalesce(ins.title, ins.identifier) as title, content_revision__get_content(cr.revision_id) as content, ins.instance_id, ins.object_id, - ins.parent_id + ins.parent_id, + prop.type as property_type from imsld_property_instancesx ins, cr_revisions cr, - imsld_properties prop + imsld_propertiesi prop where ins.property_id = prop.property_id and prop.property_id = :property_id and ((prop.type = 'global') or (prop.type = 'loc' and ins.run_id = :run_id) - or (prop.type = 'locpers' and ins.run_id = :run_id and ins.party_id = :owner_user_id) - or (prop.type = 'locrole' and ins.run_id = :run_id and ins.party_id = :role_instance_id) + or (prop.type = 'locpers' and + ins.run_id = :run_id and ins.party_id = :owner_user_id) + or (prop.type = 'locrole' and + ins.run_id = :run_id and ins.party_id = :role_instance_id) or (prop.type = 'globpers' and ins.party_id = :owner_user_id)) and cr.revision_id = ins.instance_id and content_revision__is_live(ins.instance_id) = 't' } - # prepare replacement - # by the moment, the only different case are the properties of type file + # prepare replacement by the moment, the only different case are the + # properties of type file switch $datatype { file { set a_node "" if { ![string eq "" $content] } { - set folder_path [db_exec_plsql get_folder_path { - select content_item__get_path(:parent_id,:root_folder_id); - }] + # This is incorrect for global properties. It only works for + # local ones because root_folder_id is always obtained for the + # package + if { [string eq $property_type "global"] || + [string eq $property_type "globpers"] } { + # global or globpers properties + set root_folder_id [dotlrn_fs::get_dotlrn_root_folder_id] + set url_prefix \ + [site_node_object_map::get_url \ + -object_id $root_folder_id] + } else { + set root_folder_id \ + [fs::get_root_folder -package_id $fs_package_id] + set url_prefix [apm_package_url_from_id $fs_package_id] + } + + set folder_path \ + [content::item::get_path -item_id $parent_id \ + -root_folder_id $root_folder_id] + db_1row get_fs_file_url { select case @@ -149,7 +199,7 @@ from fs_objects fs where fs.live_revision = :instance_id } - set file_url "[apm_package_url_from_id $fs_package_id]view/${file_url}" + set file_url "${url_prefix}view/${file_url}" set a_node [$dom_doc createElement a] $a_node setAttribute href [export_vars -base "$file_url"] $a_node appendChild [$dom_doc createTextNode "[_ imsld.view_file]"] @@ -223,7 +273,7 @@ select ins.property_id, prop.datatype, coalesce(ins.value, prop.initial_value) as value, - ins.title, + coalesce(ins.title, ins.identifier) as title, content_revision__get_content(cr.revision_id) as content, ins.instance_id, ins.object_id, @@ -326,7 +376,8 @@ # get the value, depending on the property type. # the only different case is when viewing the proprty in the context of the role set role_instance_id 0 - if { ![string eq $property_of "self"] } { + if { ![string eq $property_of "self"] || + [string eq $type "locrole"] } { # find the role instance which the user belongs to set role_instance_id [imsld::roles::get_user_role_instance -run_id $run_id -role_id $role_id -user_id $owner_user_id] if { !$role_instance_id } { @@ -341,7 +392,7 @@ prop.datatype, prop.item_id as property_item_id, coalesce(ins.value, prop.initial_value) as value, - ins.title, + coalesce(ins.title, ins.identifier) as title, ins.instance_id from imsld_property_instancesx ins, cr_revisions cr, @@ -443,6 +494,22 @@ $owner_node setAttribute value "$owner_user_id" $form_node appendChild $owner_node + # adding run_id + set run_id_node [$dom_doc createElement "input"] + $run_id_node setAttribute name "run_id" + $run_id_node setAttribute type "hidden" + $run_id_node setAttribute value "$run_id" + $form_node appendChild $run_id_node + + if { [string eq $type "locrole"] } { + # adding role_instance_id + set role_instance_id_node [$dom_doc createElement "input"] + $role_instance_id_node setAttribute name "role_instance_id" + $role_instance_id_node setAttribute type "hidden" + $role_instance_id_node setAttribute value "$role_instance_id" + $form_node appendChild $role_instance_id_node + } + # adding return url set return_url_node [$dom_doc createElement "input"] $return_url_node setAttribute name "return_url" @@ -455,6 +522,7 @@ $submit_node setAttribute type "submit" $submit_node setAttribute value "ok" $form_node appendChild $submit_node + # done... add the form to the root set parent_node [$set_property_node parentNode] # first, replace property node with the form node @@ -589,7 +657,7 @@ prop.item_id as property_item_id, prop.datatype, coalesce(ins.value, prop.initial_value) as value, - ins.title, + coalesce(ins.title, ins.identifier) as title, content_revision__get_content(cr.revision_id) as content, ins.instance_id, ins.object_id, @@ -702,6 +770,13 @@ $owner_node setAttribute value "$owner_user_id" $form_node appendChild $owner_node + # adding run_id + set run_id_node [$dom_doc createElement "input"] + $run_id_node setAttribute name "run_id" + $run_id_node setAttribute type "hidden" + $run_id_node setAttribute value "$run_id" + $form_node appendChild $run_id_node + # adding return url set return_url_node [$dom_doc createElement "input"] $return_url_node setAttribute name "return_url" @@ -714,6 +789,7 @@ $submit_node setAttribute type "submit" $submit_node setAttribute value "ok" $form_node appendChild $submit_node + # finally, replace property node with the form node $parent_node replaceChild $form_node $set_property_group_node # FIXME: tDOME apparently adds automathically the attribute xmlns when replacing a node... @@ -848,18 +924,22 @@ and map.displayable_p = 't' }] -set folder_path [db_exec_plsql get_folder_path {select content_item__get_path(:parent_id,:root_folder_id); }] -set file_url "[apm_package_url_from_id $fs_package_id]view/${folder_path}" +# It doesn't make sense to have a base attribute defined, since there could be +# multiple properties to be shown in the page, and therefore, the base URL is +# not so easy to compute. -set head_node [$dom_root selectNodes {//*[local-name()='head']}] -if {![llength [$head_node selectNodes {/*[local-name()='base']}]]} { - set base_node [$dom_doc createElement "base"] - set base_prefix [ns_conn location] - $base_node setAttribute href "$base_prefix/$file_url/" - $head_node appendChild $base_node -} +# set folder_path [db_exec_plsql get_folder_path {select content_item__get_path(:parent_id,:root_folder_id); }] +# set file_url "[apm_package_url_from_id $fs_package_id]view/${folder_path}" +# set head_node [$dom_root selectNodes {//*[local-name()='head']}] +# if {![llength [$head_node selectNodes {/*[local-name()='base']}]]} { +# set base_node [$dom_doc createElement "base"] +# set base_prefix [ns_conn location] +# $base_node setAttribute href "$base_prefix/$file_url/" +# $head_node appendChild $base_node +# } + set xmloutput {} append xmloutput [$dom_root asXML] ns_return 200 text/html $xmloutput Index: openacs-4/packages/imsld/www/imsld-frameset.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/Attic/imsld-frameset.adp,v diff -u -r1.8 -r1.8.6.1 --- openacs-4/packages/imsld/www/imsld-frameset.adp 25 Apr 2007 10:52:30 -0000 1.8 +++ openacs-4/packages/imsld/www/imsld-frameset.adp 24 Apr 2008 10:50:34 -0000 1.8.6.1 @@ -1,15 +1,15 @@ - + @course_name@ - - + + - - + + - + Index: openacs-4/packages/imsld/www/imsld-sendmail-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-sendmail-2.adp,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/imsld-sendmail-2.adp 18 May 2006 11:13:01 -0000 1.1 +++ openacs-4/packages/imsld/www/imsld-sendmail-2.adp 24 Apr 2008 10:50:34 -0000 1.1.6.1 @@ -1,5 +1,4 @@ - - + @page_title;noquote@ @context;noquote@ Index: openacs-4/packages/imsld/www/imsld-sendmail.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-sendmail.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/imsld-sendmail.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/imsld-sendmail.adp 24 Apr 2008 10:50:34 -0000 1.4.2.1 @@ -1,11 +1,21 @@ - + @page_title;noquote@ @context;noquote@ + + + +

#imsld.lt_Select_a_role_to_send#

  • - @all_email_data.title@ + @all_email_data.title@
    Index: openacs-4/packages/imsld/www/imsld-tree.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-tree.adp,v diff -u -r1.15 -r1.15.2.1 --- openacs-4/packages/imsld/www/imsld-tree.adp 30 May 2007 08:36:22 -0000 1.15 +++ openacs-4/packages/imsld/www/imsld-tree.adp 24 Apr 2008 10:50:34 -0000 1.15.2.1 @@ -1,106 +1,51 @@ - - - - - - - + + 1 - - + - - - -#imsld.Exit# -
    -
    - - - -
    -
    -@html_tree;noquote@ -@aux_html_tree;noquote@ - -@user_message@ - - +
    + + + +
    - + - - Index: openacs-4/packages/imsld/www/imsld-tree.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-tree.tcl,v diff -u -r1.18 -r1.18.2.1 --- openacs-4/packages/imsld/www/imsld-tree.tcl 30 May 2007 08:36:22 -0000 1.18 +++ openacs-4/packages/imsld/www/imsld-tree.tcl 24 Apr 2008 10:50:34 -0000 1.18.2.1 @@ -25,8 +25,10 @@ # current role information. # the user must have an active role in the run -set possible_user_roles [imsld::roles::get_user_roles -user_id $user_id -run_id $run_id] -set possible_user_role_names [imsld::roles::get_roles_names -roles_list $possible_user_roles] +set possible_user_roles [imsld::roles::get_user_roles -user_id $user_id \ + -run_id $run_id] +set possible_user_role_names [imsld::roles::get_roles_names \ + -roles_list $possible_user_roles] # remove   added in the previous proc regsub -all " " $possible_user_role_names "" $possible_user_role_names @@ -57,22 +59,23 @@ and iruge.run_id = :run_id and map.active_role_id is not null }] } { - # generate the first option + # no role have been selected, generate the first option set possible_user_roles [linsert $possible_user_roles 0 0] set possible_user_role_names [linsert $possible_user_role_names 0 "[_ imsld.Select_role]"] set user_role_id -1 } -template::multirow create possible_roles role_id role_name +template::multirow create possible_roles item_id item_name foreach role $possible_user_roles { - template::multirow append possible_roles $role [lindex $possible_user_role_names [lsearch -exact $possible_user_roles $role]] + template::multirow append possible_roles \ + $role [lindex $possible_user_role_names \ + [lsearch -exact $possible_user_roles $role]] } set user_message "" set next_activity_id [imsld::get_next_activity_list -run_id $run_id -user_id $user_id] - set remaining_activities [llength [join $next_activity_id]] if {!$remaining_activities} { @@ -84,7 +87,7 @@ where run_id=:run_id } } else { - set user_message "Please wait for other users ..." + set user_message "[_ imsld.lt_Please_wait_for_other]" } } @@ -95,13 +98,12 @@ }] if {[string eq "stopped" $run_status]} { - set user_message "The course has been finished" + set user_message "[_ imsld.lt_The_course_has_been_f]" } dom createDocument ul doc set dom_root [$doc documentElement] $dom_root setAttribute class "mktree" -$dom_root setAttribute style "white-space: nowrap;" set imsld_title_node [$doc createElement li] $imsld_title_node setAttribute class "liOpen" set text [$doc createTextNode "$imsld_title"] @@ -114,7 +116,6 @@ set html_tree "" set aux_html_tree "" } else { - imsld::generate_activities_tree -run_id $run_id \ -user_id $user_id \ -next_activity_id_list $next_activity_id \ @@ -135,7 +136,6 @@ dom createDocument ul aux_doc set aux_dom_root [$aux_doc documentElement] $aux_dom_root setAttribute class "mktree" - $aux_dom_root setAttribute style "white-space: nowrap;" set aux_title_node [$aux_doc createElement li] $aux_title_node setAttribute class "liOpen" set text [$doc createTextNode "[_ imsld.Extra_Activities]"] @@ -156,3 +156,5 @@ } } + +set select_string "[_ imsld.Select_role]" Index: openacs-4/packages/imsld/www/monitor-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/monitor-frame.adp,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/monitor-frame.adp 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/monitor-frame.adp 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -1,17 +1,5 @@ - - - - + - - - - - #imsld.Monitoring#: @monitoring_user_name@ @@ -33,14 +21,12 @@ -
    - +
    +
    - - - Index: openacs-4/packages/imsld/www/properties-value-set.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/properties-value-set.tcl,v diff -u -r1.4 -r1.4.6.1 --- openacs-4/packages/imsld/www/properties-value-set.tcl 25 Apr 2007 10:52:30 -0000 1.4 +++ openacs-4/packages/imsld/www/properties-value-set.tcl 24 Apr 2008 10:50:34 -0000 1.4.6.1 @@ -6,6 +6,8 @@ instances_ids:array return_url owner_id + run_id + {role_instance_id ""} } -validate { no_instance { if { [array size instances_ids] == 0 } { @@ -19,24 +21,28 @@ # avoiding hacks db_1row instance_info_id { select ins.property_id, - ins.run_id, prop.datatype from imsld_property_instances ins, imsld_properties prop where ins.instance_id = :instance_id and ins.property_id = prop.property_id + and content_revision__is_live(ins.instance_id) = 't' } if { [string eq "file" $datatype] } { - imsld::runtime::property::property_value_set -run_id $run_id \ + imsld::runtime::property::property_value_set \ + -run_id $run_id \ -user_id $owner_id \ + -role_instance_id $role_instance_id \ -value $instances_ids($instance_id) \ -property_id $property_id \ -upload_file $instances_ids($instance_id) \ -tmpfile $instances_ids(${instance_id}.tmpfile) } else { - imsld::runtime::property::property_value_set -run_id $run_id \ + imsld::runtime::property::property_value_set \ + -run_id $run_id \ -user_id $owner_id \ + -role_instance_id $role_instance_id \ -value $instances_ids($instance_id) \ -property_id $property_id } Index: openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-admin-roles.adp 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -1,38 +1,57 @@ + @page_title;noquote@ + @context;noquote@ + + + - - - - - - - + + + - + + + - - - -
    - - +
    +
    + +
    +
    - -
    - + + + +
    - -
    - Index: openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl,v diff -u -r1.7 -r1.7.2.1 --- openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl 30 May 2007 08:36:22 -0000 1.7 +++ openacs-4/packages/imsld/www/admin/imsld-admin-roles.tcl 24 Apr 2008 10:50:34 -0000 1.7.2.1 @@ -13,6 +13,9 @@ {finishable 0} } +set page_title "[_ imsld.Admin_roles]" +set context "" + #check if the run is waiting if { [db_0or1row get_run_status { select run_id Index: openacs-4/packages/imsld/www/admin/imsld-confirm-finish.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-confirm-finish.tcl,v diff -u -r1.8 -r1.8.6.1 --- openacs-4/packages/imsld/www/admin/imsld-confirm-finish.tcl 21 Dec 2006 15:20:47 -0000 1.8 +++ openacs-4/packages/imsld/www/admin/imsld-confirm-finish.tcl 24 Apr 2008 10:50:34 -0000 1.8.6.1 @@ -9,9 +9,6 @@ } -# instantiating properties and activity attributes for the run -imsld::instance::instantiate_properties -run_id $run_id -imsld::instance::instantiate_activity_attributes -run_id $run_id # NOTE: we should verify the permissions here set conditions 1 if {$conditions == 1} { @@ -28,8 +25,24 @@ foreach role_id [imsld::roles::get_list_of_roles -imsld_id $imsld_id] { set users_list [concat $users_list [imsld::roles::get_users_in_role -role_id [lindex $role_id 0] -run_id $run_id]] } - + +set group_run_id [db_string get_run_group_id { + select group_id + from imsld_run_users_group_ext + where run_id = :run_id +}] + +# add the users to the run_group foreach user_id $users_list { + relation_add imsld_run_users_group_rel $group_run_id $user_id +} + +# instantiating properties and activity attributes for the run +imsld::instance::instantiate_properties -run_id $run_id +imsld::instance::instantiate_activity_attributes -run_id $run_id + +# execute the conditions +foreach user_id $users_list { imsld::condition::execute_all -run_id $run_id -user_id $user_id } Index: openacs-4/packages/imsld/www/admin/imsld-create-instance.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-create-instance.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/imsld-create-instance.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/imsld-create-instance.adp 24 Apr 2008 10:50:34 -0000 1.4.2.1 @@ -1,4 +1,7 @@ + @page_title;noquote@ + @context;noquote@ +

    #imsld.lt_Select_parent_for_the#

    Index: openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-create-instance.tcl 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -12,6 +12,8 @@ run_id parent_group_id:optional } +set page_title "[_ imsld.Create_role_instance]" +set context "" db_1row get_imsld_role_info {} set number_of_groups [llength [db_list get_related_groups {}]] @@ -20,8 +22,8 @@ if { !([string eq $number_of_groups "0"] || [string eq $create_new_p "t"] ) } { - set mensaje "

    Current Unit of Learning does not allow creation of multiple instances of this role.

    - Go back" + set mensaje "

    [_ imsld.lt_Current_Unit_of_Learn]

    + [_ imsld.Go_back]" ad_return_complaint 1 $mensaje ad_script_abort } Index: openacs-4/packages/imsld/www/admin/imsld-finish.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-finish.adp,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/admin/imsld-finish.adp 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-finish.adp 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -1,4 +1,6 @@ + @page_title;noquote@ + @context;noquote@

    #imsld.lt_Some_warnings_has_bee#

    @@ -10,15 +12,15 @@

    #imsld.lt_Some_errors_has_been_#

      @errors;noquote@
    - #imsld.Go_back# + #imsld.Go_back#

    #imsld.lt_Are_all_the_students_#

    -

    #imsld.lt_If_you_are_not_sure_t# #imsld.go_back#

    -

    #imsld.lt_Otherwise_if_everthin# #imsld.Confirm#.

    +

    #imsld.lt_If_you_are_not_sure_t# #imsld.go_back#

    +

    #imsld.lt_Otherwise_if_everthin# #imsld.Confirm#.

    Index: openacs-4/packages/imsld/www/admin/imsld-finish.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-finish.tcl,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/admin/imsld-finish.tcl 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-finish.tcl 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -7,8 +7,12 @@ imsld_id run_id } -#aqui tengo que poner la comprobación de que todo sea correcto (errores y warnings) +set page_title "[_ imsld.lt_Confirm_roles_assignm]" +set context "" + +# NOTE(lfuente): here there should be a check of all the input + set roles_list_depth [imsld::roles::get_list_of_roles -imsld_id $imsld_id] Index: openacs-4/packages/imsld/www/admin/imsld-groups.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-groups.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/imsld-groups.adp 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/imsld-groups.adp 24 Apr 2008 10:50:34 -0000 1.3.2.1 @@ -1,3 +1,3 @@ -
    + Index: openacs-4/packages/imsld/www/admin/imsld-groups.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-groups.tcl,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/imsld/www/admin/imsld-groups.tcl 30 May 2007 08:36:22 -0000 1.6 +++ openacs-4/packages/imsld/www/admin/imsld-groups.tcl 24 Apr 2008 10:50:34 -0000 1.6.2.1 @@ -11,33 +11,32 @@ {group_instance 0} role:optional } -set lista [list [list "Select a group..." 0]] +set lista [list [list "[_ imsld.Select_a_group]" 0]] set lista_aux [lindex [db_list_of_lists get_groups_list {}] 0] lappend lista $lista_aux -set actions [list "Create new" [export_vars -base imsld-create-instance {imsld_id run_id role lista}] "Create a new group"] +set actions [list "[_ imsld.Create_new]" [export_vars -base imsld-create-instance {imsld_id run_id role lista}] "[_ imsld.Create_a_new_group]"] template::list::create \ -name role_groups \ -multirow role_groups \ -key role_groups \ + -pass_properties { imsld_id run_id role } \ -actions $actions \ -elements { group_name { - label {Group name} + label {[_ imsld.Group_name]} link_url_col {manage_roles} } delete { label {} - display_template {@role_groups.delete;noquote@} + display_template {[_ imsld.Delete]} } } db_multirow -extend { manage_roles delete } role_groups get_groups_list {} { set manage_roles [export_vars -base imsld-admin-roles {imsld_id run_id role {group_instance $group_id}}] - set delete "\"[_" - } Index: openacs-4/packages/imsld/www/admin/imsld-new-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new-2.tcl,v diff -u -r1.9 -r1.9.6.1 --- openacs-4/packages/imsld/www/admin/imsld-new-2.tcl 16 May 2006 09:24:36 -0000 1.9 +++ openacs-4/packages/imsld/www/admin/imsld-new-2.tcl 24 Apr 2008 10:50:34 -0000 1.9.6.1 @@ -28,7 +28,7 @@ -message_1 "[_ imsld.lt_Uploading_and_process]" \ -message_2 "[_ imsld.lt_We_will_continue_auto]" -ns_write "[_ imsld.lt_h2Uploading_new_IMS_L]
    " +ns_write "[_ imsld.lt_h2Uploading_new_IMS_L]" set community_id [dotlrn_community::get_community_id] # Atempting to create the new IMS LD. @@ -65,9 +65,7 @@ ns_sleep 5 } -ns_write "
    " - # go to the roles admin page... -ad_progress_bar_end -url [export_vars -base imsld-admin-roles {run_id}] +ad_progress_bar_end -url "index" Index: openacs-4/packages/imsld/www/admin/imsld-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/imsld-new.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/imsld-new.adp 24 Apr 2008 10:50:34 -0000 1.4.2.1 @@ -1,7 +1,19 @@ @page_title;noquote@ @context;noquote@ - + + + + #imsld.No# Index: openacs-4/packages/imsld/www/admin/imsld-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new.tcl,v diff -u -r1.8 -r1.8.2.1 --- openacs-4/packages/imsld/www/admin/imsld-new.tcl 30 May 2007 08:36:22 -0000 1.8 +++ openacs-4/packages/imsld/www/admin/imsld-new.tcl 24 Apr 2008 10:50:34 -0000 1.8.2.1 @@ -55,11 +55,13 @@ -elements { element_name { label "" - html {valign top style "background-color: #e0e0e0; font-weight: bold;"} + html {valign top} + class {element_title} } info { label "" - html {valign top style "background-color: #f0f0f0; font-weight: bold;"} + html {valign top} + class {element_value} } } Index: openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl 30 May 2007 08:36:22 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-role-add-members.tcl 24 Apr 2008 10:50:34 -0000 1.5.2.1 @@ -14,6 +14,9 @@ run_id } +set page_title "[_ imsld.Add_Members]" +set context "" + #only set required variables foreach user $user_id { Index: openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl,v diff -u -r1.7 -r1.7.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl 30 May 2007 08:36:22 -0000 1.7 +++ openacs-4/packages/imsld/www/admin/imsld-role-confirm.tcl 24 Apr 2008 10:50:34 -0000 1.7.2.1 @@ -30,17 +30,15 @@ } if { ![string eq "" $min_persons] && ([llength $members_list] < $min_persons)} { - set mensaje "

    Number of members does not reach the minimum allowed number of users for this role. - There must be at least $min_persons members.

    - Go back" + set mensaje "

    [_ imsld.lt_Number_of_members_doe]

    + [_ imsld.Go_back]" ad_return_complaint 1 $mensaje ad_script_abort } if {![string eq "" $max_persons] && ([llength $members_list] > $max_persons)} { - set mensaje "

    Number of members exceded the allowed number for this role. - You must not select more than $max_persons members.

    - Go back" + set mensaje "

    [_ imsld.lt_Number_of_members_exc]

    + [_ imsld.Go_back]" ad_return_complaint 1 $mensaje ad_script_abort } @@ -62,9 +60,9 @@ - set mensaje "

    Members $not_allowed_name are already members of other subroles of role $parent_role_name.

    -

    Current UoL does not allow to include them in more than one subroles of the role.

    - Go back" + set mensaje "

    [_ imsld.lt_Members_not_allowed_n]

    +

    [_ imsld.lt_Current_UoL_does_not_]

    + [_ imsld.Go_back]" ad_return_complaint 1 $mensaje ad_script_abort } Index: openacs-4/packages/imsld/www/admin/imsld-role-members.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.adp,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-members.adp 30 May 2007 08:36:22 -0000 1.6 +++ openacs-4/packages/imsld/www/admin/imsld-role-members.adp 24 Apr 2008 10:50:34 -0000 1.6.2.1 @@ -1,26 +1,26 @@ - - -

    @group_title@

    - -
      +
      +
      +

      @group_title@

      +
      +
      +
      • #imsld.lt_Max_number_of_student#
      • #imsld.lt_Min_number_of_student#
      • -
      - - +
    +
    + - - -

    #imsld.Not_members#

    - - - -

    #imsld.Group_members#

    - - - -
    - - +
    +
    +

    #imsld.Not_members#

    + +
    +
    +

    #imsld.Group_members#

    + +
    +
    + +
    +
    - Index: openacs-4/packages/imsld/www/admin/imsld-role-members.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.tcl,v diff -u -r1.10 -r1.10.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-members.tcl 30 May 2007 08:36:22 -0000 1.10 +++ openacs-4/packages/imsld/www/admin/imsld-role-members.tcl 24 Apr 2008 10:50:34 -0000 1.10.2.1 @@ -67,15 +67,14 @@ if {![db_0or1row get_group_name {}]} { - set group_name "No group selected" -# set create_instance_url [export_vars -base imsld-create-instance {{imsld_id $imsld_id} {role $role}}] + set group_name "[_ imsld.No_group_selected]" set create_instance_url imsld-create-instance - set bulk_actions "{Create new instance} $create_instance_url {Create a new instance of a role}" - set bulk_actions_not "{Create new instance} $create_instance_url {Create a new instance of a role}" + set bulk_actions "{Create new instance} $create_instance_url {Create a new instance of a role #>}" + set bulk_actions_not "{Create new instance} $create_instance_url {[_ imsld.lt_Create_a_new_instance]}" set bulk_action_export_vars "{imsld_id} {role} {run_id}" } else { - set bulk_actions "{<------} {imsld-role-remove-members} {Remove selected members from the group}" - set bulk_actions_not "{------->} {imsld-role-add-members} {Add selected members to the group}" + set bulk_actions "{<------} {imsld-role-remove-members} {[_ imsld.lt_Remove_selected_membe]}" + set bulk_actions_not "{------->} {imsld-role-add-members} {[_ imsld.lt_Add_selected_members_]}" set bulk_action_export_vars "{group_instance} {role} {imsld_id} {run_id} {members_list}" } @@ -96,11 +95,6 @@ -bulk_actions "$bulk_actions"\ -bulk_action_export_vars "$bulk_action_export_vars" -#set orderby [template::list::orderby_clause -orderby -name asign_members] -#if {[string equal $orderby ""]} { -# set orderby " order by username asc" -#} - template::list::create \ -name asign_not_members \ -multirow asign_not_members \ Index: openacs-4/packages/imsld/www/admin/imsld-role-members.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-members.xql,v diff -u -r1.5 -r1.5.6.1 --- openacs-4/packages/imsld/www/admin/imsld-role-members.xql 10 Jul 2006 13:45:29 -0000 1.5 +++ openacs-4/packages/imsld/www/admin/imsld-role-members.xql 24 Apr 2008 10:50:34 -0000 1.5.6.1 @@ -23,13 +23,11 @@ select aua.user_id from acs_users_all aua, - acs_rels ar, - imsld_run_users_group_ext r_map + acs_rels ar where aua.user_id > 0 and aua.user_id not in ([join $members_list ","]) and aua.user_id=ar.object_id_two - and ar.object_id_one = r_map.group_id - and r_map.run_id = :run_id + and ar.object_id_one = :community_id Index: openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/imsld-role-remove-members.adp 24 Apr 2008 10:50:34 -0000 1.3.2.1 @@ -1,3 +1,5 @@ + @page_title;noquote@ + @context;noquote@ @user_id@ Index: openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/imsld-role-remove-members.tcl 24 Apr 2008 10:50:34 -0000 1.4.2.1 @@ -1,4 +1,4 @@ -#/packages/imsld/www/admin/imsld-role-add-members.tcl +#/packages/imsld/www/admin/imsld-role-remove-members.tcl ad_page_contract { Remove members from an specified group @@ -13,6 +13,9 @@ imsld_id run_id } +set page_title "[_ imsld.Remove_Members]" +set context "" + #only set required variables set temp_list [list] foreach member $members_list { Index: openacs-4/packages/imsld/www/admin/imsld-view-roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-view-roles.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/imsld-view-roles.adp 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/imsld-view-roles.adp 24 Apr 2008 10:50:34 -0000 1.3.2.1 @@ -1,4 +1,6 @@ + @page_title;noquote@ + @context;noquote@ Index: openacs-4/packages/imsld/www/admin/imsld-view-roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-view-roles.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/imsld-view-roles.tcl 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/imsld-view-roles.tcl 24 Apr 2008 10:50:34 -0000 1.3.2.1 @@ -24,6 +24,8 @@ set roles_list [imsld::roles::get_list_of_roles -imsld_id $imsld_id] set roles_list_names [imsld::roles::get_roles_names -roles_list $roles_list] +set page_title "[_ imsld.View_Roles]" +set context "" set lista [list] lappend lista [list "[_ imsld.Select_a_role]" 0] Index: openacs-4/packages/imsld/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/index.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/index.adp 24 Apr 2008 10:50:34 -0000 1.4.2.1 @@ -1,12 +1,13 @@ @page_title;noquote@ @context;noquote@ + -

    +

    -

    #imsld.IMS-LDs_1#

    -
    +

    #imsld.IMS-LDs_1#

    +
    -

    #imsld.Runs#

    -
    +

    #imsld.Runs#

    +
    Index: openacs-4/packages/imsld/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.tcl,v diff -u -r1.16 -r1.16.2.1 --- openacs-4/packages/imsld/www/admin/index.tcl 30 May 2007 08:36:22 -0000 1.16 +++ openacs-4/packages/imsld/www/admin/index.tcl 24 Apr 2008 10:50:34 -0000 1.16.2.1 @@ -23,7 +23,12 @@ content::item::set_live_revision -revision_id [content::item::get_best_revision -item_id $set_imsld_id_live] } if { ![string eq "" $set_run_id_live] } { - db_dml make_run_live { *SQL* } + # if there are no users assigned to the run, we mark it as waiting, otherwise mark it active + if { ![llength [imsld::runtime::users_in_run -run_id $set_run_id_live]] } { + db_dml make_run_waiting { *SQL* } + } else { + db_dml make_run_live { *SQL* } + } } set package_id [ad_conn package_id] @@ -47,6 +52,7 @@ -name imslds \ -multirow imslds \ -key imsld_id \ + -pass_properties { return_url } \ -orderby_name imsld_orderby \ -orderby { default_value imsld_title } \ -elements { @@ -62,12 +68,19 @@ } create_run { label {} - display_template {@imslds.create_run;noquote@} + display_template { + [_ imsld.create_new_run] + } } delete { label {} sub_class narrow - display_template {@imslds.delete_template;noquote@} + display_template { + [_ imsld.Deleted] [_ imsld.Make_it_live] + + + [_ imsld.Delete] + } link_html { title "[_ imsld.Delete_IMS_LD]" } } } @@ -76,17 +89,8 @@ set cr_root_folder_id [imsld::cr::get_root_folder -community_id $community_id] -db_multirow -extend { delete_template create_run } imslds get_imslds { *SQL* } { +db_multirow -extend { delete_template create_run } imslds get_imslds { *SQL* } {} - if { [empty_string_p $live_revision] } { - set delete_template "[_ imsld.Deleted] [_ imsld.Make_it_live]" - set create_run "" - } else { - set delete_template "\"<\#_\">" - set create_run " [_ imsld.create_new_run] " - } -} - set imsld_package_id [site_node_apm_integration::get_child_package_id \ -package_id [dotlrn_community::get_package_id $community_id] \ -package_key "[imsld::package_key]"] @@ -95,6 +99,7 @@ template::list::create \ -name imsld_runs \ -multirow imsld_runs \ + -pass_properties { return_url } \ -key run_id \ -elements { imsld_title { @@ -115,13 +120,25 @@ orderby_desc {creation_date desc} } manage { - label "" - display_template {@imsld_runs.manage;noquote@} + label {} + display_template { + [_ imsld.View_members] | [_ imsld.Monitor] + + + + [_ imsld.Manage_Members] + + } } delete { label {} sub_class narrow - display_template {@imsld_runs.delete_template;noquote@} + display_template { + [_ imsld.Deleted] [_ imsld.Make_it_live] + + + [_ imsld.Delte] + } link_html { title "[_ imsld.Delete_Run]" } } } \ @@ -134,32 +151,22 @@ set cr_root_folder_id [imsld::cr::get_root_folder -community_id $community_id] db_multirow -extend { manage delete_template image_path image_alt image_title } imsld_runs get_runs { *SQL* } { - - set delete_template "\"[_" - switch $status { - deleted { - set delete_template "[_ imsld.Deleted] [_ imsld.Make_it_live]" - } active { - set delete_template "\"[_" set image_alt "[_ imsld.active]" set image_title "[_ imsld.active]" set image_path "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/active.png" - set manage "[_ imsld.View_members] | [_ imsld.Monitor]" } waiting { set image_alt "[_ imsld.waiting]" set image_title "[_ imsld.waiting]" set image_path "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/waiting.png" - set create_run " [_ imsld.create_new_run] " - set manage "[_ imsld.Manage_Members]" } stopped { set image_alt "[_ imsld.stopped]" set image_title "[_ imsld.stopped]" set image_path "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]/resources/completed.png" - set manage "[_ imsld.View_members] | [_ imsld.Monitor]" } } } + Index: openacs-4/packages/imsld/www/admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.xql,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/imsld/www/admin/index.xql 16 May 2006 09:24:36 -0000 1.2 +++ openacs-4/packages/imsld/www/admin/index.xql 24 Apr 2008 10:50:34 -0000 1.2.6.1 @@ -56,5 +56,15 @@ + + + + update imsld_runs + set status = 'waiting' + where run_id = :set_run_id_live + + + + Index: openacs-4/packages/imsld/www/admin/monitor/activity-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/activity-frame.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/monitor/activity-frame.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/monitor/activity-frame.adp 24 Apr 2008 10:50:35 -0000 1.4.2.1 @@ -1,39 +1,12 @@ - + @page_title;noquote@ @context;noquote@ + 1 - -#imsld.Hide# - - - -@list_header@ -

    - -
    - - +
    @frame_header@
    + +
    + +
    + +
    Index: openacs-4/packages/imsld/www/admin/monitor/activity-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/activity-frame.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/monitor/activity-frame.tcl 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/monitor/activity-frame.tcl 24 Apr 2008 10:50:35 -0000 1.3.2.1 @@ -23,15 +23,42 @@ set page_title "[_ imsld.lt_Monitoring_One_Activi]" set context [list] -set elements [list user_name \ +set elements [list portrait \ + [list label "" \ + display_template {No Portrait}] \ + user_name \ [list label "[_ imsld.Name]" \ - display_template {@related_users.user_name@}] \ + display_template {@related_users.user_name@}] \ email \ [list label "[_ imsld.Email]"]] if { [string eq $type "learning"] || [string eq $type "support"] || [string eq $type "structure"] } { + set frame_header "[_ imsld.lt_Users_who_have_starte] " + # status directly recorded in the status table, get the info - set list_header "[_ imsld.lt_Users_who_have_starte]" + if { [string eq $type "structure"] } { + db_1row activity_info { + select title as activity_title + from imsld_activity_structuresi + where structure_id = :activity_id + } + } elseif { [string eq $type "support"] } { + db_1row activity_info { + select title as activity_title + from imsld_support_activitiesi + where activity_id = :activity_id + } + } else { + db_1row activity_info { + select title as activity_title + from imsld_learning_activitiesi + where activity_id = :activity_id + } + } + append frame_header " \"$activity_title\"" + template::multirow create related_users user_id user_name email role start_date finish_date lappend elements start_date \ [list label "[_ imsld.Start_Date]"] @@ -104,18 +131,20 @@ foreach user $users_list { template::multirow append related_users [lindex $user 0] [lindex $user 1] [lindex $user 2] [lindex $user 3] [lindex $user 4] [lindex $user 5] } - } elseif { [string eq $type "learning_object"] } { - # the environment has been viwed (finished) if the user have seen the referenced resources - set list_header "[_ imsld.lt_Users_who_have_bviewe]" + # the environment has been viwed (finished) if the user have seen the + # referenced resources + set frame_header "[_ imsld.lt_Users_who_have_bviewe]" template::multirow create related_users user_name email user_id db_1row lo_info { select item_id as learning_object_item_id, - environment_id as environment_item_id + environment_id as environment_item_id, + title as lo_title from imsld_learning_objectsi where learning_object_id = :learning_object_id } + append frame_header " \"$lo_title\"" set item_list [db_list item_linear_list { select ii.imsld_item_id @@ -154,11 +183,12 @@ } } elseif { [string eq $type "service"] } { - # currently, we support there are three types of services: 1. conference, 2. monitory and 3. send-mail - # the first two types have resources associated whereas the last one doesn't and has to be treated as a separate case + # currently, we support there are three types of services: 1. conference, + # 2. monitory and 3. send-mail the first two types have resources + # associated whereas the last one doesn't and has to be treated as a + # separate case + set frame_header "[_ imsld.lt_Users_who_have_bat_le]" - set list_header "[_ imsld.lt_Users_who_have_bat_le]" - template::multirow create related_users user_name email user_id db_1row service_info { @@ -171,7 +201,7 @@ switch $service_type { conference { - append list_header "[_ imsld.conference]" + append frame_header " [_ imsld.conference]" db_1row conference_info { select conf.conference_id, conf.conference_type, @@ -183,6 +213,7 @@ and cr.item_id = conf.imsld_item_id and content_revision__is_live(cr.live_revision) = 't' } + append frame_header " \"$conf_title\"" set related_resources [db_list conf_resources_list { select cpr.resource_id @@ -208,7 +239,7 @@ template::multirow append related_users [person::name -person_id $user_id] [party::email -party_id $user_id] $user_id } } monitor { - append list_header "[_ imsld.monitor]" + append frame_header "[_ imsld.monitor]" db_1row monitor_info { select ims.title as monitor_service_title, ims.monitor_id, @@ -249,9 +280,9 @@ } send-mail { # 1. get the users associated to the run # 2. get the users IN the run who have sent a bulk-mail message - append list_header "[_ imsld.sendmail]" + append frame_header "[_ imsld.sendmail]" - append list_header "
    [_ imsld.lt_This_is_a_special_cas]" + append frame_header "
    [_ imsld.lt_This_is_a_special_cas]" db_foreach user_in_run { select gmm.member_id, Index: openacs-4/packages/imsld/www/admin/monitor/environment-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/environment-frame.adp,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/monitor/environment-frame.adp 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/monitor/environment-frame.adp 24 Apr 2008 10:50:35 -0000 1.3.2.1 @@ -1,36 +1,16 @@ - - - - - - - - - + + @page_title;noquote@ + @context;noquote@ + 1 -@environments;noquote@ +
    @frame_header@
    - + @environments;noquote@ - - - + Index: openacs-4/packages/imsld/www/admin/monitor/environment-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/environment-frame.tcl,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/imsld/www/admin/monitor/environment-frame.tcl 25 Apr 2007 10:52:31 -0000 1.2 +++ openacs-4/packages/imsld/www/admin/monitor/environment-frame.tcl 24 Apr 2008 10:50:35 -0000 1.2.6.1 @@ -9,36 +9,28 @@ run_id:integer,notnull } +set frame_header "[_ imsld.Context_info]" +set page_title $frame_header +set context [list] + dom createDocument ul doc set dom_root [$doc documentElement] -#set environments_node_ul [$doc createElement ul] -set environments_node_li [$doc createElement li] -set text [$doc createTextNode "[_ imsld.Context_info]"] -$environments_node_li appendChild $text -set environments_node [$doc createElement ul] -$environments_node setAttribute class "mktree" -$environments_node setAttribute style "white-space: nowrap;" +# Create the ul element which will hold all the environment info +$dom_root setAttribute class "mktree" +$dom_root setAttribute style "white-space: nowrap;" -# FIX-ME: if the ul is empty, the browser shows the ul incorrectly -set text [$doc createTextNode ""] -$environments_node appendChild $text - +# Create the li nodes for each environment set activity_item_id [content::revision::item_id -revision_id $activity_id] - imsld::monitor::activity_environments_tree -activity_item_id $activity_item_id \ -run_id $run_id \ - -dom_node $environments_node \ + -dom_node $dom_root \ -dom_doc $doc -$dom_root appendChild $environments_node_li -set environments_node_li [$doc createElement li] -$environments_node_li setAttribute class "liOpen" +# Set the result only if it is not empty +if { [$dom_root hasChildNodes]} { + # Set the result + set environments [$dom_root asXML] +} -$environments_node_li appendChild $environments_node -$dom_root appendChild $environments_node_li -set environments [$dom_root asXML] - -set page_title {} -set context [list] Index: openacs-4/packages/imsld/www/admin/monitor/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/index.adp,v diff -u -r1.2 -r1.2.6.1 --- openacs-4/packages/imsld/www/admin/monitor/index.adp 25 Apr 2007 10:52:31 -0000 1.2 +++ openacs-4/packages/imsld/www/admin/monitor/index.adp 24 Apr 2008 10:50:35 -0000 1.2.6.1 @@ -1,15 +1,16 @@ - + @course_name@ - - - - - - + + + + + + + Index: openacs-4/packages/imsld/www/admin/monitor/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/index.tcl,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/admin/monitor/index.tcl 21 Dec 2006 15:20:47 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/monitor/index.tcl 24 Apr 2008 10:50:35 -0000 1.1.6.1 @@ -14,4 +14,9 @@ } -errors { } -set course_name "" +set course_name "[db_string run_name { + select obj.title + from acs_objects obj, imsld_runs ir + where obj.object_id = ir.imsld_id + and ir.run_id = :run_id}]" + Index: openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.adp 24 Apr 2008 10:50:35 -0000 1.4.2.1 @@ -1,37 +1,25 @@ - + @page_title;noquote@ @context;noquote@ + 1 - -Hide - +
    + + + @frame_header;noquote@ +
    -#imsld.This# +
    -

    - - - - + +
    + +
    +
    Index: openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.tcl,v diff -u -r1.3 -r1.3.2.1 --- openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.tcl 30 May 2007 08:36:22 -0000 1.3 +++ openacs-4/packages/imsld/www/admin/monitor/individual-report-frame.tcl 24 Apr 2008 10:50:35 -0000 1.3.2.1 @@ -8,16 +8,57 @@ @creation-date Dic 2006 } -query { run_id:integer,notnull - member_id:integer,notnull + {member_id:integer ""} } set page_title "[_ imsld.Individual_Report]" set context [list] -set member_name [party::name -party_id $member_id] +set frame_header "[_ imsld.This]: " +# Fetch the users that are active in the run +set users_in_run [imsld::runtime::users_in_run -run_id $run_id] + +if { [llength $users_in_run] == 1 } { + set member_id [lindex $users_in_run 0] +} + +template::multirow create item_select item_id item_name + +set select_name "member_id" +set select_id "users_in_run" +set post_text "" +set selected_item "" +set select_string "" + +# If no member_id has been given, add the option pull-down menu +if { [string eq "" $member_id] } { + set select_string "[_ imsld.Select]" +} else { + # Set variable portrait_revision if user has portrait + if { [db_0or1row get_member_portrait { + select c.live_revision + from acs_rels a, cr_items c + where a.object_id_two = c.item_id + and a.object_id_one = :member_id + and a.rel_type = 'user_portrait_rel'}]} { + + set post_text "\"Portrait\"/" + } +} + +foreach user_id_in_run $users_in_run { + template::multirow append item_select $user_id_in_run \ + "[person::name -person_id $user_id_in_run]" + + if { $member_id == $user_id_in_run} { + set selected_item $member_id + } +} + set elements [list user_name \ [list label "[_ imsld.Activity_Name]" \ - display_template {@related_activities.activity_name@}] \ + display_template \ + {@related_activities.activity_name@}] \ type \ [list label "[_ imsld.Activity_Type]"] \ started_time \ @@ -44,20 +85,36 @@ # the elemen exists, replace the list element switch $status { started { - set activities_list [lreplace $activities_list [lsearch -regexp $activities_list $related_id] [lsearch -regexp $activities_list $related_id] \ - [list $related_id \ - [content::item::get_title -item_id [content::revision::item_id -revision_id $related_id]] \ - $type \ - $status_date \ - [lindex [lindex $activities_list [lsearch -regexp $activities_list $related_id]] 4]]] + set activities_list \ + [lreplace $activities_list \ + [lsearch -regexp $activities_list $related_id] \ + [lsearch -regexp $activities_list $related_id] \ + [list $related_id \ + [content::item::get_title \ + -item_id \ + [content::revision::item_id \ + -revision_id $related_id]] \ + $type \ + $status_date \ + [lindex [lindex $activities_list \ + [lsearch -regexp $activities_list \ + $related_id]] 4]]] } finished { - set activities_list [lreplace $activities_list [lsearch -regexp $activities_list $related_id] [lsearch -regexp $activities_list $related_id] \ - [list $related_id \ - [content::item::get_title -item_id [content::revision::item_id -revision_id $related_id]] \ - $type \ - [lindex [lindex $activities_list [lsearch -regexp $activities_list $related_id]] 3] \ - $status_date]] + set activities_list \ + [lreplace $activities_list \ + [lsearch -regexp $activities_list $related_id] \ + [lsearch -regexp $activities_list $related_id] \ + [list $related_id \ + [content::item::get_title \ + -item_id \ + [content::revision::item_id \ + -revision_id $related_id]] \ + $type \ + [lindex [lindex $activities_list \ + [lsearch -regexp $activities_list \ + $related_id]] 3] \ + $status_date]] } } } else { @@ -66,20 +123,24 @@ started { lappend activities_list \ [list $related_id \ - [content::item::get_title -item_id [content::revision::item_id -revision_id $related_id]] \ + [content::item::get_title \ + -item_id [content::revision::item_id \ + -revision_id $related_id]] \ $type \ $status_date \ {}] } finished { lappend activities_list \ [list $related_id \ - [content::item::get_title -item_id [content::revision::item_id -revision_id $related_id]] \ + [content::item::get_title \ + -item_id [content::revision::item_id \ + -revision_id $related_id]] \ $type \ {} \ $status_date] } - } + } } } @@ -93,4 +154,4 @@ -multirow related_activities \ -key related_id \ -no_data "[_ imsld.No_info_was_found]" \ - -elements $elements \ No newline at end of file + -elements $elements Index: openacs-4/packages/imsld/www/admin/monitor/monitor-tree.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/monitor-tree.adp,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/monitor/monitor-tree.adp 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/monitor/monitor-tree.adp 24 Apr 2008 10:50:35 -0000 1.4.2.1 @@ -1,80 +1,37 @@ - - - - - - + + @page_title;noquote@ + @context;noquote@ + 1 - - + +
    #imsld.Activities#
    + +
    - - - -#imsld.Exit# -
    -@properties_tree;noquote@ -@html_tree;noquote@ -@aux_html_tree;noquote@ - - - + - Index: openacs-4/packages/imsld/www/admin/monitor/monitor-tree.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/monitor-tree.tcl,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/imsld/www/admin/monitor/monitor-tree.tcl 30 May 2007 08:36:22 -0000 1.4 +++ openacs-4/packages/imsld/www/admin/monitor/monitor-tree.tcl 24 Apr 2008 10:50:35 -0000 1.4.2.1 @@ -12,7 +12,8 @@ set cr_root_folder_id [imsld::cr::get_root_folder -community_id $community_id] set user_id [ad_conn user_id] set imsld_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id $community_id] \ + -package_id [dotlrn_community::get_package_id \ + $community_id] \ -package_key "[imsld::package_key]"] set imsld_admin_url [export_vars -base "[lindex [site_node::get_url_from_object_id -object_id $imsld_package_id] 0]admin/"] @@ -31,12 +32,12 @@ from imsld_property_instances where run_id = :run_id or run_id is null + and content_revision__is_live(instance_id) = 't' }] } { # there is at least one property dom createDocument ul props_doc set props_dom_root [$props_doc documentElement] $props_dom_root setAttribute class "mktree" - $props_dom_root setAttribute style "white-space: nowrap;" set props_title_node [$props_doc createElement li] $props_title_node setAttribute class "liOpen" set text [$props_doc createTextNode "[_ imsld.Monitor_properties]"] @@ -55,10 +56,28 @@ set properties_tree "" } +# Create the link to the page to monitor user activity dom createDocument ul doc set dom_root [$doc documentElement] $dom_root setAttribute class "mktree" -$dom_root setAttribute style "white-space: nowrap;" + +set li_node [$doc createElement li] +$dom_root appendChild $li_node +$li_node setAttribute class "liBullet" + +set a_node [$doc createElement a] +$a_node setAttribute href \ + "[export_vars -base "individual-report-frame" -url {run_id}]" +$a_node setAttribute target "content" +$a_node appendChild [$doc createTextNode "[_ imsld.User_activity_reports]"] +$li_node appendChild $a_node + +set user_activity [$dom_root asXML] + +# Create the activity tree +dom createDocument ul doc +set dom_root [$doc documentElement] +$dom_root setAttribute class "mktree" set imsld_title_node [$doc createElement li] $imsld_title_node setAttribute class "liOpen" set text [$doc createTextNode "$imsld_title"] @@ -84,7 +103,6 @@ dom createDocument ul aux_doc set aux_dom_root [$aux_doc documentElement] $aux_dom_root setAttribute class "mktree" - $aux_dom_root setAttribute style "white-space: nowrap;" set aux_title_node [$aux_doc createElement li] $aux_title_node setAttribute class "liOpen" set text [$doc createTextNode "[_ imsld.Extra_Activities]"] Index: openacs-4/packages/imsld/www/admin/monitor/properties-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/properties-frame.tcl,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/admin/monitor/properties-frame.tcl 25 Apr 2007 10:52:31 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/monitor/properties-frame.tcl 24 Apr 2008 10:50:35 -0000 1.1.6.1 @@ -20,172 +20,108 @@ } } -# context info -db_1row context_info { - select ic.item_id as component_item_id, - ii.imsld_id, - rug.group_id as run_group_id - from imsld_componentsi ic, imsld_imsldsi ii, imsld_runs ir, imsld_run_users_group_ext rug - where ic.imsld_id = ii.item_id - and content_revision__is_live(ii.imsld_id) = 't' - and ii.imsld_id = ir.imsld_id - and rug.run_id = ir.run_id - and ir.run_id = :run_id -} - # Get file-storage root folder_id set fs_package_id [site_node_apm_integration::get_child_package_id \ -package_id [dotlrn_community::get_package_id [dotlrn_community::get_community_id]] \ -package_key "file-storage"] set root_folder_id [fs::get_root_folder -package_id $fs_package_id] -dom createDocument html dom_doc -set dom_root [$dom_doc documentElement] -set head_node [$dom_doc createElement head] -set link_node [$dom_doc createElement link] -$link_node setAttribute rel "stylesheet" -$link_node setAttribute type "text/css" -$link_node setAttribute href "/resources/acs-templating/lists.css" -$link_node setAttribute media "all" -$head_node appendChild $link_node - -set script_node [$dom_doc createElement script] -$script_node appendChild [$dom_doc createTextNode { - function confirmValue(myform){ - myform.submit() - } -}] - -$head_node appendChild $script_node -$dom_root appendChild $head_node - -set body_node [$dom_doc createElement body] - -# prepare final output... a little bit tedious to get it "pretty" -# using the default css of openacs - # if the property type is of type locpers or globpers # we first need to specify which user will be monitorized if { [string eq $type "locpers"] || [string eq $type "globpers"] } { - set form_node [$dom_doc createElement form] - $form_node setAttribute name "choose" - $form_node setAttribute action "" - set select_node [$dom_doc createElement select] - $select_node setAttribute name "user_id" - $select_node setAttribute id "users_in_run" - $select_node setAttribute onChange "confirmValue(this.form)" + # Fetch the users that are active in the run + set users_in_run [imsld::runtime::users_in_run -run_id $run_id] - if { [string eq "" $user_id] } { - set option_node [$dom_doc createElement option] - $option_node setAttribute value "select" - set text [$dom_doc createTextNode "[_ imsld.Select]"] - $option_node appendChild $text - $select_node appendChild $option_node + template::multirow create item_select item_id item_name + + # Add the frame main title depending on the type of property + if { [string eq $type "locpers"] } { + set frame_header "[_ imsld.lt_Local-personal_Prop]: " + } else { + set frame_header "[_ imsld.lt_Global-personal_Pro]: " } - foreach user_id_in_run [imsld::runtime::users_in_run -run_id $run_id] { - set option_node [$dom_doc createElement option] - $option_node setAttribute value $user_id_in_run - set text [$dom_doc createTextNode "[person::name -person_id $user_id_in_run]"] - $option_node appendChild $text + if { [llength $users_in_run] == 1 } { + set user_id [lindex $users_in_run 0] + } + set select_name "user_id" + set select_id "users_in_run" + set post_text "" + set selected_item "" + set select_string "" + + # If no user has been given, add the option pull-down menu + if { [string eq "" $user_id] } { + set select_string "[_ imsld.Select]" + } else { + # Set variable portrait_revision if user has portrait + if { [db_0or1row get_member_portrait { + select c.live_revision + from acs_rels a, cr_items c + where a.object_id_two = c.item_id + and a.object_id_one = :user_id + and a.rel_type = 'user_portrait_rel'}]} { + + set post_text "\"Portrait\"/" + } + } + + foreach user_id_in_run $users_in_run { + template::multirow append item_select $user_id_in_run \ + "[person::name -person_id $user_id_in_run]" + if { $user_id == $user_id_in_run} { - $option_node setAttribute selected "selected" + set selected_item $user_id } - $select_node appendChild $option_node } - $form_node appendChild $select_node +} elseif { [string eq $type "locrole"] } { + # first, the role instance must be selected + set role_instance_ids [imsld::roles::get_role_instances \ + -role_id $role_id \ + -run_id $run_id] - # adding hidden variables - set run_id_node [$dom_doc createElement "input"] - $run_id_node setAttribute name "run_id" - $run_id_node setAttribute type "hidden" - $run_id_node setAttribute value "$run_id" - $form_node appendChild $run_id_node + template::multirow create item_select item_id item_name - set type_node [$dom_doc createElement "input"] - $type_node setAttribute name "type" - $type_node setAttribute type "hidden" - $type_node setAttribute value "$type" - $form_node appendChild $type_node + set frame_header "[_ imsld.lt_Local-role_Properti]: " + set page_title $frame_header - # adding the submit button - set submit_node [$dom_doc createElement "input"] - $submit_node setAttribute type "submit" - $submit_node setAttribute value "ok" - $submit_node setAttribute name "ok" - $form_node appendChild $submit_node + if { [llength $role_instance_ids] == 1 } { + set role_instance_id [lindex $role_instance_ids 0] + set role_name "[db_string role_instance_name { select acs_group__name(:role_instance_id) }]" + } - # done... add the form to the document - $body_node appendChild $form_node + set select_name "role_instance_id" + set select_id "roles_in_run" + set post_text "" + set selected_item "" + set select_string "" -} elseif { [string eq $type "locrole"] } { - - # first, the role instance must be selected - - set form_node [$dom_doc createElement form] - $form_node setAttribute name "choose" - $form_node setAttribute action "" - set select_node [$dom_doc createElement select] - $select_node setAttribute name "role_instance_id" - $select_node setAttribute id "roles_in_run" - $select_node setAttribute onChange "confirmValue(this.form)" - if { [string eq "" $role_instance_id] } { - set option_node [$dom_doc createElement option] - $option_node setAttribute value "select" - set text [$dom_doc createTextNode "[_ imsld.Select_role]"] - $option_node appendChild $text - $select_node appendChild $option_node + set select_string "[_ imsld.Select_role]" } + + foreach role_instance_id_in_role $role_instance_ids { + template::multirow append item_select $role_instance_id_in_role \ + "[db_string role_instance_name {select + acs_group__name(:role_instance_id_in_role) }]" - foreach role_instance_id_in_role [imsld::roles::get_role_instances -role_id $role_id -run_id $run_id] { - set option_node [$dom_doc createElement option] - $option_node setAttribute value $role_instance_id_in_role - set text [$dom_doc createTextNode "[db_string role_instance_name { select acs_group__name(:role_instance_id_in_role) }]"] - $option_node appendChild $text - if { $role_instance_id == $role_instance_id_in_role } { - $option_node setAttribute selected "selected" + set selected_item $role_instance_id } - $select_node appendChild $option_node } - $form_node appendChild $select_node - # adding hidden variables - set run_id_node [$dom_doc createElement "input"] - $run_id_node setAttribute name "run_id" - $run_id_node setAttribute type "hidden" - $run_id_node setAttribute value "$run_id" - $form_node appendChild $run_id_node +} elseif { [string eq $type "glob"] } { + set frame_header "[_ imsld.Global_Properties]" +} elseif { [string eq $type "loc"] } { + set frame_header "[_ imsld.Local_Properties]" +} - set type_node [$dom_doc createElement "input"] - $type_node setAttribute name "type" - $type_node setAttribute type "hidden" - $type_node setAttribute value "$type" - $form_node appendChild $type_node - - set role_id_node [$dom_doc createElement "input"] - $role_id_node setAttribute name "role_id" - $role_id_node setAttribute type "hidden" - $role_id_node setAttribute value "$role_id" - $form_node appendChild $role_id_node - - # adding the submit button - set submit_node [$dom_doc createElement "input"] - $submit_node setAttribute type "submit" - $submit_node setAttribute value "ok" - $submit_node setAttribute name "ok" - $form_node appendChild $submit_node - - # done... add the form to the document - $body_node appendChild $form_node - -} - -set table_node [$dom_doc createElement table] -$table_node setAttribute class list +# Create the table with the properties +dom createDocument table dom_doc +set table_node [$dom_doc documentElement] +$table_node setAttribute class list-table $table_node setAttribute cellpadding 3 $table_node setAttribute cellspacing 1 @@ -230,7 +166,7 @@ prop.datatype, prop.item_id as property_item_id, coalesce(ins.value, prop.initial_value) as value, - ins.title, + coalesce(ins.title, ins.identifier) as title, ins.instance_id from imsld_property_instancesx ins, cr_revisions cr, @@ -239,6 +175,7 @@ and $where_clause and cr.revision_id = ins.instance_id and content_revision__is_live(ins.instance_id) = 't' + order by title " { # if the property is of type file, we must provide a file-upload field set input_text_node "" @@ -334,6 +271,21 @@ $owner_node setAttribute value "$user_id" $form_node appendChild $owner_node + if { ![string eq "" $role_instance_id] } { + set role_instance_node [$dom_doc createElement "input"] + $role_instance_node setAttribute name "role_instance_id" + $role_instance_node setAttribute type "hidden" + $role_instance_node setAttribute value "$role_instance_id" + $form_node appendChild $role_instance_node + } + + # adding hidden variables + set run_id_node [$dom_doc createElement "input"] + $run_id_node setAttribute name "run_id" + $run_id_node setAttribute type "hidden" + $run_id_node setAttribute value "$run_id" + $form_node appendChild $run_id_node + # adding return url set return_url_node [$dom_doc createElement "input"] $return_url_node setAttribute name "return_url" @@ -346,6 +298,7 @@ $submit_node setAttribute type "submit" $submit_node setAttribute value "ok" $form_node appendChild $submit_node + # done... add the form to the table set td_node [$dom_doc createElement td] $td_node setAttribute class list @@ -366,14 +319,13 @@ $table_node appendChild $tr_node } -$body_node appendChild $table_node -$dom_root appendChild $body_node +# Render table only if user_id or role_instance_id is set +if { ![string eq "" $user_id] || ![string eq "" $role_instance_id] + || [string eq $type "glob"] || [string eq $type "loc"]} { + set table_node [$table_node asXML] +} else { + set table_node "" +} -set script_node [$dom_doc createElement script] -$script_node appendChild [$dom_doc createTextNode {document.forms['choose'].elements['ok'].style.display="none"}] +set page_title $frame_header -$dom_root appendChild $script_node - -set xmloutput {} -append xmloutput [$dom_root asXML] -ns_return 200 text/html $xmloutput Index: openacs-4/packages/imsld/www/admin/monitor/run-info.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/run-info.adp,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/admin/monitor/run-info.adp 21 Dec 2006 15:20:47 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/monitor/run-info.adp 24 Apr 2008 10:50:35 -0000 1.1.6.1 @@ -1,29 +1,38 @@ - + - + - + - - - -

    #imsld.Runinfo_Name# @imsld_title@ #imsld._Assigned_users# @number_of_members@ #imsld._Creation_Date# @creation_date@ #imsld._Status_The_run_is# @status@ #imsld.since# @status_date@

    - + + + + +

    + #imsld.Runinfo_Name# + @imsld_title@ #imsld._Assigned_users# + @number_of_members@ #imsld._Creation_Date# + @creation_date@ #imsld._Status_The_run_is# + @status@ #imsld.since# + @status_date@ +

    + Index: openacs-4/packages/imsld/www/admin/monitor/run-info.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/monitor/run-info.tcl,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/admin/monitor/run-info.tcl 21 Dec 2006 15:20:47 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/monitor/run-info.tcl 24 Apr 2008 10:50:35 -0000 1.1.6.1 @@ -33,4 +33,4 @@ where iruge.run_id=:run_id and ar1.object_id_two=iruge.group_id and ar1.object_id_one=gmm.group_id -} \ No newline at end of file +} Index: openacs-4/packages/imsld/www/doc/resources/behavioral_model.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/doc/resources/behavioral_model.gif,v diff -u -r1.1.6.1 -r1.1.6.2 Binary files differ Index: openacs-4/packages/imsld/www/doc/resources/imsld_diagram_A.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/doc/resources/imsld_diagram_A.gif,v diff -u -r1.1.6.1 -r1.1.6.2 Binary files differ Index: openacs-4/packages/imsld/www/doc/resources/imsld_diagram_B.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/doc/resources/imsld_diagram_B.gif,v diff -u -r1.1.6.1 -r1.1.6.2 Binary files differ Index: openacs-4/packages/imsld/www/doc/resources/imsld_diagram_C.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/doc/resources/imsld_diagram_C.gif,v diff -u -r1.1.6.1 -r1.1.6.2 Binary files differ Index: openacs-4/packages/imsld/www/doc/resources/imsld_diagram_run_tables.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/doc/resources/imsld_diagram_run_tables.gif,v diff -u -r1.1.6.1 -r1.1.6.2 Binary files differ Index: openacs-4/packages/imsld/www/resources/tabber.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/resources/tabber.js,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/imsld/www/resources/tabber.js 5 Apr 2006 18:39:58 -0000 1.1 +++ openacs-4/packages/imsld/www/resources/tabber.js 24 Apr 2008 10:50:35 -0000 1.1.6.1 @@ -471,7 +471,6 @@ /* Run tabberAutomaticOnload() unless the "manualStartup" option was specified */ - if (typeof tabberOptions == 'undefined') { tabberAutomaticOnLoad(); @@ -482,4 +481,4 @@ tabberAutomaticOnLoad(tabberOptions); } -} +}