Index: openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql 2 Sep 2008 01:08:46 -0000 1.7 +++ openacs-4/packages/assessment/sql/oracle/assessment-collected-data-create.sql 9 Sep 2008 17:28:21 -0000 1.8 @@ -74,7 +74,7 @@ constraint as_section_data_staff_id_fk references users(user_id) on delete cascade, - points integer, + points float, -- when the subject initiated the section creation_datetime date, -- when the final submission produced a complete section Index: openacs-4/packages/assessment/sql/oracle/assessment-item-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-item-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/sql/oracle/assessment-item-create.sql 15 May 2007 20:14:16 -0000 1.5 +++ openacs-4/packages/assessment/sql/oracle/assessment-item-create.sql 9 Sep 2008 17:28:22 -0000 1.6 @@ -32,7 +32,7 @@ -- wrong feedback feedback_wrong clob, -- number of points for item; might be used for defining difficulty levels - points integer + points float ); -- contains additional information for all multiple choices (radiobutton, checkbox) Index: openacs-4/packages/assessment/sql/oracle/assessment-section-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-section-create.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/assessment/sql/oracle/assessment-section-create.sql 15 May 2007 20:14:16 -0000 1.8 +++ openacs-4/packages/assessment/sql/oracle/assessment-section-create.sql 9 Sep 2008 17:28:22 -0000 1.9 @@ -50,7 +50,7 @@ -- number of items displayed num_items integer, -- number of points for section; might be used for defining difficulty levels - points integer, + points float, -- preset text to show user feedback_text clob, -- max number of seconds to perform Section Index: openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d5-0.22d6.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d5-0.22d6.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d5-0.22d6.sql 2 Sep 2008 01:08:46 -0000 1.2 +++ openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d5-0.22d6.sql 9 Sep 2008 17:28:22 -0000 1.3 @@ -78,3 +78,4 @@ / show errors; drop procedure as_item_data_choices_upd_trg; + Index: openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d6-0.22d7.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d6-0.22d7.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d6-0.22d7.sql 7 Sep 2008 19:38:13 -0000 1.2 +++ openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-0.22d6-0.22d7.sql 9 Sep 2008 17:28:22 -0000 1.3 @@ -53,3 +53,12 @@ / show errors; +alter table as_assessment_section_map rename column points to points_int; +alter table as_assessment_section_map add points type float; +update as_assessment_section_map set points=points_int; +alter table as_assessment_section_map drop column points_int; +alter table as_item_section_map alter points type float; +alter table as_item_section_map add points type float; +update as_item_section_map set points=points_int; +alter table as_item_section_map drop column points_int; + Index: openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql,v diff -u -r1.14 -r1.15 --- openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 2 Sep 2008 01:08:46 -0000 1.14 +++ openacs-4/packages/assessment/sql/postgresql/assessment-collected-data-create.sql 9 Sep 2008 17:28:22 -0000 1.15 @@ -74,7 +74,7 @@ constraint as_section_data_staff_id_fk references users(user_id) on delete cascade, - points integer, + points float, -- when the subject initiated the section creation_datetime timestamptz, -- when the final submission produced a complete section 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 -r1.18 -r1.19 --- openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql 15 May 2007 20:14:16 -0000 1.18 +++ openacs-4/packages/assessment/sql/postgresql/assessment-item-create.sql 9 Sep 2008 17:28:22 -0000 1.19 @@ -32,7 +32,7 @@ -- wrong feedback feedback_wrong text, -- number of points for item; might be used for defining difficulty levels - points integer, + points float, -- ad_form validation block validate_block text ); Index: openacs-4/packages/assessment/sql/postgresql/assessment-section-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-section-create.sql,v diff -u -r1.20 -r1.21 --- openacs-4/packages/assessment/sql/postgresql/assessment-section-create.sql 27 May 2008 16:15:59 -0000 1.20 +++ openacs-4/packages/assessment/sql/postgresql/assessment-section-create.sql 9 Sep 2008 17:28:22 -0000 1.21 @@ -50,7 +50,7 @@ -- number of items displayed num_items integer, -- number of points for section; might be used for defining difficulty levels - points integer, + points float, -- preset text to show user feedback_text text, -- max number of seconds to perform Section @@ -164,7 +164,7 @@ -- order in which a section will be displayed sort_order integer, -- this is the relative weight of a section in an assessment - points integer, + points float, constraint as_assessment_section_map_pk primary key (assessment_id, section_id) ); @@ -192,7 +192,7 @@ -- fixed position in display. 0 for default, negative values relative to section end fixed_position integer, -- this is the relative weight of an item in a section - points integer, + points float, constraint as_item_section_map_pk primary key (section_id, as_item_id) ); Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.22d6-0.22d7.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.22d6-0.22d7.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.22d6-0.22d7.sql 7 Sep 2008 19:38:13 -0000 1.2 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-0.22d6-0.22d7.sql 9 Sep 2008 17:28:22 -0000 1.3 @@ -22,3 +22,6 @@ drop view as_section_datai cascade; alter table as_section_data alter points type float; select content_type__refresh_view('as_section_data'); + +alter table as_assessment_section_map alter points type float; +alter table as_item_section_map alter points type float; Index: openacs-4/packages/assessment/www/asm-admin/item-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-add.adp,v diff -u -r1.10 -r1.11 --- openacs-4/packages/assessment/www/asm-admin/item-add.adp 5 Sep 2008 18:58:06 -0000 1.10 +++ openacs-4/packages/assessment/www/asm-admin/item-add.adp 9 Sep 2008 17:28:22 -0000 1.11 @@ -1,517 +1,251 @@ - - @page_title;noquote@ - @context;noquote@ - yui-skin-sam -

#assessment.Add_Question#

