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.2 -r1.3 --- openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml 27 Apr 2006 04:34:33 -0000 1.2 +++ openacs-4/packages/lab-report-central/catalog/lab-report-central.en_US.ISO-8859-1.xml 30 Apr 2006 09:27:41 -0000 1.3 @@ -5,12 +5,14 @@ Add Instructor Add instructor to list Add Lab + Add Section Add Template Add template to list Admin Attach Template Create Lab Create Report Template + Create Section Create Template Delete Description @@ -21,6 +23,8 @@ Enter the last day of the lab. Enter name for lab. Enter start date for the lab. + Enter a description for the section. + Enter section name. Enter a description for the report template. Enter a name for the report template. Select "Search" then click on OK to search for a user, otherwise select a user from the list. 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.2 -r1.3 --- openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql 27 Apr 2006 04:34:33 -0000 1.2 +++ openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-create.sql 30 Apr 2006 09:27:41 -0000 1.3 @@ -113,6 +113,10 @@ references acs_objects (object_id) constraint lrc_section_pk primary key, + template_id integer + constraint lrc_section_template_id_fk + references lrc_template (template_id) + on delete cascade, name varchar (5120) constraint lrc_section_name_nn not null, @@ -146,16 +150,6 @@ on delete cascade ); -create table lrc_template_section_map ( - template_id integer - constraint lrc_ts_map_template_id_fk - references lrc_template (template_id) - on delete cascade, - section_id integer - constraint lrc_ts_map_section_id_fk - references lrc_section (section_id) - on delete cascade -); -- -- Create functions @@ -396,3 +390,120 @@ return v_template_name; end; ' language 'plpgsql'; + + +select define_function_args('lrc_section__new','section_id,template_id,name,description,package_id,creation_date;now,creation_user,creation_ip,context_id'); + +create function lrc_section__new ( + integer, + integer, + varchar, + text, + integer, + timestamptz, + integer, + varchar, + integer +) returns integer as ' +declare + p_section_id alias for $1; -- default null + p_template_id alias for $2; + p_name alias for $3; + p_description alias for $4; + p_package_id alias for $5; + p_creation_date alias for $6; -- default now() + p_creation_user alias for $7; -- default null + p_creation_ip alias for $8; -- default null + p_context_id alias for $9; -- default null + + v_section_id lrc_section.section_id%TYPE; + v_inst_group_id integer; +begin + + v_section_id := acs_object__new ( + p_section_id, + ''lrc_section'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id + ); + + INSERT INTO lrc_section ( + section_id, + template_id, + name, + description, + package_id + ) VALUES ( + v_section_id, + p_template_id, + p_name, + 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_section_id, + v_inst_group_id, + ''lab_report_central_read'' + ); + + PERFORM acs_permission__grant_permission( + v_section_id, + v_inst_group_id, + ''lab_report_central_write'' + ); + + PERFORM acs_permission__grant_permission( + v_section_id, + v_inst_group_id, + ''lab_report_central_admin'' + ); + + return v_section_id; + +end;' language 'plpgsql'; + + +select define_function_args('lrc_section__del','section_id'); + +create function lrc_section__del (integer) +returns integer as ' +declare + p_section_id alias for $1; +begin + DELETE FROM acs_permissions + WHERE object_id = p_section_id; + + DELETE FROM lrc_section + WHERE section_id = p_section_id; + + raise NOTICE ''Deleting section...''; + PERFORM acs_object__delete(p_section_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('lrc_section__name','section_id'); + +create function lrc_section__name (integer) +returns varchar as ' +declare + p_section_id alias for $1; + v_section_name lrc_section.name%TYPE; +begin + SELECT name INTO v_section_name + FROM lrc_section + WHERE section_id = p_section_id; + + return v_section_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.2 -r1.3 --- openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql 27 Apr 2006 04:34:33 -0000 1.2 +++ openacs-4/packages/lab-report-central/sql/postgresql/lab-report-central-drop.sql 30 Apr 2006 09:27:41 -0000 1.3 @@ -23,18 +23,16 @@ -- -- Drop functions -- -drop function lrc_lab__name (integer); -drop function lrc_lab__del (integer); -drop function lrc_lab__new ( +drop function lrc_section__name (integer); +drop function lrc_section__del (integer); +drop function lrc_section__new ( integer, + integer, varchar, text, integer, timestamptz, - timestamptz, integer, - timestamptz, - integer, varchar, integer ); @@ -52,14 +50,29 @@ integer ); +drop function lrc_lab__name (integer); +drop function lrc_lab__del (integer); +drop function lrc_lab__new ( + integer, + varchar, + text, + integer, + timestamptz, + timestamptz, + integer, + timestamptz, + integer, + varchar, + integer +); + -- -- Drop tables -- drop table lrc_lab; drop table lrc_section; drop table lrc_template; drop table lrc_groups; -drop table lrc_template_section_map; drop table lrc_lab_template_map; delete from acs_objects where object_type='lrc_lab'; Index: openacs-4/packages/lab-report-central/www/section-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/section-ae-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/section-ae-postgresql.xql 30 Apr 2006 09:27:41 -0000 1.1 @@ -0,0 +1,31 @@ + + + + postgresql7.4 + + + + SELECT name FROM lrc_template WHERE template_id = :template_id + + + + + + UPDATE lrc_section + SET name = :name, + description = :description + WHERE section_id = :section_id + + + + + + UPDATE acs_objects + SET modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + package_id = :package_id + WHERE object_id = :section_id + + + + Index: openacs-4/packages/lab-report-central/www/section-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/section-ae.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/section-ae.adp 30 Apr 2006 09:27:41 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title;noquote@ +@context;noquote@ +section.name + + Index: openacs-4/packages/lab-report-central/www/section-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/section-ae.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/section-ae.tcl 30 Apr 2006 09:27:41 -0000 1.1 @@ -0,0 +1,74 @@ +ad_page_contract { + Add/Edit a template section. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-04-18 + @cvs-id $Id: section-ae.tcl,v 1.1 2006/04/30 09:27:41 ncarroll Exp $ +} { + template_id:integer + section_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 section_id] } { + set page_title [_ lab-report-central.edit_section] +} else { + set page_title [_ lab-report-central.add_section] +} + +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] \ + $page_title] + +set return_url [export_vars -url -base template {template_id}] + +ad_form -name section -cancel_url $return_url -form { + {section_id:key(acs_object_id_seq)} + {template_id:integer(hidden) {value $template_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_section_name]"} + } + {description:richtext(richtext),optional + {label "[_ lab-report-central.description]" } + {help_text "[_ lab-report-central.help_enter_section_description]"} + {html {cols 48 rows 6}} + {htmlarea_p 0} + {nospell} + } +} -select_query { + SELECT name, description + FROM lrc_section + WHERE section_id = :section_id +} -new_data { + + package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list template_id $template_id] \ + [list name $name] \ + [list description $description]] \ + -form_id section lrc_section + +} -edit_data { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml section_update {} + db_dml object_update {} +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} Index: openacs-4/packages/lab-report-central/www/section-del-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/section-del-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/section-del-postgresql.xql 30 Apr 2006 09:27:41 -0000 1.1 @@ -0,0 +1,12 @@ + + + + postgresql7.4 + + + + SELECT lrc_section__del(:section_id) + + + + Index: openacs-4/packages/lab-report-central/www/section-del.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/section-del.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lab-report-central/www/section-del.tcl 30 Apr 2006 09:27:41 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { + Delete the specified section. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-04-30 + @cvs-id $Id: section-del.tcl,v 1.1 2006/04/30 09:27:41 ncarroll Exp $ +} { + section_id:integer + template_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 section_delete {} +} + +ad_returnredirect [export_vars -url -base template {template_id}] +ad_script_abort Index: openacs-4/packages/lab-report-central/www/template-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lab-report-central/www/template-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lab-report-central/www/template-postgresql.xql 27 Apr 2006 04:34:34 -0000 1.1 +++ openacs-4/packages/lab-report-central/www/template-postgresql.xql 30 Apr 2006 09:27:41 -0000 1.2 @@ -12,4 +12,14 @@ + + + SELECT section_id, name AS section_name, description AS section_desc + FROM lrc_section + WHERE template_id = :template_id + AND package_id = :package_id + ORDER BY section_id ASC + + + 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.1 -r1.2 --- openacs-4/packages/lab-report-central/www/template.adp 27 Apr 2006 04:34:34 -0000 1.1 +++ openacs-4/packages/lab-report-central/www/template.adp 30 Apr 2006 09:27:41 -0000 1.2 @@ -20,3 +20,26 @@ +
+ + + +
+ +
+ +
+ + +
+ +
+ - +
+
+
+
+
\ No newline at end of file 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.1 -r1.2 --- openacs-4/packages/lab-report-central/www/template.tcl 27 Apr 2006 04:34:34 -0000 1.1 +++ openacs-4/packages/lab-report-central/www/template.tcl 30 Apr 2006 09:27:41 -0000 1.2 @@ -36,4 +36,22 @@ -object_id $package_id \ -privilege lab_report_central_admin_modify] +db_multirow -extend {edit_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 create_section_url [export_vars -url -base section-ae {template_id}] + +# section_id is the last section_id retrieved from the db_multirow block +# above. +set delete_section_url [export_vars -url -base section-del {template_id section_id}] +set confirm_msg "[_ lab-report-central.want_to_delete_section]" + ad_return_template 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.2 -r1.3 --- openacs-4/packages/lab-report-central/www/resources/lab-report-central.css 27 Apr 2006 04:34:34 -0000 1.2 +++ openacs-4/packages/lab-report-central/www/resources/lab-report-central.css 30 Apr 2006 09:27:41 -0000 1.3 @@ -164,6 +164,78 @@ } +/* Navlist styles */ +#lrc-navlist { + margin: 0px auto; + width: 100px; + margin-top: 1em; +} + +#lrc-navlist .float { + float: left; + width: 30px; + padding: 5px; +} + +#lrc-navlist a { + padding: 3px 10px; + font-weight: bold; + font-size: 20pt; + font-family: "Courier New"; +} + +#lrc-navlist a:link { + color: #FFF; + background-color: #666; + text-decoration: none; +} + +#lrc-navlist a:visited { + color: #FFF; + background-color: #666; + text-decoration: none; +} + +#lrc-navlist a:hover { + color: #FFF; + background-color: #CCC; + text-decoration: none; +} + + +/* Section List Styles */ +#lrc-section-container { + margin-top: 2em; +} + +#lrc-section-container ul { + list-style-type: none; + font-family: verdana, arial, sans-serif; + border: 3px solid #336699; + margin: 0px auto; + margin-top: 1em; + padding: 5px; + width: 400px; + background-color: #99CCFF; + font-size: 12px; +} + +#lrc-section-container ul li.name { + text-align: center; + font-weight: bold; + margin-bottom: 6px; + font-size: 16px; +} + +#lrc-section-container ul li.description { + margin-bottom: 6px; +} + +#lrc-section-container ul li.edit { + text-align: right; +} + + /* Global styles */ .spacer { clear: both;