Index: openacs-4/packages/dotlrn-homework/dotlrn-homework.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/dotlrn-homework.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/dotlrn-homework.info 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,104 @@ + + + + + dotLRN Homework + dotLRN Homework + f + f + + + + oracle + postgresql + + Don Baccus + Provides a homework assignment dropboxes for dotLRN classes. + Furfly.net + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-applet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-applet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-applet-create.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,109 @@ + +-- +-- The dotlrn_homework applet for dotLRN +-- distributed under GPL v2.0 +-- +-- +-- Don Baccus (dhogaza2pacifier.com) +-- + + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'dotlrn_homework_applet' + ); + + -- add all the hooks + + -- GetPrettyName + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'GetPrettyName', + 'dotlrn_homework_applet::get_pretty_name', + 'TCL' + ); + + -- AddApplet + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddApplet', + 'dotlrn_homework_applet::add_applet', + 'TCL' + ); + + -- AddAppletToCommunity + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddAppletToCommunity', + 'dotlrn_homework_applet::add_applet_to_community', + 'TCL' + ); + + -- RemoveApplet + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'RemoveApplet', + 'dotlrn_homework_applet::remove_applet', + 'TCL' + ); + + -- AddUser + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddUser', + 'dotlrn_homework_applet::add_user', + 'TCL' + ); + + -- AddUserToCommunity + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddUserToCommunity', + 'dotlrn_homework_applet::add_user_to_community', + 'TCL' + ); + + -- RemoveUser + foo := acs_sc_impl.new_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'RemoveUser', + 'dotlrn_homework_applet::remove_user', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_homework_applet', + impl_operation_name => 'Clone', + impl_alias => 'dotlrn_homework_applet::clone', + impl_pl => 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_homework_applet', + impl_operation_name => 'ChangeEventHandler', + impl_alias => 'dotlrn_homework_applet::change_event_handler', + impl_pl => 'TCL' + ); + + -- Add the binding + acs_sc_binding.new ( + contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_homework_applet' + ); +end; +/ +show errors Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-applet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-applet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-applet-drop.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,87 @@ + +-- +-- Drop the dotlrn homework applet for dotLRN +-- distributed under GPL v2.0 +-- +-- +-- Don Baccus (dhogaza@pacifier.com) +-- +-- 2002-08-06 +-- + + +declare + foo integer; +begin + + -- drop all the hooks + + -- GetPrettyName + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'GetPrettyName' + ); + + -- AddApplet + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddApplet' + ); + + -- AddAppletToCommunity + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddAppletToCommunity' + ); + + -- RemoveApplet + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'RemoveApplet' + ); + + -- AddUser + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddUser' + ); + + -- AddUserToCommunity + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'AddUserToCommunity' + ); + + -- RemoveUser + foo := acs_sc_impl.delete_alias ( + 'dotlrn_applet', + 'dotlrn_homework_applet', + 'RemoveUser' + ); + + foo := acs_sc_impl.delete_alias ( + impl_contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_homework_applet', + impl_operation_name => 'ChangeEventHandler' + ); + + -- Add the binding + acs_sc_binding.delete ( + contract_name => 'dotlrn_applet', + impl_name => 'dotlrn_homework_applet' + ); + + -- create the implementation + foo := acs_sc_impl.delete ( + 'dotlrn_applet', + 'dotlrn_homework_applet' + ); +end; +/ +show errors Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-create.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,19 @@ +@dotlrn-homework-applet-create +@dotlrn-homework-portlet-create +@dotlrn-homework-notifications-create + +-- We'll use the content repository's built-in relationships on items to relate +-- a homework assignment to the correction or critique uploaded by a class +-- admin + +begin + content_type.register_relation_type ( + content_type => 'file_storage_object', + target_type => 'file_storage_object', + relation_tag => 'homework_correction', + min_n => 0, + max_n => 1 + ); +end; +/ +show errors; Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-drop.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,12 @@ +@dotlrn-homework-applet-drop +@dotlrn-homework-portlet-drop + +begin + content_type.unregister_relation_type ( + content_type => 'content_item', + target_type => 'content_item', + relation_tag => 'homework_correction' + ); +end; +/ +show errors; Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-notifications-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-notifications-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-notifications-create.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,123 @@ +-- Notifications Service Contract implementation for dotlrn-homework + +-- Don Baccus (dhogaza@pacifier.com) + +declare + impl_id integer; + v_foo integer; +begin + + -- the notification type impl + impl_id := acs_sc_impl.new ( + 'NotificationType', + 'homework_file_upload', + 'dotlrn-homework' + ); + + v_foo := acs_sc_impl.new_alias ( + 'NotificationType', + 'homework_file_upload', + 'GetURL', + 'dotlrn_homework::notification::get_homework_url', + 'TCL' + ); + + v_foo := acs_sc_impl.new_alias ( + 'NotificationType', + 'homework_file_upload', + 'ProcessReply', + 'dotlrn_homework::notification::process_homework_reply', + 'TCL' + ); + + acs_sc_binding.new ( + contract_name => 'NotificationType', + impl_name => 'homework_file_upload' + ); + + v_foo:= notification_type.new ( + short_name => 'homework_upload', + sc_impl_id => impl_id, + pretty_name => 'Homework', + description => 'Notification of Homework File Upload', + creation_user => NULL, + creation_ip => NULL + ); + + -- enable the various intervals and delivery methods + + -- we only support instant delivery of homework notifications + + -- it seems a bit odd that Open Force stepped outside the service contract + -- realm to do this. Why not do it in a PL/SQL init routine or something + -- like that and call it via service contract? + + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name = 'instant'; + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in ('email'); + + + -- the notification type impl + impl_id := acs_sc_impl.new ( + 'NotificationType', + 'correction_file_upload', + 'dotlrn-homework' + ); + + v_foo := acs_sc_impl.new_alias ( + 'NotificationType', + 'correction_file_upload', + 'GetURL', + 'dotlrn_homework::notification::get_correction_url', + 'TCL' + ); + + v_foo := acs_sc_impl.new_alias ( + 'NotificationType', + 'correction_file_upload', + 'ProcessReply', + 'dotlrn_homework::notification::process_correction_reply', + 'TCL' + ); + + acs_sc_binding.new ( + contract_name => 'NotificationType', + impl_name => 'correction_file_upload' + ); + + v_foo:= notification_type.new ( + short_name => 'correction_upload', + sc_impl_id => impl_id, + pretty_name => 'Comment File', + description => 'Notification of Comment File Upload', + creation_user => NULL, + creation_ip => NULL + ); + + -- enable the various intervals and delivery methods + + -- we only support instant delivery of homework notifications + + -- it seems a bit odd that Open Force stepped outside the service contract + -- realm to do this. Why not do it in a PL/SQL init routine or something + -- like that and call it via service contract? + + insert into notification_types_intervals + (type_id, interval_id) + select v_foo, interval_id + from notification_intervals where name = 'instant'; + + insert into notification_types_del_methods + (type_id, delivery_method_id) + select v_foo, delivery_method_id + from notification_delivery_methods where short_name in ('email'); + +end; +/ +show errors Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-notifications-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-notifications-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-notifications-drop.sql 17 Feb 2003 20:56:14 -0000 1.1 @@ -0,0 +1,79 @@ +declare + foo integer; +begin +-- Notifications Service Contract implementation for dotlrn-homework + +-- Don Baccus (dhogaza@pacifier.com) + +declare + impl_id integer; + v_foo integer; +begin + + select type_id into v_foo + from notification_types + where short_name = 'homework_upload'; + + notification_type.delete( + type_id => v_foo + ); + + v_foo := acs_sc_impl.delete_alias ( + 'NotificationType', + 'homework_file_upload', + 'GetURL' + ); + + v_foo := acs_sc_impl.delete_alias ( + 'NotificationType', + 'homework_file_upload', + 'ProcessReply' + ); + + acs_sc_binding.delete ( + contract_name => 'NotificationType', + impl_name => 'homework_file_upload' + ); + + + impl_id := acs_sc_impl.delete ( + 'NotificationType', + 'homework_file_type' + ); + + select type_id into v_foo + from notification_types + where short_name = 'correction_upload'; + + notification_type.delete( + type_id => v_foo + ); + + + v_foo := acs_sc_impl.delete_alias ( + 'NotificationType', + 'correction_file_upload', + 'GetURL' + ); + + v_foo := acs_sc_impl.delete_alias ( + 'NotificationType', + 'correction_file_upload', + 'ProcessReply' + ); + + acs_sc_binding.delete ( + contract_name => 'NotificationType', + impl_name => 'correction_file_upload' + ); + + + -- the notification type impl + impl_id := acs_sc_impl.delete ( + 'NotificationType', + 'correction_file_upload' + ); + +end; +/ +show errors Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-portlet-create.sql 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,366 @@ +-- +-- dotlrn-events/sql/oracle/dotlrn-events-portlet-create.sql +-- + +-- Creates dotlrn-homework user and admin portlets + +-- @author Don Baccus (dhogaza@pacifier.com) +-- @creation-date 2002-07-19 + +-- $Id: dotlrn-homework-portlet-create.sql,v 1.1 2003/02/17 20:56:15 donb Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +-- user portlet +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + ds_id := portal_datasource.new( + name => 'dotlrn_homework_portlet', + description => 'Displays dotLRN Events ' + ); + + -- the standard 4 params + + -- shadeable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 't' +); + + + -- hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_p', + value => 't' +); + + -- link_hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 't' +); + + -- user_editable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 't' +); + + -- shaded_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' +); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'folder_id', + value => '' + ); + + + -- dotlrn_homework-specific params + + -- The package_id of the package associated with this portal + -- serves as our instance key. + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' +); + +-- XXX community dotlrn_homeworks + +end; +/ +show errors + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'dotlrn_homework_portlet' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- add all the hooks + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'GetMyName', + 'dotlrn_homework_portlet::my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'GetPrettyName', + 'dotlrn_homework_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Link', + 'dotlrn_homework_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'AddSelfToPage', + 'dotlrn_homework_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Show', + 'dotlrn_homework_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Edit', + 'dotlrn_homework_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'RemoveSelfFromPage', + 'dotlrn_homework_portlet::remove_self_from_page', + 'TCL' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- Add the binding + acs_sc_binding.new ( + contract_name => 'portal_datasource', + impl_name => 'dotlrn_homework_portlet' + ); +end; +/ +show errors + +-- Create the admin portlet +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + ds_id := portal_datasource.new( + name => 'dotlrn_homework_admin_portlet', + description => 'dotLRN Homework Administration ' + ); + + + -- the standard 4 params + + -- shadeable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 't' +); + + + -- hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_p', + value => 't' +); + + -- link_hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 't' +); + + -- user_editable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 't' +); + + -- shaded_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' +); + + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'folder_id', + value => '' + ); + + + -- dotlrn_homework-specific params + + -- The package_id of the package associated with this portal + -- serves as our instance key. + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' +); + +end; +/ +show errors + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'dotlrn_homework_admin_portlet' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- add all the hooks + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'GetMyName', + 'dotlrn_homework_admin_portlet::my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'GetPrettyName', + 'dotlrn_homework_admin_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Link', + 'dotlrn_homework_admin_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'AddSelfToPage', + 'dotlrn_homework_admin_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Show', + 'dotlrn_homework_admin_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Edit', + 'dotlrn_homework_admin_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'RemoveSelfFromPage', + 'dotlrn_homework_admin_portlet::remove_self_from_page', + 'TCL' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- Add the binding + acs_sc_binding.new ( + contract_name => 'portal_datasource', + impl_name => 'dotlrn_homework_admin_portlet' + ); +end; +/ +show errors + Index: openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/sql/oracle/Attic/dotlrn-homework-portlet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/sql/oracle/dotlrn-homework-portlet-drop.sql 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,179 @@ + +-- Drops homework portlets + +-- @author Don Baccus (dhogaza@pacifier.com) +-- @creation-date 2002-07-19 + +-- $Id: dotlrn-homework-portlet-drop.sql,v 1.1 2003/02/17 20:56:15 donb Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'dotlrn_homework_portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + +end; +/ +show errors; + +declare + foo integer; +begin + + -- drop the hooks + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'GetMyName' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'GetPrettyName' + ); + + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Link' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'AddSelfToPage' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Show' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'Edit' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_portlet', + 'RemoveSelfFromPage' + ); + + -- Drop the binding + acs_sc_binding.delete ( + contract_name => 'portal_datasource', + impl_name => 'dotlrn_homework_portlet' + ); + + -- drop the impl + acs_sc_impl.delete ( + 'portal_datasource', + 'dotlrn_homework_portlet' + ); +end; +/ +show errors + +-- Drop admin portlet +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'dotlrn_homework_admin_portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + +end; +/ +show errors; + +declare + foo integer; +begin + + -- drop the hooks + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'GetMyName' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'GetPrettyName' + ); + + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Link' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'AddSelfToPage' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Show' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'Edit' + ); + + foo := acs_sc_impl.delete_alias ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet', + 'RemoveSelfFromPage' + ); + + -- Drop the binding + acs_sc_binding.delete ( + contract_name => 'portal_datasource', + impl_name => 'dotlrn_homework_admin_portlet' + ); + + -- drop the impl + acs_sc_impl.delete ( + 'portal_datasource', + 'dotlrn_homework_admin_portlet' + ); +end; +/ +show errors + Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.tcl 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,267 @@ +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_library { + + Procs to set up the dotLRN homework applet + + @author Don Baccus (dhogaza@pacifier.com) + +} + +namespace eval dotlrn_homework_applet { + + ad_proc -public applet_key { + } { + What's my key? + } { + return dotlrn_homework_applet + } + + ad_proc -public package_key { + } { + What package do I deal with? + } { + return dotlrn-homework + } + + ad_proc -public my_package_key { + } { + What's my package_key? + } { + return "dotlrn-homework" + } + + ad_proc -public get_pretty_name { + } { + returns the pretty name + } { + return "Homework" + } + + ad_proc -public add_applet { + } { + Used for one-time init - must be repeatable! + } { + dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] -package_key [package_key] + } + + ad_proc -public remove_applet { + } { + remove the applet from dotlrn + } { + ad_return_complaint 1 "[applet_key] remove_applet not implemented!" + } + + ad_proc -private create_homework_folder { + -community_id:required + -package_id:required + } { + + Helper proc for adding the homework applet to a community or cloning of an + existing community. This proc creates the target community's homework folder + and sets the proper permissions. + + @community_id The community we're creating the homefolder for + @package_id Our package id + + @return The new folder id + + } { + + set community_name [dotlrn_community::get_community_name $community_id] + set folder_id [fs::get_root_folder -package_id $package_id] + + fs::rename_folder -folder_id $folder_id -name "${community_name}'s Homework Folder" + + set node_id [site_node::get_node_id_from_object_id -object_id $package_id] + site_node_object_map::new -object_id $folder_id -node_id $node_id + + set party_id [acs_magic_object registered_users] + permission::revoke -party_id $party_id -object_id $folder_id -privilege read + permission::revoke -party_id $party_id -object_id $folder_id -privilege write + permission::revoke -party_id $party_id -object_id $folder_id -privilege admin + + set party_id [acs_magic_object the_public] + permission::revoke -party_id $party_id -object_id $folder_id -privilege read + permission::revoke -party_id $party_id -object_id $folder_id -privilege write + permission::revoke -party_id $party_id -object_id $folder_id -privilege admin + + # Set up permissions on the homework folder + # The homework folder is available only to community members + set members [dotlrn_community::get_rel_segment_id \ + -community_id $community_id \ + -rel_type dotlrn_member_rel \ + ] + + # Class members can read from and write to the folder. We'll manipulate direct + # perms on files in order to implement the special restrictions placed on members + # actions + + permission::grant -party_id $members -object_id $folder_id -privilege read + permission::grant -party_id $members -object_id $folder_id -privilege write + + # admins of this community can admin the folder + set admins [dotlrn_community::get_rel_segment_id \ + -community_id $community_id \ + -rel_type dotlrn_admin_rel \ + ] + permission::grant -party_id $admins -object_id $folder_id -privilege admin + + return $folder_id + } + + ad_proc -public add_applet_to_community { + community_id + } { + Add the homework applet to a specifc dotlrn community + } { + set portal_id [dotlrn_community::get_portal_id -community_id $community_id] + set package_id [dotlrn::instantiate_and_mount $community_id [package_key]] + + set folder_id [create_homework_folder -community_id $community_id -package_id $package_id] + + # add the portlet + + dotlrn_homework_portlet::add_self_to_page -portal_id $portal_id -package_id $package_id \ + -folder_id $folder_id -param_action overwrite + + # add the admin portlet + set admin_portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id] + dotlrn_homework_admin_portlet::add_self_to_page -portal_id $admin_portal_id -package_id $package_id \ + -folder_id $folder_id -param_action overwrite + + return $package_id + } + + ad_proc -public remove_applet_from_community { + community_id + } { + remove the fs applet from a specifc dotlrn community + } { + ad_return_complaint 1 "[applet_key] remove_applet_from_community not implemented!" + } + + ad_proc -public add_user { + user_id + } { + One time user-specfic init + } { + # no-op + } + + ad_proc -public remove_user { + user_id + } { + } { + # no-op + } + + ad_proc -public add_user_to_community { + community_id + user_id + } { + Add a user to a to a specifc dotlrn community + } { + # no-op + } + + ad_proc -public remove_user_from_community { + community_id + user_id + } { + Remove a user from a community + } { + # no-op + } + + ad_proc -public clone { + old_community_id + new_community_id + } { + + Clone this applet's content from the old community to the new one + + We just create the homework folder and portlets in the new community, + as requested by Sloan. + + @old_community_id The old (source) community + @new_community_id The new (destination) community + + @return The package id for the homework package mounted in the new community + } { + + # this code is copied from add_applet_to_community above + # they should be refactored together + + # get the old comm's root folder id + set old_package_id [dotlrn_community::get_applet_package_id -community_id $old_community_id -applet_key [applet_key]] + set old_root_folder [fs::get_root_folder -package_id $old_package_id] + + # do homework folder stuff + + set portal_id [dotlrn_community::get_portal_id -community_id $new_community_id] + set package_id [dotlrn::instantiate_and_mount $new_community_id [package_key]] + + set folder_id [create_homework_folder -community_id $new_community_id -package_id $package_id] + + # add the portlet + + dotlrn_homework_portlet::add_self_to_page -portal_id $portal_id -package_id $package_id \ + -folder_id $folder_id -param_action overwrite + + # add the admin portlet + set admin_portal_id [dotlrn_community::get_admin_portal_id -community_id $new_community_id] + dotlrn_homework_admin_portlet::add_self_to_page -portal_id $admin_portal_id -package_id $package_id \ + -folder_id $folder_id -param_action overwrite + + return $package_id + + } + + ad_proc -public get_package_id { + } { + returns the package_id of the dotlrn-homework package + } { + return [db_string select_package_id {}] + } + + ad_proc -public get_url { + } { + returns the URL for the dotlrn-homework package + } { + return [site_node::get_url_from_object_id -object_id [get_package_id]] + } + + ad_proc -public change_event_handler { + community_id + event + old_value + new_value + } { + dotlrn-homework listens only for rename + + @community_id The community experiencing an event + @event The event (rename) + @old_value The old community name being changed + @new_value The new community name + } { + switch $event { + rename { + fs::rename_folder -folder_id [fs::get_root_folder -package_id [get_package_id]] \ + -name "${new_value}'s Homework Folder" + } + } + } + +} Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-applet-procs.xql 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + + select min(package_id) + from apm_packages + where package_key = 'dotlrn-homework' + + + + + + Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-notifications.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-notifications.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-notifications.tcl 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,27 @@ +ad_library { + + dotlrn-homework notifications + + @creation-date 2002-07-24 + @author Don Baccus (dhogaza@pacifier.com) + @cvs-id $Id: dotlrn-homework-notifications.tcl,v 1.1 2003/02/17 20:56:15 donb Exp $ + +} + +namespace eval dotlrn_homework::notification { + + # We don't really use either of these at the moment though this might change + # in the future ... + + ad_proc -public get_url { + object_id + } { + + } + + ad_proc -public process_reply { + reply_id + } { + } + +} Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-portlet-procs.tcl 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,174 @@ +# This file is part of dotLRN. +# +# dotLRN is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +ad_library { + + Procedures to support the homework portlet + + @author Don Baccus (dhogaza@pacifier.com) + +} + +namespace eval dotlrn_homework_portlet { + + ad_proc -private my_package_key { + } { + return "dotlrn-homework" + } + + ad_proc -private get_my_name { + } { + return dotlrn_homework_portlet + } + + ad_proc -public get_pretty_name { + } { + return "Homework" + } + + ad_proc -public link { + } { + return "" + } + + ad_proc -public add_self_to_page { + {-portal_id:required} + {-page_name ""} + {-package_id:required} + {-folder_id:required} + {-param_action:required} + } { + Adds a homework PE to the given page. + + @param portal_id The page to add self to + @param folder_id The homework folder to associate with this portlet + @return element_id The new element's id + + } { + return [portal::add_element_parameters \ + -portal_id $portal_id \ + -page_name $page_name \ + -pretty_name [get_pretty_name] \ + -portlet_name [get_my_name] \ + -param_action $param_action \ + -value $folder_id \ + -key folder_id \ + -extra_params [list package_id $package_id] + ] + } + + ad_proc -public remove_self_from_page { + {-portal_id:required} + {-package_id:required} + {-folder_id:required} + } { + Removes a homework PE from the given page + } { + portal::remove_element_parameters \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value $folder_id \ + -key folder_id \ + -extra_params [list package_id $package_id] + } + + ad_proc -public show { + cf + } { + } { + + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "dotlrn-homework-portlet" + + } + +} + +namespace eval dotlrn_homework_admin_portlet { + + ad_proc -private my_package_key { + } { + return "dotlrn-homework" + } + + ad_proc -private get_my_name { + } { + return dotlrn_homework_admin_portlet + } + + ad_proc -public get_pretty_name { + } { + return "Homework Administration" + } + + ad_proc -public link { + } { + return "" + } + + ad_proc -public add_self_to_page { + {-portal_id:required} + {-page_name ""} + {-package_id:required} + {-folder_id:required} + {-param_action:required} + } { + Adds a homework PE to the given page. + + @param portal_id The page to add self to + @param folder_id The homework folder to associate with this portlet + @return element_id The new element's id + + } { + return [portal::add_element_parameters \ + -portal_id $portal_id \ + -page_name $page_name \ + -pretty_name [get_pretty_name] \ + -portlet_name [get_my_name] \ + -param_action $param_action \ + -value $folder_id \ + -key folder_id \ + -extra_params [list package_id $package_id] + ] + } + + ad_proc -public remove_self_from_page { + {-portal_id:required} + {-package_id:required} + {-folder_id:required} + } { + Removes a homework PE from the given page + } { + portal::remove_element_parameters \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value $folder_id \ + -key folder_id \ + -extra_params [list package_id $package_id] + } + + ad_proc -public show { + cf + } { + } { +ns_log Notice "Huh? show..." + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "dotlrn-homework-admin-portlet" + + } + +} Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-oracle.xql 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,92 @@ + + + +oracle8.1.6 + + + + + select 1 + from dual + where exists (select name + from cr_items + where parent_id = :parent_folder_id + and name = :title) + + + + + + + + begin + :1 := file_storage.new_file ( + item_id => :file_id, + title => :title, + folder_id => :parent_folder_id, + creation_user => :user_id, + creation_ip => :creation_ip, + indb_p => :indb_p + ); + end; + + + + + + + + + begin + :1 := file_storage.new_version ( + filename => :filename, + description => :description, + mime_type => :mime_type, + item_id => :file_id, + creation_user => :user_id, + creation_ip => :creation_ip + ); + end; + + + + + + + + update cr_revisions + set content = empty_blob() + where revision_id = :revision_id + returning content into :1 + + + + + + + + + update cr_revisions + set content_length = dbms_lob.getlength(content) + where revision_id = :revision_id + + + + + + + + + begin + :1 := content_item.relate( + item_id => :homework_file_id, + object_id => :correction_file_id, + relation_tag => 'homework_correction' + ); + end; + + + + + + Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs-postgresql.xql 17 Feb 2003 20:56:15 -0000 1.1 @@ -0,0 +1,99 @@ + + + +postgresql7.1 + + + + + select 1 + where exists (select name + from cr_items + where parent_id = :parent_folder_id + and name = :title) + + + + + + + + FIX ME PLSQL +FIX ME PLSQL + + begin + :1 := file_storage__new_file ( + item_id => :file_id, + title => :title, + folder_id => :parent_folder_id, + creation_user => :user_id, + creation_ip => :creation_ip, + indb_p => :indb_p + ); + end; + + + + + + + + FIX ME PLSQL +FIX ME PLSQL + + begin + :1 := file_storage__new_version ( + filename => :filename, + description => :description, + mime_type => :mime_type, + item_id => :file_id, + creation_user => :user_id, + creation_ip => :creation_ip + ); + end; + + + + + + + FIX ME LOB + + update cr_revisions + set content = empty_blob() + where revision_id = :revision_id + returning content into :1 + + + + + + + + + update cr_revisions + set content_length = dbms_lob__getlength(content) + where revision_id = :revision_id + + + + + + + + FIX ME PLSQL +FIX ME PLSQL + + begin + :1 := content_item__relate( + item_id => :homework_file_id, + object_id => :correction_file_id, + relation_tag => 'homework_correction' + ); + end; + + + + + + Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,288 @@ +ad_library { + + General purpose procedures used by the homework package + + @author Don Baccus (dhogaza@pacifier.com) + +} + +ad_proc dotlrn_homework_post_instantiation { + package_id +} { + + Post package instantiation procedure to insert a package_id, + folder_id pair in fs_root_folders. The homework package wants its own root folder + because we don't want it to be visible to any mounted instance of file storage. + + This proc is automatically called by the APM whenever an instance of dotlrn_homework + is mounted. + +} { + return [fs::new_root_folder -package_id $package_id] +} + +namespace eval dotlrn_homework { + + ad_proc -public encode_name { + -user_id:required + unencoded_name + } { + + Encode the user-supplied file name with the user's ID. We do this because the homework + folder hides files uploaded by other users and we want to avoid apparently mysterious duplicate + file name errors when two different users give their homework assignment the same name. + + } { + return "${user_id}_$unencoded_name" + } + + ad_proc -public decode_name { + encoded_name + } { + + Undo what encode_name does + + } { + if { [regexp {^([0-9]+)_(.*)} $encoded_name match user_id unencoded_name] } { + return $unencoded_name + } else { + return -code error "Name was not encoded" + } + } + + # Convenient Tcl procs for uploading file content vaguely based on code from the GPL'd work DRB + # did for Greenpeace International combined with code poached from file-storage. + + ad_proc -public new { + -file_id:required + -new_file_p:required + -parent_folder_id + -title + -description:required + -upload_file:required + -homework_file_id + } { + + Build a new content revision in the given folder. If new_file_p is set true then + a new item is first created, otherwise a new revision is created for the item indicated + by file_id. + + This code provides better double-click protection (old ACS 3.x style) than file-storage and + integrates nicely with ad_form. I couldn't use the standard file-storage pages without hacking + on them so decided it would be easiest to just write new ones. + + @param file_id The item to update or create. + @param new_file_p If true make a new item using file_id + @param title The title given the new revision + @param description The description of the new revision + @param upload_file The file structure passed us by the browser + @param homework_file_id If nonzero, this is a correction file to relate to homework_file_id + + } { + + set user_id [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + + set filename [template::util::file::get_property filename $upload_file] + set tmp_filename [template::util::file::get_property tmp_filename $upload_file] + + # The content repository is kinda stupid about mime types, + # so we have to check if we know about this one and possibly + # add it. + set mime_type [fs_maybe_create_new_mime_type $filename] + + # Get the storage type + set indb_p [ad_decode [ad_parameter "StoreFilesInDatabaseP" -package_id [ad_conn package_id]] 1 "t" "f"] + + if { $new_file_p } { + + if { $homework_file_id > 0 } { + db_1row get_owner_id {} + } else { + set homework_user_id $user_id + } + + set title [encode_name -user_id $homework_user_id $title] + + if { [db_0or1row check_duplicate {}]} { + return -code error "A file named \"$title\" already exists in this folder" + } + + db_exec_plsql new_lob_file {} + + # The file storage package more or less sucks as the API makes unnecessary assumptions about + # the desired permissions. I'd like to fix that in 4.6 but don't really want to tread on + # OF's toes by making more last-minute changes to the OpenACS 4 CVS tip. + + # This hack will leave the site-wide admin able to munge user homework files. That's probably + # a good thing ... + + db_dml update_context {} + + set admins [dotlrn_community::get_rel_segment_id \ + -community_id [dotlrn_community::get_community_id] \ + -rel_type dotlrn_admin_rel] + + # admins of this community can read the file + permission::grant -party_id $admins -object_id $file_id -privilege read + + if { $homework_file_id == 0 } { + + # The student uploading a homework file can read and edit it + permission::grant -party_id $user_id -object_id $file_id -privilege write + permission::grant -party_id $user_id -object_id $file_id -privilege read + + } else { + + # A correction file. Relate it to the homework file. + add_correction_relation -homework_file_id $homework_file_id -correction_file_id $file_id + + # And let the homework file's owner read it. + permission::grant -party_id $homework_user_id -object_id $file_id -privilege read + + # All admins can upload a correction file + permission::grant -party_id $admins -object_id $file_id -privilege write + + } + + } + + # Grab key for new revision + set revision_id [db_exec_plsql new_version {}] + + # A community admin can delete their own comment file revision + if { $homework_file_id > 0 } { + permission::grant -party_id $user_id -object_id $revision_id -privilege delete + } + + if { [string is true $indb_p] } { + + db_dml lob_content {} -blob_files [list $tmp_filename] + + # Unfortunately, we can only calculate the file size after the lob is uploaded + db_dml lob_size {} + + } else { + + set tmp_filename [cr_create_content_file $file_id $revision_id $tmp_filename] + set tmp_size [cr_file_size $tmp_filename] + + db_dml fs_content_size {} + + } + + return $revision_id + + } + + ad_proc -public get_file_storage_url { + } { + + Return the URL of our sibling file-storage package + + } { + + # The proc I need to do this went missing after an Open Force CVS update so for now we'll + # just guarantee that file-storage is mounted under dotlrn and run with it. + + site_node::get -url "/dotlrn/file-storage" + return "/dotlrn/file-storage" + + } + + ad_proc -public add_correction_relation { + -homework_file_id:required + -correction_file_id:required + } { + + Add a correction file to a homework file, using the Content Repository's handy-dandy, + built-in item relations facility. + + } { + db_exec_plsql relate {} + } + + ad_proc -public send_homework_alerts { + -folder_id:required + -file_id:required + } { + + Send any alerts triggered by uploading a homework file + + } { + + # Forums build HTML but then slam it out as text. We should probably build + # text and convert to HTML later and include http: links as the text to html + # routine in text-html-procs turns these into links automatically. + + # For now we'll just build vanilla text + + db_1row get_alert_info {} + + set message " + +A file named \"[decode_name $name]\" has been uploaded to the folder \"$folder_name\" by +\"$student_name\". + +" + notification::new -type_id [notification::type::get_type_id -short_name homework_upload] \ + -object_id $folder_id -response_id $folder_id -notif_subject "Homework upload alert" \ + -notif_text $message + + } + + ad_proc -public send_correction_alerts { + -homework_file_id:required + -folder_id:required + } { + + Send any alerts triggered by uploading a correction file + + } { + + set user_id [ad_conn user_id] + + db_1row get_alert_info {} + + set message " + +$admin_name has uploaded comments to your homework file named \"[decode_name $name]\" in the +homework folder \"$folder_name\". + +" + notification::new -type_id [notification::type::get_type_id -short_name correction_upload] \ + -object_id $homework_file_id -response_id $homework_file_id -notif_subject "Correction file alert" \ + -notif_text $message + + } + + ad_proc -public request_correction_alert { + -homework_file_id:required + } { + + Set an alert for the user on our recently uploaded homework file + + } { + + set type_id [notification::type::get_type_id -short_name correction_upload] + + set intervals [notification::get_intervals -type_id $type_id] + set delivery_methods [notification::get_delivery_methods -type_id $type_id] + + # Sanity check to make sure the db entries are set up correctly. + + if { [llength $intervals] != 1 || [llength $delivery_methods] != 1 } { + return -code error "Internal error: interval or delivery method for homework notifications broken" + } + + # The get routines return a list of name/id pairs so extract the ids + set interval_id [lindex [lindex $intervals 0] 1] + set delivery_method_id [lindex [lindex $delivery_methods 0] 1] + + # Add the alert + notification::request::new -type_id $type_id -user_id [ad_conn user_id] -object_id $homework_file_id \ + -interval_id $interval_id -delivery_method_id $delivery_method_id + + } + +} Index: openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/tcl/dotlrn-homework-procs.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,62 @@ + + + + + + select creation_user as homework_user_id from acs_objects where object_id = :homework_file_id + + + + + + + + update acs_objects + set context_id = null + where object_id = :file_id + + + + + + + + + update cr_revisions + set content = :tmp_filename, + content_length = :tmp_size + where revision_id = :revision_id + + + + + + + + + select f.name, folder.label as folder_name, + u.first_names || ' ' || u.last_name as student_name + from cr_items f, cr_folders folder, cc_users u, acs_objects o + where f.item_id = :file_id + and o.object_id = :file_id + and folder.folder_id = :folder_id + and u.user_id = o.creation_user + + + + + + + + + select f.name, folder.label as folder_name, + u.first_names || ' ' || u.last_name as admin_name + from cr_items f, cr_folders folder, cc_users u + where item_id = :homework_file_id + and folder.folder_id = :folder_id + and u.user_id = :user_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.adp 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,16 @@ + +
+
+ + + Index: openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/dotlrn-homework-admin-portlet.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,51 @@ +ad_page_contract { + + The display logic for the homework portlet. + + @author Don Baccus (dhogaza@pacifier.com) + +} -properties { + shaded_p:onevalue + toggle_url:onevalue + subscribe_p:onevalue + request_id:onevalue + type_id:onevalue + return_url:onevalue +} + +set community_id [dotlrn_community::get_community_id] +dotlrn::require_user_admin_community -community_id $community_id + +array set config $cf +set list_of_folder_ids $config(folder_id) +set shaded_p $config(shaded_p) +set package_id $config(package_id) + +set n_folders [llength $list_of_folder_ids] + +if {$n_folders != 1} { + # something went wrong, we can't have more than one folder here + ad_return -error +} +set folder_id [lindex $list_of_folder_ids 0] + +# No need to do any more work if the shade's pulled up +if { $shaded_p } { + ad_return_template + return +} + +set return_url "[ad_conn url]?[ad_conn query]" + +# Get the type_id for homework file notifications +set type_id [notification::type::get_type_id -short_name homework_upload] + +# Check to see if our admin has already asked for alerts on this folder +set request_id [notification::request::get_request_id -object_id $folder_id -user_id [ad_conn user_id] -type_id $type_id] + +set subscribe_p [expr {[string equal "" $request_id]}] + +set url [site_node::get_url_from_object_id -object_id $package_id] +set toggle_url "${url}toggle-homework-alert?[export_vars {folder_id subscribe_p request_id type_id return_url}]" + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.adp 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,7 @@ + +
+
+ + + Index: openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/dotlrn-homework-portlet.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,53 @@ +ad_page_contract { + + The display logic for the homework portlet. + + @author Don Baccus (dhogaza@pacifier.com) + +} -properties { + list_of_file_ids:onevalue + package_id:onevalue + admin_p:onevalue + show_upload_url_p:onevalue + admin_actions_p:onevalue +} + +array set config $cf +set list_of_folder_ids $config(folder_id) +set shaded_p $config(shaded_p) +set package_id $config(package_id) + +set n_folders [llength $list_of_folder_ids] + +if {$n_folders != 1} { + # something went wrong, we can't have more than one folder here + ad_return -error +} +set folder_id [lindex $list_of_folder_ids 0] + +# Make sure our visitor can read the folder. +if { ![permission::permission_p -object_id $folder_id -privilege "read"] } { + ad_return -error +} + +# No need to do any more work if the shade's pulled up +if { $shaded_p } { + ad_return_template + return +} + +set community_id [dotlrn_community::get_community_id] +set admin_p [permission::permission_p -object_id $folder_id -privilege "admin"] +set show_upload_url_p [expr {!$admin_p && [permission::permission_p -object_id $folder_id -privilege "write"]}] +set admin_actions_p 0 + +set min_level 1 +if { $admin_p } { + # Admin view is limited to the folder name due to the fact that the admin can see every + # student's files + set max_level 1 +} else { + set max_level 2 +} + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/file-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-add.adp 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,5 @@ + +Submit New Assignment File +@context_bar@ + + Index: openacs-4/packages/dotlrn-homework/www/file-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-add.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,93 @@ +ad_page_contract { + + Upload a new homework assignment. + + Don Baccus (dhogaza@pacifier.com) + +} { + folder_id:naturalnum,notnull + name:optional + return_url:notnull + {homework_file_id:naturalnum,notnull 0} +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ad_complain "The specified parent folder is not valid." + } + } +} -properties { + context_bar:onevalue + page_title:onevalue +} + +# check for write permission on the folder +ad_require_permission $folder_id write + +# Homework_file_id tells us whether or not we're uploading a correction file to relate +# to an existing homework file, or a new home work file + +if { $homework_file_id == 0 } { + set page_title "Submit New Assignment File" + set context_bar {"Upload New Assignment"} +} else { + set page_title "Submit Comments" + set context_bar {"Upload Comments"} +} + +ad_form -name homework_form -html { enctype multipart/form-data } -export { return_url folder_id homework_file_id } -form { + file_id:key + {upload_file:file {label "Version filename"}} + {-section "Use the \"Browse...\" button to locate your file, then click \"Open\"

 "} +} + +if { $homework_file_id == 0 } { + ad_form -extend -name homework_form -form { + {name:text {label "Title"} + {html {size 30}}} + } +} else { + ad_form -extend -name homework_form -export { name } -form {} +} + +ad_form -extend -name homework_form -form { + + {description:text(textarea),optional {label "Description"} + {html {rows 5 cols 50 wrap physical}}} +} -validate { + {upload_file + { [file size [template::util::file::get_property tmp_filename $upload_file]] <= [ad_parameter "MaximumFileSize"] } + "Your file is larger than the maximum file size allowed on this system ([util_commify_number [ad_parameter MaximumFileSize]] bytes)" + } +} -new_data { + + db_transaction { + + dotlrn_homework::new -file_id $file_id -new_file_p 1 -parent_folder_id $folder_id -title $name \ + -description $description -upload_file $upload_file -homework_file_id $homework_file_id + + # Alert management. Semantics are hardwired to Sloan's spec. Eventually it would probably be nice + # to make 'em configurable for non-admin users as they are now for admin users + + if { $homework_file_id == 0 } { + + # We're uploading a new homework file, send alerts associated with our folder + dotlrn_homework::send_homework_alerts -folder_id $folder_id -file_id $file_id + + # Now set an alert for our student so they'll get pinged when a correction file is uploaded + dotlrn_homework::request_correction_alert -homework_file_id $file_id + + } else { + + # We're uploading a correction file, send alerts associated with the related homework file + dotlrn_homework::send_correction_alerts -folder_id $folder_id -homework_file_id $homework_file_id + + } + + } on_error { + ad_return_exception_template -params {errmsg} "/packages/acs-subsite/www/shared/db-error" + } + + ad_returnredirect $return_url +} + +ad_return_template "homework-form" Index: openacs-4/packages/dotlrn-homework/www/file-copy-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy-2-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy-2-oracle.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,36 @@ + + + + oracle8.1.6 + + + + + begin + :1 := file_storage.copy_file( + file_id => :correction_file_id, + target_folder_id => :parent_id, + creation_user => :user_id, + creation_ip => :ip_address + ); + end; + + + + + + + + begin + :1 := file_storage.copy_file( + file_id => :file_id, + target_folder_id => :parent_id, + creation_user => :user_id, + creation_ip => :ip_address + ); + end; + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-copy-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy-2-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy-2-postgresql.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,34 @@ + + + + postgresql7.1 + + + + + select file_storage__copy_file ( + :correction_file_id, -- correction_file_id + :parent_id, -- taget_folder_id + :user_id, -- creation_user + :ip_address -- creation_ip + ); + + + + + + + + select file_storage__copy_file ( + :file_id, -- file_id + :parent_id, -- taget_folder_id + :user_id, -- creation_user + :ip_address -- creation_ip + ); + + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-copy-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy-2.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,82 @@ +ad_page_contract { + script to copy a file into a new folder + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 14 Nov 2000 + @cvs-id $Id: file-copy-2.tcl,v 1.1 2003/02/17 20:56:16 donb Exp $ +} { + file_id:integer,notnull + parent_id:integer,notnull +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } + + valid_folder -requires {parent_id} { + if ![fs_folder_p $parent_id] { + ad_complain "The specified parent folder is not valid." + } + } +} + +# check for read permission on the file and write permission on the +# target folder + +ad_require_permission $file_id read +ad_require_permission $parent_id write + +set user_id [ad_conn user_id] +set ip_address [ad_conn peeraddr] + +# Question - do we copy revisions or not? +# Current Answer - we copy the live revision only + +db_transaction { + + set correction_file_id [db_string correction_file_id {} -default ""] + + # file_copy returns the new revision id, not the new file id, so we need to retrieve + # the new homework and correction file ids. + + # DRB: Note for future reference - copy_file does not work for content stored in the + # filesystem rather than db. + + set new_homework_revision_id [db_exec_plsql file_copy {}] + db_1row get_new_homework_info {} + + # See dotlrn_homework::new for comments about file-storage's generally lame handling of + # permissions. + + db_dml update_homework_context {} + + permission::grant -party_id $user_id -object_id $new_homework_id -privilege write + permission::grant -party_id $user_id -object_id $new_homework_id -privilege read + + # Copy the comment/correction file if any + if { ![string equal $correction_file_id ""] } { + + set new_correction_revision_id [db_exec_plsql correction_file_copy {}] + + db_1row get_new_correction_info {} + + dotlrn_homework::add_correction_relation -homework_file_id $new_homework_id -correction_file_id $new_correction_id + + db_dml update_correction_context {} + + # I'm assuming the user is making their own copy of the homework and correction file for their + # own use and that they don't want the TA or Prof messing around with it. As opposed to move + # which is presumably used to put stuff in the right place after having first putting stuff in + # the wrong place. + + permission::grant -party_id $user_id -object_id $new_correction_id -privilege read + + } + +} on_error { + ad_return_complaint 1 "The folder you selected already contains a file with the same name. " + return +} + +ad_returnredirect "folder-contents?folder_id=$parent_id" Index: openacs-4/packages/dotlrn-homework/www/file-copy-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy-2.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,83 @@ + + + + + + + select related_object_id as correction_file_id + from cr_item_rels + where item_id = :file_id + and relation_tag = 'homework_correction' + + + + + + + + select name, content_type from cr_items where item_id = :file_id + + + + + + + + select item_id as new_homework_id + from cr_revisions + where revision_id = :new_homework_revision_id + + + + + + + + select item_id as new_correction_id + from cr_revisions + where revision_id = :new_correction_revision_id + + + + + + + + update acs_objects + set security_inherit_p = 'f' + where object_id = :new_homework_id + + + + + + + + update acs_objects + set security_inherit_p = 'f' + where object_id = :new_correction_id + + + + + + + + update acs_objects + set context_id = null + where object_id = :new_homework_id + + + + + + + + update acs_objects + set context_id = null + where object_id = :new_correction_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-copy.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy.adp 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,13 @@ + +Copy +@context_bar@ + +

Select the folder that you would like to copy "@file_name@" to + +

+ + + +

+ +

Index: openacs-4/packages/dotlrn-homework/www/file-copy.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,31 @@ +ad_page_contract { + page to select a new folder to copy a file to + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 14 Nov 2000 + @cvs-id $Id: file-copy.tcl,v 1.1 2003/02/17 20:56:16 donb Exp $ +} { + file_id:integer,notnull +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } +} -properties { + file_id:onevalue + file_name:onevalue + context_bar:onevalue +} + +# check for read permission on the file + +ad_require_permission $file_id read + +# set templating datasources + +set file_name [dotlrn_homework::decode_name [db_string file_name {}]] + +set context_bar {"Copy"} + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/file-copy.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-copy.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-copy.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,14 @@ + + + + + + + select name as title + from cr_items + where item_id = :file_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-delete-oracle.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,28 @@ + + + + oracle8.1.6 + + + + + select count(*) + from cr_revisions + where item_id = :file_id + and acs_permission.permission_p(revision_id,:user_id,'delete') = 'f' + + + + + + + + begin + file_storage.delete_file(:file_id); + end; + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-delete-postgresql.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,25 @@ + + + + postgresql7.1 + + + + + select count(*) + from cr_revisions + where item_id = :file_id + and acs_permission__permission_p(revision_id,:user_id,'delete') = 'f' + + + + + + + + select file_storage__delete_file(:file_id); + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-delete.adp 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,26 @@ + +Delete @title@ +@context_bar@ + + + +

This file has versions that you do not have permission to delete, +so you cannot delete the file. + + + + +

+ + + +

Are you sure you want to delete the file "@title@" and all of +its versions? This action cannot be reversed. + +

+

+ +
+
+ + Index: openacs-4/packages/dotlrn-homework/www/file-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-delete.tcl 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,74 @@ +ad_page_contract { + page to confirm and delete a file + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 10 Nov 2000 + @cvs-id $Id: file-delete.tcl,v 1.1 2003/02/17 20:56:18 donb Exp $ +} { + file_id:integer,notnull + {confirmed_p "f"} +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } +} -properties { + file_id:onevalue + file_name:onevalue + blocked_p:onevalue + context_bar:onevalue +} + +# check for delete permission on the file + +ad_require_permission $file_id delete + +# check the file doesn't have any revisions that the user +# doesn't have permission to delete + +set user_id [ad_conn user_id] + +set blocked_p [ad_decode [db_string blockers " +select count(*) +from cr_revisions +where item_id = :file_id +and acs_permission.permission_p(revision_id,:user_id,'delete') = 'f'"] 0 f t] + +if {[string equal $confirmed_p "t"] && [string equal $blocked_p "f"] } { + # they confirmed that they want to delete the file + + db_1row parent_id "select parent_id from cr_items where item_id = :file_id" + + db_transaction { + + # DRB: damned permissions table has no "on delete cascade" and file storage + # delete assumes there are perms on the revision itself. This code breaks + # the permissions abstraction but some day, 4.7 perhaps, we'll have proper + # referential integrity operators in at least some of the datamodel + + db_dml version_perms_delete {} + + db_exec_plsql delete_file " + begin + file_storage.delete_file(:file_id); + end;" + + } + + ad_returnredirect "folder-contents?folder_id=$parent_id" + +} else { + # they need to confirm that they really want to delete the file + + db_1row file_name " + select name as title + from cr_items + where item_id = :file_id" + + set title [dotlrn_homework::decode_name $title] + + set context_bar {"Delete"} + + ad_return_template +} Index: openacs-4/packages/dotlrn-homework/www/file-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-delete.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + + + select parent_id from cr_items where item_id = :file_id + + + + + + + + delete from acs_permissions + where object_id in (select revision_id + from cr_revisions + where item_id = :file_id) + + + + + + + + select name as title + from cr_items + where item_id = :file_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-move-2-oracle.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,33 @@ + + + + oracle8.1.6 + + + + + begin + file_storage.move_file ( + file_id => :file_id, + target_folder_id => :parent_id + ); + end; + + + + + + + + begin + file_storage.move_file ( + file_id => :correction_file_id, + target_folder_id => :parent_id + ); + end; + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-move-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-move-2.tcl 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,49 @@ +ad_page_contract { + script to move a file into a new folder + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 13 Nov 2000 + @cvs-id $Id: file-move-2.tcl,v 1.1 2003/02/17 20:56:16 donb Exp $ +} { + file_id:integer,notnull + parent_id:integer,notnull +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } + + valid_folder -requires {parent_id} { + if ![fs_folder_p $parent_id] { + ad_complain "The specified parent folder is not valid." + } + } +} + +# check for write permission on both the file and the target folder + +ad_require_permission $file_id write +ad_require_permission $parent_id write + +db_transaction { + + set correction_file_id [db_string correction_file_id {} -default ""] + + db_exec_plsql file_move {} + db_dml context_update {} + + if { ![string equal $correction_file_id ""] } { + db_exec_plsql correction_file_move {} + db_dml correction_context_update {} + } + +} on_error { + + ad_return_exception_template -params {errmsg} "/packages/acs-subsite/www/shared/db-error" + return + +} + +ad_returnredirect "folder-contents?folder_id=$parent_id" + Index: openacs-4/packages/dotlrn-homework/www/file-move-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-move-2.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,57 @@ + + + + + + + select related_object_id as correction_file_id + from cr_item_rels + where item_id = :file_id + and relation_tag = 'homework_correction' + + + + + + + + update acs_objects + set context_id = null + where object_id = :file_id + + + + + + + + update acs_objects + set context_id = null + where object_id = :correction_file_id + + + + + + + + + select name from cr_items where item_id = :file_id + + + + + + + + + select count(*) + from cr_items + where name = :filename + and parent_id = :parent_id + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-move.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-move.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,13 @@ + +Move +@context_bar@ + +

Select the folder that you would like to move "@name@" under + +

+ + + +

+ +

Index: openacs-4/packages/dotlrn-homework/www/file-move.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-move.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-move.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,32 @@ +ad_page_contract { + page to select a new folder to move a file into (Actually, this should + work to move folders too) + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 13 Nov 2000 + @cvs-id $Id: file-move.tcl,v 1.1 2003/02/17 20:56:17 donb Exp $ +} { + file_id:integer,notnull + name:notnull +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } +} -properties { + file_id:onevalue + name:onevalue + context_bar:onevalue +} + +# check they have write permission on the file (is this really the +# right permission?) + +ad_require_permission $file_id write +set context_bar "Move" +set return_url "[ad_conn url]?[ad_conn query]" + +ad_return_template + + Index: openacs-4/packages/dotlrn-homework/www/file-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-oracle.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,56 @@ + + + + oracle8.1.6 + + + + select person.name(o.creation_user) as owner, + i.name, + acs_permission.permission_p(:file_id, :user_id, 'write') as write_file_p, + acs_permission.permission_p(:file_id, :user_id, 'delete') as delete_file_p, + decode(cir.item_id, null, 'f', 't') as correction_file_p + from acs_objects o, cr_revisions r, cr_items i, cr_item_rels cir + where o.object_id = :file_id + and i.item_id = o.object_id + and r.revision_id = i.live_revision + and cir.related_object_id(+) = i.item_id + + + + + + + select r.title, + r.revision_id as version_id, + person.name(o.creation_user) as author, + r.mime_type as type, + to_char(o.last_modified,'YYYY-MM-DD HH24:MI') as last_modified, + r.description, + r.content_length as content_size, + acs_permission.permission_p(r.revision_id, :user_id, 'delete') as delete_p + from acs_objects o, cr_revisions r, cr_items i + where o.object_id = r.revision_id + and r.item_id = i.item_id + and r.item_id = :file_id + $show_versions + + + + + + + + + + + + + + and r.revision_id = i.live_revision + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file-postgresql.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,55 @@ + + + + postgresql7.1 + + + + + select person__name(o.creation_user) as owner, + i.name as title, + r.title as name, + acs_permission__permission_p(:file_id,:user_id,'write') as write_p + from acs_objects o, cr_revisions r, cr_items i + where o.object_id = :file_id + and i.item_id = o.object_id + and r.revision_id = i.live_revision + + + + + + + select r.title, + r.revision_id as version_id, + person__name(o.creation_user) as author, + r.mime_type as type, + to_char(o.last_modified,'YYYY-MM-DD HH24:MI') as last_modified, + r.description, + r.content_length as content_size + from acs_objects o, cr_revisions r, cr_items i + where o.object_id = r.revision_id + and r.item_id = i.item_id + and r.item_id = :file_id + $show_versions + + + + + + + + + + + + + + and r.revision_id = i.live_revision + + + + + + + Index: openacs-4/packages/dotlrn-homework/www/file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,63 @@ + +@name@ +@context_bar@ + +

