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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/section-items.adp 14 Nov 2004 16:45:52 -0000 1.1 @@ -0,0 +1,76 @@ +

#assessment.Items#

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#assessment.Add_New#
@items.rownum@. * #assessment.Edit# + +#assessment.disabled# + +#assessment.Copy# + +#assessment.Add_New# + +#assessment.Add_Existing# + + + #assessment.Move_Down# + + + #assessment.Move_Up# + +#assessment.remove_item# + + (max. time allowed: @items.max_time_to_complete@) +
+
+ @items.title;noquote@
+ + + @formgroup.widget;noquote@ @formgroup.label;noquote@
+
+
+ + @items.html;noquote@ + + + + +
+
#assessment.Add_New#
+
Index: openacs-4/packages/assessment/lib/section-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/section-items.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/lib/section-items.tcl 14 Nov 2004 16:45:52 -0000 1.1 @@ -0,0 +1,16 @@ +ad_form -name admin_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 admin_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/tcl/as-assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 14 Oct 2004 11:44:51 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 14 Nov 2004 16:47:04 -0000 1.2 @@ -13,6 +13,7 @@ {-description ""} {-instructions ""} {-mode ""} + {-editable_p ""} {-anonymous_p ""} {-secure_access_p ""} {-reuse_responses_p ""} @@ -38,8 +39,181 @@ set folder_id [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] # Insert as_assessment in the CR (and as_assessments table) getting the revision_id (as_assessment_id) - set assessment_item_id [content::item::new -parent_id $folder_id -content_type {as_assessments} -name $name -title $title ] - set as_assessment_id [content::revision::new -item_id $assessment_item_id -content_type {as_assessments} -title $title -description $description -attributes [list [list creator_id $creator_id] [list instructions $instructions] [list mode $mode] [list anonymous_p $anonymous_p] [list secure_access_p $secure_access_p] [list reuse_responses_p $reuse_responses_p] [list show_item_name_p $show_item_name_p] [list entry_page $entry_page] [list exit_page $exit_page] [list consent_page $consent_page] [list return_url $return_url] [list start_time $start_time] [list end_time $end_time] [list number_tries $number_tries] [list wait_between_tries $wait_between_tries] [list time_for_response $time_for_response] [list show_feedback $show_feedback] [list section_navigation $section_navigation] ] ] + db_transaction { + set assessment_item_id [content::item::new -parent_id $folder_id -content_type {as_assessments} -name $name -title $title ] + set as_assessment_id [content::revision::new \ + -item_id $assessment_item_id \ + -content_type {as_assessments} \ + -title $title \ + -description $description \ + -attributes [list [list creator_id $creator_id] \ + [list instructions $instructions] \ + [list mode $mode] \ + [list editable_p $editable_p] \ + [list anonymous_p $anonymous_p] \ + [list secure_access_p $secure_access_p] \ + [list reuse_responses_p $reuse_responses_p] \ + [list show_item_name_p $show_item_name_p] \ + [list entry_page $entry_page] \ + [list exit_page $exit_page] \ + [list consent_page $consent_page] \ + [list return_url $return_url] \ + [list start_time $start_time] \ + [list end_time $end_time] \ + [list number_tries $number_tries] \ + [list wait_between_tries $wait_between_tries] \ + [list time_for_response $time_for_response] \ + [list show_feedback $show_feedback] \ + [list section_navigation $section_navigation] ] ] + } + return $as_assessment_id } + +ad_proc -public as::assessment::edit { + {-assessment_id:required} + {-title:required} + {-creator_id ""} + {-description ""} + {-instructions ""} + {-mode ""} + {-editable_p ""} + {-anonymous_p ""} + {-secure_access_p ""} + {-reuse_responses_p ""} + {-show_item_name_p ""} + {-entry_page ""} + {-exit_page ""} + {-consent_page ""} + {-return_url ""} + {-start_time ""} + {-end_time ""} + {-number_tries ""} + {-wait_between_tries ""} + {-time_for_response ""} + {-show_feedback ""} + {-section_navigation ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-10-26 + + Edit assessment in the database +} { + set assessment_rev_id [db_string assessment_revision {}] + + # edit as_assessment in the CR + db_transaction { + set new_rev_id [content::revision::new \ + -item_id $assessment_id \ + -content_type {as_assessments} \ + -title $title \ + -description $description \ + -attributes [list [list creator_id $creator_id] \ + [list instructions $instructions] \ + [list mode $mode] \ + [list editable_p $editable_p] \ + [list anonymous_p $anonymous_p] \ + [list secure_access_p $secure_access_p] \ + [list reuse_responses_p $reuse_responses_p] \ + [list show_item_name_p $show_item_name_p] \ + [list entry_page $entry_page] \ + [list exit_page $exit_page] \ + [list consent_page $consent_page] \ + [list return_url $return_url] \ + [list start_time $start_time] \ + [list end_time $end_time] \ + [list number_tries $number_tries] \ + [list wait_between_tries $wait_between_tries] \ + [list time_for_response $time_for_response] \ + [list show_feedback $show_feedback] \ + [list section_navigation $section_navigation] ] ] + + copy_sections -assessment_id $assessment_rev_id -new_assessment_id $new_rev_id + } + + return $assessment_rev_id +} + +ad_proc -public as::assessment::data { + {-assessment_id:required} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-10-25 + + Get all assessment info + + creates a tcl array variable named "assessment_data" in the caller's environment, + which contains key/value pairs for all properties of the requested assessment. +} { + upvar assessment_data assessment_data + + if {[empty_string_p $assessment_id]} { + db_1row lookup_assessment_id "" + } + + db_1row get_data_by_assessment_id {} -column_array assessment_data + + if {![info exists assessment_data(assessment_id)]} { + # assessment doesn't exist, caller has to handle this in their + # own way + return + } + + set assessment_data(creator_name) [person::name -person_id $assessment_data(creation_user)] +} + +ad_proc -public as::assessment::new_revision { + {-assessment_id:required} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-11-02 + + Creates new revision of an assessment with all sections +} { + data -assessment_id $assessment_id + array set a [array get assessment_data] + + db_transaction { + set new_rev_id [content::revision::new \ + -item_id $assessment_id \ + -content_type {as_assessments} \ + -title $a(title) \ + -description $a(description) \ + -attributes [list [list creator_id $a(creator_id)] \ + [list instructions $a(instructions)] \ + [list mode $a(mode)] \ + [list editable_p $a(editable_p)] \ + [list anonymous_p $a(anonymous_p)] \ + [list secure_access_p $a(secure_access_p)] \ + [list reuse_responses_p $a(reuse_responses_p)] \ + [list show_item_name_p $a(show_item_name_p)] \ + [list entry_page $a(entry_page)] \ + [list exit_page $a(exit_page)] \ + [list consent_page $a(consent_page)] \ + [list return_url $a(return_url)] \ + [list start_time $a(start_time)] \ + [list end_time $a(end_time)] \ + [list number_tries $a(number_tries)] \ + [list wait_between_tries $a(wait_between_tries)] \ + [list time_for_response $a(time_for_response)] \ + [list show_feedback $a(show_feedback)] \ + [list section_navigation $a(section_navigation)] ] ] + + copy_sections -assessment_id $a(assessment_rev_id) -new_assessment_id $new_rev_id + } + + return $new_rev_id +} + +ad_proc as::assessment::copy_sections { + {-assessment_id:required} + {-new_assessment_id:required} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-11-07 + + Copies all sections from assessment_id to new_assessment_id +} { + db_dml copy_sections {} +} Index: openacs-4/packages/assessment/tcl/as-assessment-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.xql 14 Nov 2004 16:45:52 -0000 1.1 @@ -0,0 +1,54 @@ + + + + + + + select assessment_id + from as_assessment_section_map + where section_id = :section_id + + + + + + + + select a.assessment_id as assessment_rev_id, cr.item_id as assessment_id, cr.title, + cr.description, o.creation_user, o.creation_date, a.instructions, a.mode, + a.editable_p, a.anonymous_p, a.secure_access_p, a.reuse_responses_p, + a.show_item_name_p, a.entry_page, a.exit_page, a.consent_page, a.return_url, + a.start_time, a.end_time, a.number_tries, a.wait_between_tries, + a.time_for_response, a.show_feedback, a.section_navigation, a.creator_id + from as_assessments a, cr_revisions cr, cr_items ci, acs_objects o + where ci.item_id = :assessment_id + and cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + and o.object_id = a.assessment_id + + + + + + + + select latest_revision + from cr_items + where item_id = :assessment_id + + + + + + + + insert into as_assessment_section_map + (select :new_assessment_id as assessment_id, section_id, feedback_text, + max_time_to_complete, sort_order + from as_assessment_section_map + where assessment_id = :assessment_id) + + + + + Index: openacs-4/packages/assessment/tcl/as-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-install-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/tcl/as-install-procs.tcl 25 Oct 2004 16:05:11 -0000 1.2 +++ openacs-4/packages/assessment/tcl/as-install-procs.tcl 14 Nov 2004 16:47:04 -0000 1.3 @@ -102,12 +102,18 @@ content::type::create_attribute -content_type {as_items} -attribute_name {feedback_right} -datatype {string} -pretty_name {Item Wrong Feedback} -column_spec {text} +content::type::create_attribute -content_type {as_sections} -attribute_name {section_display_type_id} -datatype {number} -pretty_name {Section Display Type} -column_spec {integer} content::type::create_attribute -content_type {as_sections} -attribute_name {instructions} -datatype {string} -pretty_name {Section Instructions} -column_spec {text} +content::type::create_attribute -content_type {as_sections} -attribute_name {definition} -datatype {string} -pretty_name {Section Definition} -column_spec {text} +content::type::create_attribute -content_type {as_sections} -attribute_name {required_p} -datatype {boolean} -pretty_name {Section Required} -column_spec {char(1)} +content::type::create_attribute -content_type {as_sections} -attribute_name {feedback_text} -datatype {string} -pretty_name {Section Feedback} -column_spec {text} +content::type::create_attribute -content_type {as_sections} -attribute_name {max_time_to_complete} -datatype {number} -pretty_name {Section Max Time to Complete} -column_spec {integer} content::type::create_attribute -content_type {as_assessments} -attribute_name {creator_id} -datatype {number} -pretty_name {Assessment Creator Identifier} -column_spec {integer} content::type::create_attribute -content_type {as_assessments} -attribute_name {instructions} -datatype {string} -pretty_name {Assessment Creator Instructions} -column_spec {text} content::type::create_attribute -content_type {as_assessments} -attribute_name {mode} -datatype {string} -pretty_name {Assessment Mode} -column_spec {varchar(25)} +content::type::create_attribute -content_type {as_assessments} -attribute_name {editable_p} -datatype {boolean} -pretty_name {Assessment Editable} -column_spec {char(1)} content::type::create_attribute -content_type {as_assessments} -attribute_name {anonymous_p} -datatype {boolean} -pretty_name {Assessment Anonymous} -column_spec {char(1)} content::type::create_attribute -content_type {as_assessments} -attribute_name {secure_access_p} -datatype {boolean} -pretty_name {Assessment Secure Access} -column_spec {char(1)} content::type::create_attribute -content_type {as_assessments} -attribute_name {reuse_responses_p} -datatype {boolean} -pretty_name {Assessment Reuse Responses} -column_spec {char(1)} Index: openacs-4/packages/assessment/tcl/as-section-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 14 Oct 2004 11:44:51 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 14 Nov 2004 16:47:04 -0000 1.2 @@ -9,8 +9,13 @@ ad_proc -public as::section::new { {-name:required} {-title:required} - {-instructions ""} {-description ""} + {-definition ""} + {-instructions ""} + {-feedback_text ""} + {-max_time_to_complete ""} + {-required_p t} + {-section_display_type_id ""} } { @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-07-26 @@ -21,8 +26,101 @@ set folder_id [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] # Insert as_section in the CR (and as_sections table) getting the revision_id (as_section_id) - set section_item_id [content::item::new -parent_id $folder_id -content_type {as_sections} -name $name -title $title -description $description ] - set as_section_id [content::revision::new -item_id $section_item_id -content_type {as_sections} -title $title -description $description -attributes [list [list instructions $instructions] ] ] + db_transaction { + set section_item_id [content::item::new -parent_id $folder_id -content_type {as_sections} -name $name -title $title -description $description ] + set as_section_id [content::revision::new \ + -item_id $section_item_id \ + -content_type {as_sections} \ + -title $title \ + -description $description \ + -attributes [list [list definition $definition] \ + [list instructions $instructions] \ + [list feedback_text $feedback_text] \ + [list max_time_to_complete $max_time_to_complete] \ + [list required_p $required_p] \ + [list section_display_type_id $section_display_type_id] ] ] + } + return $as_section_id -} \ No newline at end of file +} + +ad_proc -public as::section::edit { + {-section_id:required} + {-title:required} + {-description ""} + {-definition ""} + {-instructions ""} + {-feedback_text ""} + {-max_time_to_complete ""} + {-required_p t} + {-section_display_type_id ""} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-10-26 + + Edit section in the database +} { + # edit as_section in the CR + set section_item_id [db_string section_item_id {}] + + db_transaction { + set new_section_id [content::revision::new \ + -item_id $section_item_id \ + -content_type {as_sections} \ + -title $title \ + -description $description \ + -attributes [list [list definition $definition] \ + [list instructions $instructions] \ + [list feedback_text $feedback_text] \ + [list max_time_to_complete $max_time_to_complete] \ + [list required_p $required_p] \ + [list section_display_type_id $section_display_type_id] ] ] + + copy_items -section_id $section_id -new_section_id $new_section_id + } + + return $new_section_id +} + +ad_proc -public as::section::new_revision { + {-section_id:required} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-11-07 + + Creates a new revision of a section with all items +} { + # edit as_section in the CR + db_1row section_data {} + + db_transaction { + set new_section_id [content::revision::new \ + -item_id $section_item_id \ + -content_type {as_sections} \ + -title $title \ + -description $description \ + -attributes [list [list definition $definition] \ + [list instructions $instructions] \ + [list feedback_text $feedback_text] \ + [list max_time_to_complete $max_time_to_complete] \ + [list required_p $required_p] \ + [list section_display_type_id $section_display_type_id] ] ] + + copy_items -section_id $section_id -new_section_id $new_section_id + } + + return $new_section_id +} + +ad_proc as::section::copy_items { + {-section_id:required} + {-new_section_id:required} +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2004-11-07 + + Copies all items from section_id to new_section_id +} { + db_dml copy_items {} +} Index: openacs-4/packages/assessment/tcl/as-section-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/tcl/as-section-procs.xql 14 Nov 2004 16:45:52 -0000 1.1 @@ -0,0 +1,40 @@ + + + + + + + select item_id + from cr_revisions + where revision_id = :section_id + + + + + + + + select cr.item_id as section_item_id, cr.title, cr.description, + s.definition, s.instructions, s.feedback_text, s.max_time_to_complete, + s.required_p, s.section_display_type_id + from cr_revisions cr, as_sections s + where cr.revision_id = :section_id + and s.section_id = cr.revision_id + + + + + + + + insert into as_item_section_map + (select as_item_id, :new_section_id, enabled_p, required_p, item_default, + content_value, numeric_value, feedback_text, max_time_to_complete, + adp_chunk, sort_order + from as_item_section_map + where section_id = :section_id) + + + + + Index: openacs-4/packages/assessment/www/admin/assessment-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/assessment-form.adp 14 Nov 2004 16:42:32 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/assessment-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/assessment-form.tcl 14 Nov 2004 16:42:32 -0000 1.1 @@ -0,0 +1,150 @@ +ad_page_contract { + Form to add/edit an assessment. + + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: +} { + assessment_id:integer,optional +} -properties { + context_bar:onevalue + page_title:onevalue +} + +if {[info exists assessment_id]} { + set page_title [_ assessment.Edit_Assessment] +} else { + set page_title [_ assessment.New_Assessment2] +} + +set context_bar [ad_context_bar $page_title] +set format "YYYY-MM-DD HH24:MI" + + +ad_form -name assessment_form -action assessment-form -form { + {assessment_id:key} +} + +if {![exists_and_not_null assessment_id]} { + ad_form -extend -name assessment_form -form { + {name:text {label "[_ assessment.Name]"} {html {size 40 maxlength 400}}} + } +} + +set boolean_options [list [list "[_ assessment.yes]" t] [list "[_ assessment.no]" f]] +set feedback_options [list [list "[_ assessment.None]" none] [list "[_ assessment.All]" all] [list "[_ assessment.Only_incorrect]" incorrect] [list "[_ assessment.Only_correct]" correct]] +set navigation_options [list [list "[_ assessment.Default_Path]" "default path"] [list "[_ assessment.Randomized]" randomized] [list "[_ assessment.Rulebased_branching]" "rule-based branching"]] + + +ad_form -extend -name assessment_form -form { + {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}}} + {description:text(textarea) {label "[_ assessment.Description]"} {html {rows 5 cols 80}}} + {instructions:text(textarea),optional {label "[_ assessment.Instructions]"} {html {rows 5 cols 80}}} + {mode:text,optional {label "[_ assessment.Mode]"} {html {size 25 maxlength 25}}} + {editable_p:text(select) {label "[_ assessment.Editable]"} {options $boolean_options}} + {anonymous_p:text(select) {label "[_ assessment.Anonymous_Responses]"} {options $boolean_options}} + {secure_access_p:text(select) {label "[_ assessment.Secure_Access_1]"} {options $boolean_options}} + {reuse_responses_p:text(select) {label "[_ assessment.Reuse_Responses_1]"} {options $boolean_options}} + {show_item_name_p:text(select) {label "[_ assessment.Show_Item_Name_1]"} {options $boolean_options}} + {entry_page:text,optional {label "[_ assessment.Entry_Page]"} {html {size 50 maxlength 50}}} + {exit_page:text,optional {label "[_ assessment.Exit_Page]"} {html {size 50 maxlength 50}}} + {consent_page:text(textarea),optional {label "[_ assessment.Consent_Page]"} {html {rows 5 cols 80}}} + {return_url:text,optional {label "[_ assessment.Return_Url]"} {html {size 50 maxlength 50}}} + {start_time:date,to_sql(sql_date),to_html(display_date),optional {label "[_ assessment.Start_Time]"} {format $format} {help}} + {end_time:date,to_sql(sql_date),to_html(display_date),optional {label "[_ assessment.End_Time]"} {format $format} {help}} + {number_tries:integer,optional {label "[_ assessment.Number_of_Tries]"} {html {size 10 maxlength 10}}} + {wait_between_tries:integer,optional {label "[_ assessment.Minutes_for_Retry]"} {html {size 10 maxlength 10}}} + {time_for_response:integer,optional {label "[_ assessment.time_for_completion]"} {html {size 10 maxlength 10}}} + {show_feedback:text(select),optional {label "[_ assessment.Show_Feedback]"} {options $feedback_options}} + {section_navigation:text(select),optional {label "[_ assessment.Section_Navigation]"} {options $navigation_options}} +} -new_request { + set name "" + set title "" + set description "" + set instructions "" + set mode "" + set editable_p f + set anonymous_p f + set secure_access_p f + set reuse_responses_p f + set show_item_name_p f + set entry_page "" + set exit_page "" + set consent_page "" + set return_url "" + set start_time "" + set end_time "" + set number_tries "" + set wait_between_tries "" + set time_for_response "" + set show_feedback "none" + set section_navigation "default path" +} -edit_request { + db_1row assessment_data {} + + if {![empty_string_p $start_time]} { + set start_time [util::date::acquire clock [clock scan $start_time]] + } + if {![empty_string_p $end_time]} { + set end_time [util::date::acquire clock [clock scan $end_time]] + } +} -on_submit { + if {$start_time == "NULL"} { + set start_time "" + } + if {$end_time == "NULL"} { + set end_time "" + } +} -new_data { + set assessment_rev_id [as::assessment::new \ + -name $name \ + -title $title \ + -description $description \ + -instructions $instructions \ + -mode $mode \ + -editable_p $editable_p \ + -anonymous_p $anonymous_p \ + -secure_access_p $secure_access_p \ + -reuse_responses_p $reuse_responses_p \ + -show_item_name_p $show_item_name_p \ + -entry_page $entry_page \ + -exit_page $exit_page \ + -consent_page $consent_page \ + -return_url $return_url \ + -start_time $start_time \ + -end_time $end_time \ + -number_tries $number_tries \ + -wait_between_tries $wait_between_tries \ + -time_for_response $time_for_response \ + -show_feedback $show_feedback \ + -section_navigation $section_navigation] + + set assessment_id [db_string assessment_id_from_revision {}] +} -edit_data { + set assessment_rev_id [as::assessment::edit \ + -assessment_id $assessment_id \ + -title $title \ + -description $description \ + -instructions $instructions \ + -mode $mode \ + -editable_p $editable_p \ + -anonymous_p $anonymous_p \ + -secure_access_p $secure_access_p \ + -reuse_responses_p $reuse_responses_p \ + -show_item_name_p $show_item_name_p \ + -entry_page $entry_page \ + -exit_page $exit_page \ + -consent_page $consent_page \ + -return_url $return_url \ + -start_time $start_time \ + -end_time $end_time \ + -number_tries $number_tries \ + -wait_between_tries $wait_between_tries \ + -time_for_response $time_for_response \ + -show_feedback $show_feedback \ + -section_navigation $section_navigation] +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/assessment-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/assessment-form.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/assessment-form.xql 14 Nov 2004 16:42:32 -0000 1.1 @@ -0,0 +1,30 @@ + + + + + + + select cr.title, cr.description, a.instructions, a.mode, a.editable_p, + a.anonymous_p, a.secure_access_p, a.reuse_responses_p, a.show_item_name_p, + a.entry_page, a.exit_page, a.consent_page, a.return_url, a.number_tries, + a.wait_between_tries, a.time_for_response, a.show_feedback, a.section_navigation, + to_char(a.start_time, :format) as start_time, to_char(a.end_time, :format) as end_time + from as_assessments a, cr_revisions cr, cr_items ci + where ci.item_id = :assessment_id + and cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + + + + + + + + select item_id + from cr_revisions + where revision_id = :assessment_rev_id + + + + + Index: openacs-4/packages/assessment/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/index.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/www/admin/index.tcl 7 Oct 2004 13:38:38 -0000 1.3 +++ openacs-4/packages/assessment/www/admin/index.tcl 14 Nov 2004 16:48:08 -0000 1.4 @@ -14,7 +14,7 @@ {zipfile:file {label "[_ assessment.Import_QTI_ZIP_File]"}} } -set actions [list "[_ assessment.New_Assessment]" assessment-create "[_ assessment.New_Assessment2]"] +set actions [list "[_ assessment.New_Assessment]" assessment-form "[_ assessment.New_Assessment2]"] if {[ad_permission_p [acs_magic_object "security_context_root"] "admin"]} { lappend actions "[_ assessment.Admin_catalog]" "catalog/" "[_ assessment.Admin_catalog]" Index: openacs-4/packages/assessment/www/admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/index.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/admin/index.xql 7 Oct 2004 13:38:38 -0000 1.1 +++ openacs-4/packages/assessment/www/admin/index.xql 14 Nov 2004 16:48:08 -0000 1.2 @@ -4,9 +4,11 @@ - SELECT assessment_id, title - FROM as_assessmentsx - order by title + select ci.item_id as assessment_id, cr.title + from cr_items ci, cr_revisions cr, as_assessments a + where cr.revision_id = ci.latest_revision + and a.assessment_id = cr.revision_id + order by cr.title Index: openacs-4/packages/assessment/www/admin/item-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-delete.adp 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/item-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-delete.tcl 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,53 @@ +ad_page_contract { + Confirmation form to remove an item from a section. + + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer + as_item_id:integer +} -properties { + context_bar:onevalue + page_title:onevalue +} + +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.remove_item]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] + +set confirm_options [list [list "[_ assessment.continue_with_remove]" t] [list "[_ assessment.cancel_and_return]" f]] + +ad_form -name item_delete_confirm -action item-delete -export { assessment_id section_id } -form { + {as_item_id:key} + {item_title:text(inform) {label "[_ assessment.remove_1]"}} + {from:text(inform) {label "[_ assessment.from]"} {value $assessment_data(title)}} + {confirmation:text(radio) {label " "} {options $confirm_options} {value f}} +} -select_query_name {item_title} -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] + + db_dml update_section_in_assessment {} + db_1row get_sort_order_to_be_removed {} + db_dml remove_item_from_section {} + db_dml move_up_items {} + } + } +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/item-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-delete.xql 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,57 @@ + + + + + + + select title as item_title + from cr_revisions + where revision_id = :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 + + + + + + + + select sort_order + from as_item_section_map + where section_id = :new_section_id + and as_item_id = :as_item_id + + + + + + + + delete from as_item_section_map + where section_id = :new_section_id + and as_item_id = :as_item_id + + + + + + + + update as_item_section_map + set sort_order = sort_order-1 + where section_id = :new_section_id + and sort_order > :sort_order + + + + + Index: openacs-4/packages/assessment/www/admin/item-swap-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-swap-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-swap-oracle.xql 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,15 @@ + + +oracle8.1.6 + + + +update as_item_section_map +set sort_order = (case when sort_order = :sort_order then :next_sort_order when sort_order = :next_sort_order then :sort_order end) +where section_id = :new_section_id +and sort_order in (:sort_order, :next_sort_order) + + + + + Index: openacs-4/packages/assessment/www/admin/item-swap-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-swap-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-swap-postgresql.xql 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,18 @@ + + +postgresql7.1 + + + +update as_item_section_map +set sort_order = (case when sort_order = (cast (:sort_order as integer)) then + cast (:next_sort_order as integer) + when +sort_order = (cast (:next_sort_order as integer)) then cast (:sort_order as integer) end) +where section_id = :new_section_id +and sort_order in (:sort_order, :next_sort_order) + + + + + Index: openacs-4/packages/assessment/www/admin/item-swap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-swap.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-swap.tcl 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,37 @@ +ad_page_contract { + + Swaps two items for a section, sort_order and sort_order - 1. + + @param section_id specifies the assessment section + @param sort_order position of item to be moved up or down + + @author timo@timohentschel.de + + @cvs-id $Id: item-swap.tcl + +} { + assessment_id:integer,notnull + section_id:integer,notnull + sort_order:integer,notnull + direction:notnull +} + +ad_require_permission $assessment_id admin + +if { $direction=="up" } { + set next_sort_order [expr { $sort_order - 1 }] +} else { + set next_sort_order [expr { $sort_order + 1 }] +} + +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 {} + db_dml swap_items {} +} on_error { + ad_return_error "Database error" "A database error occured:
$errmsg
" + ad_script_abort +} + +ad_returnredirect [export_vars -base one-a {assessment_id}] Index: openacs-4/packages/assessment/www/admin/item-swap.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/item-swap.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/item-swap.xql 14 Nov 2004 16:42:31 -0000 1.1 @@ -0,0 +1,15 @@ + + + + + + + update as_assessment_section_map + set section_id = :new_section_id + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/one-a.adp 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,143 @@ + +#assessment.One_Assessment_data# +@context_bar;noquote@ + +