- - -
- -
- - #assessment.Question# - - - - - - -
- - #assessment.Question# - - - - - -
-
#assessment.required# -
-
- - -
- - -
- - -
- - -
- @formerror.question_text;noquote@ -
- -
-
- [i] - -
- -
- -
- -
- - #assessment.Answer_Required# - - - - - - -
- - #assessment.Required# - - - - - -
-
#assessment.required# -
-
- - -
- - -
- - -
- - -
- @formerror.required_p;noquote@ -
- -
-
- [i] - -
- -
- - - -
- -
- - #assessment.Points# - - - - - - -
- - #assessment.Points# - - - - - -
- - -
- - -
- - -
- - -
- @formerror.points;noquote@ -
- -
-
- [i] - -
- -
-
- - -
-
- -
-
-
- -
-
- - -
- - - - - -
- -
- -
- - #assessment.lt_Question_Type_and_Ans# - - - - - - -
- - - - - - - -
-
#assessment.required# -
-
- - -
- - -
- - - @formgroup.widget;noquote@ - -
-
-
- - -
- @formerror.item_type;noquote@ -
- -
-
- -
- -
is-visible - not-visible - - not-visible"> - - -
- - #assessment.Answer_Set# - - - - - - -
- - #assessment.Answer_Set# - - - - - -
- - -
- - -
- - -
- - -
- @formerror.add_existing_mc_id;noquote@ -
- -
-
- [i] - -
- -
- -
-
- -
-
- -
-
-
#assessment.correct_answer#
-
- - @formgroup.widget;noquote@ - -
-
-
- -
- -
-
-
- -
- - - -
- - - - - - - - -
- - - - - - - -
- - -
- - -
- - - @formgroup.widget;noquote@ - -
-
-
- - -
- @formerror.allow_other_p;noquote@ -
- -
-
- [i] - -
- -
- -
- -
- - - -
- - #assessment.lt_Save_choices_as_answe# - - - - - - -
- - #assessment.lt_Save_choices_as_answe# - - - - - -
- - - -
- -
- -
- - -
- - #assessment.Reference_Answer# - - - - - - -
- - #assessment.Reference_Answer# - - - - - -
- - -
- - -
- - -
- - -
- @formerror.reference_answer;noquote@ -
- -
-
- [i] - -
- -
- -
- -
- - -
- -
- - #assessment.lt_Correct_Response_Feed#
#assessment.Optional# -
- - - - - -
- - #assessment.lt_Correct_Response_Feed#
#assessment.Optional# -
- - - - -
- - -
- - -
- - -
- - -
- @formerror.feedback_right;noquote@ -
- -
-
- [i] - -
- -
- -
- -
- - #assessment.lt_Incorrect_Response_Fe#
#assessment.Optional# -
- - - - - -
- - #assessment.lt_Incorrect_Response_Fe#
#assessment.Optional# -
- - - - -
- - -
- - -
- - -
- - -
- @formerror.feedback_wrong;noquote@ -
- -
-
- [i] - -
- -
- -
- -
- - -
- - + +@page_title;noquote@ +@context;noquote@ + + +
+#assessment.Question# + +
+ + + + + + + + + + * + + + + + + + + + + + + + +
+ @formerror.question_text;noquote@ +
+
+ +

+ + + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ @formerror.required_p;noquote@ +
+ +

+ + + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ @formerror.feedback_right;noquote@ +
+ +

+ + + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ @formerror.feedback_wrong;noquote@ +
+ +

+ + +

+ + + + + + + + + + + + + + + + + +
+ @formerror.points;noquote@ +
+

+ +

+
+
+
+ + #assessment.Question_Type# + * + + + +
+ + +
+ + + + +
+ @formerror.item_type;noquote@ +
+
+ +
+ #assessment.Multiple_Choice# +

#assessment.item_type_multiple_choice_help#

+
+ + +

#assessment.Correct_Answer#
+ + + @formgroup.widget;noquote@ + +  
+

+ + @formgroup.widget;noquote@ +
+
+ +
+

#assessment.Or_use_choices_from_an_existing_question#
+ +

+
+
+
+
+
+#assessment.Short_Answer# +

#assessment.item_type_short_answer_help#

+ +
+
+#assessment.Long_Answer# +

#assessment.item_type_long_answer_help#

+ +
+ +

+
+
+#assessment.File_Upload# +

#assessment.item_type_file_upload_help#