+ [ + Show only live version + + + Show all versions + + + | Upload a new version + + | Move + + + + | Delete this file (including all versions) + ] +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ All Versions of "@name@" + Live version of "@name@" +
Version filenameAuthorSize (bytes)TypeModifiedVersion Notes + + Action + +
+ @version.title@ + @version.author@@version.content_size@@version.type@@version.last_modified@@version.description@ + +   + delete + +
Index: openacs-4/packages/dotlrn-homework/www/file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/file.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/file.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,71 @@ +ad_page_contract { + + Display information about a homework file. Based on the template in + file-storage. Unfortunately the semantics defined for user actions on + homework files and our desire for consistent navigation make it impossible + to just call the file-storage version directly. + + I've also cleaned things up a bit ... + + @author Don Baccus (dhogaza@pacifier.com) + +} { + file_id:integer,notnull + folder_id:integer,notnull + {show_all_versions_p "f"} +} -validate { + valid_file -requires {file_id} { + if ![fs_file_p $file_id] { + ad_complain "The specified file is not valid." + } + } +} -properties { + title:onevalue + name:onevalue + owner:onevalue + version:multirow + show_all_versions_p:onevalue + context_bar:onevalue + file_path:onevalue + version_add_url:onevalue + move_url:onevalue + correction_file_p:onevalue + folder_id:onevalue +} + +# check that they have read permission on this file. + +ad_require_permission $file_id read + +#set templating datasources + +set user_id [ad_conn user_id] +set context_bar {"One Assignment"} +set return_url "[ad_conn url]?[ad_conn query]" + +db_1row file_info {} +set name [dotlrn_homework::decode_name $name] +set version_add_url "version-add?[export_vars {return_url folder_id file_id name}]" +set move_url "file-move?[export_vars {file_id name}]" + +# DRB: I'm setting this up but think copy in the homework context is a bad +# idea so I'm not putting out a link to it. As of July Sloan agrees. +set copy_url "file-copy?[export_vars {file_id name}]" + +if {[string equal $show_all_versions_p "t"]} { + set show_versions [db_map show_all_versions] +} else { + set show_versions [db_map show_live_version] +} + +set file_storage_url [dotlrn_homework::get_file_storage_url] + +set action_exists_p 0 +db_multirow -extend {download_url} version version_info {} { + set download_url "${file_storage_url}/download/index?[export_vars {version_id}]" + if { [string is true $delete_p] } { + set action_exists_p 1 + } +} + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk-oracle.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,42 @@ + + + +oracle8.1.6 + + + + select + o.object_id, + nvl(f.label, fs_tree.name) as name, + fs_tree.live_revision as version_id, + fs_tree.content_type, + r.content_length, + fs_tree.parent_id as folder_id, + content_item.get_path(o.object_id) as item_path, + lpad(' ',(the_level - 1), ' ') as spaces, + rels.related_object_id as homework_file_id, + c.first_names || ' ' || c.last_name as file_owner_name, + o.creation_user + from cr_item_rels rels, acs_objects o, cr_revisions r, cr_folders f, cc_users c, + (select cr_items.*, level as the_level + from cr_items + where level >= :min_level and level <= :max_level + start with item_id in ([join $list_of_folder_ids ", "]) + connect by parent_id = prior item_id) fs_tree + where o.object_id = fs_tree.item_id + and c.user_id(+) = o.creation_user + and f.folder_id(+) = fs_tree.item_id + $qualify_by_owner + and r.item_id(+) = fs_tree.item_id + and r.content_length(+) = fs_tree.item_id + and rels.item_id(+) = o.object_id + and rels.relation_tag(+) = 'homework_correction' + and not exists (select 1 + from cr_item_rels + where related_object_id = o.object_id + and relation_tag = 'homework_correction') + order by item_path + + + + Index: openacs-4/packages/dotlrn-homework/www/folder-chunk.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,82 @@ + + + [ + + + | + + @toolbar.label@ + + ] + +

+
+ + + Folder is empty + + + + + <% + # This wording was provided by Sloan/MIT. Other users will probably want to modify + # it. + %> + +

There are two ways to comment on students' files: 1) upload a separate/new file or + 2) make comments directly in the student's file. For #1, upload your file from this page. + For #2, first download/open and save the file to your computer. When finished, save the + file and then return to the Homework folder and upload your comments. +

TAs and professors can upload different versions of comments from the Details page + and can use the Version notes text box to differentiate between comments files. +

For more information, read the Admin FAQ on the class Control Panel page or refer + to the Handbook. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 TitleStudentAction
@folders.spaces@@folders.name@@folders.spaces@@folders.pretty_name@ + + @folders.file_owner_name@ + + + Details + + | New Comments + + + | View/Edit Comments + +
+ Index: openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,98 @@ +ad_page_contract { + + Display one folder chunk. We don't use the file-storage version for a few + reasons. Among them are the fact that we don't need to check admin privs on + each file, only the folder, which speeds stuff up considerably. + + We expect list_of_folder_ids, min and max levels, admin_p and package_id as parameters + passed into this template by the calling include. We need a list of folders rather than a + single folder in order to make this useful for the user-level portlet that gathers all homework in + a single mega-portlet. + + @author Don Baccus (dhogaza@pacifier.com) + +} -properties { + folders:multirow + n_folders:onevalue +} + +set return_url "[ad_conn url]?[ad_conn query]" +set user_id [ad_conn user_id] + +set url [site_node::get_url_from_object_id -object_id $package_id] +set file_storage_url [dotlrn_homework::get_file_storage_url] + +# Now set up the label and target for each choice on the toolbar. + +multirow create toolbar label target + +# This is a bit of a kludge - we only allow folder-specific actions if there's just one +# folder. In our context this means we offer the links from the class portlet and +# folder display pages, but not the user portlet that lists a summary of all homework +# files for the user (if this gets written). + +if { [llength $list_of_folder_ids] == 1 } { + set folder_id [lindex $list_of_folder_ids 0] + if { $show_upload_url_p } { + template::multirow append toolbar "Submit a new Assignment" \ + "${url}file-add?[export_vars {folder_id return_url}]" + } + if { $admin_actions_p } { + template::multirow append toolbar "Create new folder" \ + "${url}folder-create?[export_vars {{parent_id $folder_id} return_url}]" + + # Even a community admin can't delete the root homework folder + if { ![string equal $folder_id [fs::get_root_folder -package_id [ad_conn package_id]]] } { + template::multirow append toolbar "Delete folder" \ + "${url}folder-delete?[export_vars {folder_id}]" + } + } +} + +# Hack to get around slow permissions checks. Admins can read all files in the +# folder, non-admins can only read their own files and all homework folders. When +# permission checks are sped up to an acceptable level this hack should be replaced +# with read checks. + +if { $admin_p } { + set qualify_by_owner "" +} else { + set qualify_by_owner [db_map qualify_by_owner] +} + +# If all the files belong to a single user we won't show the name of the user +# who has created the file. +set show_users_p 0 + +db_multirow -extend {pretty_name download_url upload_version_url view_details_url contents_url upload_correction_url view_correction_details_url} \ + folders select_folder_contents {} { + regsub -all " " $spaces {\ \ } spaces + if { [string equal $content_type "content_folder"] } { + set contents_url "${url}folder-contents?[export_vars {{folder_id $object_id} return_url}]" + } else { + + if { $user_id != $creation_user } { + set show_users_p 1 + } + + # Strip off the user_id + set pretty_name [dotlrn_homework::decode_name $name] + + # If the user can read the file the user can read the file's details + set view_details_url "${url}file?[export_vars {folder_id {file_id $object_id}}]" + + # And download the latest revision + set file_storage_url [dotlrn_homework::get_file_storage_url] + set download_url "${file_storage_url}/download/index?[export_vars {version_id}]" + + # Admin and students can read correction files but only an admin can add one ... + if { ![string equal $homework_file_id ""] } { + set view_correction_details_url "${url}file?[export_vars {folder_id {file_id $homework_file_id} {show_all_versions_p "t"}}]" + } elseif { $admin_p } { + set upload_correction_url \ + "${url}file-add?[export_vars {folder_id return_url {name "$pretty_name - Comments"} {homework_file_id $object_id}}]" + } + } +} + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/folder-chunk.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-chunk.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-chunk.xql 17 Feb 2003 20:56:16 -0000 1.1 @@ -0,0 +1,11 @@ + + + + + + + and (o.creation_user = :user_id or f.folder_id is not null) + + + + Index: openacs-4/packages/dotlrn-homework/www/folder-contents.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-contents.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-contents.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,9 @@ + + Contents of @folder_name@ + @context_bar@ + + + +
Index: openacs-4/packages/dotlrn-homework/www/folder-contents.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-contents.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-contents.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,45 @@ +ad_page_contract { + + Display the contents of a single folder + + @author Don Baccus (dhogaza@pacifier.com) + +} { + folder_id:integer,notnull + {min_level:integer 2} + {max_level:integer 2} +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ad_complain "The specified parent folder is not valid." + } + } +} -properties { + list_of_folder_ids:onevalue + min_level:onevalue + max_level:onevalue + return_url:onevalue + package_id:onevalue + folder_name:onevalue + show_upload_url_p:onevalue + admin_actions_p:onevalue + admin_p:onevalue +} + +# Make sure our visitor can read and write to the folder. +if { ![permission::permission_p -object_id $folder_id -privilege "read"] } { + ad_return -error +} + +set list_of_folder_ids [list $folder_id] +set package_id [ad_conn package_id] +set folder_name [fs_get_folder_name $folder_id] +set context_bar {"One Folder"} + +set community_id [dotlrn_community::get_community_id] +set admin_p [permission::permission_p -object_id $folder_id -privilege "admin"] + +set show_upload_url_p [expr {!$admin_p && [permission::permission_p -object_id $folder_id -privilege "write"]}] +set admin_actions_p [string is true $admin_p] + +ad_return_template Index: openacs-4/packages/dotlrn-homework/www/folder-create-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-create-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-create-oracle.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,21 @@ + + + + oracle8.1.6 + + + + +begin + :1 := file_storage.new_folder ( + name => :name, + folder_name => :folder_name, + parent_id => :parent_id, + creation_user => :user_id, + creation_ip => :creation_ip + ); +end; + + + + Index: openacs-4/packages/dotlrn-homework/www/folder-create.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-create.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-create.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,59 @@ +ad_page_contract { + + Form to create a homework subfolder + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 7 Nov 2000 + @cvs-id $Id: folder-create.tcl,v 1.1 2003/02/17 20:56:17 donb Exp $ +} { + parent_id:integer,notnull + return_url:notnull +} -validate { + valid_folder -requires {parent_id:integer} { + if ![fs_folder_p $parent_id] { + ad_complain "The specified parent folder is not valid." + } + } +} -properties { + parent_id:onevalue + context_bar:onevalue + page_title:onevalue +} + +set context_bar {"Create Folder"} +set page_title "Create Subfolder" + +set user_id [ad_conn user_id] +set creation_ip [ad_conn peeraddr] + +# Check that they have admin permission on the parent folder + +# Unlike the file-storage package, the homework package only allows writers +# to upload a file, not create a folder. In other words, we allow students +# to upload homework files but only class admins can create new homework +# subfolders. + +ad_require_permission $parent_id admin + +ad_form -name homework_form -form { + {return_url:text(hidden) {value $return_url}} + {parent_id:text(hidden) {value $parent_id}} + {folder_name:text {label "Folder Name"} + {html {size 20}}} +} -on_submit { + + regsub -all { +} [string tolower $folder_name] {_} name + + db_transaction { + + db_exec_plsql folder_create {} + + } on_error { + ad_return_exception_template -params {errmsg} "/packages/acs-subsite/www/shared/db-error" + } + + ad_returnredirect $return_url + +} + +ad_return_template homework-form Index: openacs-4/packages/dotlrn-homework/www/folder-delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-delete-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-delete-oracle.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,17 @@ + + + + oracle8.1.6 + + + + + begin + file_storage.delete_folder(:folder_id); + end; + + + + + + Index: openacs-4/packages/dotlrn-homework/www/folder-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-delete-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-delete-postgresql.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,15 @@ + + + + postgresql7.1 + + + + + select file_storage__delete_folder(:folder_id); + + + + + + Index: openacs-4/packages/dotlrn-homework/www/folder-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-delete.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,16 @@ + +Delete @folder_name@ +@context_bar@ + +

