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.5 -r1.6 --- openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 14 Nov 2004 16:46:32 -0000 1.5 +++ openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 15 Nov 2004 12:07:25 -0000 1.6 @@ -2,10 +2,14 @@ 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 Add new section + Add to assessment "%assessment_data.title%" + Add to section "%section_title%" Question Catalog Administration Administration All Index: openacs-4/packages/assessment/www/admin/item-add-existing-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-existing-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-add-existing-2.tcl 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,39 @@ +ad_page_contract { + + This page adds items from the catalog to a section. + + @param assessment_id integer specifying assessment + @param section_id integer specifying section + + @author timo@timohentschel.de + @date November 10, 2004 + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer + after:integer + as_item_id:integer,multiple +} + +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_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] + db_dml update_section_in_assessment {} + + foreach item_id $as_item_id { + incr after + db_dml add_item_to_section {} + } +} + +ad_returnredirect [export_vars -base one-a {assessment_id}] Index: openacs-4/packages/assessment/www/admin/item-add-existing-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-add-existing-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-add-existing-2.xql 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,29 @@ + + + + + + + update as_assessment_section_map + set section_id = :new_section_id + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + + + + insert into as_item_section_map + (select :item_id as as_item_id, :new_section_id as section_id, + 't' as enabled_p, 'f' as required_p, null as item_default, + null as content_value, null as numeric_value, '' as feedback_text, + max_time_to_complete, '' as adp_chunk, :after as sort_order + from as_items + where as_item_id = :item_id) + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-add-existing.adp 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,5 @@ + +@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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-add-existing.tcl 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,67 @@ +ad_page_contract { + + This page lets the user add an item from the catalog to a section. + + @param assessment_id integer specifying assessment + @param section_id integer specifying section + + @author timo@timohentschel.de + @date November 10, 2004 + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer + after:integer + {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 +} + +db_1row section_title {} + +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 bulk_actions [list "[_ assessment.Add_to_section]" item-add-existing-2] + +# 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" +} + +list::create \ + -name items \ + -key as_item_id \ + -pass_properties { assessment_id section_id after } \ + -no_data "[_ assessment.None]" \ + -elements { + title { + label "[_ assessment.Title]" + orderby "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 + + +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 "" + +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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-add-existing.xql 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,45 @@ + + + + + + + select title as section_title + from cr_revisions + where revision_id = :section_id + + + + + + + + select i.as_item_id + from cr_items ci, cr_revisions cr, as_items i + 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) + $orderby_clause + + + + + + + + select i.as_item_id, cr.title + from cr_items ci, cr_revisions cr, as_items i + 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) + $page_clause + $orderby_clause + + + + + Index: openacs-4/packages/assessment/www/admin/section-add-existing-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-add-existing-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-add-existing-2.tcl 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,35 @@ +ad_page_contract { + + This page adds sections from the catalog to an assessment. + + @param assessment_id integer specifying assessment + + @author timo@timohentschel.de + @date November 10, 2004 + @cvs-id $Id: +} { + assessment_id:integer + after:integer + section_id:integer,multiple +} + +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_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + + foreach sect_id $section_id { + incr after + db_dml add_section_to_assessment {} + } +} + +ad_returnredirect [export_vars -base one-a {assessment_id}] Index: openacs-4/packages/assessment/www/admin/section-add-existing-2.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-add-existing-2.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-add-existing-2.xql 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,16 @@ + + + + + + + insert into as_assessment_section_map + (select :new_assessment_rev_id as assessment_id, :sect_id as section_id, + feedback_text, max_time_to_complete, :after as sort_order + from as_sections + where section_id = :sect_id) + + + + + Index: openacs-4/packages/assessment/www/admin/section-add-existing.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-add-existing.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-add-existing.adp 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,5 @@ + +@page_title;noquote@ +@context_bar;noquote@ + + Index: openacs-4/packages/assessment/www/admin/section-add-existing.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-add-existing.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-add-existing.tcl 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + + This page lets the user add sections from the catalog to an assessment. + + @param assessment_id integer specifying assessment + + @author timo@timohentschel.de + @date November 10, 2004 + @cvs-id $Id: +} { + assessment_id:integer + after:integer + {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 +} + + +set assessment_rev_id $assessment_data(assessment_rev_id) +set page_title "[_ assessment.add_existing_section_1]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] "[_ assessment.add_existing_section]"] + +set bulk_actions [list "[_ assessment.Add_to_assessment]" section-add-existing-2] + +# 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" +} + +list::create \ + -name sections \ + -key section_id \ + -pass_properties { assessment_id after } \ + -no_data "[_ assessment.None]" \ + -elements { + title { + label "[_ assessment.Title]" + orderby "title" + } + } -bulk_actions $bulk_actions -bulk_action_export_vars { assessment_id after } \ + -filters { + assessment_id {} + after {} + } -page_size 20 -page_query_name section_list + + +set orderby_clause [list::orderby_clause -orderby -name sections] +set page_clause [list::page_where_clause -and -name sections] + +db_multirow sections unmapped_sections_to_assessment "" + +ad_return_template +return Index: openacs-4/packages/assessment/www/admin/section-add-existing.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-add-existing.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-add-existing.xql 15 Nov 2004 12:05:39 -0000 1.1 @@ -0,0 +1,35 @@ + + + + + + + select s.section_id + from cr_items ci, cr_revisions cr, as_sections s + where cr.revision_id = ci.latest_revision + and s.section_id = cr.revision_id + and s.section_id not in (select m.section_id + from as_assessment_section_map m + where m.assessment_id = :assessment_rev_id) + $orderby_clause + + + + + + + + select s.section_id, cr.title + from cr_items ci, cr_revisions cr, as_sections s + where cr.revision_id = ci.latest_revision + and s.section_id = cr.revision_id + and s.section_id not in (select m.section_id + from as_assessment_section_map m + where m.assessment_id = :assessment_rev_id) + $page_clause + $orderby_clause + + + + +