Index: openacs-4/packages/dotlrn/tcl/applets-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/applets-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/tcl/applets-procs.tcl 3 Oct 2001 01:56:56 -0000 1.1
@@ -0,0 +1,55 @@
+
+#
+# Procs for DOTLRN Class Management
+# Copyright 2001 OpenForce, inc.
+# Distributed under the GNU GPL v2
+#
+# October 1st, 2001
+#
+
+ad_library {
+ Procs to manage dotLRN Applets
+
+ @author ben@openforce.net
+ @creation-date 2001-10-01
+}
+
+namespace eval dotlrn_applet {
+
+ ad_proc -public register {
+ applet_key
+ } {
+ Register an applet.
+ } {
+ # Check if it's registered
+
+ # Add it
+ nsv_lappend dotlrn applets $applet_key
+ }
+
+ ad_proc -public deregister {
+ applet_key
+ } {
+ Deregister an applet. Not currently threadsafe!
+ } {
+ # If the array hasn't even been created! The Horror!
+ if {![nsv_exists dotlrn applets]} {
+ return
+ }
+
+ # Get the list, remove the element, reset the list
+ set current_list [nsv_get dotlrn applets]
+ set index [lsearch -exact $current_list $applet_key]
+ set new_list [lreplace $current_list $index $index]
+
+ nsv_set dotlrn applets $new_list
+ }
+
+ ad_proc -public list_applets {
+ } {
+ List all registered applets.
+ } {
+ return [nsv_get dotlrn applets]
+ }
+
+}
Index: openacs-4/packages/dotlrn/tcl/class-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/class-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn/tcl/class-procs.tcl 30 Sep 2001 20:08:47 -0000 1.2
+++ openacs-4/packages/dotlrn/tcl/class-procs.tcl 3 Oct 2001 01:56:56 -0000 1.3
@@ -36,7 +36,7 @@
db_transaction {
# Create a new group type for that class
- set one_class_group_type_key [group_type::new -group_type $group_type_name -supertype $top_group_type $pretty_name $pretty_name]
+ set class_group_type_key [group_type::new -group_type $group_type_name -supertype $top_group_type $pretty_name $pretty_name]
# Instantiate the DOTLRN Class Manager package at that node
set result [site_node_mount_application -return "package_id,node_id" $parent_node_id $name [package_key] $name]
@@ -48,7 +48,9 @@
ad_parameter -package_id $package_id -set 1 community_type_level_p
ad_parameter -package_id $package_id -set 0 community_level_p
- # Insert the community into the DB
+ # Insert the community
+ dotlrn_community::new_type $class_group_type_key dotlrn_class $pretty_name
+ dotlrn_community::set_type_site_node $class_group_type_key $node_id
# insert the class into the DB
db_dml insert_class {}
@@ -57,26 +59,27 @@
ad_proc -public new_instance {
+ class_type
class_name
term
year
} {
Creates a new instance of a class for a particular term and year,
and returns the class instance key.
} {
- set parent_node_id [db_string select_parent_node_id {}]
- set class_inst_key "$class_name-$term-$year"
+ set short_name "$class_type-$term-$year"
- # Create a group of the right group type
- template::form create add_group
- template::element create add_group group_name -value $class_inst_key
- template::element create add_group term -value $term
- template::element create add_group year -value $year
+ # Create the community
+ set community_id [dotlrn_community::new dotlrn_class $short_name $pretty_name]
- set group_id [group::new -form_id add_group $class_name]
+ # Insert the class instance
+ db_dml insert_class_instance {}
+ # Set up the node
+ set parent_node_id [db_string select_parent_node_id {}]
+
# Instantiate the right package at that site node, probably portals
- set result [site_node_mount_application -return "package_id,node_id" $parent_node_id $class_inst_key [one_class_package_key] $class_inst_key]
+ set result [site_node_mount_application -return "package_id,node_id" $parent_node_id $short_name [one_class_package_key] $short_name]
set package_id [lindex $result 0]
set node_id [lindex $result 1]
@@ -85,39 +88,26 @@
ad_parameter -package_id $package_id -set 0 class_level_p
ad_parameter -package_id $package_id -set 1 class_instance_level_p
- # Insert the class instance
- db_dml insert_class_instance {}
+ # Set up the node
+ dotlrn_community::set_site_node $community_id $node_id
# Assign proper permissions to the site node
# NOT CERTAIN what to do here yet
}
- ad_proc -public assign_role {
- class_instance_name
- rel_type
- user_id
+ ad_proc -public available_roles {
} {
- Assigns a user to a particular role for that class. Roles in DOTLRN can be student, prof, ta, admin
+ Returns the available roles
} {
- # Get the group_id
- set group_id [db_string select_group_id {}]
-
- # Do the right relationship mapping to assigne the role
- relation_add $rel_type $group_id $user_id
+ return {
+ {instructor_rel "Instructor"}
+ {ta_rel "Teaching Assistant"}
+ {student_rel "Student"}
+ {admin_rel "Administrator"}
+ }
}
-
- ad_proc -public add_applet {
- class_instance_name
- applet_name
- } {
- Adds an applet for a particular class
- } {
- # Create the site node for that applet
- # Instantiate the right package at the site node
- }
-
ad_proc -public package_key {
} {
Returns the package key for this package
Index: openacs-4/packages/dotlrn/tcl/class-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/class-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn/tcl/class-procs.xql 20 Sep 2001 18:29:35 -0000 1.1
+++ openacs-4/packages/dotlrn/tcl/class-procs.xql 3 Oct 2001 01:56:56 -0000 1.2
@@ -4,7 +4,7 @@
-insert into dotlrn_classes (class_key, node_id) values (:one_class_group_type_key, :node_id)
+insert into dotlrn_classes (class_key) values (:class_group_type_key)
@@ -17,16 +17,10 @@
insert into dotlrn_class_instances
- (class_instance_id, class_instance_key, class_key, node_id)
+ (class_instance_id, class_key)
values
- (:group_id, :class_inst_key, :class_name, :node_id)
+ (:community_id, :short_name)
-
-
-select class_instance_id from dotlrn_class_instances where class_instance_key= :class_instance_name
-
-
-
Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn/tcl/community-procs.tcl 30 Sep 2001 20:08:47 -0000 1.1
+++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 3 Oct 2001 01:56:56 -0000 1.2
@@ -47,10 +47,136 @@
community_type
name
pretty_name
+ {-description ""}
} {
create a new community
} {
-
+ # Create the group
+ set community_id [group::new -group_name $name $community_type]
+
+ # insert the community row
+ db_dml insert_community {}
+
+ return $community_id
}
+ ad_proc set_site_node {
+ community_id
+ node_id
+ } {
+ Update the node ID for the community
+ } {
+ # Exec the statement, easy
+ db_dml update_site_node {}
+ }
+
+
+ ad_proc set_attribute {
+ community_id
+ attribute_name
+ attribuate_value
+ } {
+ Set an attribute for a community
+ } {
+ # Not sure what to do here yet
+ }
+
+ ad_proc -public list_users {
+ community_id
+ } {
+ Returns the list of users with a membership_id, a user_id, first name, last name, email, and role
+ } {
+ return [db_list_of_lists select_users {}]
+ }
+
+ ad_proc -public add_user {
+ community_id
+ rel_type
+ user_id
+ } {
+ Assigns a user to a particular role for that class. Roles in DOTLRN can be student, prof, ta, admin
+ } {
+ # Set up the relationship
+ set rel_id [relation_add $rel_type $community_id $user_id]
+
+ # Set up a portal page for that user
+ # NPP call
+ set page_id []
+
+ # Insert the membership
+ db_dml insert_membership {}
+
+ # do the callbacks
+ applets_dispatch AddUser [list $community_id $user_id]
+ }
+
+ ad_proc -public remove_user {
+ community_id
+ user_id
+ } {
+ Removes a user from a class
+ } {
+ # Callbacks
+ applets_dispatch RemoveUser [list $community_id $user_id]
+
+ # Get the relationship ID
+ set rel_id [db_string select_rel_id {}]
+
+ # Remove the membership
+ db_dml delete_membership {}
+
+ # Remove it
+ relation_remove $rel_id
+ }
+
+ ad_proc -public get_page_id {
+ community_id
+ user_id
+ } {
+ Get the page ID for a particular community and user
+ } {
+ return [db_string select_page_id {}]
+ }
+
+ ad_proc -public add_applet {
+ community_id
+ applet_key
+ } {
+ Adds an applet to the community
+ } {
+ # Insert in the DB
+ db_dml insert_applet {}
+ }
+
+ ad_proc -public remove_applet {
+ community_id
+ applet_key
+ } {
+ Removes an applet from a community
+ } {
+ # Delete from the DB
+ db_dml delete_applet {}
+ }
+
+ ad_proc -public list_applets {
+ community_id
+ } {
+ Lists the applets associated with a community
+ } {
+ # List from the DB
+ return [db_list select_community_applets {}]
+ }
+
+ ad_proc -public applets_dispatch {
+ op
+ list_args
+ } {
+ Dispatch an operation to every applet
+ } {
+ foreach applet [list_applets] {
+ # Callback on applet
+ acs_sc_call dotlrn $op $list_args $applet
+ }
+ }
+
}