#assessment.Assessment_Administration#

+ +@assessment_data.title@ #assessment.Created_by# @assessment_data.creator_name@#assessment.on_creation_date# + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#assessment.Assessment_Title#:

#assessment.Description#:

#assessment.Instructions#:

#assessment.Preview# + #assessment.Edit# + @assessment_data.title@ +

#assessment.None#@assessment_data.description;noquote@ +

#assessment.None#@assessment_data.instructions;noquote@

#assessment.View_Responses# + #assessment.By_user# | + #assessment.Summary# | + #assessment.CSV_file#
#assessment.Response_Options# #assessment.Users_may_edit_their_##assessment.Users_may_not_edit_th# - + [ + #assessment.make_non_editable##assessment.make_editable# ]
#assessment.anonymous_users_allow##assessment.reg_users_required# - + [ + #assessment.make_non_anonymous##assessment.make_anonymous# ]
#assessment.secure_access_require##assessment.unsecure_access_allow# - + [ + #assessment.make_unsecure##assessment.make_secure# ]
#assessment.reuse_responses##assessment.dont_reuse_responses# - + [ + #assessment.make_not_reuse_respo##assessment.make_reuse_responses# ]
#assessment.show_item_name##assessment.hide_item_name# - + [ + #assessment.make_hide_item_name##assessment.make_show_item_name# ]
#assessment.limited_tries##assessment.unlimited_tries# - + [ #assessment.Edit# ]
#assessment.time_to_wait##assessment.no_waiting# - + [ #assessment.Edit# ]
#assessment.time_response##assessment.unlimited_time# - + [ #assessment.Edit# ]
#assessment.Email_Options#@notification_chunk;noquote@
#assessment.Send_bulkmail# #assessment.regarding_this_assess#
+ +
#assessment.Extreme_Actions# #assessment.Delete_this_assess# #assessment.Removes_all_questio#
+ #assessment.Copy_this_assess# #assessment.Lets_you_use_this_a#
+
+ + + + + +

