Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -r1.9 -r1.10 --- openacs-4/packages/assessment/assessment.info 6 Dec 2004 12:27:48 -0000 1.9 +++ openacs-4/packages/assessment/assessment.info 9 Dec 2004 11:11:04 -0000 1.10 @@ -7,7 +7,7 @@ f f - + oracle postgresql @@ -20,7 +20,7 @@ 0 E-LANE Create assessments and evalueate. - + Index: openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 8 Dec 2004 15:30:32 -0000 1.10 +++ openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 9 Dec 2004 11:10:57 -0000 1.11 @@ -3,10 +3,6 @@ Above Absolute Size - Add existing question - Add existing question to section "%section_title%" - Add existing section - Add existing section to assessment "%assessment_data.title%" Add new question Add new question: Checkbox Display Add new question: Radiobutton Display @@ -18,8 +14,10 @@ Add new question: Multiple Choices Add new question: Short Answer Add new question: Open Question + Add items to section Add new question Add new section + Add sections to assessment Add to assessment "%assessment_data.title%" Add to section "%section_title%" Question Catalog Administration @@ -30,6 +28,7 @@ Allow Negative allow %assessment_data.number_tries% Alphabetical + AND Anonymous Responses Anonymous respondents allowed Answer Alignment @@ -39,17 +38,24 @@ Assessment Imported Correctly Title Attempt + Author Below Beside-Left Beside-Right Bottom Box Orientation By user Cancel and Return to Assessment + Combine categories by + To deselect or select multiple categories use the Control-Key on your keyboard. + Categorization + Exact + Include Subcategories Choice Choice Orientation Consent Page Continue with Copy + Continue with Insert Continue with Remove Copy Copy: @@ -121,17 +127,21 @@ Selectbox Textarea Textbox - Item Type + Question Type Database Question File Multiple Choice Open Question Short Answer Instructions Items + Search Keywords Label Orientation Left - Lets you use this assessment as a template to create a new assessment. + First Letter + All + Other Only %assessment_data.number_tries% tries allowed Make anonymous Make editable @@ -163,6 +173,7 @@ One Assessment: %assessment_data.title% Only correct Responses Only incorrect Responses + OR Order of Entry Order Type Out of @@ -191,10 +202,17 @@ Right Rule-based Branching Score + Search + Search and add questions + Search and add questions to section "%section_title%" + Search and add sections + Search and add sections to assessment "%assessment_data.title%" SECTION Section Navigation + Sections Secure Access Required Secure access required + Selected Sections Send bulk mail Session Sessions Index: openacs-4/packages/assessment/lib/section-items.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/section-items.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/lib/section-items.adp 8 Dec 2004 15:30:32 -0000 1.4 +++ openacs-4/packages/assessment/lib/section-items.adp 9 Dec 2004 11:10:57 -0000 1.5 @@ -6,7 +6,7 @@ #assessment.Add_New# - #assessment.Add_Existing# + #assessment.Search_Item# @@ -29,7 +29,7 @@ #assessment.Add_New# -#assessment.Add_Existing# +#assessment.Search_Item# #assessment.Move_Down# @@ -39,7 +39,7 @@ #assessment.remove_item# - (max. time allowed: @items.max_time_to_complete@) + (#assessment.max_time# @items.max_time_to_complete@) @@ -74,7 +74,7 @@ #assessment.Add_New# - #assessment.Add_Existing# + #assessment.Search_Item# Index: openacs-4/packages/assessment/lib/section-show.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/section-show.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/section-show.adp 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,47 @@ +

