Index: openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml,v diff -u -r1.5 -r1.6 --- openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml 30 Apr 2006 12:04:45 -0000 1.5 +++ openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml 21 May 2006 08:57:24 -0000 1.6 @@ -5,6 +5,7 @@ Add Instructor Add instructor to list Add Lab + Add Resource Add Section Add Student Add Template @@ -16,16 +17,23 @@ Create Section Create Template Delete + Delete Resource Delete Section Description Edit + Edit Details Edit Lab + Edit Resource + Edit Resources Edit Section Edit Template Enter lab description. Enter the last day of the lab. Enter name for lab. Enter start date for the lab. + Enter a description for this resource. + Enter resource name. + Enter a URL for the location of the online resource. Enter a description for the section. Enter section name. Enter a description for the report template. @@ -50,24 +58,31 @@ No report templates have been created. No students have been added to this lab. No templates have been created. + There are currently no resources allocated to this section. Resources can be added by clicking on the add resource button below. + There are currently no sections allocated to this report template. Sections can be added by clicking on the add section button below. Remove Remove instructor Remove report template. Report Sections Report Templates + Resources Section + Section resources for %section_name% Sections Student Students Template Template Sections Templates + The following resources have been allocated to the %section_name% section. to + URL View View Instructors View Report Templates Continue with deleting the instructor? Continue with deleting the lab? + Continue with deleting the resource? Continue with deleting the last section? Continue with removing the report template? Continue with removing student from the lab? Index: openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql 30 Apr 2006 12:01:30 -0000 1.4 +++ openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql 21 May 2006 08:57:24 -0000 1.5 @@ -67,6 +67,19 @@ null ); +select acs_object_type__create_type ( + 'lrc_resource', + '#lab-report-central.resource#', + '#lab-report-central.resources#', + 'acs_object', + 'lrc_resource', + 'resource_id', + null, + 'f', + null, + null + ); + -- -- Create tables -- @@ -127,6 +140,27 @@ on delete cascade ); +create table lrc_resource ( + resource_id integer + constraint lrc_resource_resource_id_fk + references acs_objects (object_id) + constraint lrc_resource_pk + primary key, + section_id integer + constraint lrc_resource_section_id_fk + references lrc_section (section_id) + on delete cascade, + name varchar (5120) + constraint lrc_resource_name_nn + not null, + url varchar (5120), + description text, + package_id integer + constraint lrc_resource_package_id_fk + references apm_packages (package_id) + on delete cascade +); + create table lrc_groups ( magic_name varchar(512) constraint lrc_groups_name_nn @@ -518,3 +552,125 @@ return v_section_name; end; ' language 'plpgsql'; + + +select define_function_args('lrc_resource__new','resource_id,section_id,name,url,description,package_id,creation_date;now,creation_user,creation_ip,context_id'); + +create function lrc_resource__new ( + integer, + integer, + varchar, + varchar, + text, + integer, + timestamptz, + integer, + varchar, + integer +) returns integer as ' +declare + p_resource_id alias for $1; -- default null + p_section_id alias for $2; + p_name alias for $3; + p_url alias for $4; + p_description alias for $5; + p_package_id alias for $6; + p_creation_date alias for $7; -- default now() + p_creation_user alias for $8; -- default null + p_creation_ip alias for $9; -- default null + p_context_id alias for $10; -- default null + + v_resource_id lrc_resource.resource_id%TYPE; + v_inst_group_id integer; +begin + + v_resource_id := acs_object__new ( + p_resource_id, + ''lrc_resource'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id + ); + + INSERT INTO lrc_resource ( + resource_id, + section_id, + name, + url, + description, + package_id + ) VALUES ( + v_resource_id, + p_section_id, + p_name, + p_url, + p_description, + p_package_id + ); + + SELECT group_id into v_inst_group_id + FROM lrc_groups + WHERE magic_name = ''instructors''; + + -- Grant permissions to instructors on this object. + PERFORM acs_permission__grant_permission( + v_resource_id, + v_inst_group_id, + ''lab_report_central_read'' + ); + + PERFORM acs_permission__grant_permission( + v_resource_id, + v_inst_group_id, + ''lab_report_central_write'' + ); + + PERFORM acs_permission__grant_permission( + v_resource_id, + v_inst_group_id, + ''lab_report_central_admin'' + ); + + return v_resource_id; + +end;' language 'plpgsql'; + + +select define_function_args('lrc_resource__del','resource_id'); + +create function lrc_resource__del (integer) +returns integer as ' +declare + p_resource_id alias for $1; +begin + raise NOTICE ''Deleting resource...''; + + DELETE FROM acs_permissions + WHERE object_id = p_resource_id; + + DELETE FROM lrc_resource + WHERE resource_id = p_resource_id; + + PERFORM acs_object__delete(p_resource_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('lrc_resource__name','resource_id'); + +create function lrc_resource__name (integer) +returns varchar as ' +declare + p_resource_id alias for $1; + v_resource_name lrc_resource.name%TYPE; +begin + SELECT name INTO v_resouce_name + FROM lrc_resource + WHERE resource_id = p_resource_id; + + return v_resource_name; +end; +' language 'plpgsql'; Index: openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql 30 Apr 2006 12:01:30 -0000 1.4 +++ openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql 21 May 2006 08:57:24 -0000 1.5 @@ -23,6 +23,21 @@ -- -- Drop functions -- +drop function lrc_resource__name (integer); +drop function lrc_resource__del (integer); +drop function lrc_resource__new ( + integer, + integer, + varchar, + varchar, + text, + integer, + timestamptz, + integer, + varchar, + integer +); + drop function lrc_section__name (integer); drop function lrc_section__del (integer); drop function lrc_section__new ( @@ -70,6 +85,7 @@ -- Drop tables -- drop table lrc_lab; +drop table lrc_resource; drop table lrc_section; drop table lrc_template; drop table lrc_groups; @@ -79,10 +95,12 @@ delete from acs_objects where object_type='lrc_lab'; delete from acs_objects where object_type='lrc_template'; delete from acs_objects where object_type='lrc_section'; +delete from acs_objects where object_type='lrc_resource'; -- -- Drop object types. -- select acs_object_type__drop_type ('lrc_lab', 'f'); select acs_object_type__drop_type ('lrc_template', 'f'); select acs_object_type__drop_type ('lrc_section', 'f'); +select acs_object_type__drop_type ('lrc_resource', 'f'); Index: openacs-4/packages/lab-report-central/www/resource-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resource-ae-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resource-ae-postgresql.xql 21 May 2006 08:57:24 -0000 1.1 @@ -0,0 +1,32 @@ + + + + postgresql7.4 + + + + SELECT name FROM lrc_template WHERE template_id = :template_id + + + + + + UPDATE lrc_resource + SET name = :name, + url = :url, + description = :description + WHERE resource_id = :resource_id + + + + + + UPDATE acs_objects + SET modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + package_id = :package_id + WHERE object_id = :resource_id + + + + Index: openacs-4/packages/lab-report-central/www/resource-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resource-ae.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resource-ae.adp 21 May 2006 08:57:24 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title;noquote@ +@context;noquote@ +resource.name + + Index: openacs-4/packages/lab-report-central/www/resource-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resource-ae.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resource-ae.tcl 21 May 2006 08:57:24 -0000 1.1 @@ -0,0 +1,84 @@ +ad_page_contract { + Add/Edit a template section. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-04-18 + @cvs-id $Id: resource-ae.tcl,v 1.1 2006/05/21 08:57:24 ncarroll Exp $ +} { + template_id:integer + section_id:integer + resource_id:integer,optional + {return_url "."} +} + +auth::require_login + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] +set peeraddr [ad_conn peeraddr] + +permission::require_permission -party_id $user_id -object_id $package_id \ + -privilege lab_report_central_admin + +if { [info exists resource_id] } { + set page_title [_ lab-report-central.edit_resource] +} else { + set page_title [_ lab-report-central.add_resource] +} + +set template_name [db_string template_name {} -default ""] + +set context [list [list templates [_ lab-report-central.templates]] \ + [list [export_vars -url -base template {template_id}] $template_name] \ + [list [export_vars -url -base resources {template_id section_id}] [_ lab-report-central.resources]] \ + $page_title] + +set return_url [export_vars -url -base resources {template_id section_id}] + +ad_form -name resource -cancel_url $return_url -form { + {resource_id:key(acs_object_id_seq)} + {template_id:integer(hidden) {value $template_id}} + {section_id:integer(hidden) {value $section_id}} + {return_url:text(hidden) {value $return_url}} + {name:text + {html {size 50}} + {label "[_ lab-report-central.name]" } + {help_text "[_ lab-report-central.help_enter_resource_name]"} + } + {url:text + {html {size 50}} + {label "[_ lab-report-central.URL]" } + {help_text "[_ lab-report-central.help_enter_resource_url]"} + } + {description:richtext(richtext),optional + {label "[_ lab-report-central.description]" } + {help_text "[_ lab-report-central.help_enter_resource_description]"} + {html {cols 48 rows 6}} + {htmlarea_p 0} + {nospell} + } +} -select_query { + SELECT name, url, description + FROM lrc_resource + WHERE resource_id = :resource_id +} -new_data { + + package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list template_id $template_id] \ + [list section_id $section_id] \ + [list name $name] \ + [list url $url] \ + [list description $description]] \ + -form_id resource lrc_resource + +} -edit_data { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml resource_update {} + db_dml object_update {} +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} Index: openacs-4/packages/lab-report-central/www/resource-del-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resource-del-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resource-del-postgresql.xql 21 May 2006 08:57:25 -0000 1.1 @@ -0,0 +1,12 @@ + + + + postgresql7.4 + + + + SELECT lrc_resource__del(:resource_id) + + + + Index: openacs-4/packages/lab-report-central/www/resource-del.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resource-del.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resource-del.tcl 21 May 2006 08:57:25 -0000 1.1 @@ -0,0 +1,24 @@ +ad_page_contract { + Delete the specified resource. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-04-30 + @cvs-id $Id: resource-del.tcl,v 1.1 2006/05/21 08:57:25 ncarroll Exp $ +} { + section_id:integer + template_id:integer + resource_id:integer +} + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] + +permission::require_permission -party_id $user_id -object_id $package_id \ + -privilege lab_report_central_admin + +db_transaction { + db_exec_plsql resource_delete {} +} + +ad_returnredirect [export_vars -url -base resources {template_id section_id}] +ad_script_abort Index: openacs-4/packages/lab-report-central/www/resources-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resources-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resources-postgresql.xql 21 May 2006 08:57:25 -0000 1.1 @@ -0,0 +1,28 @@ + + + + postgresql7.4 + + + + SELECT s.name AS section_name, s.description AS section_desc, + t.name AS template_name + FROM lrc_section s, lrc_template t + WHERE s.section_id = :section_id + AND s.template_id = t.template_id + AND s.package_id = :package_id + + + + + + SELECT resource_id, name AS resource_name, + url AS resource_url, description AS resource_desc + FROM lrc_resource + WHERE section_id = :section_id + AND package_id = :package_id + ORDER BY resource_id ASC + + + + Index: openacs-4/packages/lab-report-central/www/resources.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resources.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resources.adp 21 May 2006 08:57:25 -0000 1.1 @@ -0,0 +1,37 @@ + +@page_title;noquote@ +@context;noquote@ +[#lab-report-central.admin#] + + + + +#lab-report-central.the_following_resources_have_been_allocated# + + +#lab-report-central.notice_currently_no_resources# + + + + + + @resource.resource_name@ + @resource.resource_desc;noquote@ + #lab-report-central.edit_details# Visit Resource + + + + + + + + + + + + + - + + + + + Index: openacs-4/packages/lab-report-central/www/resources.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resources.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/resources.tcl 21 May 2006 08:57:25 -0000 1.1 @@ -0,0 +1,61 @@ +ad_page_contract { + Page for displaying resources for a specific section of a template + report. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-05-21 + @cvs-id $Id: resources.tcl,v 1.1 2006/05/21 08:57:25 ncarroll Exp $ +} { + template_id + section_id +} + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +db_1row section_details {} + +set page_title [_ lab-report-central.section_resources_for_section_name] +set context [list [list templates [_ lab-report-central.templates]] \ + [list [export_vars -url -base template {template_id}] \ + $template_name] \ + $page_title] + +if { [info exists section_desc] } { + set section_desc [template::util::richtext::get_property html_value \ + $section_desc] +} else { + set section_desc "" +} + +set create_p [permission::permission_p -party_id $user_id \ + -object_id $package_id \ + -privilege lab_report_central_admin_create] + +set delete_p [permission::permission_p -party_id $user_id \ + -object_id $package_id \ + -privilege lab_report_central_admin_delete] + +set modify_p [permission::permission_p -party_id $user_id \ + -object_id $package_id \ + -privilege lab_report_central_admin_modify] + +db_multirow -extend {details_url resources_url} resource select_resources {} { + if { [info exists resource_desc] } { + set resource_desc \ + [template::util::richtext::get_property html_value $resource_desc] + } else { + set resource_desc "" + } + + set details_url [export_vars -url -base resource-ae {template_id section_id resource_id}] +} + +set create_resource_url [export_vars -url -base resource-ae {template_id section_id}] + +# resource_id is the last resource_id retrieved from the db_multirow block +# above. +set delete_resource_url [export_vars -url -base resource-del {template_id section_id resource_id}] +set confirm_msg "[_ lab-report-central.want_to_delete_resource]" + +ad_return_template Index: openacs-4/packages/lab-report-central/www/template.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/template.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/lab-report-central/www/template.adp 30 Apr 2006 09:33:18 -0000 1.3 +++ openacs-4/packages/lab-report-central/www/template.adp 21 May 2006 08:57:25 -0000 1.4 @@ -20,12 +20,16 @@ + +#lab-report-central.notice_currently_no_sections# + + @section.section_name@ @section.section_desc;noquote@ - #lab-report-central.edit# + #lab-report-central.edit_details# #lab-report-central.edit_resources# Index: openacs-4/packages/lab-report-central/www/template.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/template.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/lab-report-central/www/template.tcl 30 Apr 2006 09:27:41 -0000 1.2 +++ openacs-4/packages/lab-report-central/www/template.tcl 21 May 2006 08:57:25 -0000 1.3 @@ -36,15 +36,16 @@ -object_id $package_id \ -privilege lab_report_central_admin_modify] -db_multirow -extend {edit_url} section select_sections {} { +db_multirow -extend {details_url resources_url} section select_sections {} { if { [info exists section_desc] } { set section_desc \ [template::util::richtext::get_property html_value $section_desc] } else { set section_desc "" } - set edit_url [export_vars -url -base section-ae {template_id section_id}] + set details_url [export_vars -url -base section-ae {template_id section_id}] + set resources_url [export_vars -url -base resources {template_id section_id}] } set create_section_url [export_vars -url -base section-ae {template_id}] Index: openacs-4/packages/lab-report-central/www/resources/lab-report-central.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/resources/lab-report-central.css,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lab-report-central/www/resources/lab-report-central.css 30 Apr 2006 12:01:31 -0000 1.4 +++ openacs-4/packages/lab-report-central/www/resources/lab-report-central.css 21 May 2006 08:57:25 -0000 1.5 @@ -3,6 +3,16 @@ clear: both; } +.notice { + border: 3px solid #FF6600; + margin: 0px auto; + margin-top: 2em; + padding: 5px; + width: 280px; + text-align: center; + background-color: #FF9966; + font-size: 12px; +} /* Action Container */ #lrc-actions-container { @@ -240,3 +250,36 @@ #lrc-section-container ul li.edit { text-align: right; } + + +/* Resource List Styles */ +#lrc-resource-container { + margin-top: 2em; +} + +#lrc-resource-container ul { + list-style-type: none; + font-family: verdana, arial, sans-serif; + border: 3px solid #339933; + margin: 0px auto; + margin-top: 1em; + padding: 5px; + width: 400px; + background-color: #CCFF99; + font-size: 12px; +} + +#lrc-resource-container ul li.name { + text-align: center; + font-weight: bold; + margin-bottom: 6px; + font-size: 16px; +} + +#lrc-resource-container ul li.description { + margin-bottom: 6px; +} + +#lrc-resource-container ul li.edit { + text-align: right; +} \ No newline at end of file