Sections

+ + + + + + + + + + + + + + +
@sections.rownum@. * #assessment.Edit# + +#assessment.add_new_section# + +#assessment.add_existing_section# + + + #assessment.Move_Down# + + + #assessment.Move_Up# + +#assessment.remove_section# + + (#assessment.max_time# @sections.max_time_to_complete@) +
+
+ @sections.title@ +
+
+ +
+ +
+ + + +

Sections

+ + + + +
+ #assessment.add_new_section# + #assessment.add_existing_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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/one-a.tcl 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,58 @@ +ad_page_contract { + + This page allows the admin to administer a single assessment. + + @param assessment_id integer specifying assessment + + @author timo@timohentschel.de + @date September 28, 2004 + @cvs-id $Id: +} { + assessment_id:integer + {section_id: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 +} + +set assessment_rev_id $assessment_data(assessment_rev_id) + +set creation_date [util_AnsiDatetoPrettyDate $assessment_data(creation_date)] +set creator_link [acs_community_member_url -user_id $assessment_data(creation_user)] +if {$assessment_data(number_tries) > 0} { + set response_limit_toggle "[_ assessment.allow_multiple]" +} else { + set response_limit_toggle "[_ assessment.allow_tries]" +} + +# allow site-wide admins to enable/disable assessments directly from here +set target "[export_vars -base one-a {assessment_id}]" + + +set context_bar [ad_context_bar $assessment_data(title)] + +set notification_chunk [notification::display::request_widget \ + -type assessment_response_notif \ + -object_id $assessment_id \ + -pretty_name $assessment_data(title) \ + -url [ad_conn url]?assessment_id=$assessment_id \ +] + +set sort_order 1 +db_multirow sections assessment_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 +return Index: openacs-4/packages/assessment/www/admin/one-a.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/one-a.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/one-a.xql 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,16 @@ + + + + + + select s.section_id, cr.title, s.definition, s.instructions, s.required_p, + s.feedback_text, s.max_time_to_complete, asm.sort_order + from as_sections s, cr_revisions cr, as_assessment_section_map asm + where cr.revision_id = s.section_id + and s.section_id = asm.section_id + and asm.assessment_id = :assessment_rev_id + order by asm.sort_order + + + + Index: openacs-4/packages/assessment/www/admin/section-delete.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-delete.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-delete.adp 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/section-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-delete.tcl 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,50 @@ +ad_page_contract { + Confirmation form to remove a section from an assessment. + + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer +} -properties { + context_bar:onevalue + page_title:onevalue +} + +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.remove_section]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] + +set confirm_options [list [list "[_ assessment.continue_with_remove]" t] [list "[_ assessment.cancel_and_return]" f]] + +ad_form -name section_delete_confirm -action section-delete -export { assessment_id } -form { + {section_id:key} + {section_title:text(inform) {label "[_ assessment.remove_1]"}} + {from:text(inform) {label "[_ assessment.from]"} {value $assessment_data(title)}} + {confirmation:text(radio) {label " "} {options $confirm_options} {value f}} +} -select_query_name {section_title} -on_submit { +} -on_submit { + if {$confirmation} { + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + + db_1row get_sort_order_to_be_removed {} + db_dml remove_section_from_assessment {} + db_dml move_up_sections {} + } + } +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/section-delete.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-delete.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-delete.xql 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,46 @@ + + + + + + + select title as section_title + from cr_revisions + where revision_id = :section_id + + + + + + + + select sort_order + from as_assessment_section_map + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + + + + delete from as_assessment_section_map + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + + + + update as_assessment_section_map + set sort_order = sort_order-1 + where assessment_id = :new_assessment_rev_id + and sort_order > :sort_order + + + + + Index: openacs-4/packages/assessment/www/admin/section-form.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-form.adp 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/section-form.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-form.tcl 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,111 @@ +ad_page_contract { + Form to add/edit a section. + + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: +} { + assessment_id:integer + section_id:integer,optional + after:integer,optional +} -properties { + context_bar:onevalue + page_title:onevalue +} + +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]} { + set page_title [_ assessment.edit_section] +} else { + set page_title [_ assessment.add_new_section] +} + +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] + +set display_types [db_list_of_lists section_display_types {}] +set display_types [concat [list [list "" ""]] $display_types] + + +ad_form -name section_form -action section-form -export { assessment_id after } -form { + {section_id:key} +} + +if {[exists_and_not_null after]} { + ad_form -extend -name section_form -form { + {name:text {label "[_ assessment.Name]"} {html {size 40 maxlength 400}}} + } +} + +set boolean_options [list [list "[_ assessment.yes]" t] [list "[_ assessment.no]" f]] + +ad_form -extend -name section_form -form { + {title:text {label "[_ assessment.Title]"} {html {size 80 maxlength 1000}}} + {description:text(textarea) {label "[_ assessment.Description]"} {html {rows 5 cols 80}}} + {definition:text(textarea),optional {label "[_ assessment.Definition]"} {html {rows 5 cols 80}}} + {instructions:text(textarea),optional {label "[_ assessment.Instructions]"} {html {rows 5 cols 80}}} + {feedback_text:text(textarea),optional {label "[_ assessment.Feedback]"} {html {rows 5 cols 80}}} + {max_time_to_complete:integer,optional {label "[_ assessment.time_for_completion]"} {html {size 10 maxlength 10}}} + {section_display_type_id:text(select),optional {label "[_ assessment.Display_Type]"} {options $display_types}} + {required_p:text(select) {label "[_ assessment.Required]"} {options $boolean_options}} +} -new_request { + set name "" + set title "" + set description "" + set definition "" + set instructions "" + set feedback_text "" + set max_time_to_complete "" + set section_display_type_id "" + set required_p t +} -edit_request { + db_1row section_data {} +} -new_data { + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + + set section_id [as::section::new \ + -name $name \ + -title $title \ + -description $description \ + -definition $definition \ + -instructions $instructions \ + -feedback_text $feedback_text \ + -max_time_to_complete $max_time_to_complete \ + -required_p $required_p \ + -section_display_type_id $section_display_type_id] + + db_dml move_down_sections {} + set sort_order [expr $after + 1] + db_dml add_section_to_assessment {} + } +} -edit_data { + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + + set new_section_id [as::section::edit \ + -section_id $section_id \ + -title $title \ + -description $description \ + -definition $definition \ + -instructions $instructions \ + -feedback_text $feedback_text \ + -max_time_to_complete $max_time_to_complete \ + -required_p $required_p \ + -section_display_type_id $section_display_type_id] + + db_dml update_section_of_assessment {} + } +} -after_submit { + ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/section-form.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-form.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-form.xql 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,59 @@ + + + + + + + select section_display_type_id, pagination_style + from as_section_display_types + + + + + + + + select ci.name, cr.title, cr.description, s.definition, s.instructions, + s.required_p, s.feedback_text, s.max_time_to_complete + from as_sections s, cr_revisions cr, cr_items ci + where cr.revision_id = s.section_id + and ci.item_id = cr.item_id + and s.section_id = :section_id + + + + + + + + update as_assessment_section_map + set sort_order = sort_order+1 + 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, :feedback_text, :max_time_to_complete, :sort_order) + + + + + + + + update as_assessment_section_map + set feedback_text = :feedback_text, + max_time_to_complete = :max_time_to_complete, + section_id = :new_section_id + where assessment_id = :new_assessment_rev_id + and section_id = :section_id + + + + + Index: openacs-4/packages/assessment/www/admin/section-swap-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-swap-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-swap-oracle.xql 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,16 @@ + + +oracle8.1.6 + + + + +update as_assessment_section_map +set sort_order = (case when sort_order = :sort_order then :next_sort_order when sort_order = :next_sort_order then :sort_order end) +where assessment_id = :new_assessment_rev_id +and sort_order in (:sort_order, :next_sort_order) + + + + + Index: openacs-4/packages/assessment/www/admin/section-swap-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-swap-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-swap-postgresql.xql 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,19 @@ + + +postgresql7.1 + + + + +update as_assessment_section_map +set sort_order = (case when sort_order = (cast (:sort_order as integer)) then + cast (:next_sort_order as integer) + when +sort_order = (cast (:next_sort_order as integer)) then cast (:sort_order as integer) end) +where assessment_id = :new_assessment_rev_id +and sort_order in (:sort_order, :next_sort_order) + + + + + Index: openacs-4/packages/assessment/www/admin/section-swap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/section-swap.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/section-swap.tcl 14 Nov 2004 16:43:21 -0000 1.1 @@ -0,0 +1,34 @@ +ad_page_contract { + + Swaps two sections for an assessment, sort_order and sort_order - 1. + + @param assessment_id specifies the assessment + @param sort_order position of section to be moved up or down + + @author timo@timohentschel.de + + @cvs-id $Id: section-swap.tcl + +} { + assessment_id:integer,notnull + sort_order:integer,notnull + direction:notnull +} + +ad_require_permission $assessment_id admin + +if { $direction=="up" } { + set next_sort_order [expr { $sort_order - 1 }] +} else { + set next_sort_order [expr { $sort_order + 1 }] +} + +db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + db_dml swap_sections {} +} on_error { + ad_return_error "Database error" "A database error occured:
$errmsg
" + ad_script_abort +} + +ad_returnredirect [export_vars -base one-a {assessment_id}]