Index: openacs-4/packages/lors/lib/course-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-new.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/course-new.adp 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1 @@ + \ No newline at end of file Index: openacs-4/packages/lors/lib/course-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-new.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/course-new.tcl 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,52 @@ +ad_page_contract { + Includable form to create a new empty LORS course + + @param package_id (optional) optional package to create the course under, probably lorsm or lors-central + @param folder_id root folder to store stuff in + @param return_url (defaults to ad_return_url) +} + +if {![info exists community_id]} { + set community_id [dotlrn_community::get_community_id] +} + +if {![info exists package_id]} { + set package_id [ad_conn package_id] +} +ad_form -name course-new -export {return_url package_id folder_id} -form { + man_id:key + {name:text(text) {label "Course Name"} {size 50}} +} -new_data { + + # FIXME only works with dotlrn, lame, should just create a lors + # folder as a child of the package_id of the manifest object + + set new_parent_id [lors::cr::add_folder \ + -parent_id $folder_id \ + -folder_name $name] + set new_items_parent_id [lors::cr::add_folder \ + -parent_id $folder_id \ + -folder_name "${name}_items"] + + lors::imscp::manifest_add \ + -man_id $man_id \ + -course_name $name \ + -identifier [util_text_to_url -text $name] \ + -hasmetadata f \ + -isscorm f \ + -package_id $package_id \ + -community_id $community_id \ + -folder_id $new_items_parent_id \ + -content_folder_id $new_parent_id + + lors::imscp::organization_add \ + -man_id $man_id \ + -identifier [util_text_to_url -text $name] \ + -org_folder_id $new_items_parent_id + + if {![info exists return_url] || $return_url eq ""} { + set return_url [export_vars -base course-structure {man_id}] + } + ad_returnredirect -message "[_ lors Course_created]" $return_url + +} Index: openacs-4/packages/lors/lib/course-structure.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/course-structure.adp 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ #lorsm.Course_Information# +
+ #lorsm.Course_Name# + + @course_name;noquote@ +
+ #lorsm.Version# + + + @version_msg;noquote@ + + + @version;noquote@ Course Versions + +
+ #lorsm.Metadata# + + + + #lorsm.Yes# + + + #lorsm.Yes# + + + + #lorsm.No# + +
+ #lorsm.Identifier# + + @identifier@ +
+ #lorsm.Is_SCORM# + + #lorsm.lt_classlist_stylefont-w# + + + class="list" + + valign="top" align="left">@isscorm;noquote@ +
+ #lorsm.Storage_Folder# + + @instance@ +
+ #lorsm.Created_By# + + @created_by@ +
+ #lorsm.Date# + + @creation_date;noquote@ +
+ #lorsm.Submanifests# + + @submanifests@ +
+ #lorsm.Status# + + + #lorsm.Enabled# + + + #lorsm.Disabled# + +
+ #lorsm.Change# +
+
+ #lorsm.Trackable# + + + #lorsm.Yes# + + + #lorsm.No# + +
+ #lorsm.Change# +
+
+ #lorsm.Is_shared# + + + #lorsm.Shared# + + + #lorsm.Not_Shared# + +
+ #lorsm.Change# +
+
+ #lorsm.Course# + + @format_pretty_name@ +
+ #lorsm.Change# +
+
+ #lorsm.Organizations# +
+ +
+ + @orgs_list;noquote@ +
+ + + + Index: openacs-4/packages/lors/lib/course-structure.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/course-structure.tcl 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,142 @@ +# packages/lorsm/www/course_structure.tcl + +ad_page_contract { + + View Manifest Course Structure + + @author Ernie Ghiglione (ErnieG@mm.st) + @creation-date 2004-03-31 + @arch-tag 208f2801-d110-45d3-9401-d5eae1f72c93 + @cvs-id $Id: course-structure.tcl,v 1.1 2006/06/07 13:54:46 daveb Exp $ + + @param man_id manifest id of course +} +set package_id [ad_conn package_id] +set community_id [dotlrn_community::get_community_id] + +ad_proc -public getFolderKey { + {-object_id:required} +} { + Gets the Folderkey for a file-storage folder_id + + @option object_id Folder_id for file-storage folder + @author Ernie Ghiglione (ErnieG@mm.st) + +} { + return [db_string select_folder_key "select key from fs_folders where object_id = :object_id"] +} + +# set context & title +set context [list "[_ lorsm.Course_Structure]"] +set title "[_ lorsm.Course_Structure]" + + +if {[db_0or1row manifest { }]} { + + # Sets the variable for display. + set display 1 + + # Course Name + if {[empty_string_p $course_name]} { + set course_name "[_ lorsm.No_course_Name]" + } + + # Version + set version [db_string get_versions { } -default 0] + + if {[string equal $version "0"]} { + set version_msg "[_ lorsm.No_version_Available]" + } + + if { ![empty_string_p $fs_package_id] } { + # Folder + set folder [apm_package_url_from_id $fs_package_id]?[export_vars folder_id] + # Instance + set instance [apm_package_key_from_id $fs_package_id] + } else { + 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"] + # Instance + set instance [lorsm::get_course_name -manifest_id $man_id] + # Folder +# set root_folder [lorsm::get_root_folder_id] + +# set folder_id [db_string get_folder_id { }] + set folder [apm_package_url_from_id $fs_package_id]?[export_vars folder_id] + } + + # Created By + set created_by [person::name -person_id $creation_user] + + # Creation Date + set creation_date [lc_time_fmt $creation_date "%x %X"] + + # Check for submanifests + if {[db_0or1row submans { }]} { + } else { + set submanifests 0 + } + + +} else { + + set display 0 + +} + + +append orgs_list "" +append orgs_list " + + +" +db_foreach organizations { } { + + + set total_items [db_string items_count {select count(*) from ims_cp_items where org_id=:org_id} -default 0] + # We get the indent of the items in this org_id + set indent_list [lorsm::get_items_indent -org_id $org_id] + template::util::list_of_lists_to_array $indent_list indent_array + + append orgs_list "" + #"" } + { type "\#lorsm.Type\#" "no_sort" "" } + } + + set table_item [ad_table -Tmissing_text $missing_text -Textra_vars $table_extra_vars -Theader_row_extra "style=\"background-color: #e0e0e0; font-weight: bold;\" class=\"list-header\"" -Ttable_extra_html $table_extra_html blah { } $table_def] + + append orgs_list "$table_item" + + + append orgs_list "" + +} if_no_rows { + append orgs_list "" +} + +append orgs_list "
[_ lorsm.Items]
$org_title$hasmetadata" + + set indent [expr $indent +1] + set missing_text "[_ lorsm.Nothing_here]" + set return_url [export_vars -base [ns_conn url] man_id] + set table_extra_html { width="100%" } + set table_extra_vars {return_url indent_array lorsm_p} + set table_def { + { title "\#lorsm.Item_Name\#" "no_sort" " + [set indent \"\" + for { set i 0 } { $i < [expr $indent_array($item_id)-1]} { incr i } { + append indent \"      \" + } + if {$type eq \"webcontent\" && ![string equal $identifierref {}]} {set href \"$indent$item_title\"} else {set href \"$item_title\"}]$type
" + +set enabler_url [export_vars -base enabler {man_id}] +set tracker_url [export_vars -base tracker {man_id}] +set sharer_url [export_vars -base sharer {man_id folder_id return_url}] +set formater_url [export_vars -base formater {man_id return_url}] + +set add_type_options [list [list Assessment assessment] [list Wiki wiki]] +ad_form -name add-new -action object-new -export {man_id} -form { + {add_type:text(select) {label ""} {options $add_type_options}} + {add_new:text(submit) {label "#acs-kernel.common_Add#"}} +} \ No newline at end of file Index: openacs-4/packages/lors/lib/course-structure.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/course-structure.xql 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,171 @@ + + + + + + select + cp.man_id, + cp.course_name, + cp.identifier, + text 'Yes' as hello, + case + when hasmetadata = 't' then 'Yes' + else 'No' + end as man_metadata, + case + when isscorm = 't' then 'Yes' + else 'No' + end as isscorm, + cp.fs_package_id, + case + when fs_package_id is null then 'f' + else 't' + end as lorsm_p, + cp.folder_id, + cp.isshared, + acs.creation_user, + acs.creation_date, + acs.context_id, + cpmc.isenabled, + pf.format_pretty_name, + cpmc.istrackable + from + ims_cp_manifests cp, acs_objects acs, ims_cp_manifest_class cpmc, lorsm_course_presentation_formats pf + where + cp.man_id = acs.object_id + and cp.man_id = :man_id + and cp.man_id = cpmc.man_id + and cpmc.lorsm_instance_id = :package_id + and cp.parent_man_id = 0 + and cp.course_presentation_format = pf.format_id + + + + + + select + count(revision_id) + from + cr_revisions + where + item_id = ( + select + item_id + from + cr_revisions + where + revision_id = :man_id + ) + + + + + + select + item_id + from + cr_items + where + name = :instance and + parent_id = :root_folder + + + + + + select + count(*) as submanifests + from + ims_cp_manifests + where + man_id = :man_id + and + parent_man_id = :man_id + + + + + + + select + org.org_id, + org.org_title as org_title, + org.hasmetadata, + tree_level(o.tree_sortkey) as indent + from + ims_cp_organizations org, acs_objects o + where + org.org_id = o.object_id + and + man_id = :man_id + order by + org_id + + + + + + SELECT + o.object_id, + repeat(' ', (tree_level(o.tree_sortkey) - :indent)* 3) as indent, + i.ims_item_id as item_id, + i.item_title as item_title, + i.hasmetadata, + i.org_id, + case + when i.isshared = 'f' then ( + 'false' + ) + else 'true' + end as isshared, + r.href, + r.identifier as res_identifier, + case + when i.identifierref <> '' then r.href + else '' + end as identifierref, + case + when i.identifierref <> '' + then coalesce(ot.pretty_name,r.type) + else '' + end as type, + m.fs_package_id, + m.folder_id, + m.course_name + FROM + acs_objects o, ims_cp_items i, ims_cp_manifests m, + ims_cp_items_to_resources i2r,ims_cp_resources r left + join acs_object_types ot on r.type=ot.object_type + WHERE + o.object_type = 'ims_item_object' + AND + i.org_id = :org_id + AND + o.object_id = i.ims_item_id + AND r.res_id=i2r.res_id + AND i2r.ims_item_id=i.ims_item_id + AND + i.ims_item_id = ( + select + live_revision + from + cr_items + where + item_id = ( + select + item_id + from + cr_revisions + where + revision_id = i.ims_item_id + ) + ) + AND + m.man_id = :man_id + ORDER BY + o.tree_sortkey, o.object_id + + + + + \ No newline at end of file Index: openacs-4/packages/lors/lib/object-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/object-new.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/object-new.adp 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,4 @@ +

Add an existing @add_type@

+ +

or create a new @add_type@

+ \ No newline at end of file Index: openacs-4/packages/lors/lib/object-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/object-new.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/lib/object-new.tcl 7 Jun 2006 13:54:46 -0000 1.1 @@ -0,0 +1,149 @@ +ad_page_contract { + create a new lors object + @param man_id +} + + +switch $add_type { + assessment { + # get a list of assessment + set options [db_list_of_lists get_assessments "select o.title,a.assessment_id from as_assessments a, cr_items i, acs_objects o where o.object_id=a.assessment_id and i.latest_revision=a.assessment_id"] + } + wiki { + # get a list of all the wiki pages + # find xowiki package + array set xowiki_node [site_node::get_from_url -url /wiki] + + # get the folder_id + set folder_id [::xowiki::Page require_folder -package_id $xowiki_node(object_id) -name xowiki] + set options [list] + set order_clause "order by ci.name" + + db_foreach instance_select \ + [::xowiki::Page instance_select_query \ + -folder_id $folder_id \ + -with_subtypes t \ + -select_attributes [list title last_modified] \ + -order_clause $order_clause \ + ] { + lappend options [list $title $item_id] + } + } + +} + +set search_p 0 + +if {[llength options] > 10} { + set search_p 1 +} + +set return_url [export_vars -base course_structure {man_id}] + +# show available objects +set options [concat [list [list "-- Choose --" ""]] $options] + +ad_form -name choose -export {man_id add_type} -form { + {existing_object:text(select) {label "[_ acs-kernel.common_Add]"} {options $options}} +} -on_submit { + # FIXME pretend we can only have one organization per course + # this is fine since we are not supporting a user interface to + # create more than one way to organize the items in one manifest + set org_id [db_string get_org_id "select org_id from ims_cp_organizations where man_id=:man_id"] + set item_folder_id [db_string get_folder_id "select parent_id from cr_items where latest_revision=:org_id"] + switch $add_type { + assessment { + # we want one lors item per section + + + set sections [db_list_of_lists get_sections "select a.section_id,a.name,a.title from as_sectionsx a, as_assessment_section_map m where m.assessment_id=:existing_object and a.section_id=m.section_id"] + + foreach {section} $sections { + foreach {section_id section_name section_title} [lrange $section 0 2] {break} + + # make sure this section isn't already associated with this course + # we'll just let an admin add the assessment as many times + # as they like, if there a new sections they will get added + + if {![db_0or1row section_exists "select res_id from ims_cp_resources where identifier=:section_id and man_id=:man_id"]} { + set item_id [lors::imscp::item_add_from_object \ + -object_id $section_id \ + -org_id $org_id \ + -folder_id $item_folder_id \ + -title $section_title] + + # FIXME see if anyone is using this resource + # already. objects should be # able to be resources + # without being tied to one manifest, # since you can use + # a resource in more than one course and # it doesn't make + # sense to have a seperate row every time # we reuse an + # object + + set res_id [lors::imscp::resource_add_from_object \ + -man_id $man_id \ + -object_id $section_id \ + -folder_id $item_folder_id] + + lors::imscp::item_to_resource_add \ + -item_id $item_id \ + -res_id $res_id + } else { + # FIXME update the title of the ims_cp_item for display + # from the section title + } + } + } + wiki { + + set page [::Generic::CrItem instantiate \ + -item_id $existing_object] + $page instvar {title page_title} {name page_name} + if {![db_0or1row section_exists "select res_id from ims_cp_resources where identifier=:existing_object and man_id=:man_id"]} { + set item_id [lors::imscp::item_add_from_object \ + -object_id $existing_object \ + -org_id $org_id \ + -folder_id $item_folder_id \ + -title $page_title] + + # FIXME see if anyone is using this resource + # already. objects should be # able to be resources + # without being tied to one manifest, # since you can use + # a resource in more than one course and # it doesn't make + # sense to have a seperate row every time # we reuse an + # object + + set res_id [lors::imscp::resource_add_from_object \ + -man_id $man_id \ + -object_id $existing_object \ + -folder_id $item_folder_id] + + lors::imscp::item_to_resource_add \ + -item_id $item_id \ + -res_id $res_id + } else { + # FIXME update the title of the ims_cp_item for display + # from the section title + } + } + } +} + + +ad_form -name new -export {man_id add_type} -form { + {name:text(text) {label "Name"}} +} -on_submit { + switch $add_type { + wiki { + set url [export_vars -base /wiki/edit {name return_url}] + } + assessment { + set url [export_vars -base ../assessment/asm-admin/assessment-form { name return_url}] + } + } + ad_returnredirect $url + ad_script_abort +} + + + +