Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -N -r1.36.2.9 -r1.36.2.10 --- openacs-4/packages/assessment/assessment.info 29 Oct 2005 19:52:54 -0000 1.36.2.9 +++ openacs-4/packages/assessment/assessment.info 27 Jan 2006 09:41:10 -0000 1.36.2.10 @@ -7,7 +7,7 @@ f f - + Eduardo Perez Ureta Assessment package that will replace the survey, quizz, complex survey, poll and other data collection packages @@ -17,7 +17,7 @@ Create assessments and evaluate. 0 - + 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 -N -r1.68.2.14 -r1.68.2.15 --- openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 29 Oct 2005 19:52:54 -0000 1.68.2.14 +++ openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 27 Jan 2006 09:41:09 -0000 1.68.2.15 @@ -335,6 +335,7 @@ Everyone who has already completed this assessment Everyone who has not yet completed this assessment Prepend an empty item to the list + This field is used to validate the answer entered. This must have a multiple of 2 lines. The first line is a TCL expression to be used to check the answer and the second line is the error message. The string %%answer%% will be replaced by the answer entered. Make anonymous Make editable Hide item name @@ -570,6 +571,7 @@ User Users may edit their responses Users may not edit their responses + Validation Block Name Vertical All responses Index: openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql,v diff -u -N -r1.16.2.2 -r1.16.2.3 --- openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql 4 Jul 2005 15:26:16 -0000 1.16.2.2 +++ openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql 27 Jan 2006 09:41:09 -0000 1.16.2.3 @@ -31,7 +31,9 @@ -- wrong feedback feedback_wrong text, -- number of points for item; might be used for defining difficulty levels - points integer + points integer, + -- ad_form validation block + validate_block text ); -- contains additional information for all multiple choices (radiobutton, checkbox) Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.16-0.17.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.16-0.17.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.16-0.17.sql 27 Jan 2006 09:41:09 -0000 1.1.2.1 @@ -0,0 +1,10 @@ +-- +-- packages/assessment/sql/postgresql/upgrade/upgrade-0.16-0.17.sql +-- +-- @author Roel Canicula (roel@solutiongrove.com) +-- @creation-date 2006-01-25 +-- @arch-tag: 63dc39c9-c94d-454b-ac93-b81135ebb6ae +-- @cvs-id $Id: upgrade-0.16-0.17.sql,v 1.1.2.1 2006/01/27 09:41:09 roelc Exp $ +-- + +alter table as_items add validate_block text; 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 -N -r1.30.2.12 -r1.30.2.13 --- openacs-4/packages/assessment/tcl/as-install-procs.tcl 29 Oct 2005 19:52:53 -0000 1.30.2.12 +++ openacs-4/packages/assessment/tcl/as-install-procs.tcl 27 Jan 2006 09:41:09 -0000 1.30.2.13 @@ -128,6 +128,7 @@ content::type::attribute::new -content_type {as_items} -attribute_name {feedback_wrong} -datatype {text} -pretty_name {Item Right Feedback} -column_spec {text} content::type::attribute::new -content_type {as_items} -attribute_name {feedback_right} -datatype {text} -pretty_name {Item Wrong Feedback} -column_spec {text} content::type::attribute::new -content_type {as_items} -attribute_name {points} -datatype {number} -pretty_name {Points awarded for this item} -column_spec {integer} +content::type::attribute::new -content_type {as_items} -attribute_name {validate_block} -datatype {text} -pretty_name {Validation Block} -column_spec {text} # Sections content::type::attribute::new -content_type {as_sections} -attribute_name {display_type_id} -datatype {number} -pretty_name {Section Display Type} -column_spec {integer} @@ -425,6 +426,9 @@ 0.15 0.16 { content::type::attribute::new -content_type {as_item_display_sb} -attribute_name {prepend_empty_p} -datatype {string} -pretty_name {Prepend Empty Item} -column_spec {char(1)} } + 0.16 0.17 { + content::type::attribute::new -content_type {as_items} -attribute_name {validate_block} -datatype {text} -pretty_name {Validation Block} -column_spec {text} + } } } Index: openacs-4/packages/assessment/tcl/as-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-procs.tcl,v diff -u -N -r1.14.2.2 -r1.14.2.3 --- openacs-4/packages/assessment/tcl/as-item-procs.tcl 9 Aug 2005 00:31:14 -0000 1.14.2.2 +++ openacs-4/packages/assessment/tcl/as-item-procs.tcl 27 Jan 2006 09:41:09 -0000 1.14.2.3 @@ -20,6 +20,7 @@ {-feedback_wrong ""} {-points ""} {-package_id ""} + {-validate_block ""} } { @author Eduardo Perez (eperez@it.uc3m.es) @creation-date 2004-07-26 @@ -53,7 +54,8 @@ [list max_time_to_complete $max_time_to_complete] \ [list feedback_right $feedback_right] \ [list feedback_wrong $feedback_wrong] \ - [list points $points] ] ] + [list points $points] \ + [list validate_block $validate_block] ] ] } return $as_item_id @@ -72,6 +74,7 @@ {-feedback_right ""} {-feedback_wrong ""} {-points ""} + {-validate_block ""} } { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2004-12-07 @@ -94,7 +97,8 @@ [list max_time_to_complete $max_time_to_complete] \ [list feedback_right $feedback_right] \ [list feedback_wrong $feedback_wrong] \ - [list points $points] ] ] + [list points $points] \ + [list validate_block $validate_block] ] ] copy_types -as_item_id $as_item_id -new_item_id $new_item_id } @@ -126,7 +130,8 @@ [list max_time_to_complete $max_time_to_complete] \ [list feedback_right $feedback_right] \ [list feedback_wrong $feedback_wrong] \ - [list points $points] ] ] + [list points $points] \ + [list validate_block $validate_block] ] ] copy_types -as_item_id $as_item_id -new_item_id $new_item_id as::assessment::copy_categories -from_id $as_item_id -to_id $new_item_id @@ -189,7 +194,8 @@ [list max_time_to_complete $max_time_to_complete] \ [list feedback_right $feedback_right] \ [list feedback_wrong $feedback_wrong] \ - [list points $points] ] ] + [list points $points] \ + [list validate_block $validate_block] ] ] as::assessment::copy_categories -from_id $as_item_id -to_id $new_item_id Index: openacs-4/packages/assessment/tcl/as-item-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-procs.xql,v diff -u -N -r1.6 -r1.6.2.1 --- openacs-4/packages/assessment/tcl/as-item-procs.xql 15 Apr 2005 17:26:46 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-item-procs.xql 27 Jan 2006 09:41:09 -0000 1.6.2.1 @@ -16,7 +16,7 @@ select cr.item_id as item_item_id, cr.title, cr.description, i.subtext, i.field_code, i.field_name, i.required_p, i.data_type, i.max_time_to_complete, - i.feedback_right, i.feedback_wrong, i.points + i.feedback_right, i.feedback_wrong, i.points, i.validate_block from cr_revisions cr, as_items i where cr.revision_id = :as_item_id and i.as_item_id = cr.revision_id Index: openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql,v diff -u -N -r1.6 -r1.6.2.1 --- openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql 11 Mar 2005 18:54:12 -0000 1.6 +++ openacs-4/packages/assessment/tcl/as-section-procs-postgresql.xql 27 Jan 2006 09:41:09 -0000 1.6.2.1 @@ -8,7 +8,7 @@ select s.as_item_id, ci.name, r.title, r.description, i.subtext, m.required_p, m.max_time_to_complete, r2.revision_id as content_rev_id, r2.title as content_filename, ci2.content_type, - ir.target_rev_id as as_item_type_id + ir.target_rev_id as as_item_type_id, i.validate_block from cr_items ci, as_items i, as_item_section_map m, cr_revisions r, as_item_rels ir, as_session_items s left outer join as_item_rels ar on (ar.item_rev_id = s.as_item_id and ar.rel_type = 'as_item_content_rel') @@ -34,7 +34,7 @@ select i.as_item_id, ci.name, cr.title, cr.description, i.subtext, m.required_p, m.max_time_to_complete, r2.revision_id as content_rev_id, r2.title as content_filename, ci2.content_type, m.fixed_position, - ir.target_rev_id as as_item_type_id + ir.target_rev_id as as_item_type_id, i.validate_block from as_item_section_map m, cr_revisions cr, cr_items ci, as_item_rels ir, as_items i left outer join as_item_rels ar on (ar.item_rev_id = i.as_item_id and ar.rel_type = 'as_item_content_rel') 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 -N -r1.23.2.3 -r1.23.2.4 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 26 Jul 2005 17:14:53 -0000 1.23.2.3 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 27 Jan 2006 09:41:09 -0000 1.23.2.4 @@ -220,7 +220,7 @@ set open_positions "" set max_pos 0 db_foreach section_items {} { - set section_items($as_item_id) [list $name $title $description $subtext $required_p $max_time_to_complete $content_rev_id $content_filename $content_type $as_item_type_id] + set section_items($as_item_id) [list $name $title $description $subtext $required_p $max_time_to_complete $content_rev_id $content_filename $content_type $as_item_type_id $validate_block] if {![empty_string_p $fixed_position] && $fixed_position != "0"} { set fixed_positions($fixed_position) $as_item_id if {$max_pos < $fixed_position} { Index: openacs-4/packages/assessment/www/assessment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/assessment.tcl,v diff -u -N -r1.47.2.6 -r1.47.2.7 --- openacs-4/packages/assessment/www/assessment.tcl 26 Jul 2005 13:41:25 -0000 1.47.2.6 +++ openacs-4/packages/assessment/www/assessment.tcl 27 Jan 2006 09:41:09 -0000 1.47.2.7 @@ -257,20 +257,27 @@ {session_id:text(hidden) {value $session_id}} } -multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html submitted_p content as_item_type_id choice_orientation next_title +multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html submitted_p content as_item_type_id choice_orientation next_title validate_block set unsubmitted_list [list] set validate_list [list] set required_count 0 foreach one_item $item_list { - util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id + util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id validate_block if {$required_p == "t"} { # make sure that mandatory items are answered lappend validate_list "response_to_item.$as_item_id {\[exists_and_not_null response_to_item($as_item_id)\]} \"\[_ assessment.form_element_required\]\"" incr required_count } + + foreach {check_expr check_message} [split $validate_block \n] { + regsub -all {%answer%} $check_expr \$response_to_item($as_item_id) check_expr + regsub -all {%answer%} [lang::util::localize $check_message] \$response_to_item($as_item_id) check_message + lappend validate_list "response_to_item.$as_item_id { $check_expr } { $check_message }" + } + set default_value "" set submitted_p f Index: openacs-4/packages/assessment/www/asm-admin/item-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-add.tcl,v diff -u -N -r1.7.2.4 -r1.7.2.5 --- openacs-4/packages/assessment/www/asm-admin/item-add.tcl 6 Sep 2005 12:45:40 -0000 1.7.2.4 +++ openacs-4/packages/assessment/www/asm-admin/item-add.tcl 27 Jan 2006 09:41:08 -0000 1.7.2.5 @@ -95,6 +95,7 @@ ad_form -extend -name item_add -form { {item_type:text(select) {label "[_ assessment.Item_Type]"} {options $item_types} {help_text "[_ assessment.Item_Type_help]"}} {num_choices:integer,optional,nospell {label "[_ assessment.Num_Choices]"} {html {size 5 maxlength 3}} {help_text "[_ assessment.Num_Choices_help]"}} + {validate_block:text(textarea),optional {label "[_ assessment.Validation_Block]"} {help_text "[_ assessment.lt_This_field_is_used_to]"} {html {cols 70 rows 6}}} } -new_request { set name "" set title "" @@ -143,7 +144,8 @@ -feedback_right $feedback_right \ -feedback_wrong $feedback_wrong \ -max_time_to_complete $max_time_to_complete \ - -points $points] + -points $points \ + -validate_block $validate_block] } else { set as_item_id [as::item::edit \ -as_item_id $as_item_id \ @@ -157,7 +159,8 @@ -feedback_right $feedback_right \ -feedback_wrong $feedback_wrong \ -max_time_to_complete $max_time_to_complete \ - -points $points] + -points $points \ + -validate_block $validate_block] db_dml delete_files {} } Index: openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl,v diff -u -N -r1.7.2.3 -r1.7.2.4 --- openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl 6 Sep 2005 12:45:40 -0000 1.7.2.3 +++ openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl 27 Jan 2006 09:41:08 -0000 1.7.2.4 @@ -92,6 +92,7 @@ {data_type_disp:text(inform) {label "[_ assessment.Data_Type]"} {help_text "[_ assessment.Data_Type_help]"}} {data_type:text(hidden)} {display_type:text(select) {label "[_ assessment.Display_Type]"} {options $display_types} {help_text "[_ assessment.Display_Type_help]"}} + {validate_block:text(textarea),optional {label "[_ assessment.Validation_Block]"} {help_text "[_ assessment.lt_This_field_is_used_to]"} {html {cols 70 rows 6}}} } -edit_request { db_1row general_item_data {} if {[empty_string_p $data_type]} { @@ -119,7 +120,8 @@ -feedback_right $feedback_right \ -feedback_wrong $feedback_wrong \ -max_time_to_complete $max_time_to_complete \ - -points $points] + -points $points \ + -validate_block $validate_block] if {[exists_and_not_null category_ids]} { category::map_object -object_id $new_item_id $category_ids Index: openacs-4/packages/assessment/www/asm-admin/item-edit-general.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-edit-general.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/assessment/www/asm-admin/item-edit-general.xql 15 Apr 2005 17:26:46 -0000 1.2 +++ openacs-4/packages/assessment/www/asm-admin/item-edit-general.xql 27 Jan 2006 09:41:08 -0000 1.2.2.1 @@ -40,7 +40,7 @@ select r.title, r.description, i.subtext, i.field_name, i.field_code, i.required_p, - i.feedback_right, i.feedback_wrong, i.max_time_to_complete, i.data_type, i.points + i.feedback_right, i.feedback_wrong, i.max_time_to_complete, i.data_type, i.points, i.validate_block from cr_revisions r, as_items i where r.revision_id = i.as_item_id and i.as_item_id = :as_item_id