+ + + +

Are you sure you want to delete the folder "@folder_name@"? This action cannot be reversed. + +

+

+ +
+ +
Index: openacs-4/packages/dotlrn-homework/www/folder-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-delete.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,44 @@ +ad_page_contract { + page to confirm and delete folder. At the moment only works + for empty folders, but ultimately should allow recursive deletes. + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 10 November 2000 + @cvs-id $Id: folder-delete.tcl,v 1.1 2003/02/17 20:56:17 donb Exp $ +} { + folder_id:integer,notnull + {confirmed_p "f"} +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ad_complain "The specified folder is not valid." + } + } + + no_children -requires {not_root_folder} { + if { [db_string child_count {}] > 0 } { + ad_complain "We're sorry, but at the moment you cannot delete folders unless they are already empty." + } + } +} -properties { + folder_id:onevalue + folder_name:onevalue + context_bar:onevalue +} + +# check for delete permission on the folder + +ad_require_permission $folder_id delete + +if { [string equal $confirmed_p "t"] } { + # they have confirmed that they want to delete the folder + db_1row parent_id {} + db_exec_plsql folder_delete {} + ad_returnredirect "folder-contents?folder_id=$parent_id" +} else { + # they still need to confirm + set folder_name [db_string folder_name {}] + set context_bar {"Delete"} + ad_return_template +} Index: openacs-4/packages/dotlrn-homework/www/folder-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/folder-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/folder-delete.xql 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,24 @@ + + + + + + + select count(*) from cr_items where parent_id = :folder_id + + + + + + select parent_id from cr_items where item_id = :folder_id + + + + + + select label from cr_folders where folder_id = :folder_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/homework-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/homework-form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/homework-form.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title@ + @context_bar@ + + Index: openacs-4/packages/dotlrn-homework/www/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/master.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/master.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,10 @@ + +@title@ + +

