Index: openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml,v diff -u -r1.24 -r1.25 --- openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 6 Jan 2006 05:46:13 -0000 1.24 +++ openacs-4/packages/curriculum-central/catalog/curriculum-central.en_US.ISO-8859-1.xml 6 Jan 2006 12:37:38 -0000 1.25 @@ -2,6 +2,26 @@ <message_catalog package_key="curriculum-central" package_version="0.1d" locale="en_US" charset="ISO-8859-1"> <msg key="uos">UoS</msg> + <msg key="manage_your_list_of_textbooks">Manage your list of textbooks</msg> + <msg key="help_enter_textbook_title">Enter the title of the textbook.</msg> + <msg key="help_enter_textbook_author">Enter the author of the textbook.</msg> + <msg key="help_enter_textbook_publisher">Enter the publisher's details.</msg> + <msg key="help_enter_textbook_isbn">Enter the ISBN for the book.</msg> + <msg key="title">Title</msg> + <msg key="author">Author</msg> + <msg key="publisher">Publisher</msg> + <msg key="isbn">ISBN</msg> + <msg key="no_textbooks_created">No textbooks have been added to the list.</msg> + <msg key="add_textbook">Add Textbook</msg> + <msg key="add_textbook_to_list">Add textbook to list.</msg> + <msg key="edit_textbook">Edit Textbook</msg> + <msg key="textbook">Textbook</msg> + <msg key="textbooks">Textbooks</msg> + <msg key="uos_textbooks">UoS Textbooks</msg> + <msg key="uos_textbook_set">UoS Textbook Set</msg> + <msg key="uos_textbook_sets">UoS Textbook Sets</msg> + <msg key="uos_textbook_set_revision">UoS Textbook Set Revision</msg> + <msg key="uos_textbook_set_revisions">UoS Textbook Set Revisions</msg> <msg key="current_assessment_total">Current Assessment Total</msg> <msg key="help_assess_method_ids">Select one or more assessment methods that are used in this Unit of Study. To select more than one item from the list, hold down the Shirt key whilst selecting an item. If an item doesn't appear in the list, then click <a href="assess-method-ae?return_url=%return_url%">here</a> to add it (Note: clicking on the link will redirect you to another page).</msg> <msg key="assessment_methods">Assessment Methods</msg> Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql,v diff -u -r1.9 -r1.10 --- openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 6 Jan 2006 04:50:18 -0000 1.9 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-create.sql 6 Jan 2006 12:37:39 -0000 1.10 @@ -320,3 +320,6 @@ -- UoS Assessment Methods \i uos-assess-create.sql + +-- UoS Textbooks +\i uos-textbook-create.sql \ No newline at end of file Index: openacs-4/packages/curriculum-central/sql/postgresql/uos-textbook-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/sql/postgresql/uos-textbook-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/sql/postgresql/uos-textbook-create.sql 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,452 @@ +-- +-- packages/curriculum-central/sql/postgresql/uos-textbook-create.sql +-- +-- @author Nick Carroll (nick.c@rroll.net) +-- @creation-date 2006-01-06 +-- @cvs-id $Id: uos-textbook-create.sql,v 1.1 2006/01/06 12:37:39 ncarroll Exp $ +-- +-- + + +create function inline_0 () +returns integer as' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_textbook_set'', -- object_type + ''#curriculum-central.uos_textbook_set#'', -- pretty_name + ''#curriculum-central.uos_textbook_sets#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_textbook_set'', -- table_name + ''textbook_set_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + null -- name_method + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); +drop function inline_0 (); + + +-- Register UoS textbook set as a child type of Uos. +select content_type__register_child_type ( + 'cc_uos', -- parent_type + 'cc_uos_textbook_set', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- content_item subtype +create table cc_uos_textbook_set ( + textbook_set_id integer + constraint cc_uos_textbook_set_fk + references cr_items(item_id) + on delete cascade + constraint cc_uos_textbook_set_pk + primary key, + parent_uos_id integer, + live_revision_id integer, + latest_revision_id integer +); + + +-- Create the UoS Textbook set content_revision +-- A revision may point to many Textbooks in the mapping +-- table below. +create table cc_uos_textbook_set_revs ( + tb_set_revision_id integer + constraint cc_uos_textbook_set_rev_pk + primary key + constraint cc_uos_textbook_set_rev_fk + references cr_revisions(revision_id) + on delete cascade +); + +-- Create the UoS revision content type. +select content_type__create_type ( + 'cc_uos_textbook_set_rev', + 'content_revision', + '#curriculum-central.uos_textbook_set_revision#', + '#curriculum-central.uos_textbook_set_revisions#', + 'cc_uos_textbook_set_revs', + 'tb_set_revision_id', + 'content_revision.revision_name' +); + +-- Register uos_textbook_set_revision as a child type of uos_revision. +select content_type__register_child_type ( + 'cc_uos_revision', -- parent_type + 'cc_uos_textbook_set_rev', -- child_type + 'generic', -- relation_tag + 0, -- min_n + null -- max_n +); + + +-- Create Textbook object +create function inline_0 () +returns integer as ' +begin + PERFORM acs_object_type__create_type ( + ''cc_uos_textbook'', -- object_type + ''#curriculum-central.textbook#'', -- pretty_name + ''#curriculum-central.textbooks#'', -- pretty_plural + ''acs_object'', -- supertype + ''cc_uos_textbook'', -- table_name + ''textbook_id'', -- id_column + null, -- package_name + ''f'', -- abstract_p + null, -- type_extension_table + ''cc_uos_textbook__name'' -- name_method + ); + + return 0; +end;' language 'plpgsql'; + +select inline_0 (); +drop function inline_0 (); + +-- Create the table that will be used to store information about a textbook. +create table cc_uos_textbook ( + textbook_id integer + constraint cc_uos_textbook_id_fk + references acs_objects(object_id) + constraint cc_uos_textbook_id_pk + primary key, + title varchar(256), -- title of book + author varchar(256), -- author of book + publisher varchar(256), -- publisher of book + isbn varchar(256) -- book's ISBN +); + +-- Create Mapping table between revision and texbook. +-- A revision can refer to many textbookss, since a +-- Unit of Study may require students to study many textbooks. +create table cc_uos_textbook_map ( + revision_id integer + constraint cc_uos_textbook_map_rev_id_fk + references cc_uos_textbook_set_revs(tb_set_revision_id), + textbook_id integer + constraint cc_uos_textbook_map_textbook_id_fk + references cc_uos_textbook(textbook_id) +); + + +-- +-- +-- Create the functions for the textbook content item and revisions. +-- +-- + +select define_function_args('cc_uos_textbook_set__new', 'textbook_set_id,parent_uos_id,creation_user,creation_ip,context_id,item_subtype;cc_uos_textbook_set,content_type;cc_uos_textbook_set_rev,object_type,package_id'); + +create function cc_uos_textbook_set__new( + integer, -- textbook_set_id + integer, -- parent_uos_id + integer, -- creation_user + varchar, -- creation_ip + integer, -- context_id + varchar, -- item_subtype + varchar, -- content_type + varchar, -- object_type + integer -- package_id +) returns integer as' +declare + + p_textbook_set_id alias for $1; + p_parent_uos_id alias for $2; + p_creation_user alias for $3; + p_creation_ip alias for $4; + p_context_id alias for $5; + p_item_subtype alias for $6; + p_content_type alias for $7; + p_object_type alias for $8; + p_package_id alias for $9; + + v_textbook_set_id cc_uos_textbook_set.textbook_set_id%TYPE; + v_folder_id integer; + v_revision_id integer; + v_name varchar; + v_rel_id integer; +begin + -- get the content folder for this instance + select folder_id into v_folder_id + from cc_curriculum + where curriculum_id = p_package_id; + + -- Create a unique name + -- Can only have one textbook set per Unit of Study, + -- so append uos_id + -- to "uos_textbook_set_for_". + v_name := ''uos_textbook_set_for_'' || p_parent_uos_id; + + -- create the content item + v_textbook_set_id := content_item__new ( + v_name, -- name + v_folder_Id, -- parent_id + p_textbook_set_id, -- item_id + null, -- locale + now(), -- creation_date + p_creation_user, -- creation_user + v_folder_id, -- context_id + p_creation_ip, -- creation_ip + p_item_subtype, -- item_subtype + p_content_type, -- content_type + null, -- title + null, -- description + null, -- mime_type + null, -- nls_language + null, -- data + p_package_id + ); + + -- create the initial revision + v_revision_id := cc_uos_textbook_set_rev__new ( + null, -- textbook_set_revision_id + v_textbook_set_id, -- textbook_set_id + now(), -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + + -- create the item type row + INSERT INTO cc_uos_textbook_set ( + textbook_set_id, parent_uos_id, latest_revision_id + ) VALUES ( + v_textbook_set_id, p_parent_uos_id, v_revision_id + ); + + + -- associate the UoS textbook set with the parent UoS + v_rel_id := acs_object__new( + NULL, + ''cr_item_child_rel'', + current_timestamp, + p_creation_user, + p_creation_ip, + p_package_id + ); + + INSERT INTO cr_child_rels ( + rel_id, parent_id, child_id, relation_tag + ) VALUES ( + v_rel_id, + p_parent_uos_id, + v_textbook_set_id, + ''cc_uos_textbook_set'' + ); + + return v_textbook_set_id; + +end; +' language plpgsql; + + +select define_function_args('cc_uos_textbook_set__delete', 'textbook_set_id'); + +create function cc_uos_textbook_set__delete (integer) +returns integer as ' +declare + p_textbook_set_id alias for $1; +begin + + perform content_item__delete(p_textbook_set_id); + + return 0; + +end; +' language 'plpgsql'; + + +create or replace function cc_uos_textbook_set_rev__new ( + integer, -- textbook_set_revision_id + integer, -- textbook_set_id + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns int +as ' +declare + p_textbook_set_revision_id alias for $1; + p_textbook_set_id alias for $2; + p_creation_date alias for $3; + p_creation_user alias for $4; + p_creation_ip alias for $5; + + v_revision_id integer; + v_title varchar; +begin + + -- create the initial revision + v_revision_id := content_revision__new ( + ''#curriculum-central.uos_textbooks#'', -- title + null, -- description + current_timestamp, -- publish_date + null, -- mime_type + null, -- nls_language + null, -- new_data + p_textbook_set_id, -- item_id + p_textbook_set_revision_id, -- revision_id + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + + -- insert into the uos-specific revision table + INSERT INTO cc_uos_textbook_set_revs (tb_set_revision_id) + VALUES (v_revision_id); + + -- Update the latest revision id in cc_uos_textbook_set + UPDATE cc_uos_textbook_set SET latest_revision_id = v_revision_id + WHERE textbook_set_id = p_textbook_set_id; + + return v_revision_id; +end; +' language 'plpgsql'; + + +-- +-- +-- Create the functions for the cc_uos_textbook object. +-- +-- + +select define_function_args('cc_uos_textbook__new','textbook_id,title,author,publisher,isbn,creation_date;now,creation_user,creation_ip,package_id,context_id'); + +create function cc_uos_textbook__new ( + integer, -- textbook_id + varchar, -- title + varchar, -- author + varchar, -- publisher + varchar, -- isbn + timestamptz, -- creation_date + integer, -- creation_user + varchar, -- creation_ip + integer, -- package_id + integer -- context_id +) returns integer as ' +declare + p_textbook_id alias for $1; -- default null + p_title alias for $2; + p_author alias for $3; + p_publisher alias for $4; + p_isbn 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_package_id alias for $9; + p_context_id alias for $10; -- default null + + v_textbook_id cc_uos_textbook.textbook_id%TYPE; + v_title varchar; +begin + v_title := p_title || '', '' || p_author; + + v_textbook_id := acs_object__new ( + p_textbook_id, + ''cc_uos_textbook'', + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id, + v_title, + p_package_id + ); + + INSERT INTO cc_uos_textbook ( + textbook_id, title, author, publisher, isbn + ) + VALUES ( + v_textbook_id, p_title, p_author, p_publisher, p_isbn + ); + + return v_textbook_id; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_textbook__del','textbook_id'); + +create function cc_uos_textbook__del (integer) +returns integer as ' +declare + p_textbook_id alias for $1; +begin + DELETE FROM acs_permissions WHERE object_id = p_textbook_id; + + DELETE FROM cc_uos_textbook WHERE textbook_id = p_textbook_id; + + RAISE NOTICE ''Deleting textbook...''; + PERFORM acs_object__delete(p_textbook_id); + + return 0; + +end;' language 'plpgsql'; + + +select define_function_args('cc_uos_textbook__name','textbook_id'); + +create function cc_uos_textbook__name (integer) +returns varchar as ' +declare + p_textbook_id alias for $1; + + v_textbook_title cc_uos_textbook.title%TYPE; +begin + SELECT title INTO v_textbook_title + FROM cc_uos_textbook + WHERE textbook_id = p_textbook_id; + + return v_textbook_title; +end; +' language 'plpgsql'; + + +-- +-- Maps a textbook to a textbook revision set. +-- +create function cc_uos_textbook__map ( + integer, -- revision_id + integer -- textbook_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_textbook_id alias for $2; +begin + + RAISE NOTICE ''Mapping textbook to a revision set...''; + + INSERT INTO cc_uos_textbook_map (revision_id, textbook_id) + VALUES (p_revision_id, p_textbook_id); + + return 0; +end; +' language 'plpgsql'; + + +-- +-- Unmaps a textbook from a revision set. +-- +create function cc_uos_textbook__unmap ( + integer, -- revision_id + integer -- textbook_id +) returns integer as ' +declare + p_revision_id alias for $1; + p_textbook_id alias for $2; +begin + + RAISE NOTICE ''Deleting mapping between textbook and revision set...''; + + DELETE FROM cc_uos_textbook_map + WHERE revision_id = p_revision_id + AND textbook_id = p_textbook_id; + + return 0; +end; +' language 'plpgsql'; Index: openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 6 Jan 2006 04:50:18 -0000 1.8 +++ openacs-4/packages/curriculum-central/tcl/curriculum-central-procs.tcl 6 Jan 2006 12:37:39 -0000 1.9 @@ -60,6 +60,11 @@ -content_type "cc_uos_assess_revision" \ -include_subtypes "t" + content::folder::register_content_type \ + -folder_id $folder_id \ + -content_type "cc_uos_textbook_set_rev" \ + -include_subtypes "t" + set keyword_id [content::keyword::new -heading "$instance_name"] # Inserts into cc_curriculum Index: openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql,v diff -u -r1.13 -r1.14 --- openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 6 Jan 2006 05:46:13 -0000 1.13 +++ openacs-4/packages/curriculum-central/tcl/uos-procs-postgresql.xql 6 Jan 2006 12:37:39 -0000 1.14 @@ -39,6 +39,17 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::get_textbooks.latest_textbook_set"> + <querytext> + SELECT t.textbook_set_id, t.latest_revision_id + FROM cc_uos u, cc_uos_revisions r, cr_items i, cc_uos_textbook_set t + WHERE u.uos_id = :uos_id + AND i.item_id = u.uos_id + AND r.uos_revision_id = i.latest_revision + AND t.parent_uos_id = :uos_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::get_graduate_attributes.latest_ga"> <querytext> SELECT g.gradattr_set_id, g.latest_revision_id @@ -90,6 +101,13 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::get_textbooks.latest_textbook_ids"> + <querytext> + SELECT textbook_id FROM cc_uos_textbook_map + WHERE revision_id = :latest_revision_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::get_graduate_attributes.latest_gradattr_ids"> <querytext> SELECT gradattr_id FROM cc_uos_gradattr_map @@ -215,6 +233,18 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::update_textbooks.update_textbook_set"> + <querytext> + SELECT cc_uos_textbook_set_rev__new ( + null, + :textbook_set_id, + now(), + :user_id, + :creation_ip + ); + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::update_graduate_attributes.update_ga"> <querytext> SELECT cc_uos_gradattr_set_rev__new ( @@ -254,6 +284,15 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::update_textbooks.map_textbook_revision"> + <querytext> + SELECT cc_uos_textbook__map ( + :revision_id, + :textbook_id + ); + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::update_assess.map_assess_to_revision"> <querytext> SELECT cc_uos_assess_method__map ( @@ -283,6 +322,17 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::textbook_get_options.textbooks"> + <querytext> + SELECT t.title || ' (' || t.author || ')' AS textbook_name, + t.textbook_id + FROM cc_uos_textbook t, acs_objects o + WHERE o.object_id = t.textbook_id + AND o.package_id = :package_id + AND o.creation_user = :user_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::graduate_attributes_get_options.select_ga"> <querytext> SELECT g.name || ' (' || g.identifier || ')' AS ga_name, @@ -341,6 +391,16 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_textbook_revision"> + <querytext> + SELECT i.latest_revision AS latest_textbook_revision + FROM cr_items i, cr_child_rels c + WHERE c.relation_tag = 'cc_uos_textbook_set' + AND c.parent_id = :object_id + AND i.item_id = c.child_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.get_latest_ga_revision"> <querytext> SELECT i.latest_revision AS latest_ga_revision @@ -396,6 +456,14 @@ </querytext> </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.set_live_textbook_revision"> + <querytext> + UPDATE cc_uos_textbook_set + SET live_revision_id = :latest_textbook_revision + WHERE parent_uos_id = :object_id + </querytext> + </fullquery> + <fullquery name="curriculum_central::uos::go_live::do_side_effect.set_live_workload_revision"> <querytext> UPDATE cc_uos_workload SET live_revision_id = :latest_workload_revision Index: openacs-4/packages/curriculum-central/tcl/uos-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/tcl/uos-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 6 Jan 2006 06:43:38 -0000 1.19 +++ openacs-4/packages/curriculum-central/tcl/uos-procs.tcl 6 Jan 2006 12:37:39 -0000 1.20 @@ -131,6 +131,7 @@ online_course_content tl_approach_ids gradattr_ids + textbook_ids formal_contact_hrs informal_study_hrs student_commitment @@ -407,6 +408,13 @@ [list object_type "cc_uos_tl"]] \ "cc_uos_tl"] + # Initiate cc_uos_textbook_set + set textbook_set_id [package_instantiate_object \ + -var_list [list [list parent_uos_id $uos_id] \ + [list package_id $package_id] \ + [list object_type "cc_uos_textbook_set"]] \ + "cc_uos_textbook_set"] + # Initiate cc_uos_gradattr_set set ga_id [package_instantiate_object \ -var_list [list [list parent_uos_id $uos_id] \ @@ -641,6 +649,47 @@ } +ad_proc -public curriculum_central::uos::update_textbooks { + -textbook_set_id:required + -textbook_ids:required + {-user_id ""} + {-creation_ip ""} +} { + Updates the textbooks component for a Unit of Study. + This update proc creates a new textbook revision. + + @param textbook_set_id The ID for a set of textbooks. + @param textbook_ids List of selected textbooks that need + to be mapped to the textbook set. + @param user_id The ID of the user that updated the Unit of Study. + @param creation_ip The IP of the user that made the update. + + @return revision_id Returns the ID of the newly created revision for + convenience, otherwise the empty string if unsuccessful. +} { + if { $user_id eq "" } { + set user_id [ad_conn user_id] + } + if { $creation_ip eq "" } { + set creation_ip [ad_conn peeraddr] + } + + # Set the default value for revision_id. + set revision_id "" + db_transaction { + set revision_id [db_exec_plsql update_textbook_set {}] + + # Foreach textbook_id map to the newly created revision_id + # retrieved above. + foreach textbook_id $textbook_ids { + db_exec_plsql map_textbook_revision {} + } + } + + return $revision_id +} + + ad_proc -public curriculum_central::uos::update_graduate_attributes { -gradattr_set_id:required -gradattr_ids:required @@ -829,6 +878,37 @@ } +ad_proc -public curriculum_central::uos::get_textbooks { + {-uos_id:required} + {-array:required} +} { + Get textbook info for the given Unit of Study. + + @param uos_id The ID of the Unit of Study for which we return + textbook info for. + @param array A predefined array for returning fields in. Values include + textbook_set_id, textbook_ids, latest_revision_id. + + @return Array containing all valid fields for the cc_uos_textbook table. +} { + # Select the info into the upvar'ed Tcl array + upvar $array row + + if { ![db_0or1row latest_textbook_set {} -column_array row] } { + # Set default values + set row(textbook_set_id) "" + set row(latest_revision_id) "" + } + + if { $row(latest_revision_id) ne "" } { + set latest_revision_id $row(latest_revision_id) + set row(textbook_ids) [db_list latest_textbook_ids {}] + } else { + set row(textbook_ids) "" + } +} + + ad_proc -public curriculum_central::uos::get_graduate_attributes { {-uos_id:required} {-array:required} @@ -949,6 +1029,33 @@ } +ad_proc curriculum_central::uos::textbook_get_options { + {-package_id ""} + {-user_id ""} +} { + Returns a two-column list of registered textbooks. + + @param package_id ID of the current package instance. + @param user_id Specify a user to retrieve their list of + textbooks, otherwise a list of textbooks are + returned by default for the requesting user. + + @return Returns a two-column list of registered textbooks. +} { + if { $package_id eq ""} { + set package_id [ad_conn package_id] + } + + if { $user_id eq ""} { + set user_id [ad_conn user_id] + } + + set textbook_list [db_list_of_lists textbooks {}] + + return $textbook_list +} + + ad_proc curriculum_central::uos::graduate_attributes_get_options { {-package_id ""} {-user_id ""} @@ -1200,6 +1307,11 @@ content::item::set_live_revision -revision_id $latest_tl_revision db_dml set_live_tl_revision {} + # Do the same for cc_uos_textbook_set + db_1row get_latest_textbook_revision {} + content::item::set_live_revision -revision_id $latest_textbook_revision + db_dml set_live_textbook_revision {} + # Do the same for cc_uos_gradattr_set db_1row get_latest_ga_revision {} content::item::set_live_revision -revision_id $latest_ga_revision Index: openacs-4/packages/curriculum-central/www/coordinate/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/index.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/curriculum-central/www/coordinate/index.adp 6 Jan 2006 05:46:13 -0000 1.6 +++ openacs-4/packages/curriculum-central/www/coordinate/index.adp 6 Jan 2006 12:37:39 -0000 1.7 @@ -6,6 +6,7 @@ <li><a href="tl-methods">#curriculum-central.manage_your_list_of_tl_approaches#</a></i> <li><a href="gradattrs">#curriculum-central.manage_your_list_of_graduate_attributes#</a></li> <li><a href="assess-methods">#curriculum-central.manage_your_list_of_assessment_methods#</a></li> +<li><a href="textbooks">#curriculum-central.manage_your_list_of_textbooks#</a></li> </ul> <ul> Index: openacs-4/packages/curriculum-central/www/coordinate/textbook-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbook-ae-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbook-ae-postgresql.xql 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,27 @@ +<?xml version="1.0"?> + +<queryset> + <rdbms><type>postgresql</type><version>7.4</version></rdbms> + + <fullquery name="textbook_update"> + <querytext> + UPDATE cc_uos_textbook + SET title = :title, + author = :author, + publisher = :publisher, + isbn = :isbn + WHERE textbook_id = :textbook_id + </querytext> + </fullquery> + + <fullquery name="object_update"> + <querytext> + UPDATE acs_objects + SET modifying_user = :modifying_user, + modifying_ip = :modifying_ip, + package_id = :package_id + WHERE object_id = :textbook_id + </querytext> + </fullquery> + +</queryset> Index: openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.adp 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,6 @@ +<master> +<property name="title">@page_title;noquote@</property> +<property name="context">@context;noquote@</property> +<property name="focus">textbook.title</property> + +<formtemplate id="textbook"></formtemplate> Index: openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbook-ae.tcl 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + Add/Edit a textbook. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-01-04 + @cvs-id $Id: textbook-ae.tcl,v 1.1 2006/01/06 12:37:39 ncarroll Exp $ +} { + textbook_id:integer,optional + {return_url "textbooks"} +} + +auth::require_login + +if { [info exists textbook_id] } { + set page_title [_ curriculum-central.edit_textbook] +} else { + set page_title [_ curriculum-central.add_textbook] +} + +set context [list $page_title] +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +ad_form -name textbook -cancel_url $return_url -form { + {textbook_id:key(acs_object_id_seq)} + {return_url:text(hidden) {value $return_url}} + {title:text + {html {size 50}} + {label "[_ curriculum-central.title]" } + {help_text "[_ curriculum-central.help_enter_textbook_title]"} + } + {author:text + {html {size 50}} + {label "[_ curriculum-central.author]" } + {help_text "[_ curriculum-central.help_enter_textbook_author]"} + } + {publisher:text,optional + {html {size 50}} + {label "[_ curriculum-central.publisher]" } + {help_text "[_ curriculum-central.help_enter_textbook_publisher]"} + } + {isbn:text,optional + {html {size 15}} + {label "[_ curriculum-central.isbn]" } + {help_text "[_ curriculum-central.help_enter_textbook_isbn]"} + } +} -select_query { + SELECT title, author, publisher, isbn + FROM cc_uos_textbook WHERE textbook_id = :textbook_id +} -new_data { + package_instantiate_object \ + -var_list [list [list package_id $package_id] \ + [list object_type cc_uos_textbook] \ + [list title $title] \ + [list author $author] \ + [list publisher $publisher] \ + [list isbn $isbn]] \ + -form_id textbook cc_uos_textbook + +} -edit_data { + set modifying_user [ad_conn user_id] + set modifying_ip [ad_conn peeraddr] + + db_dml textbook_update {} + db_dml object_update {} +} -after_submit { + ad_returnredirect $return_url + ad_script_abort +} Index: openacs-4/packages/curriculum-central/www/coordinate/textbooks-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbooks-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbooks-postgresql.xql 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,17 @@ +<?xml version="1.0"?> + +<queryset> + <rdbms><type>postgresql</type><version>7.4</version></rdbms> + + <fullquery name="get_textbooks"> + <querytext> + SELECT t.textbook_id, t.title, t.author, t.publisher, t.isbn + FROM cc_uos_textbook t, acs_objects o + WHERE package_id = :package_id + AND t.textbook_id = o.object_id + AND o.creation_user = :user_id + [template::list::orderby_clause -orderby -name "textbooks"] + </querytext> + </fullquery> + +</queryset> Index: openacs-4/packages/curriculum-central/www/coordinate/textbooks.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbooks.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbooks.adp 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,5 @@ +<master> +<property name="title">@page_title;noquote@</property> +<property name="context">@context;noquote@</property> + +<listtemplate name="textbooks"></listtemplate> Index: openacs-4/packages/curriculum-central/www/coordinate/textbooks.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/textbooks.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/curriculum-central/www/coordinate/textbooks.tcl 6 Jan 2006 12:37:39 -0000 1.1 @@ -0,0 +1,56 @@ +ad_page_contract { + Page for listing textbooks. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2006-1-4 + @cvs-id $Id: textbooks.tcl,v 1.1 2006/01/06 12:37:39 ncarroll Exp $ +} { + {orderby "title,asc"} +} + +auth::require_login + +set page_title "[_ curriculum-central.textbooks]" +set context [list [list . [_ curriculum-central.coordinate]] $page_title] +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] + +set elements { + edit { + sub_class narrow + display_template { + <img src="/shared/images/Edit16.gif" height="16" width="16" border="0"> + } + link_url_eval {[export_vars -base textbook-ae { textbook_id }]} + link_html {title "#curriculum-central.edit_textbook#"} + } + title { + label "#curriculum-central.title#" + } + author { + label "#curriculum-central.author#" + } + publisher { + label "#curriculum-central.publisher#" + } + isbn { + label "#curriculum-central.isbn#" + } +} + +template::list::create \ + -name textbooks \ + -actions [list "#curriculum-central.add_textbook#" [export_vars -base textbook-ae {}] "#curriculum-central.add_textbook_to_list#"] \ + -multirow textbooks \ + -no_data "#curriculum-central.no_textbooks_created#" \ + -elements $elements \ + -orderby { + title {orderby {lower(t.title)}} + author {orderby {lower(author)}} + publisher {orderby {lower(publisher)}} + isbn {orderby isbn} + } + +db_multirow textbooks get_textbooks {} + +ad_return_template Index: openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 6 Jan 2006 06:43:38 -0000 1.11 +++ openacs-4/packages/curriculum-central/www/coordinate/uos-edit.tcl 6 Jan 2006 12:37:39 -0000 1.12 @@ -201,6 +201,27 @@ } +# Retrieve textbook info for Unit of Study. +curriculum_central::uos::get_textbooks \ + -uos_id $uos_id \ + -array uos_textbook + +# Add widgets for textbook +ad_form -extend -name uos -form { + {textbook_set_id:integer(hidden),optional + {value $uos_textbook(textbook_set_id)} + } + {textbook_ids:text(multiselect),multiple,optional + {label "[_ curriculum-central.textbooks]"} + {options [curriculum_central::uos::textbook_get_options]} + {html {size 5}} + {values $uos_textbook(textbook_ids)} + {mode display} + {help_text "[_ curriculum-central.help_select_textbook_ids]"} + } +} + + # Retrieve workload info for Unit of Study. curriculum_central::uos::get_workload \ -uos_id $uos_id \ @@ -344,8 +365,7 @@ -array action_info # Do edits specific to a workflow action. - # If action is edit_details, then update edit_details. - if { $action_info(short_name) eq "edit_details" } { + if { $action_info(short_name) eq "edit_tl"} { curriculum_central::uos::update_details \ -detail_id $detail_id \ @@ -356,12 +376,14 @@ -relevance $relevance \ -online_course_content $online_course_content - } elseif { $action_info(short_name) eq "edit_tl"} { - curriculum_central::uos::update_tl \ -tl_id $tl_id \ -tl_approach_ids $tl_approach_ids + curriculum_central::uos::update_textbooks \ + -textbook_set_id $textbook_set_id \ + -textbook_ids $textbook_ids + curriculum_central::uos::update_graduate_attributes \ -gradattr_set_id $gradattr_set_id \ -gradattr_ids $gradattr_ids