#assessment.Items#

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
@items.rownum@. * +#assessment.disabled# + (#assessment.max_time# @items.max_time_to_complete@) +
+
+ @items.title;noquote@
+ + + @formgroup.widget;noquote@ @formgroup.label;noquote@
+
+
+ + @items.html;noquote@ + + + + +
+
+
Index: openacs-4/packages/assessment/lib/section-show.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/section-show.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/section-show.tcl 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,16 @@ +ad_form -name show_section -form { + {section_id:text(hidden) {value $section_id}} +} + +db_multirow -extend { presentation_type html } items section_items {} { + set presentation_type [as::item_form::add_item_to_form show_section $as_item_id] + if {$presentation_type == "fitb"} { + regsub -all -line -nocase -- { + + + + + + select i.as_item_id, cr.title, i.definition, ism.required_p, + ism.enabled_p, ism.section_id, ism.sort_order, ism.adp_chunk, + ism.max_time_to_complete + from as_items i, cr_revisions cr, as_item_section_map ism + where cr.revision_id = i.as_item_id + and i.as_item_id = ism.as_item_id + and ism.section_id = :section_id + order by ism.sort_order + + + + + + Index: openacs-4/packages/assessment/www/admin/catalog-browse.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-browse.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-browse.adp 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title;noquote@ +@context_bar;noquote@ + + Index: openacs-4/packages/assessment/www/admin/catalog-browse.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-browse.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-browse.tcl 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,173 @@ +ad_page_contract { + + This page lets the user browse the catalog and select items/sections to add. + + @param assessment_id integer specifying assessment + @param section_id integer specifying section + + @author timo@timohentschel.de + @date 2004-12-08 + @cvs-id $Id: +} { + assessment_id:integer + {section_id:integer,optional} + after:integer + {itype:optional} + {subtree_p:optional} + letter:optional + {category_ids:integer,multiple,optional ""} + {join:optional} + keywords:optional + {orderby:optional "title,asc"} + {page:optional 1} +} + +ad_require_permission $assessment_id admin + +# Get the assessment data +as::assessment::data -assessment_id $assessment_id + +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} + +if {[info exists section_id]} { + db_1row section_title {} + set page_title "[_ assessment.Search_Item_1]" + set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Item]"] +} else { + set page_title "[_ assessment.Search_Section_1]" + set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Section]"] +} + +set package_id [ad_conn package_id] + +# somehow this should be done in a better way... +switch -exact $orderby { + "title,desc" { set orderby_clause "order by lower(cr.title) desc" } + "title,asc" { set orderby_clause "order by lower(cr.title) asc" } + "type,desc" { set orderby_clause "order by o.object_type desc, lower(cr.title) desc" } + "type,asc" { set orderby_clause "order by o.object_type asc, lower(cr.title) asc" } + "name,desc" { set orderby_clause "order by lower(ci.name) desc" } + "name,asc" { set orderby_clause "order by lower(ci.name) asc" } + "author,desc" { set orderby_clause "order by lower(p.last_name) desc, lower(p.first_names) desc, lower(cr.title) desc" } + "author,asc" { set orderby_clause "order by lower(p.last_name) asc, lower(p.first_names) asc, lower(cr.title) asc" } +} + +switch -exact $letter { + other { + set letter_where_clause [db_map other_letter] + } + all { + set letter_where_clause "" + } + default { + set bind_letter "$letter%" + set letter_where_clause [db_map regular_letter] + } +} + +set itype_where_clause "" +if {[exists_and_not_null itype]} { + set obj_type "as_item_type_$itype" + set itype_where_clause [db_map item_type] +} + +set category_ids_length [llength $category_ids] +if {$category_ids_length > 0} { + set category_id_sql [join $category_ids ,] + if {$join == "and"} { + # combining categories with and + if {$subtree_p == "t"} { + # generate sql for exact categorizations plus subcategories + set subtree_sql [db_map include_subtree_and] + } else { + # generate sql for exact categorization + set subtree_sql [db_map exact_categorization_and] + } + } else { + # combining categories with or + if {$subtree_p == "t"} { + # generate sql for exact categorizations plus subcategories + set subtree_sql [db_map include_subtree_or] + } else { + # generate sql for exact categorization + set subtree_sql [db_map exact_categorization_or] + } + } + set category_table_clause ", ($subtree_sql) s" + set category_where_clause [db_map categories] +} else { + set category_table_clause "" + set category_where_clause "" +} + +set keyword_where_clause "" +if {![empty_string_p $keywords]} { + set keyword_sql "%$keywords%" + set keyword_where_clause [db_map keywords] +} + + +if {[info exists section_id]} { + set bulk_actions [list "[_ assessment.Add_to_section]" catalog-item-add] +} else { + set bulk_actions [list "[_ assessment.Add_to_assessment]" catalog-section-add] +} + +set elements { + title { + label "[_ assessment.Title]" + orderby "lower(cr.title)" + } +} +if {[info exists section_id]} { + lappend elements type { + label "[_ assessment.Item_Type]" + display_template "@objects.item_type@" + orderby_asc "o.object_type asc, lower(cr.title) asc" + orderby_desc "o.object_type desc, lower(cr.title) desc" + } + set key_name as_item_id + set page_query item_list +} else { + set assessment_rev_id $assessment_data(assessment_rev_id) + set key_name section_id + set page_query section_list +} +lappend elements name { + label "[_ assessment.Name]" + orderby "lower(ci.name)" +} +lappend elements author { + label "Author" + display_template "@objects.last_name@, @objects.first_names@" + orderby_asc "lower(p.last_name) asc, lower(p.first_names) asc, lower(cr.title) asc" + orderby_desc "lower(p.last_name) desc, lower(p.first_names) desc, lower(cr.title) desc" +} + + +list::create \ + -name objects \ + -key $key_name \ + -pass_properties { assessment_id section_id after } \ + -no_data "[_ assessment.None]" \ + -filters { assessment_id {} section_id {} after {} category_ids { type multival } join_cat {} subtree_p {} keywords {} join_key {} letter {} itype {} } \ + -elements $elements \ + -bulk_actions $bulk_actions -bulk_action_export_vars { assessment_id section_id after } -page_size 20 -page_flush_p 1 -page_query_name $page_query + + +set orderby_clause [list::orderby_clause -orderby -name objects] +set page_where_clause [list::page_where_clause -and -name objects] + +if {[info exists section_id]} { + db_multirow objects unmapped_items_to_section "" { + set item_type "[_ assessment.item_type_[string range $item_type end-1 end]]" + } +} else { + db_multirow objects unmapped_sections_to_assessment "" +} + +ad_return_template +return Index: openacs-4/packages/assessment/www/admin/catalog-browse.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-browse.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-browse.xql 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,184 @@ + + + + + + + select title as section_title + from cr_revisions + where revision_id = :section_id + + + + + + + and (lower(cr.title) < 'a' or lower(cr.title) > 'z') + + + + + + and lower(cr.title) like :bind_letter + + + + + + and o.object_type = :obj_type + + + + + + and cr.revision_id = s.object_id + + + + + + and (cr.title like :keyword_sql or cr.description like :keyword_sql or ci.name like :keyword_sql) + + + + + + select v.object_id + from (select distinct m.object_id, c.category_id + from category_object_map m, categories c, + categories c_sub + where c.category_id in ($category_id_sql) + and m.category_id = c_sub.category_id + and c_sub.tree_id = c.tree_id + and c_sub.left_ind >= c.left_ind + and c_sub.left_ind < c.right_ind) v + group by v.object_id having count(*) = :category_ids_length + + + + + + select m.object_id + from category_object_map m + where m.category_id in ($category_id_sql) + group by m.object_id having count(*) = :category_ids_length + + + + + + select distinct m.object_id + from category_object_map m, categories c, + categories c_sub + where c.category_id in ($category_id_sql) + and m.category_id = c_sub.category_id + and c_sub.tree_id = c.tree_id + and c_sub.left_ind >= c.left_ind + and c_sub.left_ind < c.right_ind + + + + + + select distinct m.object_id + from category_object_map m + where m.category_id in ($category_id_sql) + + + + + + + select i.as_item_id + from cr_items ci, cr_revisions cr, as_items i, acs_objects ao, + persons p, as_item_rels ir, acs_objects o $category_table_clause + where cr.revision_id = ci.latest_revision + and i.as_item_id = cr.revision_id + and i.as_item_id not in (select m.as_item_id + from as_item_section_map m + where m.section_id = :section_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + and ir.item_rev_id = cr.revision_id + and ir.target_rev_id = o.object_id + and ir.rel_type = 'as_item_type_rel' + $category_where_clause + $keyword_where_clause + $letter_where_clause + $itype_where_clause + $orderby_clause + + + + + + + + select i.as_item_id, cr.title, ci.name, p.first_names, p.last_name, + o.object_type as item_type + from cr_items ci, cr_revisions cr, as_items i, acs_objects ao, + persons p, as_item_rels ir, acs_objects o $category_table_clause + where cr.revision_id = ci.latest_revision + and i.as_item_id = cr.revision_id + and i.as_item_id not in (select m.as_item_id + from as_item_section_map m + where m.section_id = :section_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + and ir.item_rev_id = cr.revision_id + and ir.target_rev_id = o.object_id + and ir.rel_type = 'as_item_type_rel' + $page_where_clause + $category_where_clause + $keyword_where_clause + $letter_where_clause + $itype_where_clause + $orderby_clause + + + + + + + + select i.section_id + from cr_items ci, cr_revisions cr, as_sections i, acs_objects ao, + persons p $category_table_clause + where cr.revision_id = ci.latest_revision + and i.section_id = cr.revision_id + and i.section_id not in (select m.section_id + from as_assessment_section_map m + where m.assessment_id = :assessment_rev_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + $category_where_clause + $keyword_where_clause + $letter_where_clause + $orderby_clause + + + + + + + + select i.section_id, cr.title, ci.name, p.first_names, p.last_name + from cr_items ci, cr_revisions cr, as_sections i, acs_objects ao, + persons p $category_table_clause + where cr.revision_id = ci.latest_revision + and i.section_id = cr.revision_id + and i.section_id not in (select m.section_id + from as_assessment_section_map m + where m.assessment_id = :assessment_rev_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + $page_where_clause + $category_where_clause + $keyword_where_clause + $letter_where_clause + $orderby_clause + + + + + Index: openacs-4/packages/assessment/www/admin/catalog-item-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-item-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-item-add.adp 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,45 @@ + +@page_title;noquote@ +@context_bar;noquote@ + + +

#assessment.Items#

+ + + + + + + + + + + + + + + + + + + + +
@items.rownum@. +
+ @items.title;noquote@
+ + + @formgroup.widget;noquote@ @formgroup.label;noquote@
+
+
+ + @items.html;noquote@ + + + + +
+
+
+ + Index: openacs-4/packages/assessment/www/admin/catalog-item-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-item-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-item-add.tcl 9 Dec 2004 11:10:57 -0000 1.1 @@ -0,0 +1,78 @@ +ad_page_contract { + + This page adds the sections the user selected for insertion into assessment. + + @param assessment_id integer specifying assessment + @param section_id integer specifying section + @param as_item_id list of integers specifying items + + @author timo@timohentschel.de + @date 2004-12-08 + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer + after:integer + as_item_id:integer,multiple,optional + item_ids:optional +} + +ad_require_permission $assessment_id admin + +# Get the assessment data +as::assessment::data -assessment_id $assessment_id + +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} + +db_1row section_title {} +set page_title "[_ assessment.Search_Item_1]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Item]"] + +if {[info exists as_item_id]} { + set item_ids $as_item_id +} + +set confirm_options [list [list "[_ assessment.continue_with_insert]" t] [list "[_ assessment.cancel_and_return]" f]] + +ad_form -name catalog_item_add -action catalog-item-add -export { assessment_id item_ids after } -form { + {section_id:key} + {to:text(inform) {label "[_ assessment.Add_Items]"} {value $section_title}} + {confirmation:text(radio) {label " "} {options $confirm_options} {value f}} +} -edit_request { +} -on_submit { + if {$confirmation} { + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + set new_section_id [as::section::new_revision -section_id $section_id] + + set item_count [llength $item_ids] + db_dml update_section_in_assessment {} + db_dml move_down_items {} + + foreach as_item_id $item_ids { + incr after + db_dml add_item_to_section {} + } + } + } +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + + +ad_form -name show_items -form { + {section_id:text(hidden) {value $section_id}} +} + +db_multirow -extend { presentation_type html } items items {} { + set presentation_type [as::item_form::add_item_to_form show_items $as_item_id] + if {$presentation_type == "fitb"} { + regsub -all -line -nocase -- { + + + + + + select title as section_title + from cr_revisions + where revision_id = :section_id + + + + + + + + select i.as_item_id, cr.title, i.definition + from as_items i, cr_revisions cr + where cr.revision_id = i.as_item_id + and i.as_item_id in ([join $as_item_id ,]) + order by i.as_item_id + + + + + + + + update as_assessment_section_map + set section_id = :new_section_id + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + + + + update as_item_section_map + set sort_order = sort_order + :item_count + where section_id = :new_section_id + and sort_order > :after + + + + + + + + insert into as_item_section_map (as_item_id, section_id, sort_order) + values (:as_item_id, :new_section_id, :after) + + + + + Index: openacs-4/packages/assessment/www/admin/catalog-search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-search.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-search.adp 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/catalog-search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-search.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-search.tcl 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,85 @@ +ad_page_contract { + + This page lets the user search for objects in the catalog to add them + + @param assessment_id integer specifying assessment + @param section_id integer specifying section + + @author timo@timohentschel.de + @date 2004-12-08 + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer,optional + after:integer +} + +ad_require_permission $assessment_id admin + +# Get the assessment data +as::assessment::data -assessment_id $assessment_id + +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} + + +if {[info exists section_id]} { + db_1row section_title {} + set page_title "[_ assessment.Search_Item_1]" + set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Item]"] +} else { + set page_title "[_ assessment.Search_Section_1]" + set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Section]"] +} + +set package_id [ad_conn package_id] +set combine_options [list [list "[_ assessment.and]" and] [list "[_ assessment.or]" or]] +set subtree_options [list [list "[_ assessment.Categorization_exact]" f] [list "[_ assessment.Categorization_sub]" t]] +set letter_options [list [list "[_ assessment.Letter_all]" all] {A a} {B b} {C c} {D d} {E e} {F f} {G g} {H h} {I i} {J j} {K k} {L l} {M m} {N n} {O o} {P p} {Q q} {R r} {S s} {T t} {U u} {V v} {W w} {X x} {Y y} {Z z} [list "[_ assessment.Letter_other]" other]] + + +ad_form -name catalog_search -action catalog-search -export { section_id after } -form { + {assessment_id:key} +} + +if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { + category::ad_form::add_widgets -container_object_id $package_id -form_name catalog_search + + ad_form -extend -name catalog_search -form { + {join:text(radio),optional {label "[_ assessment.Categories_combine]"} {options $combine_options} {help_text "[_ assessment.categories_combine_help]"}} + {subtree_p:text(radio),optional {label "[_ assessment.Categorization]"} {options $subtree_options} {help_text "[_ assessment.Categorization_help]"}} + } +} + +ad_form -extend -name catalog_search -form { + {keywords:text,optional {label "[_ assessment.Keywords]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Keywords_help]"}} + {letter:text(select),optional {label "[_ assessment.Letter]"} {options $letter_options} {help_text "[_ assessment.Letter_help]"}} +} + +if {[info exists section_id]} { + set item_types [list [list "[_ assessment.Letter_all]" ""]] + foreach one_item_type [db_list item_types {}] { + lappend item_types [list "[_ assessment.item_type_$one_item_type]" $one_item_type] + } + ad_form -extend -name catalog_search -form { + {itype:text(select),optional {label "[_ assessment.Item_Type]"} {options $item_types} {help_text "[_ assessment.Item_Type_help]"}} + } +} + +ad_form -extend -name catalog_search -edit_request { + set join or + set subtree_p f + set keywords "" + set letter and + set itype "" +} -on_submit { + set category_ids [category::ad_form::get_categories -container_object_id $package_id] +} -after_submit { + # now go to item-type specific form (i.e. multiple choice) + ad_returnredirect [export_vars -base catalog-browse {assessment_id section_id after category_ids:multiple join subtree_p keywords letter itype}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/catalog-search.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-search.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-search.xql 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,23 @@ + + + + + + + select title as section_title + from cr_revisions + where revision_id = :section_id + + + + + + + + select distinct item_type + from as_item_types_map + + + + + Index: openacs-4/packages/assessment/www/admin/catalog-section-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-section-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-section-add.adp 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,35 @@ + +@page_title;noquote@ +@context_bar;noquote@ + + + + +

#assessment.Selected_Sections#

+ + + + + + + + + + + + +
@sections.rownum@. * + (#assessment.max_time# @sections.max_time_to_complete@) +
+
+ @sections.title@ +
+
+ +
+ +
+ +
+ + Index: openacs-4/packages/assessment/www/admin/catalog-section-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-section-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-section-add.tcl 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + + This page adds the sections the user selected for insertion into assessment. + + @param assessment_id integer specifying assessment + @param section_id list of integers specifying sections + + @author timo@timohentschel.de + @date 2004-12-08 + @cvs-id $Id: +} { + assessment_id:integer + after:integer + section_id:integer,multiple,optional + section_ids:optional +} + +ad_require_permission $assessment_id admin + +# Get the assessment data +as::assessment::data -assessment_id $assessment_id + +if {![info exists assessment_data(assessment_id)]} { + ad_return_complaint 1 "[_ assessment.Requested_assess_does]" + ad_script_abort +} + +set page_title "[_ assessment.Search_Section_1]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Search_Section]"] + +if {[info exists section_id]} { + set section_ids $section_id +} + +set confirm_options [list [list "[_ assessment.continue_with_insert]" t] [list "[_ assessment.cancel_and_return]" f]] + +ad_form -name catalog_section_add -action catalog-section-add -export { section_ids after } -form { + {assessment_id:key} + {to:text(inform) {label "[_ assessment.Add_Sections]"} {value $assessment_data(title)}} + {confirmation:text(radio) {label " "} {options $confirm_options} {value f}} +} -edit_request { +} -on_submit { + if {$confirmation} { + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + + set section_count [llength $section_ids] + db_dml move_down_sections {} + foreach section_id $section_ids { + incr after + db_dml add_section_to_assessment {} + } + } + } +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + + +db_multirow sections sections {} { + if {![empty_string_p $max_time_to_complete]} { + set max_min [expr $max_time_to_complete / 60] + set max_sec [expr $max_time_to_complete - ($max_min * 60)] + set max_time_to_complete "$max_min\:$max_sec min" + } +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/catalog-section-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/catalog-section-add.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/catalog-section-add.xql 9 Dec 2004 11:10:58 -0000 1.1 @@ -0,0 +1,35 @@ + + + + + + select s.section_id, cr.title, s.definition, s.instructions, s.required_p, + s.feedback_text, s.max_time_to_complete + from as_sections s, cr_revisions cr + where cr.revision_id = s.section_id + and s.section_id in ([join $section_id ,]) + order by s.section_id + + + + + + + update as_assessment_section_map + set sort_order = sort_order + :section_count + where assessment_id = :new_assessment_rev_id + and sort_order > :after + + + + + + + + insert into as_assessment_section_map (assessment_id, section_id, feedback_text, max_time_to_complete, sort_order) + values (:new_assessment_rev_id, :section_id, null, null, :after) + + + + + Index: openacs-4/packages/assessment/www/admin/item-add-existing.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-existing.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-add-existing.adp 15 Nov 2004 12:05:39 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-add-existing.adp 9 Dec 2004 11:10:58 -0000 1.2 @@ -2,4 +2,6 @@ @page_title;noquote@ @context_bar;noquote@ + +
Index: openacs-4/packages/assessment/www/admin/item-add-existing.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-existing.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-add-existing.tcl 15 Nov 2004 12:05:39 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-add-existing.tcl 9 Dec 2004 11:10:58 -0000 1.2 @@ -14,6 +14,13 @@ after:integer {orderby:optional "title,asc"} {page:optional 1} + {itype:optional ""} + {subtree_p:optional f} + {letter:optional all} + {category_ids:integer,multiple,optional ""} + {join_cat:optional or} + {join_key:optional and} + {keywords:optional ""} } ad_require_permission $assessment_id admin @@ -30,38 +37,91 @@ set page_title "[_ assessment.Add_Existing_1]" set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.Add_Existing]"] +set package_id [ad_conn package_id] -set bulk_actions [list "[_ assessment.Add_to_section]" item-add-existing-2] +set __category__ad_form__category_id_1114 1115 +set combine_options [list [list "[_ assessment.and]" and] [list "[_ assessment.or]" or]] +set subtree_options [list [list "[_ assessment.Categorization_exact]" f] [list "[_ assessment.Categorization_sub]" t]] +set letter_options [list [list "[_ assessment.Letter_all]" all] {A a} {B b} {C c} {D d} {E e} {F f} {G g} {H h} {I i} {J j} {K k} {L l} {M m} {N n} {O o} {P p} {Q q} {R r} {S s} {T t} {U u} {V v} {W w} {X x} {Y y} {Z z} [list "[_ assessment.Letter_other]" other]] +set item_types [list [list "[_ assessment.Letter_all]" ""]] +foreach one_item_type [db_list item_types {}] { + lappend item_types [list "[_ assessment.item_type_$one_item_type]" $one_item_type] +} + + +ad_form -name item_search -action item-add-existing -export { assessment_id after } -form { + {section_id:text(hidden) {value $section_id}} +} + +if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} { + category::ad_form::add_widgets -container_object_id $package_id -categorized_object_id 0 -form_name item_search +} +ad_form -extend -name item_search -form { + {join_cat:text(radio),optional {label "[_ assessment.Categories_combine]"} {options $combine_options} {value $join_cat} {help_text "[_ assessment.categories_combine_help]"}} + {subtree_p:text(radio),optional {label "[_ assessment.Categorization]"} {options $subtree_options} {value $subtree_p} {help_text "[_ assessment.Categorization_help]"}} + {keywords:text,optional {label "[_ assessment.Keywords]"} {html {size 80 maxlength 500}} {value $keywords} {help_text "[_ assessment.Keywords_help]"}} + {join_key:text(radio),optional {label "[_ assessment.Keywords_combine]"} {options $combine_options} {value $join_key} {help_text "[_ assessment.keywords_combine_help]"}} + {letter:text(select),optional {label "[_ assessment.Letter]"} {options $letter_options} {value $letter} {help_text "[_ assessment.Letter_help]"}} + {itype:text(select),optional {label "[_ assessment.Item_Type]"} {options $item_types} {value $itype} {help_text "[_ assessment.Item_Type_help]"}} +} + +ad_form -extend -name item_search -select_query { +} + + # somehow this should be done in a better way... -if {$orderby == "title,desc"} { - set orderby_clause "order by title desc" -} else { - set orderby_clause "order by title asc" +switch -- $orderby { + "title,desc" { set orderby_clause "order by lower(cr.title) desc" } + "title,asc" { set orderby_clause "order by lower(cr.title) asc" } + "type,desc" { set orderby_clause "order by o.object_type desc, lower(cr.title) desc" } + "type,asc" { set orderby_clause "order by o.object_type asc, lower(cr.title) asc" } + "name,desc" { set orderby_clause "order by lower(ci.name) desc" } + "name,asc" { set orderby_clause "order by lower(ci.name) asc" } + "author,desc" { set orderby_clause "order by lower(p.last_name) desc, lower(p.first_names) desc, lower(cr.title) desc" } + "author,asc" { set orderby_clause "order by lower(p.last_name) asc, lower(p.first_names) asc, lower(cr.title) asc" } } + +set bulk_actions [list "[_ assessment.Add_to_section]" item-add-existing-2] + + list::create \ -name items \ -key as_item_id \ - -pass_properties { assessment_id section_id after } \ + -pass_properties { assessment_id section_id after join_cat subtree_p keywords join_key letter itype category_ids } \ -no_data "[_ assessment.None]" \ + -filters { assessment_id {} section_id {} after {} } \ -elements { title { label "[_ assessment.Title]" - orderby "title" + orderby "lower(cr.title)" } - } -bulk_actions $bulk_actions -bulk_action_export_vars { assessment_id section_id after } \ - -filters { - assessment_id {} - section_id {} - after {} - } -page_size 20 -page_query_name item_list + type { + label "[_ assessment.Item_Type]" + display_template "@items.item_type@" + orderby_asc "o.object_type asc, lower(cr.title) asc" + orderby_desc "o.object_type desc, lower(cr.title) desc" + } + name { + label "[_ assessment.Name]" + orderby "lower(ci.name)" + } + author { + label "Author" + display_template "@items.last_name@, @items.first_names@" + orderby_asc "lower(p.last_name) asc, lower(p.first_names) asc, lower(cr.title) asc" + orderby_desc "lower(p.last_name) desc, lower(p.first_names) desc, lower(cr.title) desc" + } + } -bulk_actions $bulk_actions -bulk_action_export_vars { assessment_id section_id after } -page_size 20 -page_query_name item_list set orderby_clause [list::orderby_clause -orderby -name items] set page_clause [list::page_where_clause -and -name items] -db_multirow items unmapped_items_to_section "" +db_multirow items unmapped_items_to_section "" { + set item_type "[_ assessment.item_type_[string range $item_type end-1 end]]" +} ad_return_template return Index: openacs-4/packages/assessment/www/admin/item-add-existing.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-existing.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/item-add-existing.xql 15 Nov 2004 12:05:39 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/item-add-existing.xql 9 Dec 2004 11:10:58 -0000 1.2 @@ -11,16 +11,31 @@ + + + + select distinct item_type + from as_item_types_map + + + + select i.as_item_id - from cr_items ci, cr_revisions cr, as_items i + from cr_items ci, cr_revisions cr, as_items i, acs_objects ao, + persons p, as_item_rels ir, acs_objects o where cr.revision_id = ci.latest_revision and i.as_item_id = cr.revision_id and i.as_item_id not in (select m.as_item_id from as_item_section_map m where m.section_id = :section_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + and ir.item_rev_id = cr.revision_id + and ir.target_rev_id = o.object_id + and ir.rel_type = 'as_item_type_rel' $orderby_clause @@ -29,13 +44,20 @@ - select i.as_item_id, cr.title - from cr_items ci, cr_revisions cr, as_items i + select i.as_item_id, cr.title, ci.name, p.first_names, p.last_name, + o.object_type as item_type + from cr_items ci, cr_revisions cr, as_items i, acs_objects ao, + persons p, as_item_rels ir, acs_objects o where cr.revision_id = ci.latest_revision and i.as_item_id = cr.revision_id and i.as_item_id not in (select m.as_item_id from as_item_section_map m where m.section_id = :section_id) + and ao.object_id = cr.revision_id + and p.person_id = ao.creation_user + and ir.item_rev_id = cr.revision_id + and ir.target_rev_id = o.object_id + and ir.rel_type = 'as_item_type_rel' $page_clause $orderby_clause Index: openacs-4/packages/assessment/www/admin/one-a.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/one-a.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/one-a.adp 8 Dec 2004 15:30:34 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/one-a.adp 9 Dec 2004 11:10:58 -0000 1.4 @@ -87,7 +87,7 @@ -

Sections

+

#assessment.Sections#

@@ -99,7 +99,7 @@ #assessment.add_new_section# -#assessment.add_existing_section# +#assessment.Search_Section# #assessment.Move_Down# @@ -131,12 +131,12 @@ -

Sections

+

#assessment.Sections#

#assessment.add_new_section# - #assessment.add_existing_section# + #assessment.Search_Section#
Index: openacs-4/packages/assessment/www/admin/one-a.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/one-a.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/admin/one-a.tcl 15 Nov 2004 12:06:06 -0000 1.2 +++ openacs-4/packages/assessment/www/admin/one-a.tcl 9 Dec 2004 11:10:58 -0000 1.3 @@ -53,4 +53,3 @@ } ad_return_template -return