Index: openacs-4/packages/ratings/tcl/rating-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ratings/tcl/rating-procs.tcl,v diff -u -r1.4.2.1 -r1.4.2.2 --- openacs-4/packages/ratings/tcl/rating-procs.tcl 27 Jun 2005 15:28:06 -0000 1.4.2.1 +++ openacs-4/packages/ratings/tcl/rating-procs.tcl 29 Jul 2005 23:08:24 -0000 1.4.2.2 @@ -156,16 +156,22 @@ ad_proc -public ratings::rate { {-dimension_key "quality"} - -object_id - -user_id - -rating + -object_id:required + -user_id:required + -rating:required + {-nomem_p "f"} } { Sets the rating for object_id for user user_id. @author Jeff Davis davis@xarg.net @creation-date 2004-01-30 } { - array set dim [ratings::dimensions::get -dimension_key $dimension_key] + if { $nomem_p } { + array set dim [ratings::dimensions::get_nomem $dimension_key] + } else { + array set dim [ratings::dimensions::get -dimension_key $dimension_key] + } + set dimension_id $dim(dimension_id) set vars [list \ @@ -279,3 +285,110 @@ +ad_proc -public ratings::dimension_form { + -object_id:required + {-dimensions_key_list ""} + {-return_url ""} + {-context_object_id ""} +} { + Returns a form to include on an adp page, displaying a group of stars with a checkbox acording to the max and + min ranges especified when creating the dimension. If dimension_key_list is not provided then it will create a form + with all dimensions. If it is provided then it will create a form for just the dimension_key's on the list. + + @param object_id The object you want to rate. + @param dimension_key_list the rating dimension_key's. + @param return_url The url to return after the form is submited. + @param context_object_id The context object to group ratings. + +} { + set output "" + set dimensions_num [llength $dimensions_key_list] + # For each dimension we receive, we are going to use it's value to restrict the query + if { [expr [llength $dimensions_key_list] > 1] } { + set dimensions_query "(" + foreach item $dimensions_key_list { + append dimensions_query "'" + append dimensions_query "$item'," + } + append dimensions_query "'[lindex $dimensions_key_list 0]')" + set extra_query "where dimension_key in $dimensions_query" + } elseif {[string equal [llength $dimensions_key_list] 1] } { + set extra_query "where dimension_key = '$dimensions_key_list'" + } else { + set extra_query "" + } + + set dimensions "" + db_foreach get_dimensions " " { + append dimensions "${dimension_key}-" + } + + append output "" + set count 0 + # For each dimension we create a new form to rate all dimensions. + append output "