timoh
committed
on 26 Sep 05
bugfixing
openacs-4/.../lors/lib/course-new.tcl (+45 -39)
1 1 ad_page_contract {
2 2     Includable form to create a new empty LORS course
3 3
4 4     @param package_id (optional) optional package to create the course under, probably lorsm or lors-central
5 5     @param folder_id root folder to store stuff in
6 6     @param return_url (defaults to ad_return_url)
7 7     @param return_url_base (if you want to redirect to return_url_base?man_id={man_id} use this
8 8 }
9 9
10 10 # ad_form requires man_id NOT to be set if its new
11 11
12 12 if {![info exists community_id]} {
13 13     set community_id [dotlrn_community::get_community_id]
14 14 }
15 15
16 16 if {![info exists package_id]} {
17 17     set package_id [ad_conn package_id]
18 18 }
19   ad_form -name course-new -export {return_url package_id folder_id} -form {
  19
  20 ad_form \
  21     -name course-new \
  22     -export {return_url package_id folder_id} \
  23     -form {
20 24         man_id:key
21       {name:text(text) {label "Course Name"} {size 50}}
22   } -new_data {
  25         {name:text(text)
  26             {label "Course Name"} {size 50}}
23 27
  28     } -new_data {
24 29         # FIXME only works with dotlrn, lame, should just create a lors
25 30         # folder as a child of the package_id of the manifest object
26 31
27 32         set new_parent_id [lors::cr::add_folder \
28 33                             -parent_id $folder_id \
29 34                             -folder_name $name]
30 35         set new_items_parent_id [lors::cr::add_folder \
31 36                                     -parent_id $folder_id \
32 37                                     -folder_name "${name}_items"]
33 38
34 39         lors::imscp::manifest_add \
35 40             -man_id $man_id \
36 41             -course_name $name \
37 42             -identifier [util_text_to_url -text $name] \
38 43             -hasmetadata f \
39 44             -isscorm f \
40 45             -package_id $package_id \
41 46             -community_id $community_id \
42 47             -folder_id $new_items_parent_id \
43 48             -content_folder_id $new_parent_id
44 49
45 50         lors::imscp::organization_add \
46 51             -man_id $man_id \
47 52             -identifier [util_text_to_url -text $name] \
48 53             -org_folder_id $new_items_parent_id
49 54
50 55         if {[info exists return_url_base] && $return_url_base ne ""} {
51 56             set return_url [export_vars -base $return_url_base {man_id}]
52 57         }
  58
53 59         if {![info exists return_url] || $return_url eq ""} {
54 60             set return_url [export_vars -base course-structure {man_id}]
55 61         }
56       ad_returnredirect -message "[_ lors.Course_created]" $return_url
57 62
  63         ad_returnredirect -message "[_ lors.Course_created]" $return_url
58 64     }