+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.
+
+
+
+
+
+
+
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 filename |
+ Author |
+ Size (bytes) |
+ Type |
+ Modified |
+ Version 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.
+
+
+
+
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@
+
+
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@
+
+
+
+
+
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.
+
+