@title@

+ +@context_bar@ + +
+ + Index: openacs-4/packages/dotlrn-homework/www/master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/master.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/master.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1 @@ +set context_bar [eval ad_context_bar -node_id [site_node::get_parent_id -node_id [ad_conn node_id]] $context_bar] Index: openacs-4/packages/dotlrn-homework/www/toggle-homework-alert.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/toggle-homework-alert.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/toggle-homework-alert.tcl 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,53 @@ +ad_page_contract { + Toggle the admin's alert on the given folder. + + We don't use the standard request form because it will ask the user to + choose an interval and delivery type. The homework package only supports + instant e-mail notifications of file uploads. + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2002-07-25 + @cvs-id $Id: toggle-homework-alert.tcl,v 1.1 2003/02/17 20:56:17 donb Exp $ +} { + folder_id:integer,notnull + request_id:integer + type_id:integer,notnull + subscribe_p:boolean,notnull + return_url:notnull +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ad_complain "The specified parent folder is not valid." + } + } +} + +ns_log Notice "Huh? type_id: $type_id subscribe_p: $subscribe_p request_id: $request_id" +set community_id [dotlrn_community::get_community_id] +dotlrn::require_user_admin_community -community_id $community_id + +if { $subscribe_p } { + + set intervals [notification::get_intervals -type_id $type_id] + set delivery_methods [notification::get_delivery_methods -type_id $type_id] + + # Sanity check to make sure the db entries are set up correctly. + + if { [llength $intervals] != 1 || [llength $delivery_methods] != 1 } { + ad_return_error "Internal Error" "Interval or delivery method for homework notifications broken" + } + + # The get routines return a list of name/id pairs so extract the ids + set interval_id [lindex [lindex $intervals 0] 1] + set delivery_method_id [lindex [lindex $delivery_methods 0] 1] + + # Add the alert + notification::request::new -type_id $type_id -user_id [ad_conn user_id] -object_id $folder_id \ + -interval_id $interval_id -delivery_method_id $delivery_method_id + +} else { + # Remove the alert + notification::request::delete -request_id $request_id +} + +ad_returnredirect $return_url Index: openacs-4/packages/dotlrn-homework/www/version-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-add.adp 17 Feb 2003 20:56:17 -0000 1.1 @@ -0,0 +1,5 @@ + +Upload New Version of @name@ +@context_bar@ + + Index: openacs-4/packages/dotlrn-homework/www/version-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-add.tcl 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,74 @@ +ad_page_contract { + + Upload a new version of an existing homework assignment. + + Don Baccus (dhogaza@pacifier.com) + +} { + file_id:integer,notnull + folder_id:integer,notnull + name:notnull + return_url:notnull +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ad_complain "The specified parent folder is not valid." + } + } +} -properties { + context_bar:onevalue + name:onevalue + page_title:onevalue +} + +# check for write permission on the file +ad_require_permission $file_id write + +set page_title "Upload New Version of $name" +set context_bar {"Upload New Assignment Version"} + +ad_form -name homework_form -html { enctype multipart/form-data } -export { return_url name folder_id } -form { + file_id:key + {upload_file:file {label "Version filename"}} + {-section "Use the \"Browse...\" button to locate your file, then click \"Open\"

 "} + {description:text(textarea),optional {label "Version notes"} + {html {rows 5 cols 50 wrap physical}}} +} -edit_request { +} -validate { + {upload_file + { [file size [template::util::file::get_property tmp_filename $upload_file]] <= [ad_parameter "MaximumFileSize"] } + "Your file is larger than the maximum file size allowed on this system ([util_commify_number [ad_parameter MaximumFileSize]] bytes)" + } +} -edit_data { + + db_transaction { + + # Alert management. Semantics are hardwired to Sloan's spec. Eventually it would probably be nice + # to make 'em configurable for non-admin users as they are now for admin users + + set homework_file_p [db_0or1row get_homework_info {}] + + dotlrn_homework::new -file_id $file_id -new_file_p 0 -description $description -upload_file $upload_file \ + -homework_file_id $homework_file_id + + if { $homework_file_p } { + + # We're uploading a correction file version, send alerts associated with the related homework file + dotlrn_homework::send_correction_alerts -folder_id $folder_id -homework_file_id $homework_file_id + + } else { + + # We're uploading a new homework file version, send alerts associated with our folder + dotlrn_homework::send_homework_alerts -folder_id $folder_id -file_id $file_id + + } + + } on_error { + ad_return_exception_template -params {errmsg} "/packages/acs-subsite/www/shared/db-error" + } + + ad_returnredirect $return_url + ad_script_abort +} + +ad_return_template homework-form Index: openacs-4/packages/dotlrn-homework/www/version-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-add.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-add.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,14 @@ + + + + + + + select item_id as homework_file_id + from cr_item_rels + where related_object_id = :file_id + and relation_tag = 'homework_correction' + + + + Index: openacs-4/packages/dotlrn-homework/www/version-delete-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-delete-oracle.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,31 @@ + + + + oracle8.1.6 + + + + + begin + :1 := file_storage.delete_version( + :item_id, + :version_id + ); + end; + + + + + + + + begin + file_storage.delete_file( + :item_id + ); + end; + + + + + Index: openacs-4/packages/dotlrn-homework/www/version-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-delete-postgresql.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,26 @@ + + + + postgresql7.1 + + + + + select file_storage__delete_version( + :item_id, + :version_id + ); + + + + + + + select file_storage__delete_file( + :item_id + ); + + + + + Index: openacs-4/packages/dotlrn-homework/www/version-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-delete.adp 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,19 @@ + +Delete @version_name@ +@context_bar@ + +

+ + + +

Are you sure that you want to delete this version "@version_name@" of "@title@"? +This action cannot be reversed. +

+

+ +
+ +
+ + + Index: openacs-4/packages/dotlrn-homework/www/version-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-delete.tcl 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,83 @@ +ad_page_contract { + confirmation page for version deletion + + @author Kevin Scaldeferri (kevin@arsdigita.com) + @creation-date 10 November 2000 + @cvs-id $Id: version-delete.tcl,v 1.1 2003/02/17 20:56:18 donb Exp $ +} { + version_id:integer,notnull + {confirmed_p "f"} +} -validate { + valid_version -requires {version_id} { + if ![fs_version_p $version_id] { + ad_complain "The specified version is not valid." + } + } +} -properties { + version_id:onevalue + version_name:onevalue + title:onevalue + context_bar:onevalue +} + +# check for delete permission on the version + +ad_require_permission $version_id delete + +db_1row item_select " +select item_id +from cr_revisions +where revision_id = :version_id" + +if {[string equal $confirmed_p "t"]} { + # they have confirmed that they want to delete the version + + db_transaction { + + # DRB: damned permissions table has no "on delete cascade" and file storage + # delete assumes there are perms on the revision itself. This code breaks + # the permissions abstraction but some day, 4.7 perhaps, we'll have proper + # referential integrity operators in at least some of the datamodel + + db_dml version_perms_delete {} + + set parent_id [db_exec_plsql delete_version " + begin + :1 := file_storage.delete_version(:item_id,:version_id); + end;" + ] + + if {$parent_id > 0} { + + # Delete the item if there is no more revision. We do this here only because of PostgreSQL's RI bug + db_exec_plsql delete_file " + begin + file_storage.delete_file(:item_id); + end;" + + } + + } + + if {$parent_id > 0} { + # Redirect to the folder, instead of the latest revision (which does not exist anymore) + ad_returnredirect "folder-contents?[export_vars {{folder_id $parent_id}}]" + } else { + # Ok, we don't have to do anything fancy, just redirect to th last revision + ad_returnredirect "file?[export_vars {{file_id $item_id} {folder_id $parent_id}}]" + } + +} else { + # they still need to confirm + + db_1row version_name " + select i.name as title,r.title as version_name + from cr_items i,cr_revisions r + where i.item_id = r.item_id + and revision_id = :version_id" + + set title [dotlrn_homework::decode_name $title] + + set context_bar {"Delete Version"} + ad_return_template +} Index: openacs-4/packages/dotlrn-homework/www/version-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/version-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/version-delete.xql 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + + + select item_id + from cr_revisions + where revision_id = :version_id + + + + + + + + delete from acs_permissions where object_id = :version_id + + + + + + + + select i.name as title, r.title as version_name + from cr_items i, cr_revisions r + where i.item_id = r.item_id + and r.revision_id = :version_id + + + + + Index: openacs-4/packages/dotlrn-homework/www/doc/design.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-homework/www/doc/design.html,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-homework/www/doc/design.html 17 Feb 2003 20:56:18 -0000 1.1 @@ -0,0 +1,75 @@ + + +dotLRN Homework Package Design Document + + + + +

dotLRN Homework Package Design Document

+ +by Don Baccus + +
+ +

Introduction

+ +The dotLRN Homework package provides a dropbox for students to upload homework files and +for professors, teaching assistants and other graders to upload their comments and corrections +to such files. The user interface is very similar to that provided by the standard file +storage package, with the result that users already familiar with that package will find the +Homework package very easy to learn. The Homework package is designed to be mounted under +each dotLRN class instance, and creates a separate root folder for each class. + +

Administrators can make subfolders in class homework dropbox folders. Typically this will +be used to create a separate subfolder for each homework assignment. + +

Administrators can ask to be notified by e-mail when a student uploads a new homework file. +Likewise, students are notified when a comment or correction file is uploaded by a grader. + +

+Students can only access homework files they've uploaded themselves along with each file's associated +comments and corrections files. + +

+ +Two applets and their associated portlets are provided: +

+

+
User applet
+

When added to a class home portal page students will see a list of folders and links to homework +files they've uploaded for the class. In addition a link is provided that allows students to upload a +new homework file. +

Administrators (professors, etc) see a collapsed view which displays a single link to the homework +folder display page for the class. We choose to do this because administrators are able to see homework +files uploaded by every student in the class. The resulting list of folders and files in a large +class with a number of homework assignments will be too long to display on a crowded portal page. +

+
Admin applet
+

The admin applet allows administrators to enable or disable e-mail alerts sent when a student +uploads a new homework file. +

+
+ +

In addition several display pages are provided to view or download file revisions, to view or +download comment files associated with a particular homework file, to delete files, move them from +one subfolder to another, and so forth. The actions that are available depend on whether the user +is a student or administrator. + +

Implementation

+ +The implementation is based on the standard OpenACS 4 File Storage package. The requirements and +design documents for the File Storage package apply directly to the dotLRN Homework package. + +

+The dotLRN Homework package differs from File Storage mostly in the actions that are made available to various +classes of users and by the fact that the content repository's item-to-object mapping functionality is +used to map a set of zero or more comment/correction files to each homework file. Actions are restricted +by use of the acs permissions system. The user interface has been modified slightly to simplify the +uploading of comment/correction files by graders. + +

+ +ad_form is used to build forms in the dotLRN Homework package. This means that the look and feel of +all the forms generated by the package can be changed by creating a single new form template file. + +