Index: openacs-4/packages/assessment/www/asm-admin/item-create-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-create-2.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/asm-admin/item-create-2.tcl 7 Aug 2017 23:48:04 -0000 1.4 +++ openacs-4/packages/assessment/www/asm-admin/item-create-2.tcl 20 Jan 2018 22:38:28 -0000 1.5 @@ -55,72 +55,82 @@ #for each type of item we create some elements switch -- $item_type { "textarea" { - element create item-add-2 as_item_type_oq__as_item_default -label "Default value" -datatype text -html {size 15} - element create item-add-2 as_item_type_oq__feedback_text -label "Feedback" -datatype text -html {rows 5 cols 50} -widget textarea -optional + element create item-add-2 as_item_type_oq__as_item_default -label "Default value" \ + -datatype text -html {size 15} + element create item-add-2 as_item_type_oq__feedback_text -label "Feedback" \ + -datatype text -html {rows 5 cols 50} -widget textarea -optional form set_properties item-add-2 -action "index" } "checkbox" - - "radiobutton" { - element create item-add-2 as_item_type_mc__increasing_p -label "Increasing" -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional + "radiobutton" { + element create item-add-2 as_item_type_mc__increasing_p -label "Increasing" \ + -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional - element create item-add-2 as_item_type_mc__allow_negative_p -label "Allow negative?" -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional - element create item-add-2 as_item_type_mc__num_correct_answers -label "Number of Correct Answers" -datatype integer -html {size 7} -optional - element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" -datatype integer -html {size 7} + element create item-add-2 as_item_type_mc__allow_negative_p -label "Allow negative?" \ + -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional + element create item-add-2 as_item_type_mc__num_correct_answers -label "Number of Correct Answers" \ + -datatype integer -html {size 7} -optional + element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" \ + -datatype integer -html {size 7} - element set_properties item-add-2 as_item_type_mc__num_answers -value $as_item_type_mc__num_answers + element set_properties item-add-2 as_item_type_mc__num_answers -value $as_item_type_mc__num_answers - - + if { [template::form is_valid item-add-2] } { + #valid new item submission so create new item type + set as_item_type_mc__increasing_p [template::element::get_value item-add-2 as_item_type_mc__increasing_p] + set as_item_type_mc__allow_negative_p [template::element::get_value item-add-2 as_item_type_mc__allow_negative_p] + set as_item_type_mc__num_correct_answers [template::element::get_value item-add-2 as_item_type_mc__num_correct_answers] + set as_item_type_mc__num_answers [template::element::get_value item-add-2 as_item_type_mc__num_answers] -if { [template::form is_valid item-add-2] } { - #valid new item submission so create new item type - set as_item_type_mc__increasing_p [template::element::get_value item-add-2 as_item_type_mc__increasing_p] - set as_item_type_mc__allow_negative_p [template::element::get_value item-add-2 as_item_type_mc__allow_negative_p] - set as_item_type_mc__num_correct_answers [template::element::get_value item-add-2 as_item_type_mc__num_correct_answers] - set as_item_type_mc__num_answers [template::element::get_value item-add-2 as_item_type_mc__num_answers] + db_transaction { + #Insert as_item_type_mc in the CR (and as_item_type_mc table) getting the revision_id (as_item_type_id) + set as_item_type_id [as::item_type_mc::new -increasing_p $as_item_type_mc__increasing_p \ + -allow_negative_p $as_item_type_mc__allow_negative_p \ + -num_correct_answers $as_item_type_mc__num_correct_answers \ + -num_answers $as_item_type_mc__num_answers] + #set the relation between as_items table and as_item_type_mc table + content::item::relate \ + -item_id [db_string cr_item_from_revision "select item_id from cr_revisions where revision_id=:as_item_id1"] \ + -object_id [db_string cr_item_from_revision "select item_id from cr_revisions where revision_id=:as_item_type_id"] \ + -relation_tag {as_item_type_rel} \ + -relation_type {cr_item_rel} + } - db_transaction { - #Insert as_item_type_mc in the CR (and as_item_type_mc table) getting the revision_id (as_item_type_id) - set as_item_type_id [as::item_type_mc::new -increasing_p $as_item_type_mc__increasing_p -allow_negative_p $as_item_type_mc__allow_negative_p -num_correct_answers $as_item_type_mc__num_correct_answers -num_answers $as_item_type_mc__num_answers] - #set the relation between as_items table and as_item_type_mc table - content::item::relate -item_id [db_string cr_item_from_revision "select item_id from cr_revisions where revision_id=:as_item_id1"] -object_id [db_string cr_item_from_revision "select item_id from cr_revisions where revision_id=:as_item_type_id"] -relation_tag {as_item_type_rel} -relation_type {cr_item_rel} - } - - #redirect back to choice-add - ad_returnredirect "choice-add?as_item_type_id=$as_item_type_id&as_item_type_mc__num_answers=$as_item_type_mc__num_answers&item_type=$item_type" - - } - + #redirect back to choice-add + ad_returnredirect [export_vars -base choice-add {as_item_type_id as_item_type_mc__num_answers item_type}] + ad_script_abort + } } "open_question" { - element create item-add-2 as_item_type_oq__as_item_default -label "Item default" -datatype text -html {size 15} -optional - element create item-add-2 as_item_type_oq__feedback_text -label "Feedback" -datatype text -widget textarea -html {rows 5 cols 50} -optional + element create item-add-2 as_item_type_oq__as_item_default -label "Item default" \ + -datatype text -html {size 15} -optional + element create item-add-2 as_item_type_oq__feedback_text -label "Feedback" \ + -datatype text -widget textarea -html {rows 5 cols 50} -optional - form set_properties item-add-2 -action "index" + form set_properties item-add-2 -action "index" } "shortanswer" { - element create item-add-2 as_item_type_sa__increasing_p -label "Increasing" -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional - element create item-add-2 as_item_type_sa__allow_negative_p -label "Allow negative?" -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional - element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" -datatype integer -html {size 7} - - + element create item-add-2 as_item_type_sa__increasing_p -label "Increasing" \ + -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional + element create item-add-2 as_item_type_sa__allow_negative_p -label "Allow negative?" \ + -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional + element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" \ + -datatype integer -html {size 7} } - "imagemap" { - element create item-add-2 as_item_type_im__increasing_p -label "Increasing" -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional - element create item-add-2 as_item_type_im__allow_negative_p -label "Allow negative?" -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional - element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" -datatype integer -html {size 7} - - + element create item-add-2 as_item_type_im__increasing_p -label "Increasing" \ + -datatype text -widget select -options {{{All or Nothing} f } {Increasing t} } -optional + element create item-add-2 as_item_type_im__allow_negative_p -label "Allow negative?" \ + -datatype text -widget radio -options {{Yes t} {No f}} -value f -optional + element create item-add-2 as_item_type_mc__num_answers -label "Number of Answers" \ + -datatype integer -html {size 7} } - - -} +} ad_return_template