Index: openacs-4/packages/assessment/assessment.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/assessment.info,v diff -u -N -r1.57.2.3 -r1.57.2.4 --- openacs-4/packages/assessment/assessment.info 2 Jul 2019 08:05:32 -0000 1.57.2.3 +++ openacs-4/packages/assessment/assessment.info 21 Nov 2019 18:54:20 -0000 1.57.2.4 @@ -7,7 +7,7 @@ f f - + Eduardo Perez Ureta Assessment package that will replace the surveys quizz, complex survey, poll and other data collection packages @@ -18,7 +18,7 @@ 2 #assessment.Assessment# - + Index: openacs-4/packages/assessment/lib/assessment.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/lib/assessment.tcl,v diff -u -N -r1.33.2.2 -r1.33.2.3 --- openacs-4/packages/assessment/lib/assessment.tcl 17 Aug 2019 09:29:28 -0000 1.33.2.2 +++ openacs-4/packages/assessment/lib/assessment.tcl 21 Nov 2019 18:54:20 -0000 1.33.2.3 @@ -360,7 +360,7 @@ if {$presentation_type in {rbo sbo cbo}} { lappend validate_list "response_to_item.$as_item_id {\$\{response_to_item.$as_item_id\} ne \"\" || \[ns_queryget response_to_item.${as_item_id}\.text\] ne \"\"} \"\[_ assessment.form_element_required\]\"" } else { - lappend validate_list "response_to_item.$as_item_id {\[exists_and_not_null response_to_item($as_item_id)\]} \"\[_ assessment.form_element_required\]\"" + lappend validate_list "response_to_item.$as_item_id {\[info exists response_to_item($as_item_id)\] && \$response_to_item($as_item_id) ne \"\"} \"\[_ assessment.form_element_required\]\"" } incr required_count } @@ -393,9 +393,9 @@ if {$required_p == "t"} { # make sure that mandatory items are answered if {$presentation_type in {rbo sbo cbo}} { - lappend validate_list "response_to_item.$as_item_id {\[exists_and_not_null response_to_item($as_item_id)\] || \[exists_and_not_null response_to_item($as_item_id)\.text\]} \"\[_ assessment.form_element_required\]\"" + lappend validate_list "response_to_item.$as_item_id {\[info exists response_to_item($as_item_id)\] && \$response_to_item($as_item_id) ne \"\" || {\[info exists response_to_item($as_item_id)\.text\] && \$response_to_item($as_item_id)\.text ne \"\"} \"\[_ assessment.form_element_required\]\"" } else { - lappend validate_list "response_to_item.$as_item_id {\[exists_and_not_null response_to_item($as_item_id)\]} \"\[_ assessment.form_element_required\]\"" + lappend validate_list "response_to_item.$as_item_id {\[info exists response_to_item($as_item_id)\] && \$response_to_item($as_item_id) ne \"\"} \"\[_ assessment.form_element_required\]\"" } incr required_count } Index: openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql,v diff -u -N -r1.9 -r1.9.4.1 --- openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql 27 Oct 2014 16:40:55 -0000 1.9 +++ openacs-4/packages/assessment/sql/oracle/assessment-actions-package-create.sql 21 Nov 2019 18:54:20 -0000 1.9.4.1 @@ -181,7 +181,7 @@ name => 'Add to Community', description => 'Add user to a community', tcl_code => 'set user_id [ad_conn user_id] -if { [exists_and_not_null subject_id] } { +if { [info exists subject_id] && $subject_id ne "" } { set user_id $subject_id } dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" Index: openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-2.10.0d4-2.10.0d5.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/oracle/upgrade/Attic/upgrade-2.10.0d4-2.10.0d5.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/oracle/upgrade/upgrade-2.10.0d4-2.10.0d5.sql 21 Nov 2019 18:54:20 -0000 1.1.2.1 @@ -0,0 +1,162 @@ +-- Disclaimer: this has not really been tested + +begin; + +create or replace package body as_action +as + function new ( + action_id in acs_objects.object_id%TYPE default null, + name in as_actions.name%TYPE, + description in as_actions.description%TYPE, + tcl_code in as_actions.tcl_code%TYPE, + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE + ) return as_actions.action_id%TYPE + is + v_action_id as_actions.action_id%TYPE; + + begin + + v_action_id := acs_object.new ( + object_id => action_id, + object_type => 'as_action', + creation_user => creation_user, + creation_ip => null, + context_id => context_id + ); + + insert into as_actions (action_id,name,description,tcl_code) + values (v_action_id,name,description,tcl_code); + + return v_action_id; + end new; + + + + procedure del ( + action_id as_actions.action_id%TYPE + ) is + begin + + delete from as_action_params where action_id=as_action.del.action_id; + delete from as_actions where action_id = as_action.del.action_id; + acs_object.del(as_action.del.action_id); + + end del; + + + procedure default_actions ( + context_id in acs_objects.context_id%TYPE, + creation_user in acs_objects.creation_user%TYPE + + ) is + v_action_id as_actions.action_id%TYPE; + + begin + + v_action_id := new ( + action_id => null, + name => 'Register User', + description => 'Register new users', + tcl_code => 'set password [ad_generate_random_string] +db_transaction { +array set user_new_info [auth::create_user -username $user_name -email $email -first_names $first_names -last_name $last_name -password $password] +} + +set admin_user_id [as::actions::get_admin_user_id] +set administration_name [db_string admin_name "select first_names || '' '' || last_name from persons where +person_id = :admin_user_id"] + +set system_name [ad_system_name] +set system_url [parameter::get -package_id [ad_acs_kernel_id] -parameter SystemURL -default ""]. +set admin_email [db_string unused "select email from parties where party_id = :admin_user_id"] +set message "$first_names $last_name, +You have been added as a user to $system_name +at $system_url +Login information: +Email: $email +Password: $password +(you may change your password after you log in) +Thank you, +$administration_name" +acs_mail_lite::send -to_addr "$email" -from_addr "$admin_email" -subject "You have been added as a user to [ad_system_name] at [ad_url]" -body "$message"', + context_id => context_id, + creation_user => creation_user + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','first_names','First Names of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','last_name','Last Name of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','email','Email of the User'); + +insert into as_action_params (parameter_id, action_id,type, varname, description) +values (parameter_id_seq.nextval,v_action_id,'n','user_name','User name of the User'); + +v_action_id:= new ( + action_id => null, + name => 'Event Registration', + description => 'Register user to event', + tcl_code => 'set user_id [ad_conn user_id] +events::registration::new -event_id $event_id -user_id $user_id', + context_id => context_id, + creation_user => creation_user + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description,query) +values (parameter_id_seq.nextval,v_action_id,'q','event_id','Event to add the user', 'select event_id,event_id from acs_events'); + +v_action_id:= new ( + action_id => null, + name => 'Add to Community', + description => 'Add user to a community', + tcl_code => 'set user_id [ad_conn user_id] +if { [info exists subject_id] && $subject_id ne "" } { + set user_id $subject_id +} +dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" +dotlrn::user_add -can_browse -user_id $user_id +dotlrn_community::add_user_to_community -community_id $community_id -user_id $user_id +set community_name [db_string get_community_name { select pretty_name from dotlrn_communities where community_id = :community_id}] + +set subject "Your $community_name membership has been approved" +set message "Your $community_name membership has been approved. Please return to [ad_url] to log into [ad_system_name]." + +set email_from [parameter::get -package_id [ad_acs_kernel_id] -parameter SystemOwner] + +db_1row select_user_info { select email, first_names, last_name from registered_users where user_id = :user_id} + +if [catch {acs_mail_lite::send -to_addr $email -from_addr $email_from -subject $subject -body $message} errmsg] { + ad_return_error \ + "Error sending mail" \ + "There was an error sending email to $email." +}', + context_id => context_id, + creation_user => creation_user + ); + + +insert into as_action_params (parameter_id, action_id,type, varname, description,query) +values (parameter_id_seq.nextval,v_action_id,'q','community_id','Community to add the user', +'select pretty_name,community_id from dotlrn_communities'); + + + end default_actions; + +end as_action; +/ +show errors; + +-- update entries containing deprecated code +update as_actions set + tcl_code = replace(tcl_code, '[exists_and_not_null subject_id]', '[info exists subject_id] && $subject_id ne ""'); + +update as_actions set + tcl_code = replace(tcl_code, '[ad_parameter -package_id [ad_acs_kernel_id] SystemURL ""]', '[parameter::get -package_id [ad_acs_kernel_id] -parameter SystemURL -default ""]'); + +end; Index: openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql,v diff -u -N -r1.16 -r1.16.2.1 --- openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql 12 Jul 2018 09:00:13 -0000 1.16 +++ openacs-4/packages/assessment/sql/postgresql/assessment-actions-create.sql 21 Nov 2019 18:54:20 -0000 1.16.2.1 @@ -240,7 +240,7 @@ 'Add to Community', 'Add user to a community', 'set user_id [ad_conn user_id] -if { [exists_and_not_null subject_id] } { +if { [info exists subject_id] && $subject_id ne "" } { set user_id $subject_id } dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" Index: openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-2.10.0d4-2.10.0d5.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/sql/postgresql/upgrade/Attic/upgrade-2.10.0d4-2.10.0d5.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/sql/postgresql/upgrade/upgrade-2.10.0d4-2.10.0d5.sql 21 Nov 2019 18:54:20 -0000 1.1.2.1 @@ -0,0 +1,121 @@ +begin; + +-- +-- procedure as_action__default_actions/3 +-- +CREATE OR REPLACE FUNCTION as_action__default_actions( + new__context_id integer, + new__creation_user integer, + new__package_id integer +) RETURNS integer AS $$ +DECLARE + v_action_id integer; + v_parameter_id integer; +BEGIN + v_action_id := as_action__new ( + null, + 'Register User', + 'Register new users', + 'set password [ad_generate_random_string] +db_transaction { +array set user_new_info [auth::create_user -username $user_name -email $email -first_names $first_names -last_name $last_name -password $password] +} +set admin_user_id [as::actions::get_admin_user_id] +set administration_name [db_string admin_name "select first_names || '' '' || last_name from +persons where person_id = :admin_user_id"] +set system_name [ad_system_name] +set system_url [parameter::get -package_id [ad_acs_kernel_id] -parameter SystemURL -default ""]. +set admin_email [db_string unused "select email from parties where party_id = :admin_user_id"] +set message "$first_names $last_name, +You have been added as a user to $system_name +at $system_url +Login information: +Email: $email +Password: $password +(you may change your password after you log in) +Thank you, +$administration_name" +acs_sendmail_lite::send -to_addr "$email" -from_addr "$admin_email" -subject "You have been added as a user to [ad_system_name] at [ad_url]" -body "$message"', + new__package_id, + new__creation_user, + new__package_id + ); + +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,'n','first_names','First Names of the User'); +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,'n','last_name','Last Name of the User'); +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,'n','email','Email of the User'); +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description) values (v_parameter_id,v_action_id,'n','user_name','User name of the User'); + +v_action_id:= as_action__new ( + null, + 'Event Registration', + 'Register user to event', + 'set user_id [ad_conn user_id] +events::registration::new -event_id $event_id -user_id $user_id', + new__package_id, + new__creation_user, + new__package_id + ); + +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description,query) values (v_parameter_id,v_action_id,'q','event_id','Event to add the user', 'select event_id,event_id from acs_events'); + +v_action_id:= as_action__new ( + null, + 'Add to Community', + 'Add user to a community', + 'set user_id [ad_conn user_id] +if { [info exists subject_id] && $subject_id ne "" } { + set user_id $subject_id +} +dotlrn_privacy::set_user_guest_p -user_id $user_id -value "t" +dotlrn::user_add -can_browse -user_id $user_id +dotlrn_community::add_user_to_community -community_id $community_id -user_id $user_id + +set community_name [db_string get_community_name { select pretty_name from dotlrn_communities where community_id = :community_id}] + +set subject "Your $community_name membership has been approved" +set message "Your $community_name membership has been approved. Please return to [ad_url] to log into [ad_system_name]." + +set email_from [parameter::get -package_id [ad_acs_kernel_id] -parameter SystemOwner] + +db_1row select_user_info { select email, first_names, last_name from registered_users where user_id = :user_id} + +if [catch {acs_mail_lite::send -to_addr $email -from_addr $email_from -subject $subject -body $message} errmsg] { + ad_return_error \ + "Error sending mail" \ + "There was an error sending email to $email." +}', + new__package_id, + new__creation_user, + new__package_id + ); + +-- +-- The query below can be probably tuned if necessary. Note that also +-- the old query - accessing was acs_permissions_all - weird (get +-- permissions while ignoring privileges?). The old query was: +-- +-- select pretty_name,community_id from dotlrn_communities +-- where community_id in (select object_id from acs_permissions_all where grantee_id=:user_id) +-- +-- +v_parameter_id:= nextval('as_action_params_parameter_id'); +insert into as_action_params (parameter_id, action_id,type, varname, description,query) values (v_parameter_id,v_action_id,'q','community_id','Community to add the user', 'select pretty_name,community_id from dotlrn_communities from dotlrn_communities where acs_permission.permission_p(community_id, :user_id, ''read'')'); + + return v_action_id; +END; $$ language 'plpgsql'; + +-- update entries containing deprecated code +update as_actions set + tcl_code = replace(tcl_code, '[exists_and_not_null subject_id]', '[info exists subject_id] && $subject_id ne ""'); + +update as_actions set + tcl_code = replace(tcl_code, '[ad_parameter -package_id [ad_acs_kernel_id] SystemURL ""]', '[parameter::get -package_id [ad_acs_kernel_id] -parameter SystemURL -default ""]'); + +end; + Index: openacs-4/packages/assessment/www/asm-admin/results-export.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-export.tcl,v diff -u -N -r1.17 -r1.17.2.1 --- openacs-4/packages/assessment/www/asm-admin/results-export.tcl 29 Jun 2018 17:27:18 -0000 1.17 +++ openacs-4/packages/assessment/www/asm-admin/results-export.tcl 21 Nov 2019 18:54:20 -0000 1.17.2.1 @@ -113,15 +113,15 @@ if {$mc_item_list ne ""} { db_foreach mc_items {} { if {$text_value eq ""} { - if {[exists_and_not_null csv_${section_id}_${as_item_id}($session_id)]} { + if {[info exists csv_${section_id}_${as_item_id}($session_id)] && [set csv_${section_id}_${as_item_id}($session_id)] ne ""} { # append list of choices separated with comma append csv_${section_id}_${as_item_id}($session_id) ",[as::assessment::quote_export -text $title]" } else { # just set the choice value set csv_${section_id}_${as_item_id}($session_id) [as::assessment::quote_export -text $title] } } else { - if {[exists_and_not_null csv_${section_id}_${as_item_id}($session_id)]} { + if {[info exists csv_${section_id}_${as_item_id}($session_id)] && [set csv_${section_id}_${as_item_id}($session_id)] ne ""} { append csv_${section_id}_${as_item_id}($session_id) ",[as::assessment::quote_export -text $text_value]" } else { set csv_${section_id}_${as_item_id}($session_id) [as::assessment::quote_export -text $text_value] @@ -140,7 +140,7 @@ foreach session_id $session_list { foreach {section_id item_id} $item_list { - if {[exists_and_not_null csv_${section_id}_${item_id}($session_id)]} { + if {[info exists csv_${section_id}_${item_id}($session_id)] && [set csv_${section_id}_${item_id}($session_id)] ne ""} { lappend csv_result_list($session_id) "\"[set csv_${section_id}_${item_id}($session_id)]\"" } else { lappend csv_result_list($session_id) ""