Index: openacs-4/packages/curriculum-central/tcl/stream-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/stream-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/curriculum-central/tcl/stream-procs.tcl 24 Nov 2005 23:14:36 -0000 1.2 +++ openacs-4/packages/curriculum-central/tcl/stream-procs.tcl 22 Jan 2006 08:43:15 -0000 1.3 @@ -30,3 +30,161 @@ # Return 1 if at least one stream has been created, otherwise 0. return [db_0or1row streams_exist {}] } + + +ad_proc curriculum_central::stream::years_get_options { + {-package_id ""} +} { + Returns a two-column list of years that a stream runs for. + + @param package_id ID of the current package instance. + + @return Returns a two-column list of registered school years. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + # Create an empty option that the user can select. The value of + # which is an empty string. + set empty_option [list [list [list [_ curriculum-central.none]] 0]] + set year_list [db_list_of_lists years {}] + + return [concat $empty_option $year_list] +} + + +ad_proc curriculum_central::stream::semesters_get_options { + {-package_id ""} +} { + Returns a two-column list of years that a stream runs for. + + @param package_id ID of the current package instance. + + @return Returns a two-column list of registered semesters. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + # Create an empty option that the user can select. The value of + # which is an empty string. + set empty_option [list [list [list [_ curriculum-central.none]] 0]] + set semester_list [db_list_of_lists semesters {}] + + return [concat $empty_option $semester_list] +} + + +ad_proc curriculum_central::stream::years_for_uos_get_options { + {-package_id ""} + {-stream_id:required} +} { + Returns a two-column list of years that a Unit of Study can be assigned to. + + @param package_id ID of the current package instance. + @param stream_id Stream ID to retrieve valid years for. + + @return Returns a two-column list of registered school years. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + # Create an empty option that the user can select. The value of + # which is an empty string. + set year_list [list [list [list [_ curriculum-central.none]] 0]] + + set year_ids [db_string year_ids {} -default ""] + + foreach year_id $year_ids { + set year_name [db_string year_name {} -default ""] + lappend year_list "[list $year_name] $year_id" + } + + return $year_list +} + + +ad_proc curriculum_central::stream::semesters_in_a_year_get_options { + {-package_id ""} + {-stream_id:required} +} { + Returns a two-column list of years that a stream runs for. + + @param package_id ID of the current package instance. + @param stream_id Stream ID to retrieve valid semesters for. + + @return Returns a two-column list of registered semesters. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + # Create an empty option that the user can select. The value of + # which is an empty string. + set semester_list [list [list [list [_ curriculum-central.none]] 0]] + + set semester_ids [db_string semester_ids {} -default ""] + + foreach semester_id $semester_ids { + set semester_name [db_string semester_name {} -default ""] + lappend semester_list "[list $semester_name] $semester_id" + } + + return $semester_list +} + + +ad_proc curriculum_central::stream::all_uos_except_get_options { + {-except_uos_id:required} + {-package_id ""} + {-empty_option:boolean} +} { + Returns a two-column list of the names of all UoS and their + corresponding UoS ID. + + @param package_id ID of the current package instance. + @param empty_option If empty_option flag is set to true, then an empty + option with name set to None, and the corresponding value set to 0 will + be added to the options list. This is useful for lists that allow a + none value to be selected. + + @return Returns a two-column list of all UoS. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + set uos_list [db_list_of_lists all_uos {}] + + # Create an empty option that the user can select.. + if {$empty_option_p} { + set empty [list [list [list [_ curriculum-central.none]] 0]] + return [concat $empty $uos_list] + } else { + return $uos_list + } +} + + +ad_proc curriculum_central::stream::non_mapped_uos { + {-stream_id:required} + {-package_id ""} +} { + Returns a two-column list of the names of all UoS and their + corresponding UoS ID that have not been mapped to the given + Stream ID. + + @param stream_id Stream ID. + @param package_id ID of the current package instance. + + @return Returns a two-column list of all UoS that have not been mapped to + the given Stream ID. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + return [db_list_of_lists non_mapped_uos {}] +}