+ +
+
+
+
+
+ +
+ +
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 -r1.21 -r1.22 --- openacs-4/packages/assessment/www/asm-admin/item-add.tcl 7 Sep 2008 19:38:13 -0000 1.21 +++ openacs-4/packages/assessment/www/asm-admin/item-add.tcl 9 Sep 2008 17:28:22 -0000 1.22 @@ -6,17 +6,15 @@ } { assessment_id:integer section_id:integer - {after:integer "0"} + after:integer choice:optional,array correct:optional,array - {return_url ""} } -properties { context:onevalue page_title:onevalue } set package_id [ad_conn package_id] -set package_url [ad_conn package_url] permission::require_permission -object_id $package_id -privilege create permission::require_permission -object_id $assessment_id -privilege admin @@ -44,146 +42,82 @@ set item_types [as_item_type::get_item_types] -ad_form -name item-add -action item-add -export { assessment_id section_id after type return_url } -html {enctype multipart/form-data} -form { - - {as_item_id:key} - {question_text:richtext,nospell - {label "[_ assessment.item_Question]"} - {html {rows 12 cols 80 style {width: 99%}}} - {help_text "[_ assessment.item_Question_help]"}} - } - +ad_form -name item-add -action item-add -export { assessment_id section_id after type } -html {enctype multipart/form-data} -form { + {as_item_id:key} + {question_text:richtext,nospell {label "[_ assessment.item_Question]"} {html {rows 12 cols 80 style {width: 99%}}} {help_text "[_ assessment.item_Question_help]"}} +} if { $type ne "survey"} { -# ad_form -extend -name item-add -form { -# {description:text(textarea),optional -# {label "[_ assessment.Description]"} -# {html {rows 12 cols 80}} -# {help_text "[_ assessment.item_Description_help]"} -# } -# } +# ad_form -extend -name item-add -form {{description:text(textarea),optional {label "[_ assessment.Description]"} {html {rows 12 cols 80}} {help_text "[_ assessment.item_Description_help]"}} +# } } 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-add } if { $type ne "survey"} { -# ad_form -extend -name item-add -form { -# {content:file,optional -# {label "[_ assessment.item_Content]"} -# {help_text "[_ assessment.item_Content_help]"} -# } -# {field_name:text,optional,nospell -# {label "[_ assessment.Field_Name]"} -# {html {size 80 maxlength 500}} -# {help_text "[_ assessment.Field_Name_help]"} -# } -# {field_code:text,optional,nospell -# {label "[_ assessment.Field_Code]"} -# {html {size 80 maxlength 500}} -# {help_text "[_ assessment.Field_Code_help]"} -# } -# } -} - ad_form -extend -name item-add -form { - {required_p:text(select) - {label "[_ assessment.Required]"} - {options $boolean_options} - {help_text "[_ assessment.item_Required_help]"} - } +# {content:file,optional {label "[_ assessment.item_Content]"} {help_text "[_ assessment.item_Content_help]"}} +# {field_name:text,optional,nospell {label "[_ assessment.Field_Name]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Field_Name_help]"}} +# {field_code:text,optional,nospell {label "[_ assessment.Field_Code]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Field_Code_help]"}} } - +} +ad_form -extend -name item-add -form { {required_p:text(select) {label "[_ assessment.Required]"} {options $boolean_options} {help_text "[_ assessment.item_Required_help]"}} +} if { $type ne "survey"} { - ad_form -extend -name item-add -form { - {points:float,optional,nospell - {label "[_ assessment.points_item]"} - {html {size 10 maxlength 10}} - {value 1} - {help_text "[_ assessment.points_item_help]"} - } - {feedback_right:richtext,optional,nospell - {label "[_ assessment.Feedback_right]"} - {html {rows 12 cols 80 style {width: 99%}}} - {help_text "[_ assessment.Feedback_right_help]"} - } - {feedback_wrong:richtext,optional,nospell - {label "[_ assessment.Feedback_wrong]"} - {html {rows 12 cols 80 style {width: 99%}}} - {help_text "[_ assessment.Feedback_wrong_help]"} - } -# {max_time_to_complete:integer,optional,nospell -# {label "[_ assessment.time_for_completion]"} -# {html {size 10 maxlength 10}} -# {help_text "[_ assessment.item_time_help]"} -# } - {field_code:text(hidden),optional} - {field_name:text(hidden),optional} - {max_time_to_complete:text(hidden),optional} - {validate_block:text(hidden),optional} - {content:text(hidden),optional} - {description:text(hidden),optional {value ""}} - {data_type:text(hidden),optional {value ""}} - } +ad_form -extend -name item-add -form { + {points:integer,optional,nospell {label "[_ assessment.points_item]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.points_item_help]"}} + {feedback_right:richtext,optional,nospell {label "[_ assessment.Feedback_right]"} {html {rows 12 cols 80 style {width: 99%}}} {help_text "[_ assessment.Feedback_right_help]"}} + {feedback_wrong:richtext,optional,nospell {label "[_ assessment.Feedback_wrong]"} {html {rows 12 cols 80 style {width: 99%}}} {help_text "[_ assessment.Feedback_wrong_help]"}} +# {max_time_to_complete:integer,optional,nospell {label "[_ assessment.time_for_completion]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.item_time_help]"}} +# {points:integer,optional,nospell {label "[_ assessment.points_item]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.points_item_help]"}} + {field_code:text(hidden),optional} + {field_name:text(hidden),optional} + {max_time_to_complete:text(hidden),optional} + {validate_block:text(hidden),optional} + {content:text(hidden),optional} + {description:text(hidden),optional {value ""}} + {data_type:text(hidden),optional {value ""}} +} } else { - ad_form -extend -name item-add -form { - {description:text(hidden),optional {value ""}} - {content:text(hidden),optional {value ""}} - {field_name:text,optional,nospell - {label "[_ assessment.Field_Name]"} - {html {size 80 maxlength 500}} - {help_text "[_ assessment.Field_Name_help]"} - } - {field_code:text(hidden),optional {value ""}} - {feedback_right:text(hidden),optional {value ""}} - {feedback_wrong:text(hidden),optional {value ""}} - {max_time_to_complete:text(hidden),optional {value ""}} - {points:text(hidden),optional {value ""}} - {data_type:text(hidden),optional {value ""}} - {validate_block:text(textarea),optional \ - {label "[_ assessment.Validation_Block]"} \ - {help_text "[_ assessment.lt_This_field_is_used_to]"} \ - {html {cols 70 rows 6}}} - } +ad_form -extend -name item-add -form { + {description:text(hidden),optional {value ""}} + {content:text(hidden),optional {value ""}} + {field_name:text,optional,nospell {label "[_ assessment.Field_Name]"} {html {size 80 maxlength 500}} {help_text "[_ assessment.Field_Name_help]"}} + {field_code:text(hidden),optional {value ""}} + {feedback_right:text(hidden),optional {value ""}} + {feedback_wrong:text(hidden),optional {value ""}} + {max_time_to_complete:text(hidden),optional {value ""}} + {points:text(hidden),optional {value ""}} + {data_type:text(hidden),optional {value ""}} + {validate_block:text(textarea),optional \ + {label "[_ assessment.Validation_Block]"} \ + {help_text "[_ assessment.lt_This_field_is_used_to]"} \ + {html {cols 70 rows 6}}} } +} if { $type ne "survey"} { -# ad_form -extend -name item-add -form { -# {data_type:text(select) -# {label "[_ assessment.Data_Type]"} {options $data_types} -# {help_text "[_ assessment.Data_Type_help]"}} -# } + #ad_form -extend -name item-add -form { + # {data_type:text(select) {label "[_ assessment.Data_Type]"} {options $data_types} {help_text "[_ assessment.Data_Type_help]"}}} } -# reorder item types -foreach itype {sa oq mc sb ms fu} { - foreach elm $item_types { - if {[lindex $elm 1] eq $itype} { - lappend item_type_options $elm - } - } -} ad_form -extend -name item-add -form { - {item_type:text(radio) {label "[_ assessment.Item_Type]"} {options $item_type_options}} + {item_type:text(radio) {label "[_ assessment.Item_Type]"} {options $item_types} {help_text "[_ assessment.Item_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}}} {num_choices:text(hidden)} } -############################## +############################################################################## # Multiple Choice Section -############################## - +############################################################################## set choice_sets [db_list_of_lists existing_choice_sets {}] if {[llength $choice_sets]} { - set choice_sets [concat [list [list " -- " ""]] $choice_sets] + set choice_sets [concat [list [list "--" ""]] $choice_sets] ad_form -extend -name item-add -form { - {add_existing_mc_id:text(select),optional - {label "[_ assessment.Choice_Sets]"} - {options $choice_sets} - {help_text "[_ assessment.Choice_Sets_help]"} - } + {add_existing_mc_id:text(select),optional {label "[_ assessment.Choice_Sets]"} {options $choice_sets} {help_text "[_ assessment.Choice_Sets_help]"}} } } else { ad_form -extend -name item-add -form { @@ -192,30 +126,21 @@ } ad_form -extend -name item-add -form { - {allow_other_p:text(checkbox),optional - {label "[_ assessment.Allow_other]"} - {options {{"" t}}} - {help_text "[_ assessment.Allow_other_help]"} - } {save_answer_set:text(checkbox),optional - {label "[_ assessment.Save_this_set_of_answers_for_reuse_later]"} - {options {{"" t}}} + {options {{"#assessment.Save_this_set_of_answers_for_reuse_later#" t}}} } - {formbutton_add_another_choice:text(submit) - {label "[_ assessment.Add_another_choice]"} - } + {formbutton_add_another_choice:text(submit) {label "[_ assessment.Add_another_choice]"}} } - -if {[template::form::is_submission item-add] && [template::element::get_value item-add formbutton_add_another_choice] \ +if {[template::form::is_submission item-add] \ + && [template::element::get_value item-add formbutton_add_another_choice] \ eq [_ assessment.Add_another_choice]} { set num_choices [element::get_value item-add num_choices] incr num_choices element::set_value item-add num_choices $num_choices - # set an error in the form so that it is not processed and instead returns the form - template::form::set_error item-add item_type "" } -if {![template::form::is_submission item-add] && ![info exists num_choices]} { +if {![template::form::is_submission item-add] \ + && ![info exists num_choices]} { set num_choices 5 } else { set num_choices [template::element::get_value item-add num_choices] @@ -233,11 +158,7 @@ # for open questions ad_form -extend -name item-add -form { - {reference_answer:text(textarea),optional - {label "[_ assessment.oq_Reference_Answer]"} - {html {rows 5 style {width:95%}}} - {help_text "[_ assessment.oq_Reference_Answer_help]"} - } + {reference_answer:text(textarea),optional {label "[_ assessment.oq_Reference_Answer]"} {html {rows 5 cols 30 style {width:95%}}} {help_text "[_ assessment.oq_Reference_Answer_help]"}} } ad_form -extend -name item-add -form { @@ -248,9 +169,7 @@ ad_form -extend -name item-add -validate { {item_type {$item_type ne "mc" || [exists_and_not_null add_existing_mc_id] || [array size choice] > [llength [lsearch -all -exact [array get choice] ""]]} "Please enter at least one choice for multiple choice question."} } - ad_form -extend -name item-add -new_request { - set name "" set question_text "" set description "" @@ -260,190 +179,171 @@ set feedback_right "" set feedback_wrong "" set max_time_to_complete "" + set points "" set num_choices 5 set ms_label "Choose all that apply" - } -on_submit { - set category_ids [category::ad_form::get_categories -container_object_id $package_id] if {[empty_string_p $points]} { set points 0 } if {![exists_and_not_null formbutton_add_another_choice]} { - # map display types to data types - switch -exact $item_type { - sa { - set data_type "varchar" - set display_type "tb" - } - oq { - set data_type "text" - set display_type "ta" - } - mc { - set data_type "varchar" - set display_type "rb" - } - sb { - # sb is just multiple choice with select box - set item_type "mc" - set data_type "varchar" - set display_type "sb" - } - ms { - #multiple select is just multiple choice with checkboxes - set item_type "mc" - set data_type "varchar" - set display_type "cb" - } - fu { - set data_type "file" - set display_type "fu" - } - } - set question_text [template::util::richtext::get_property content $question_text] - set feedback_right [template::util::richtext::get_property content $feedback_right] - set feedback_wrong [template::util::richtext::get_property content $feedback_wrong] - db_transaction { - if {![db_0or1row item_exists {}]} { + # map display types to data types + switch -exact $item_type { + sa { + set data_type "varchar" + set display_type "tb" + } + oq { + set data_type "text" + set display_type "ta" + } + mc { + set data_type "varchar" + set display_type "rb" + } + ms { + #multiple select is just multiple choice with checkboxes + set item_type "mc" + set data_type "varchar" + set display_type "cb" + } + fu { + set data_type "file" + set display_type "fu" + } + } + set question_text [template::util::richtext::get_property content $question_text] + set feedback_right [template::util::richtext::get_property content $feedback_right] + set feedback_wrong [template::util::richtext::get_property content $feedback_wrong] + db_transaction { + if {![db_0or1row item_exists {}]} { - set as_item_id [as::item::new \ - -item_item_id $as_item_id \ - -title $question_text \ - -description $description \ - -field_name $field_name \ - -field_code $field_code \ - -required_p $required_p \ - -data_type $data_type \ - -feedback_right $feedback_right \ - -feedback_wrong $feedback_wrong \ - -max_time_to_complete $max_time_to_complete \ - -points $points \ - -validate_block $validate_block] - } else { - set as_item_id [as::item::edit \ - -as_item_id $as_item_id \ - -title $question_text \ - -description $description \ - -field_name $field_name \ - -field_code $field_code \ - -required_p $required_p \ - -data_type $data_type \ - -feedback_right $feedback_right \ - -feedback_wrong $feedback_wrong \ - -max_time_to_complete $max_time_to_complete \ - -points $points \ - -validate_block $validate_block] + set as_item_id [as::item::new \ + -item_item_id $as_item_id \ + -title $question_text \ + -description $description \ + -field_name $field_name \ + -field_code $field_code \ + -required_p $required_p \ + -data_type $data_type \ + -feedback_right $feedback_right \ + -feedback_wrong $feedback_wrong \ + -max_time_to_complete $max_time_to_complete \ + -points $points \ + -validate_block $validate_block] + } else { + set as_item_id [as::item::edit \ + -as_item_id $as_item_id \ + -title $question_text \ + -description $description \ + -field_name $field_name \ + -field_code $field_code \ + -required_p $required_p \ + -data_type $data_type \ + -feedback_right $feedback_right \ + -feedback_wrong $feedback_wrong \ + -max_time_to_complete $max_time_to_complete \ + -points $points \ + -validate_block $validate_block] - db_dml delete_files {} - } + db_dml delete_files {} + } - if {[exists_and_not_null category_ids]} { - category::map_object -object_id $as_item_id $category_ids - } + if {[exists_and_not_null category_ids]} { + category::map_object -object_id $as_item_id $category_ids + } - if {![empty_string_p $content]} { - set filename [lindex $content 0] - set tmp_filename [lindex $content 1] - set file_mimetype [lindex $content 2] - set n_bytes [file size $tmp_filename] - set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] - set pretty_max_size [util_commify_number $max_file_size] + if {![empty_string_p $content]} { + set filename [lindex $content 0] + set tmp_filename [lindex $content 1] + set file_mimetype [lindex $content 2] + set n_bytes [file size $tmp_filename] + set max_file_size 10000000 + # [ad_parameter MaxAttachmentSize] + set pretty_max_size [util_commify_number $max_file_size] - if { $n_bytes > $max_file_size && $max_file_size > 0 } { - ad_return_complaint 1 "[_ assessment.file_too_large]" - return - } - if { $n_bytes == 0 } { - ad_return_complaint 1 "[_ assessment.file_zero_size]" - return - } - - set content_rev_id [cr_import_content -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [as::item::generate_unique_name]] - as::item_rels::new -item_rev_id $as_item_id -target_rev_id $content_rev_id -type as_item_content_rel + if { $n_bytes > $max_file_size && $max_file_size > 0 } { + ad_return_complaint 1 "[_ assessment.file_too_large]" + return } - # check question type - set title [string range $question_text 0 999] - switch -exact $item_type { - mc { - # title for MC is the name of a saved answer set - # always set to empty on a new question and - # ask for the title seperately in save-answer-set page - if {$allow_other_p eq "on"} { - set allow_other_p "t" - } else { - set allow_other_p "f" - } - set new_mc_id [as::item_type_mc::add_to_assessment \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -choices [array get choice] \ - -correct_choices [array get correct] \ - -after $after \ - -title "" \ - -display_type $display_type \ - -allow_other_p $allow_other_p] + if { $n_bytes == 0 } { + ad_return_complaint 1 "[_ assessment.file_zero_size]" + return + } - if {[info exists add_existing_mc_id] && $add_existing_mc_id ne ""} { - set add_existing_mc_id [as::item_type_mc::copy -type_id $add_existing_mc_id -copy_correct_answer_p "f" -new_title ""] - if {![db_0or1row item_type {}] || $object_type != "as_item_type_mc"} { - if {![info exists object_type]} { - # first item type mapped - as::item_rels::new -item_rev_id $as_item_id -target_rev_id $add_existing_mc_id -type as_item_type_rel - } else { - # old item type existing - db_dml update_item_type {} - } + set content_rev_id [cr_import_content -title $filename $folder_id $tmp_filename $n_bytes $file_mimetype [as::item::generate_unique_name]] + as::item_rels::new -item_rev_id $as_item_id -target_rev_id $content_rev_id -type as_item_content_rel + } + # check question type + set title [string range $question_text 0 999] + switch -exact $item_type { + mc { + # title for MC is the name of a saved answer set + # always set to empty on a new question and + # ask for the title seperately in save-answer-set page + set new_mc_id [as::item_type_mc::add_to_assessment \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -choices [array get choice] \ + -correct_choices [array get correct] \ + -after $after \ + -title "" \ + -display_type $display_type] + + if {[info exists add_existing_mc_id] && $add_existing_mc_id ne ""} { + set add_existing_mc_id [as::item_type_mc::copy -type_id $add_existing_mc_id -copy_correct_answer_p "f" -new_title ""] + if {![db_0or1row item_type {}] || $object_type != "as_item_type_mc"} { + if {![info exists object_type]} { + # first item type mapped + as::item_rels::new -item_rev_id $as_item_id -target_rev_id $add_existing_mc_id -type as_item_type_rel } else { - # old mc item type existing + # old item type existing db_dml update_item_type {} } + } else { + # old mc item type existing + db_dml update_item_type {} } } - oq { - as::item_type_oq::add_to_assessment \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -after $after \ - -title $title \ - -reference_answer $reference_answer - } - sa { - as::item_type_sa::add_to_assessment \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -after $after \ - -title $title - } - fu { - as::item_type_fu::add_to_assessment \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -after $after \ - -title $title - } } - } + oq { + as::item_type_oq::add_to_assessment \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -after $after \ + -title $title + } + sa { + as::item_type_sa::add_to_assessment \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -after $after \ + -title $title + } + fu { + as::item_type_fu::add_to_assessment \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -after $after \ + -title $title + } + } } - -} -after_submit { - +} +} -after_submit { if {![exists_and_not_null formbutton_add_another_question] \ && ![exists_and_not_null formbutton_add_another_choice]} { - if {![info exists return_url] || $return_url eq ""} { - set return_url "[export_vars -base questions {assessment_id}]\&#Q$as_item_id" - } + set return_url "[export_vars -base questions {assessment_id}]\&#Q$as_item_id" } elseif {[exists_and_not_null formbutton_add_another_question]} { set after [expr {$after + 1}] - set return_url "[export_vars -base item-add {after assessment_id section_id return_url}]" + set return_url "[export_vars -base item-add {after assessment_id section_id}]\#Q$as_item_id" } - if {[info exists return_url] && $return_url ne ""} { if {[info exists save_answer_set] && $save_answer_set eq "on" && (![info exists add_existing_mc_id] || $add_existing_mc_id eq "")} { set return_url [export_vars -base save-answer-set {assessment_id as_item_id return_url {mc_id $new_mc_id}}] @@ -453,65 +353,5 @@ } } -#set error_p [expr {[template::form::is_submission item-add] && ![template::form::is_valid item-add]}] -#as::assessment::notify_response_on_edit -assessment_id $assessment_id -section_id $section_id -return_url "[export_vars -base questions {assessment_id}]" - -# mc item_type listener -set javascript [ah::yui::cssclass -element mc-options -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element mc-options -classname not-visible] -append javascript [ah::yui::cssclass -element open-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element open-options -classname is-visible] -append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:mc -event click -callback "function()\{$javascript\}"] -append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:ms -event click -callback "function()\{$javascript\}"] -append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:sb -event click -callback "function()\{$javascript\}"] - -# oq type listener -set javascript [ah::yui::cssclass -element open-options -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element open-options -classname not-visible] -append javascript [ah::yui::cssclass -element mc-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element mc-options -classname is-visible] -append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:oq -event click -callback "function()\{$javascript\}"] - -# other types listeners -set javascript [ah::yui::cssclass -element open-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element open-options -classname is-visible] -append javascript [ah::yui::cssclass -element mc-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element mc-options -classname is-visible] -foreach {elm} {sa fu} { - append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:sa -event click -callback "function()\{$javascript\}"] - append js_listeners [ah::yui::addlistener -element item-add:elements:item_type:fu -event click -callback "function()\{$javascript\}"] -} - -# feedback listener -set javascript [ah::yui::cssclass -element feedback-options -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element feedback-options -classname not-visible] -append javascript [ah::yui::cssclass -element link-add-feedback -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element link-add-feedback -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element link-hide-feedback -classname not-visible] -append javascript [ah::yui::cssclass -element link-hide-feedback -classname is-visible] -append js_listeners [ah::yui::addlistener -element link-add-feedback -event click -callback "function()\{$javascript\}"] -# feedback listener -set javascript [ah::yui::cssclass -element feedback-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element feedback-options -classname is-visible] -append javascript [ah::yui::cssclass -element link-hide-feedback -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element link-hide-feedback -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element link-add-feedback -classname not-visible] -append javascript [ah::yui::cssclass -element link-add-feedback -classname is-visible] -append js_listeners [ah::yui::addlistener -element link-hide-feedback -event click -callback "function()\{$javascript\}"] - -template::head::add_style \ - -style " - .form-label {text-align:left;} - .form-label label {font-weight:bold;} - .is-visible { display: block; } - .not-visible { display: none; } - form .form-item-wrapper-asm { - padding: 5px; - border: 1px solid #ccc; - margin-top: 8px; - margin-bottom: 8px; - } - " ad_return_template - 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 -r1.19 -r1.20 --- openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl 7 Sep 2008 19:38:13 -0000 1.19 +++ openacs-4/packages/assessment/www/asm-admin/item-edit-general.tcl 9 Sep 2008 17:28:22 -0000 1.20 @@ -12,7 +12,6 @@ move_up:optional,array move_down:optional,array delete:optional,array - return_url:optional } -properties { context:onevalue page_title:onevalue @@ -37,41 +36,26 @@ set boolean_options [list [list "[_ assessment.yes]" t] [list "[_ assessment.no]" f]] set type $assessment_data(type) -ad_form -name item_edit_general -action item-edit-general -export { assessment_id section_id return_url } -html {enctype multipart/form-data} -form { +ad_form -name item_edit_general -action item-edit-general -export { assessment_id section_id } -html {enctype multipart/form-data} -form { {as_item_id:key} - {question_text:richtext,nospell - {label "[_ assessment.Question]"} - {html {rows 12 cols 80 style {width: 95%}}} - {help_text "[_ assessment.item_Question_help]"} - } - {required_p:text(select) - {label "[_ assessment.Required]"} - {options $boolean_options} - {help_text "[_ assessment.item_Required_help]"} - } + {question_text:richtext,nospell {label "[_ assessment.Question]"} {html {rows 12 cols 80 style {width: 95%}}} {help_text "[_ assessment.item_Question_help]"}} + {required_p:text(select) {label "[_ assessment.Required]"} {options $boolean_options} {help_text "[_ assessment.item_Required_help]"}} } set item_type [string range [db_string get_item_type {}] end-1 end] set display_type [string range [db_string get_display_type {}] end-1 end] if { $item_type == "mc" } { ad_form -extend -name item_edit_general -form { - {display_type:text(radio),optional - {label "[_ assessment.singleanswermultipleanswer]"} - {options {{"[_ assessment.item_type_mc]" "rb"} - {"[_ assessment.Single_Response_Allowed_Dropdown_Box]" "sb"} - {"[_ assessment.item_type_ms]" "cb"}} - } - } - {allow_other_p:text(checkbox),optional - {label "[_ assessment.Allow_other]"} - {options {{"[_ assessment.Allow_Other]" "t"}}} - } - } -} else { - ad_form -extend -name item_edit_general -form { - {display_type:text(hidden),optional} + {display_type:text(radio),optional + {label "[_ assessment.singleanswermultipleanswer]"} + {options {{"[_ assessment.item_type_mc]" "rb"} {"[_ assessment.item_type_ms]" "cb"}}} + } } +} else { + ad_form -extend -name item_edit_general -form { + {display_type:text(hidden),optional} + } } set display_types [list] @@ -81,21 +65,9 @@ if { $type ne "survey"} { ad_form -extend -name item_edit_general -form { - {points:float,optional,nospell - {label "[_ assessment.points_item]"} - {html {size 10 maxlength 10}} - {help_text "[_ assessment.points_item_help]"} - } - {feedback_right:richtext,optional,nospell - {label "[_ assessment.Feedback_right]"} - {html {rows 12 cols 80 style {width:95%}}} - {help_text "[_ assessment.Feedback_right_help]"} - } - {feedback_wrong:richtext,optional,nospell - {label "[_ assessment.Feedback_wrong]"} - {html {rows 12 cols 80 style {width:95%}}} - {help_text "[_ assessment.Feedback_wrong_help]"} - } + {points:float,optional,nospell {label "[_ assessment.points_item]"} {html {size 10 maxlength 10}} {help_text "[_ assessment.points_item_help]"}} + {feedback_right:richtext,optional,nospell {label "[_ assessment.Feedback_right]"} {html {rows 12 cols 80 style {width:95%}}} {help_text "[_ assessment.Feedback_right_help]"}} + {feedback_wrong:richtext,optional,nospell {label "[_ assessment.Feedback_wrong]"} {html {rows 12 cols 80 style {width:95%}}} {help_text "[_ assessment.Feedback_wrong_help]"}} } } else { ad_form -extend -name item_edit_general -form { @@ -119,121 +91,138 @@ switch -- $item_type { - "mc" { set folder_id [as::assessment::folder_id -package_id $package_id] set choice_sets [list [list "--" ""]] - db_foreach existing_choice_sets {} { - set set_title [string trim [regsub {\[.*?\]} [ad_html_to_text $title] {}]] - lappend choice_sets [list [expr {$set_title eq "" ? $section_title : $set_title}] $revision_id] - } - if {[llength $choice_sets]} { - ad_form -extend -name item_edit_general -form { - {add_existing_mc_id:text(select),optional - {label "[_ assessment.Choice_Sets]"} - {options $choice_sets} - {help_text "[_ assessment.Choice_Sets_help]"} - } - } - } else { - ad_form -extend -name item_edit_general -form { - {add_existing_mc_id:text(hidden),optional} - } - } +db_foreach existing_choice_sets {} { + set set_title [string trim [regsub {\[.*?\]} [ad_html_to_text $title] {}]] + lappend choice_sets [list [expr {$set_title eq "" ? $section_title : $set_title}] $revision_id] +} +if {[llength $choice_sets]} { + ad_form -extend -name item_edit_general -form { + {add_existing_mc_id:text(select),optional {label "[_ assessment.Choice_Sets]"} {options $choice_sets} {help_text "[_ assessment.Choice_Sets_help]"}} + } +} else { + ad_form -extend -name item_edit_general -form { + {add_existing_mc_id:text(hidden),optional} + } +} + ad_form -extend -name item_edit_general -form { + {num_choices:text(hidden)} + {save_answer_set:text(checkbox),optional {label "[_ assessment.Save_this_set_of_answers_for_reuse_later]"} {options {{"" t}}}} + {add_another_choice:text(submit) {label "[_ assessment.Add_another_choice]"}} + } +ns_log notice "Add Another = '[template::element::get_value item_edit_general add_another_choice]' == '[_ assessment.Add_another_choice]'" + if {[template::form::is_submission item_edit_general] \ + && [template::element::get_value item_edit_general add_another_choice] eq [_ assessment.Add_another_choice]} { + set num_choices [element::get_value item_edit_general num_choices] + incr num_choices + element::set_value item_edit_general num_choices $num_choices + } - ad_form -extend -name item_edit_general -form { - {num_choices:text(hidden)} - {save_answer_set:text(checkbox),optional - {label "[_ assessment.Save_this_set_of_answers_for_reuse_later]"} - {options {{"" t}}} - } - {add_another_choice:text(submit) - {label "[_ assessment.Add_another_choice]"} - } - } - - if {[template::form::is_submission item_edit_general] \ - && [template::element::get_value item_edit_general add_another_choice] eq [_ assessment.Add_another_choice]} { - set num_choices [element::get_value item_edit_general num_choices] - incr num_choices - element::set_value item_edit_general num_choices $num_choices - } - +##### if {$display_type eq "cb"} { ad_form -extend -name item_edit_general -form { {ms_label:text,optional {label "Multiple Selection Instruction"}} } } +##### + set as_item_type_id [as::item::get_item_type_id -as_item_id $as_item_id] + if {[array exists move_up]} { + foreach n [array names move_up] { + array set new_array [as::item_type_mc::choices_swap \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -mc_id $as_item_type_id \ + -sort_order [db_string get_sort_order {}] \ + -direction up] + foreach var {as_item_id section_id} { + set $var $new_array($var) + template::element::set_value item_edit_general $var [set $var] + } + } + } + if {[array exists move_down]} { + foreach n [array names move_down] { + array set new_array [as::item_type_mc::choices_swap \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -mc_id $as_item_type_id \ + -sort_order [db_string get_sort_order {}] \ + -direction down] + } + foreach var {as_item_id section_id} { + set $var $new_array($var) + template::element::set_value item_edit_general $var [set $var] + } + } + if {[array exists delete]} { + foreach n [array names delete] { + array set new_array [as::item_type_mc::choice_delete \ + -assessment_id $assessment_id \ + -section_id $section_id \ + -as_item_id $as_item_id \ + -choice_id $n] + } + foreach var {as_item_id section_id} { + set $var $new_array($var) + } + } - set existing_choices [as::item_type_mc::existing_choices $as_item_id] +####### +####### + + + set existing_choices [as::item_type_mc::existing_choices $as_item_id] if {[llength $existing_choices] && ![info exists num_choices]} { set num_choices [llength $existing_choices] template::element::set_value item_edit_general num_choices $num_choices } - if {![template::form::is_submission item_edit_general] \ - && ![info exists num_choices]} { - set num_choices 5 - } elseif {![info exists num_choices]} { + if {![template::form::is_submission item_edit_general] \ + && ![info exists num_choices]} { + set num_choices 5 + } elseif {![info exists num_choices]} { set num_choices [expr {[set num_choices [template::element::get_value item_edit_general num_choices]] eq "" ? $num_choices : 5}] - } - - template::multirow create choice_elements id new_p - foreach c $existing_choices { - set id [lindex $c 1] - template::multirow append choice_elements $id f - if {[lindex $c 2] eq "t" && ![template::form::is_submission item_edit_general]} { - set correct($id) t - } - } + } - if {$num_choices > [llength $existing_choices]} { - set new_choices [expr {$num_choices - [llength $existing_choices] }] - for {set i 1} {$i <= $new_choices} {incr i} { - set id __new_${i} - set correct_p f - if {[info exists correct($id)]} { - set correct_p t - } - lappend existing_choices [list "" $id $correct_p] - template::multirow append choice_elements $id t - } - } - as::item_type_mc::add_existing_choices_to_edit_form \ - -form_id item_edit_general \ - -existing_choices $existing_choices \ - -choice_array_name choice \ - -correct_choice_array_name correct - + template::multirow create choice_elements id new_p + foreach c $existing_choices { + set id [lindex $c 1] + template::multirow append choice_elements $id f + if {[lindex $c 2] eq "t" && ![template::form::is_submission item_edit_general]} { + set correct($id) t + } } + + if {$num_choices > [llength $existing_choices]} { + set new_choices [expr {$num_choices - [llength $existing_choices] }] + for {set i 1} {$i <= $new_choices} {incr i} { + set id __new_${i} + set correct_p f + if {[info exists correct($id)]} { + set correct_p t + } + lappend existing_choices [list "" $id $correct_p] + template::multirow append choice_elements $id t + } + } + as::item_type_mc::add_existing_choices_to_edit_form \ + -form_id item_edit_general \ + -existing_choices $existing_choices \ + -choice_array_name choice \ + -correct_choice_array_name correct + + } "oq" { ad_form -extend -name item_edit_general -form { - {reference_answer:text(textarea),optional - {label "[_ assessment.oq_Reference_Answer]"} - {html {rows 5 cols 80}} - {help_text "[_ assessment.oq_Reference_Answer_help]"} - } + {reference_answer:text(textarea),optional {label "[_ assessment.oq_Reference_Answer]"} {html {rows 5 cols 80}} {help_text "[_ assessment.oq_Reference_Answer_help]"}} } } "sa" { } } - -# feedback listener -set javascript [ah::yui::cssclass -element feedback-options -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element feedback-options -classname not-visible] -append javascript [ah::yui::cssclass -element link-add-feedback -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element link-add-feedback -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element link-hide-feedback -classname not-visible] -append javascript [ah::yui::cssclass -element link-hide-feedback -classname is-visible] -append js_listeners [ah::yui::addlistener -element link-add-feedback -event click -callback "function()\{$javascript\}"] -# feedback listener -set javascript [ah::yui::cssclass -element feedback-options -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element feedback-options -classname is-visible] -append javascript [ah::yui::cssclass -element link-hide-feedback -classname not-visible] -append javascript [ah::yui::cssclass -action remove -element link-hide-feedback -classname is-visible] -append javascript [ah::yui::cssclass -action remove -element link-add-feedback -classname not-visible] -append javascript [ah::yui::cssclass -element link-add-feedback -classname is-visible] -append js_listeners [ah::yui::addlistener -element link-hide-feedback -event click -callback "function()\{$javascript\}"] ad_form -extend -name item_edit_general -edit_request { db_1row general_item_data {} @@ -243,21 +232,9 @@ set data_type_disp "[_ assessment.data_type_$data_type]" set question_text [template::util::richtext::create $question_text $mime_type] - if {$item_type eq "oq"} { - set reference_answer [db_string get_ra { - select reference_answer - from as_item_type_oq t join as_item_rels r on (r.target_rev_id = t.as_item_type_id) - where r.item_rev_id = :as_item_id - and rel_type = 'as_item_type_rel' - } -default ""] - } - set feedback_right [template::util::richtext::create $feedback_right $mime_type] set feedback_wrong [template::util::richtext::create $feedback_wrong $mime_type] - - if {$item_type eq "mc"} { - element set_values item_edit_general allow_other_p [as::item_type_mc::allow_other_p -item_type_id [as::item::get_item_type_id -as_item_id $as_item_id]] - } + # FIXME fill in reference answer } -on_request { set display_type [string range [db_string get_display_type {}] end-1 end] } -on_submit { @@ -266,7 +243,7 @@ set points 0 } } -edit_data { - if {![exists_and_not_null add_another_choice]} { + if {[exists_and_not_null formbutton_ok] || [exists_and_not_null formbutton_add_another_question]} { set question_text [template::util::richtext::get_property contents $question_text] set feedback_right [template::util::richtext::get_property content $feedback_right] set feedback_wrong [template::util::richtext::get_property content $feedback_wrong] @@ -344,10 +321,11 @@ -new_section_id $new_section_id \ -new_assessment_rev_id $new_assessment_rev_id + ns_log notice "HAM : $old_display_type : $display_type **********" if { ![string match $old_display_type $display_type] } { as::item_display_${display_type}::set_item_display_type -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id + -section_id $section_id \ + -as_item_id $as_item_id } set title [string range $question_text 0 999] @@ -391,18 +369,13 @@ # with each revision of the mc we decide if its # reusable or not - if {$allow_other_p ne "t"} { - set allow_other_p "f" - } - set new_item_type_id [as::item_type_mc::edit \ -as_item_type_id $as_item_type_id \ -title "" \ -increasing_p f \ -allow_negative_p f \ -num_correct_answers $num_correct_answers \ - -num_answers $num_answers \ - -allow_other_p $allow_other_p] + -num_answers $num_answers] db_dml update_item_type {} # edit existing choices set count 0 @@ -415,7 +388,6 @@ db_dml update_title {} db_dml update_correct {} - set new_choices($i) $new_choice_id } } @@ -470,72 +442,13 @@ set as_item_id $new_item_id set section_id $new_section_id -##### - set as_item_type_id [as::item::get_item_type_id -as_item_id $as_item_id] - if {[array exists move_up]} { - foreach n [array names move_up] { - set new_choice_id $new_choices($n) - array set new_array [as::item_type_mc::choices_swap \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -mc_id $as_item_type_id \ - -sort_order [db_string get_sort_order {}] \ - -direction up] - foreach var {as_item_id section_id} { - set $var $new_array($var) - template::element::set_value item_edit_general $var [set $var] - } - } - } - if {[array exists move_down]} { - - foreach n [array names move_down] { - set new_choice_id $new_choices($n) - array set new_array [as::item_type_mc::choices_swap \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -mc_id $as_item_type_id \ - -sort_order [db_string get_sort_order {}] \ - -direction down] - } - foreach var {as_item_id section_id} { - set $var $new_array($var) - template::element::set_value item_edit_general $var [set $var] - } - } - if {[array exists delete]} { - foreach n [array names delete] { - set new_choice_id $new_choices($n) - - array set new_array [as::item_type_mc::choice_delete \ - -assessment_id $assessment_id \ - -section_id $section_id \ - -as_item_id $as_item_id \ - -choice_id $new_choice_id] - } - foreach var {as_item_id section_id} { - set $var $new_array($var) - } - } - -####### - - application_data_link::update_links_from \ -object_id $as_item_id \ -text $question_text } } -after_submit { - if {[array exists move_up] || [array exists move_down] || [array exists delete]} { - ad_returnredirect [export_vars -base item-edit-general {as_item_id assessment_id section_id return_url}] - ad_script_abort - } if {[exists_and_not_null formbutton_ok]} { - if {![info exists return_url] || $return_url eq ""} { - set return_url [export_vars -base "questions" {assessment_id section_id}]&\#Q${as_item_id} - } + set return_url [export_vars -base "questions" {assessment_id section_id }]&\#${as_item_id} if {[info exists save_answer_set] && $save_answer_set eq "on" && (![info exists add_existing_mc_id] || $add_existing_mc_id eq "")} { set return_url [export_vars -base save-answer-set {assessment_id as_item_id return_url {mc_id $new_item_type_id}}] } @@ -545,6 +458,5 @@ } set advanced_options_url [export_vars -base item-edit {as_item_id section_id assessment_id}] -set error_p [expr {[template::form::is_submission item_edit_general] && ![template::form::is_valid item_edit_general]}] -#as::assessment::notify_response_on_edit -assessment_id $assessment_id -return_url "[export_vars -base questions {assessment_id}]" + ad_return_template